-
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: switch QueryArguments, PlaceholderTypes to slices #33716
Conversation
Release note: None
075c166
to
e326962
Compare
We switch `PlaceholderTypes` to a slice instead of a map. We also fix the handling of cases where some placeholders are unused (e.g. `SELECT $2:::int`) which now error out (before they would crash during execution). Note that PG also errors out in this case. Fixes cockroachdb#30086. Release note (bug fix): Preparing queries with missing placeholders (e.g. `SELECT $2::int`) now results in an error.
e326962
to
651f11b
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.
very good! Down with all maps.
Reviewable status:
complete! 1 of 0 LGTMs obtained
bors r+ |
Build failed (retrying...) |
33716: sql: switch QueryArguments, PlaceholderTypes to slices r=RaduBerinde a=RaduBerinde #### sql: change QueryArguments map to a slice Release note: None #### sql: switch PlaceholderTypes to a slice We switch `PlaceholderTypes` to a slice instead of a map. We also fix the handling of cases where some placeholders are unused (e.g. `SELECT $2:::int`) which now error out (before they would crash during execution). Note that PG also errors out in this case. Fixes #30086. Release note (bug fix): Preparing queries with missing placeholders (e.g. `SELECT $2::int`) now results in an error. Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
Build succeeded |
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! This is fantastic!
@@ -440,9 +440,6 @@ INSERT INTO add_default (a) VALUES (3) | |||
statement error could not parse "foo" as type int | |||
ALTER TABLE add_default ALTER COLUMN b SET DEFAULT 'foo' | |||
|
|||
statement error variable sub-expressions are not allowed in DEFAULT | |||
ALTER TABLE add_default ALTER COLUMN b SET DEFAULT $1 |
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.
Why remove these tests?
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 they should be converted to prepare a(int) as alter table ...
Otherwise a naked $1 is not valid in a logic test.
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 was meant to test the "variable sub-expressions" error for alter table. Using placeholders without prepare is not valid, and now we get a different (earlier) error that's not specific to alter table. There are other testcases for the same error below though.
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 explanation.
sql: change QueryArguments map to a slice
Release note: None
sql: switch PlaceholderTypes to a slice
We switch
PlaceholderTypes
to a slice instead of a map.We also fix the handling of cases where some placeholders are unused
(e.g.
SELECT $2:::int
) which now error out (before they would crashduring execution). Note that PG also errors out in this case.
Fixes #30086.
Release note (bug fix): Preparing queries with missing placeholders
(e.g.
SELECT $2::int
) now results in an error.