-
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
sql: Different handling of prepared statement arguments compared to Postgresql #86375
Comments
Hello, I am Blathers. I am here to help you get the issue triaged. Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here. I have CC'd a few people who may be able to assist you:
If we have not gotten back to your issue within a few business days, you can try the following:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
Thanks for this issue. For when we work on this, here are some tests we should add that verify the Postgres behavior that we should match.
|
Previously, we only allow having the same number of parameters and placeholders in a `PREPARE` statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. fixes cockroachdb#86375 Release justification: Release note: allow mismatch type numbers in `PREPARE` statement
Previously, we only allow having the same number of parameters and placeholders in a PREPARE statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. We now take max(#placeholders, #parameters) as the true length of parameters of the prepare statement. For each parameter, we first have the type hint as the default value for each type. Then if the type can be deduced from the query stmt, we let the deduced value override the type hint. fixes cockroachdb#86375 Release justification: Low risk, high benefit changes to existing functionality Release note: allow mismatch type numbers in PREPARE statement
Previously, we only allow having the same number of parameters and placeholders in a PREPARE statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. We now take max(#placeholders, #parameters) as the true length of parameters of the prepare statement. For each parameter, we first have the type hint as the default value for each type. Then if the type can be deduced from the query stmt, we let the deduced value override the type hint. fixes cockroachdb#86375 Release justification: Low risk, high benefit changes to existing functionality Release note: allow mismatch type numbers in PREPARE statement
Previously, we only allow having the same number of parameters and placeholders in a PREPARE statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. We now take max(#placeholders, #parameters) as the true length of parameters of the prepare statement. For each parameter, we first have the type hint as the default value for each type. Then if the type can be deduced from the query stmt, we let the deduced value override the type hint. fixes cockroachdb#86375 Release justification: Low risk, high benefit changes to existing functionality Release note: allow mismatch type numbers in PREPARE statement
86563: ts: fix the pretty-printing of tsd keys r=abarganier a=knz Found while working on #86524. Release justification: bug fix Release note (bug fix): When printing keys and range start/end boundaries for time series, the displayed structure of keys was incorrect. This is now fixed. 86904: sql: allow mismatch type numbers in `PREPARE` statement r=rafiss a=ZhouXing19 Previously, we only allow having the same number of parameters and placeholders in a `PREPARE` statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. We now take `max(#placeholders, #parameters)` as the true length of parameters of the prepare statement. For each parameter, we first look at the type deduced from the query stmt. If we can't deduce it, we take the type hint for this param. I.e. we now allow queries such as ``` PREPARE args_test_many(int, int) as select $1 // 2 parameters, but only 1 placeholder in the query. PREPARE args_test_few(int) as select $1, $2::int // 1 parameter, but 2 placeholders in the query. ``` fixes #86375 Release justification: Low risk, high benefit changes to existing functionality Release note: allow mismatch type numbers in `PREPARE` statement 87105: roachtest: skip flaky acceptance/version-upgrade r=tbg a=adityamaru Skipping the flaky roachtest while we stabilize it. Informs: #87104 Release note: None Release justification: testing only change 87117: bazci: fix output path computation r=rail a=rickystewart These updates were happening in-place so `bazci` was constructing big, silly paths like `backupccl_test/shard_6_of_16/shard_7_of_16/shard_13_of_16/...` We just need to copy the variable here. Release justification: Non-production code changes Release note: None Co-authored-by: Raphael 'kena' Poss <[email protected]> Co-authored-by: Jane Xing <[email protected]> Co-authored-by: adityamaru <[email protected]> Co-authored-by: Ricky Stewart <[email protected]>
Previously, we only allow having the same number of parameters and placeholders in a PREPARE statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. We now take max(#placeholders, #parameters) as the true length of parameters of the prepare statement. For each parameter, we first have the type hint as the default value for each type. Then if the type can be deduced from the query stmt, we let the deduced value override the type hint. fixes cockroachdb#86375 Release justification: Low risk, high benefit changes to existing functionality Release note (sql change): allow mismatch type numbers in PREPARE statement
Previously, we only allow having the same number of parameters and placeholders in a PREPARE statement. This is not compatible with Postgres14's behavior. This commit is to loosen the restriction and enable this compatibility. We now take max(#placeholders, #parameters) as the true length of parameters of the prepare statement. For each parameter, we first have the type hint as the default value for each type. Then if the type can be deduced from the query stmt, we let the deduced value override the type hint. fixes cockroachdb#86375 Release justification: Low risk, high benefit changes to existing functionality Release note (sql change): allow mismatch type numbers in PREPARE statement
Describe the problem
CockroachDB handles arguments to prepared statements differently from Postgres.
CockroachDB requires all specified arguments to a prepared statement are used in the statement being prepared, while Postgresql doesn't.
To Reproduce
On CockroachDB:
Expected behavior
On Postgresql:
Environment:
psql
Additional context
While I don't think this policy is unreasonable in and of itself, it does introduce an incompatibility with Postgresql.
This incompatibility surfaced for me in the context of adding support for CockroachDB to the Hasura GraphQL Engine.
Parallel hasura issue: hasura/graphql-engine#8792
Jira issue: CRDB-18726
Epic CRDB-11916
The text was updated successfully, but these errors were encountered: