Skip to content
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

parser: add test to check that bare_label_keywords is updated #97878

Merged
merged 1 commit into from
Mar 2, 2023

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Mar 1, 2023

fixes #84309

Previously, it was very easy to add a new keyword, but forget to add it to bare_label_keywords. This could cause regressions as queries of the form SELECT 1 new_label would fail. The new test is a guardrail against that, and the grammar was updated to match Postgres bare label keywords as best we can.

Release note: None

@rafiss rafiss requested a review from a team as a code owner March 1, 2023 21:45
@blathers-crl
Copy link

blathers-crl bot commented Mar 1, 2023

It looks like your PR touches SQL parser code but doesn't add or edit parser tests. Please make sure you add or edit parser tests if you edit the parser.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss rafiss force-pushed the test-column-bare-labels branch from b510033 to 22891cf Compare March 1, 2023 22:05
Copy link
Contributor

@chengxiong-ruan chengxiong-ruan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for doing this!

// Any new keyword should be added to this list.
bare_label_keywords:
AS_JSON
ABORT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It make sense that we want to match psql's grammar, but I don't think we have to, because at this moment user won't have valid SELECT 1 xxx queries against these keywords. I guess one counter point to my opinion is that users upgrading from much older version might run into problems because some keywords added before we have this list heh.
That's being said I'm ok with this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it's still worth it to match PG's grammar as close as we can. the reason is that we have potential future users who will be migrating their apps from PG to CRDB. for all these users, we want to make sure that queries that worked with PG also work with CRDB, to minimize the friction of migrating to CRDB.

Previously, it was very easy to add a new keyword, but forget to add it
to bare_label_keywords. This could cause regressions as queries of the
form `SELECT 1 new_label` would fail. The new test is a guardrail
against that, and the grammar was updated to match Postgres bare label
keywords as best we can.

Release note: None
@rafiss rafiss force-pushed the test-column-bare-labels branch from 22891cf to 3c5c5da Compare March 2, 2023 05:40
@rafiss
Copy link
Collaborator Author

rafiss commented Mar 2, 2023

tftr!

bors r=chengxiong-ruan

@craig
Copy link
Contributor

craig bot commented Mar 2, 2023

Build succeeded:

@craig craig bot merged commit 3036617 into cockroachdb:master Mar 2, 2023
@rafiss rafiss deleted the test-column-bare-labels branch March 2, 2023 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sql: automatic way to ensure new sql keyword is added to bare_label_keywords list
3 participants