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: doesn't allow 'index' as a column name #69420

Closed
steven-sheehy opened this issue Aug 26, 2021 · 2 comments · Fixed by #89903
Closed

sql: doesn't allow 'index' as a column name #69420

steven-sheehy opened this issue Aug 26, 2021 · 2 comments · Fixed by #89903
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-syntax Issues strictly related to the SQL grammar, with no semantic aspect C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@steven-sheehy
Copy link

steven-sheehy commented Aug 26, 2021

Describe the problem

Attempting to convert a PostgreSQL based application to CockroachDB. Found that CockroachDB is more strict than necessary in disallowing SQL keywords as column names. PostgreSQL works with a column named index while CockroachDB does not. Index is a pretty common name for fields since it denotes an application generated identifier that differs from a DB identifier. Since it does not appear where the SQL keyword usually appears it should not be considered a syntax error.

To Reproduce

  1. cockroach demo
  2. Run SQL with reserved keyword index as a column name
[email protected]:26257/movr> create table foo(index bigint);
invalid syntax: statement ignored: at or near ")": syntax error
SQLSTATE: 42601
DETAIL: source SQL:
create table foo(index bigint)
                             ^
HINT: try \h CREATE TABLE
  1. Watch it succeed after adding a 2
[email protected]:26257/movr> create table foo(index2 bigint);
CREATE TABLE

Time: 4ms total (execution 4ms / network 0ms)

Expected behavior
Parity with PostgreSQL to allow index as a column name.

Additional data / screenshots

Environment:

  • CockroachDB version v21.1.6
  • Server OS: MacOS
  • Client app: cockroach sql

Additional context

Had to rename columns

Jira issue: CRDB-9589

@steven-sheehy steven-sheehy added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Aug 26, 2021
@blathers-crl
Copy link

blathers-crl bot commented Aug 26, 2021

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 was unable to automatically find someone to ping.

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-untriaged blathers was unable to find an owner labels Aug 26, 2021
@jordanlewis
Copy link
Member

This is a known deficiency that doesn't have an easy fix. As a workaround, you can double-quote your column name (CREATE TABLE foo ("index" BIGINT)).

@rafiss rafiss added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Aug 26, 2021
@blathers-crl blathers-crl bot added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Aug 26, 2021
@rafiss rafiss added A-sql-syntax Issues strictly related to the SQL grammar, with no semantic aspect and removed X-blathers-untriaged blathers was unable to find an owner T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Aug 26, 2021
@jordanlewis jordanlewis changed the title Doesn't allow 'index' as a column name sql: doesn't allow 'index' as a column name Dec 7, 2021
@rafiss rafiss added the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Dec 7, 2021
@craig craig bot closed this as completed in 1c02afc Oct 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-syntax Issues strictly related to the SQL grammar, with no semantic aspect C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants