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: better test for unique index in CREATE TABLE #85481

Open
wenyihu6 opened this issue Aug 2, 2022 · 2 comments
Open

sql: better test for unique index in CREATE TABLE #85481

wenyihu6 opened this issue Aug 2, 2022 · 2 comments
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team

Comments

@wenyihu6
Copy link
Contributor

wenyihu6 commented Aug 2, 2022

Describe the problem

Using the same structure tree.UniqueConstraintTableDef for unique constraint
and unique indexes is causing issues in the parser tests.
Unique indexes and unique constraints have similar behaviour but they are still different.
For example, the parser supports some syntax for unique indexes but doesn't support
for unique constraints. This will cause the parser to throw an error when the parser or logic test
performs the roundtrip test. See an example below.

Additional context

Creating an invisible unique index in a CREATE TABLE statement is supported by
the grammar rule. But the parser test or a logictest will throw an error.
In sql.y, creating a unique index in a CREATE TABLE statement returns a
new structure tree.UniqueConstraintTableDef.
When the parser does a round trip test for the statement, it first
formats it to a pretty statement using the unique constraint definition and tries to parse the
pretty statement. Since the parser does not support unique constraint with not visible
index syntax, it fails while parsing the pretty statement.

As of now, no tests have been added for creating an invisible unique index in a
CREATE TABLE statement. We are manually testing the feature using
CREATE UNIQUE INDEX ... NOT VISIBLE in a cluster.

The same issue occurs for creating index with using hash in a CREATE TABLE definition.

Related: #65825

Jira issue: CRDB-18267

@wenyihu6 wenyihu6 added T-sql-schema-deprecated Use T-sql-foundations instead T-sql-queries SQL Queries Team labels Aug 2, 2022
@wenyihu6 wenyihu6 self-assigned this Aug 2, 2022
@blathers-crl
Copy link

blathers-crl bot commented Aug 2, 2022

Hi @wenyihu6, I've guessed the C-ategory of your issue and suitably labeled it. Please re-label if inaccurate.

While you're here, please consider adding an A- label to help keep our repository tidy.

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

@blathers-crl blathers-crl bot added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Aug 2, 2022
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label Aug 2, 2022
@wenyihu6 wenyihu6 changed the title sql: better test for unique invisible index in CREATE TABLE sql: better test for unique index in CREATE TABLE Aug 2, 2022
@ajwerner
Copy link
Contributor

ajwerner commented Aug 9, 2022

This relates to #65929.

@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
@exalate-issue-sync exalate-issue-sync bot added T-sql-queries SQL Queries Team and removed T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) labels Jun 27, 2023
@mgartner mgartner moved this to Backlog (DO NOT ADD NEW ISSUES) in SQL Queries Jul 24, 2023
@mgartner mgartner moved this from Backlog (DO NOT ADD NEW ISSUES) to New Backlog in SQL Queries Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-queries SQL Queries Team
Projects
Status: Backlog
Development

No branches or pull requests

2 participants