-
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
sql: equip cockroachdb to _detect_ attempts to use correlated queries #24684
Labels
A-sql-semantics
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
S-3-ux-surprise
Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
Comments
Ideally we'd really like to detect correlation (for feature tracking purposes) but that will need to wait for the new optimizer code. |
knz
added
the
S-3-ux-surprise
Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
label
Apr 11, 2018
knz
added
A-sql-semantics
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
S-3-ux-surprise
Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
and removed
S-3-ux-surprise
Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
labels
Apr 24, 2018
craig bot
pushed a commit
that referenced
this issue
Jul 11, 2018
27390: sql: properly reject nested generators in ROWS FROM r=knz a=knz Fixes #27389. Prior to this patch, invalid uses of SRFs as arguments to other functions in ROWS FROM were not properly rejected, and were only caught at evaluation time (i.e. much too late). This patch fixes it by rejecting these uses early. Release note (bug fix): invalid uses of set-generating functions in FROM clauses are now reported with the same error code as PostgreSQL. 27396: sql: help the user understand unsupported correlation r=knz a=knz Fixes #24684. Prior to this patch, a client trying to use an unsupported correlated query would encounter an obscure error like "column v does not exist" or "no data source matches prefix". Given that the new optimizer code can determine whether a query is correlated, we can use this information to enhance the error message. Before: ``` > select * from pg_class a where exists (select * from pg_class b where a.oid = b.oid); pq: no data source matches prefix: a > select * from pg_class a where exists (select * from kv where v::oid = oid); pq: column "oid" does not exist ``` After: ``` > select * from pg_class a where exists (select * from pg_class b where a.oid = b.oid); pq: no data source matches prefix: a HINT: some correlated subqueries are not supported yet - see #3288 > select * from pg_class a where exists (select * from kv where v::oid = oid); pq: column "oid" does not exist HINT: some correlated subqueries are not supported yet - see #3288 ``` Note: some correlated queries do not benefit from this improvement, specifically those for which the optimizer code aborts early before it has detected correlation (e.g. because of some other unrelated feature). Release note (sql change): CockroachDB will now report a hint in the error message if it encounters a correlated query that it does not support yet. Co-authored-by: Raphael 'kena' Poss <knz@cockroachlabs.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-sql-semantics
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
S-3-ux-surprise
Issue leaves users wondering whether CRDB is behaving properly. Likely to hurt reputation/adoption.
until CockroachDB supports correlated subqueries ( #3288, #24560 ) we want to tell users what's going on in error messages caused by a lack of support.
Currently a user attempting to run correlated subqueries will see either of the following:
We could teach CockroachDB to report better error messages:
The text was updated successfully, but these errors were encountered: