Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#17130] YSQL: Refactor ADD/DROP PK to use new table rewrite approach
Summary: This diff changes `ADD/DROP PK` to use the new table rewrite approach. The old code is kept to avoid issues with upgrade (as the new table rewrite code-paths are guarded with the auto-flag `yb_enable_alter_table_rewrite`); however, it will be removed in a future release. Specific code changes: - Add another reason for rewrite: `YB_AT_REWRITE_ALTER_PRIMARY_KEY`. Table rewrite is required in YB when changing the primary key. - In `ALTER TABLE` phase 2, when executing add/drop primary key for partitioned tables, add the children to the `ALTER TABLE` work queue and mark them to be re-written (see `ATExecAddIndex` and `ATExecDropConstraint`). Rewrites for all tables in the work queue are handled in phase 3 (`ATRewriteTables`) - Add `yb_skip_copy_split_options` to `AlterTableInfo`. Split properties are not preserved when adding a range primary key (see D23931 for more details). - Increment schema version for the old DocDB table during table rewrite, so that concurrent DMLs get aborted with a `schema version mismatch`. Additionally, add tests for table rewrite operations in `TestAlterTableWithConcurrentTxn.java`. - Move rewrite tests in `yb_alter_table` into `yb_alter_table_rewrite` (in `yb_table_serial_schedule`). - Delete `TestPgAlterTableChangePrimaryKey`, and move the relevant tests into `yb_alter_table_rewrite`. Jira: DB-6412 Test Plan: `yb_alter_table_rewrite` in `yb_table_serial_schedule` Reviewers: dsrinivasan, myang Reviewed By: myang Subscribers: ybase, jason, yql Differential Revision: https://phorge.dev.yugabyte.com/D29786
- Loading branch information