-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fix binder error and produce more informative error message. #5302
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
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.
This fix seems fine to me (if this doesn't break any other tests)
Although, I wonder what happens if you do:
SELECT avg(0) c0, (SELECT 0 OFFSET c0 + 1);
Will your check still trigger? Since the offset is now no longer a BOUND_COLUMN_REF
, but rather an expression. Maybe it still triggers because recursively the colref is bound anyway
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.
Thanks for the PR! A request for more tests below:
statement error | ||
SELECT avg(0) c0, (SELECT 0 OFFSET c0 + 1); | ||
---- | ||
Parser Error: Non-constant limit or offset not supported in correlated subquery |
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.
The same error happens if we leave out the offset, e.g.:
D select avg(0) AS c0, (SELECT c0);
Error: INTERNAL Error: Failed to bind column reference "c0" [2.0] (bindings: [15.0])
Could you test that that is fixed as well?
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.
@Mytherin added a test case for this, it's fixed as well!
https://github.com/Tmonster/duckdb/blob/22ee675570ec52e4fd254dc932456686b2ea1541/test/fuzzer/pedro/another_binder_error.test#L27
…g as h2oai also makes an https call to github. Maybe the plan_cost_runner doesnt compile duckdb with httpfs?
Thanks! LGTM |
This address fuzzer issue 48 in #4978
Originally an
INTERNAL ERROR: BINDER ERROR
message was thrown, which I don't think is the most informative message to show users. Especially theINTERNAL ERROR
BindCorrelatedColumns
gets called.ExtractCorrelatedExpressions
, should then extract the correlated column/alias into the binder context but this doesn't happen.bound_colref.depth > 0
inExtractCorrelatedExpressions
is false while the depth of the column c0 is very much 1.BindDelimiter()
inbind_select_node.cpp
, which callsexpr_binder.Bind(delimiter);
which callsauto error_msg = Bind(&expr, 0, root_expression);
inexpression_binder.cpp
. The 0 is the depth.I'm not sure if this is the best fix though, as it feels like it could mess up other logic that uses the same code path. Maybe a nicer fix would be passing the depth to the
BindDelimiter
and keep passing it along? Open to other ideas though.