-
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.
[#23118] YSQL: Add support for ADD PRIMARY KEY ... USING INDEX
Summary: This diff adds support for adding a primary key using a unique index by performing table rewrite. Code changes: - ATExecAddIndexConstraint in tablecmds.c: - If we are adding a primary key constraint on a YB relation, mark the table to be rewritten by alter table phase 3. - Skip copying split options (number of tablets) when we are adding a range based primary key. - Since primary keys are implicit to the DocDB table, drop the DocDB table associated with the secondary unique index. - pg_yb_utils.c: - Add function `YbGetIndexKeySortOrdering` to retrieve the sort ordering of the first key element of an index. - YbATIsRangePk: minor change to make the function take the sort ordering instead as a parameter instead of the index statement. Note: This operation is not supported when the unique index has key columns in descending order -- this limitation exists in Postgres, as Postgres does not allow adding primary keys with `DESC` ordering. Although we can support this in YB, it is omitted for now as the motivation for this feature is to facilitate migrations. Jira: DB-12051 Test Plan: new tests in `yb_alter_table_rewrite`, `yb_pg_create_index`, `yb_pg_index_including` ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTable' ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPgMisc' ./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPgMiscIndependent' Reviewers: myang Reviewed By: myang Subscribers: smishra, yql Differential Revision: https://phorge.dev.yugabyte.com/D37741
- Loading branch information
1 parent
24a5af0
commit 2ac2e98
Showing
9 changed files
with
278 additions
and
41 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
Oops, something went wrong.