sql: better test for unique index in CREATE TABLE #85481
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
T-sql-queries
SQL Queries Team
Describe the problem
Using the same structure
tree.UniqueConstraintTableDef
for unique constraintand 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 bythe grammar rule. But the parser test or a logictest will throw an error.
In
sql.y
, creating a unique index in aCREATE TABLE
statement returns anew 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 usingCREATE 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
The text was updated successfully, but these errors were encountered: