-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BACKPORT 2024.2][#24057] YSQL: ysql_dump generates invalid statement…
…s for colocated table unique constraint Summary: ysql_dump generates invalid statements for colocated table unique constraint. Example: ``` CREATE TABLE tbl (k INT, V INT UNQUE); ``` has the corresponding unique constraint related statements in ysql_dump output: ``` CREATE UNIQUE INDEX NONCONCURRENTLY tbl_v_key ON public.tbl USING lsm (v ASC) WITH (colocation_id=1976786484); ALTER TABLE ONLY public.tbl ADD CONSTRAINT tbl_v_key UNIQUE USING INDEX tbl_v_key WITH (colocation_id='1976786484'); ``` In the dump output, the `WITH (...` part after `USING INDEX` is invalid and redundant, and not supported by grammar. For ysql_dump, D15799 started outputing reloptions and colocation_id for a colocated table's unique constraint in the `ALTER TABLE ADD CONSTRAINT UNIQUE` statement. D19352 changed the logic of dumping unique constraints: `CREATE UNIQUE INDEX` and `ALTER TABLE ADD CONSTRAINT UNIQUE USING INDEX` are used to replace the original single `ALTER TABLE ADD CONSTRAINT UNIQUE` statement. D29672 started outputing the whole index definition including reloptions and YB table properties (e.g. colocaiton_id) in the `CREATE UNIQUE INDEX` statement. This diff solves the issue by removing the ysql_dump colocated table unique constraint change added by D15799 since the `CREATE UNIQUE INDEX` index definition introduced by D29672 is complete. In addition, a C++ backup & restore unit test is added, which would fail without the fix. Jira: DB-12949 Original commit: 326e883 / D38261 Test Plan: ./yb_build.sh --cxx-test yb-backup-test --gtest-filter YBBackupTest.TestColocatedTableUniqueConstraint ./yb_build.sh --java-test 'org.yb.pgsql.TestYsqlDump#ysqlDumpColocatedDB' Reviewers: mihnea, loginov, myang Reviewed By: myang Subscribers: yql, ybase, asrivastava Differential Revision: https://phorge.dev.yugabyte.com/D38402
- Loading branch information
Showing
7 changed files
with
146 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters