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

sql: make NOTHING and INDEX non-reserved keywords #89903

Merged
merged 2 commits into from
Oct 17, 2022

Conversation

knz
Copy link
Contributor

@knz knz commented Oct 13, 2022

Fixes #69420.

Release note (bug fix): It is now possible again to create tables,
views, columns, etc with the name nothing (e.g. CREATE TABLE nothing...) without having to quote the name, like in
PostgreSQL. This bug was introduced in CockroachDB v2.0.

Release note (bug fix): It is now possible again to create tables,
views, columns, etc with the name index (e.g. CREATE TABLE index...) without having to quote the name, like in
PostgreSQL. This bug was introduced in CockroachDB v1.0.

@knz knz requested a review from jordanlewis October 13, 2022 11:17
@knz knz requested a review from a team as a code owner October 13, 2022 11:17
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@knz knz force-pushed the 20221013-reserved-keywords branch from 90a7b72 to 7b72594 Compare October 13, 2022 11:21
@knz knz requested review from otan and rafiss October 13, 2022 11:22
@knz
Copy link
Contributor Author

knz commented Oct 13, 2022

NB: I've looked at FAMILY too but that will require a different approach. I might think about it more, perhaps in a different PR, unless you have a different idea.

@knz knz force-pushed the 20221013-reserved-keywords branch 3 times, most recently from 7a51ed7 to 7fde330 Compare October 13, 2022 13:22
@knz knz requested a review from a team October 13, 2022 13:22
@otan otan removed their request for review October 13, 2022 23:07
@otan
Copy link
Contributor

otan commented Oct 13, 2022

(recusing myself as i'm no longer actively involved in the experience team)

@knz
Copy link
Contributor Author

knz commented Oct 13, 2022

@otan i just wanted to involve you because that might simplify some migration stuff? How are identifiers from the source database handled if they are CRDB keywords?

@otan
Copy link
Contributor

otan commented Oct 13, 2022

when translating (at least from other languages), we rewrite the foreign language AST with the tree AST objects and pretty print that - tree.Name naturally handles this for us.

with PG we're not great at handling name differences atm, so this would help that!

@knz
Copy link
Contributor Author

knz commented Oct 14, 2022

we rewrite the foreign language AST with the tree AST objects

Is this also done for the SQL queries that operate on the tables afterwards?

@otan
Copy link
Contributor

otan commented Oct 14, 2022

we don't rewrite any queries atm but if we need to we could.

@knz
Copy link
Contributor Author

knz commented Oct 14, 2022

yeah ok then that's one more reason to ensure that non-quoted identifiers in pg remain non-quoted in crdb.

knz added 2 commits October 14, 2022 15:41
Release note (bug fix): It is now possible again to create tables,
views, columns, etc with the name `nothing` (e.g. `CREATE TABLE
nothing...`) without having to quote the name, like in
PostgreSQL. This bug was introduced in CockroachDB v2.0.
Release note (bug fix): It is now possible again to create tables,
views, columns, etc with the name `index` (e.g. `CREATE TABLE
index...`) without having to quote the name, like in
PostgreSQL. This bug was introduced in CockroachDB v1.0.
@knz knz force-pushed the 20221013-reserved-keywords branch from 7fde330 to d7e34e6 Compare October 14, 2022 13:41
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

nice, thanks for the comprehensive test cases as well!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @jordanlewis and @knz)


docs/generated/sql/bnf/stmt_block.bnf line 2621 at r2 (raw file):

	'INDEX'
	| 'INDEX'
	| 'INDEX'

should we fix something so there's no dupe in this generated doc?

@knz
Copy link
Contributor Author

knz commented Oct 17, 2022

should we fix something so there's no dupe in this generated doc?

the diagram generator already de-dups. Do we print the raw BNF in text form anywhere?

@rafiss
Copy link
Collaborator

rafiss commented Oct 17, 2022

Do we print the raw BNF in text form anywhere?

i don't think so

@knz
Copy link
Contributor Author

knz commented Oct 17, 2022

cheers

bors r=rafiss

@craig
Copy link
Contributor

craig bot commented Oct 17, 2022

Build succeeded:

@craig craig bot merged commit 1c02afc into cockroachdb:master Oct 17, 2022
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: doesn't allow 'index' as a column name
4 participants