-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
release-21.2: opt: do not add invalid casts to match types in set operations #75276
Conversation
13637dc
to
0b6ebd8
Compare
Thanks for opening a backport. Please check the backport criteria before merging:
If some of the basic criteria cannot be satisfied, ensure that the exceptional criteria are satisfied within.
Add a brief release justification to the body of your PR to justify this backport. Some other things to consider:
|
5126078
to
0e26ec9
Compare
pkg/sql/opt/optbuilder/union.go
Outdated
return left | ||
if _, ok := tree.LookupCastVolatility(src, tgt, nil /* sessionData */); !ok { | ||
// Error if no cast exists from src to tgt. | ||
// TODO(#75103): For legacy reasons, we check for a valid cast in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the comment got truncated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't have been there in the first place. Removed.
{ | ||
// Error. | ||
left: types.MakeArray(types.MakeTuple([]*types.T{types.Bool})), | ||
right: types.MakeArray(types.MakeTuple([]*types.T{types.Bool, types.Int})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i noticed that this test case differs from the one in #75219 - is that on purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. In #75219 we're using the OID->OID castMap
to determine which casts are valid. In the backports castMap
does not yet exist, so we're using the family->family validCasts
. They don't match up perfectly so the cast from types.Any
-> types.Bool
that is not allowed on master is allowed in these release branches, so the test had to change.
The optbuilder adds casts in order to match non-identical left/right types of set operations like UNION (see #60560). This change prevents the optbuilder from adding casts that are invalid, which caused internal errors. Now, a user error is thrown if no such cast exists from the left or right input type to the output type. Release note (bug fix): A bug has been fixed that caused internal errors in queries with set operations, like UNION, when corresponding columns on either side of the set operation were not the same. This error only occurred with a limited set of types. This bug is present in versions 20.2.6+, 21.1.0+, and 21.2.0+.
0e26ec9
to
91194f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @RaduBerinde and @rafiss)
Backport 1/1 commits from #75219 on behalf of @mgartner.
/cc @cockroachdb/release
The optbuilder adds casts in order to match non-identical left/right
types of set operations like UNION (see #60560). This change prevents
the optbuilder from adding casts that are invalid, which caused internal
errors. Now, a user error is thrown if no such cast exists from the left
or right input type to the output type.
Fixes #70831
Release note (bug fix): A bug has been fixed that caused internal errors
in queries with set operations, like UNION, when corresponding columns
on either side of the set operation were not the same. This error only
occurred with a limited set of types. This bug is present in versions
20.2.6+, 21.1.0+, and 21.2.0+.
Release justification: This fixes a rare bug that causes internal errors.