-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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 when hoisting expr with correlated subquery #32443
Conversation
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
pkg/sql/opt/norm/decorrelate.go
Outdated
// It is not necessary to descend into relational children, because only | ||
// subquery scalar operators have a relational child, and they are handled | ||
// above, either because they're not correlated, or because they've already | ||
// been hoisted. |
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 commit message explains this a little better than this comment. The comment implies that we skip over both correlated and uncorrelated relational expressions, but I think here the deal is that we (still) won't encounter correlated relational expressions, and we want to skip over the uncorrelated ones, right?
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.
[nit] I think you should put the issue number in the body of the commit/PR message rather than the header so that the GitHub workflow will work correctly. If you add a line to the body of the PR message that says "Fixes #32270", the craigbot will update the issue with a reference to this PR, and close the issue when this PR merges.
Also, I think this probably deserves a release note.
Otherwise, , once you address Justin's comment
Reviewed 2 of 2 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained
f61832c
to
282c2ef
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.
This isn't a problem in 2.1, so I don't think we use a release note in that case, do we? This bug was only introduced by my expression rewrite, so it's an intra-release bug.
Reviewable status: complete! 1 of 0 LGTMs obtained
pkg/sql/opt/norm/decorrelate.go, line 800 at r1 (raw file):
Previously, justinj (Justin Jaffray) wrote…
I think the commit message explains this a little better than this comment. The comment implies that we skip over both correlated and uncorrelated relational expressions, but I think here the deal is that we (still) won't encounter correlated relational expressions, and we want to skip over the uncorrelated ones, right?
Rewrote this.
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.
But was the bug in the first 2.2 alpha release? If so, I would think the next alpha release should still have the release note. But it's definitely less important if the bug is not in 2.1...
(Also - I saw that you updated the commit message, but I think you may also need to update the PR message for the issue to be closed automatically)
Reviewable status: complete! 0 of 0 LGTMs obtained (and 1 stale)
Fixes cockroachdb#32270. The panic occurs when hoisting an expression that has both a correlated and an uncorrelated subquery. The current code panics when calling Reconstruct on the relational input to the uncorrelated subquery. The fix is to test for relational inputs and skip over them. They are not correlated, and so no hoisting needs to be done within their subtree. Release note (sql change): Fix panic when expression contains both a correlated and uncorrelated subquery.
282c2ef
to
f429b55
Compare
bors r+ |
32443: opt: Fix panic when hoisting expr with correlated subquery r=andy-kimball a=andy-kimball Fixes #32270. The panic occurs when hoisting an expression that has both a correlated and an uncorrelated subquery. The current code panics when calling Reconstruct on the relational input to the uncorrelated subquery. The fix is to test for relational inputs and skip over them. They are not correlated, and so no hoisting needs to be done within their subtree. Release note (sql change): Fix panic when expression contains both a correlated and uncorrelated subquery. Co-authored-by: Andrew Kimball <[email protected]>
Build succeeded |
Fixes #32270.
The panic occurs when hoisting an expression that has both a correlated
and an uncorrelated subquery. The current code panics when calling
Reconstruct on the relational input to the uncorrelated subquery. The
fix is to test for relational inputs and skip over them. They are not
correlated, and so no hoisting needs to be done within their subtree.
Release note (sql change): Fix panic when expression contains both a
correlated and uncorrelated subquery.