Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt: fix panic in GenerateLookupJoin #59741

Merged
merged 2 commits into from
Feb 3, 2021

Conversation

mgartner
Copy link
Collaborator

@mgartner mgartner commented Feb 3, 2021

opt: fix panic in GenerateLookupJoin

In #57690 a new code path was introduced from findConstantFilterCols
from GenerateLookupJoins. This new code path made it possible for the
filters passed to findConstantFilterCols to contain columns that are
not part of the given table. This violated the assumption that the
filter only contains columns in the given table and caused a panic. This
commit fixes the issue by neglecting constant filters for columns not in
the given table.

Fixes #59738

Release note (bug fix): A bug has been fixed that caused errors when
joining two tables when one of the tables had a computed column. This
bug was present since version 21.1.0-alpha.2 and not present in any
production releases.

opt: move findConstantFilterCols to general_funcs.go

Release note: None

@mgartner mgartner requested a review from a team as a code owner February 3, 2021 01:12
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rytaft)

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 4 of 4 files at r1, 2 of 2 files at r2.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @mgartner)


pkg/sql/opt/xform/testdata/rules/join, line 3178 at r1 (raw file):


# Regression test for #59738. findConstantFilterCols should not panic when
# it finds constant filters that are not in the scanned table.

[nit] this comment is a bit confusing. Instead of "scanned table", maybe say "index of the lookup join"?

In cockroachdb#57690 a new code path was introduced from `findConstantFilterCols`
from `GenerateLookupJoins`. This new code path made it possible for the
filters passed to `findConstantFilterCols` to contain columns that are
not part of the given table. This violated the assumption that the
filter only contains columns in the given table and caused a panic. This
commit fixes the issue by neglecting constant filters for columns not in
the given table.

Fixes cockroachdb#59738

Release note (bug fix): A bug has been fixed that caused errors when
joining two tables when one of the tables had a computed column. This
bug was present since version 21.1.0-alpha.2 and not present in any
production releases.
Copy link
Collaborator Author

@mgartner mgartner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @rytaft)


pkg/sql/opt/xform/testdata/rules/join, line 3178 at r1 (raw file):

Previously, rytaft (Rebecca Taft) wrote…

[nit] this comment is a bit confusing. Instead of "scanned table", maybe say "index of the lookup join"?

Done.

Copy link
Collaborator

@rytaft rytaft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r3, 2 of 2 files at r4.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 2 stale)

@mgartner
Copy link
Collaborator Author

mgartner commented Feb 3, 2021

TFTRs!

bors r+

@craig
Copy link
Contributor

craig bot commented Feb 3, 2021

Build succeeded:

@craig craig bot merged commit 023e4e2 into cockroachdb:master Feb 3, 2021
@mgartner mgartner deleted the fix-lookup-join branch February 4, 2021 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

opt: GenerateLookupJoin panics on table with computed columns
4 participants