Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#24260] YSQL: ysql_dump will not emit separate CREATE INDEX statemen…
…ts for unique constraints for partitioned tables Summary: Postgres does not dump the CREATE INDEX separately for constraints, losing information present in CREATE INDEX like index type (ASC/HASH/DESC). This is acceptable for PG since it only supports a specific INDEX type for constraints (ASC). However, YB supports such index types (ASC & HASH) for constraints. To preserve this in a dump, YB emits the CREATE INDEX separately (#13603). However, this causes an issue for partitioned tables (#24260), because they do not support ALTER TABLE .. ADD CONSTRAINT .. USING INDEX and also the index on the parent partitioned table is created in an invalid state in the first place before the index partitions are attached in subsequent lines of the dump. This diff changes it so that separate CREATE INDEX is not emitted for constraints on parent partitioned tables. Separately, also removed a YB_TODO related to emitting oids for primary key indexes for child partition tables. The YB_TODO was concerned about emitting the oid for PRIMARY KEY clauses of (child) partition tables because we had special handling for that case earlier (we would omit such clauses for child tables when such keys were inherited from the parent partition). However, this behavior was changed by 180e7ae, so the YB_TODO is no longer relevant. Also added a test case to make sure that oid is emitted correctly for primary key clauses on child partitions when it comes from the parent partition table. Test Plan: 1. Add such a test case to the java unit test TestYbBackup - it fails before this fix and passes afterwards. 2. Added this test case to the java unit test TestYsqlDump. This test did not import the dump it was creating, so it doesn't catch the failure. I changed some of the tests to import the dumps created. This is not possible in all cases (ysql_dumpall emits `CREATE ROLE postgres;`) but I've fixed most of the tests to import the ysql dumps they generate. 3. Added a test case for primary keys on partition tables to verify that the index oid is correctly generated in this case. Reviewers: myang, loginov, yguan Reviewed By: myang Subscribers: fizaa, yql Differential Revision: https://phorge.dev.yugabyte.com/D40517
- Loading branch information