-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Parameters for OFFSET and LIMIT in a prepared statement get swapped #15466
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
Comments
Hi @javafanboy, thanks for reporting this! The issue can be reproduced in the DuckDB CLI client: PREPARE q AS SELECT x FROM generate_series(1, 10) t(x) OFFSET ? LIMIT ?;
EXECUTE q(3, 5);
The reason you're experiencing this issue is that the default order of these clauses is For now, a workaround is to use |
Thanks for the quick reply - will switch to the "preferred order" to avoid my code stop working once the problem is fixed! |
@javafanboy no need to close issues before they are actually fixed - that only increases the chance they'll slip through unfixed. |
hi @szarnyasg, I would like to work on this issue. I have identified the potential fix for this. |
@ashwaniYDV thanks for offering your contribution! I assigned you. Please tag me in the PR of the proposed fix once it's ready to review. |
…fied in prepared statement
hi @szarnyasg I have created a WIP PR. Added some comments in the PR. |
Hmm this is a weird one, I presume the syntactic sugar is expanded before the That should solve others problems as well, like the one Gabor mentioned where things like FROM-first are also not given the correct number |
…fied in prepared statement
…fied in prepared statement
…fied in prepared statement
…fied in prepared statement
hi @szarnyasg , I have created a PR for this fix. Please review it. |
Fix duckdb/duckdb#15466 Transform LIMIT or OFFSET first based on order specified in prepared statement (duckdb/duckdb#15484) discussions duckdb/duckdb#15981: remove confusing comment in "duckdb/tools/shell/shell.cpp" (duckdb/duckdb#15984)
Fix duckdb/duckdb#15466 Transform LIMIT or OFFSET first based on order specified in prepared statement (duckdb/duckdb#15484) discussions duckdb/duckdb#15981: remove confusing comment in "duckdb/tools/shell/shell.cpp" (duckdb/duckdb#15984)
Fix duckdb/duckdb#15466 Transform LIMIT or OFFSET first based on order specified in prepared statement (duckdb/duckdb#15484) discussions duckdb/duckdb#15981: remove confusing comment in "duckdb/tools/shell/shell.cpp" (duckdb/duckdb#15984)
Fix duckdb/duckdb#15466 Transform LIMIT or OFFSET first based on order specified in prepared statement (duckdb/duckdb#15484) discussions duckdb/duckdb#15981: remove confusing comment in "duckdb/tools/shell/shell.cpp" (duckdb/duckdb#15984)
Fix duckdb/duckdb#15466 Transform LIMIT or OFFSET first based on order specified in prepared statement (duckdb/duckdb#15484) discussions duckdb/duckdb#15981: remove confusing comment in "duckdb/tools/shell/shell.cpp" (duckdb/duckdb#15984)
Fix duckdb/duckdb#15466 Transform LIMIT or OFFSET first based on order specified in prepared statement (duckdb/duckdb#15484) discussions duckdb/duckdb#15981: remove confusing comment in "duckdb/tools/shell/shell.cpp" (duckdb/duckdb#15984)
Uh oh!
There was an error while loading. Please reload this page.
I am experiencing a strange effect with DuckDB and Java when passing in OFFSET and LIMIT as parameters in a prepared statement.
To make it work I have to swap the assignment of the parameters compared to the expected i.e. set the desired limit as first parameter and the desired offset as second even though the order is the oposite in the prepared statement....
If I do not switch the order I get zero records in the result (because the limit seems to become zero).
What am I doing wrong here or are there some known quirks/problems with DuckDB (1.1.3) parameter mapping?
My program (somewhat simplified) looks like this:
import java.sql.*;
Originally posted by @javafanboy in #14907
The text was updated successfully, but these errors were encountered: