Skip to content

Commit b7e2c83

Browse files
committed
Remove FIXME in test index_constraint_naming_upgrade
We used to rename index-backed constraints in the EXCHANGE PARTITION command in 6X. Now we don't. We've decided to keep that behavior in 7X after looking into the opposing arguments: Argument #1. It might cause problem during upgrade. - Firstly, we won't be using legacy syntax in the dump scripts so we just need to worry about the existing tables produced by EXCHANGE PARTITION. I.e. whether or not they can be restored correctly. - For upgrading from 6X->7X, since those tables already have matched constraint and index names with the table names, we should be OK. - For upgrading 7X->onward, since we implement EXCHANGE PARTIITON simply as a combination of upstream-syntax commands (see AtExecGPExchangePartition()), pg_upgrade should be able to handle them. We've verified that manually and the automated test should cover that too. In fact, this gives another point that we shouldn't do our own hacky things as part of EXCHANGE PARTITION which might confuse pg_upgrade. Argument #2. It might surprise the users and their existing workloads. - The indexed constraint names are all implicitly generated and shouldn't be directly used in most cases. - They are not the only thing that will appear changed. E.g. the normal indexes (e.g. B-tree ones) will be too. So the decision to change one should be made with changing all of them. More details see: https://docs.google.com/document/d/1enJdKYxkk5WFRV1WoqIgLgRxCGxOqI2nglJVE_Wglec
1 parent 0750421 commit b7e2c83

File tree

2 files changed

+44
-39
lines changed

2 files changed

+44
-39
lines changed

src/test/regress/expected/index_constraint_naming_upgrade.out

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -58,47 +58,52 @@ SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='table
5858
DROP TYPE table_collision_a_b_key;
5959
-- *************************************************************
6060
-- Exchange Partition Scenario
61-
-- Create a partition table with a primary key constraint
61+
-- Create two partition tables with primary key constraints.
62+
-- One to drop in this test, and one to be testd druing upgrade.
6263
CREATE TABLE part_table_for_upgrade (a INT, b INT) DISTRIBUTED BY (a) PARTITION BY RANGE(b) (PARTITION alpha END (3), PARTITION beta START (3));
64+
CREATE TABLE part_table_for_upgrade2 (a INT, b INT) DISTRIBUTED BY (a) PARTITION BY RANGE(b) (PARTITION alpha END (3), PARTITION beta START (3));
6365
ALTER TABLE part_table_for_upgrade ADD PRIMARY KEY(a, b);
66+
ALTER TABLE part_table_for_upgrade2 ADD PRIMARY KEY(a, b);
6467
-- Create a table to be used as a partition exchange.
6568
CREATE TABLE like_table (like part_table_for_upgrade INCLUDING CONSTRAINTS INCLUDING INDEXES) DISTRIBUTED BY (a) ;
69+
CREATE TABLE like_table2 (like part_table_for_upgrade INCLUDING CONSTRAINTS INCLUDING INDEXES) DISTRIBUTED BY (a) ;
6670
-- show constraint and index names
67-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='part_table_for_upgrade';
68-
table_name | table_name | constraint_name | index_name | constraint_type
69-
------------------------+------------------------+-----------------------------+-----------------------------+-----------------
70-
part_table_for_upgrade | part_table_for_upgrade | part_table_for_upgrade_pkey | part_table_for_upgrade_pkey | p
71-
(1 row)
71+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('part_table_for_upgrade', 'part_table_for_upgrade2');
72+
table_name | table_name | constraint_name | index_name | constraint_type
73+
-------------------------+-------------------------+------------------------------+------------------------------+-----------------
74+
part_table_for_upgrade | part_table_for_upgrade | part_table_for_upgrade_pkey | part_table_for_upgrade_pkey | p
75+
part_table_for_upgrade2 | part_table_for_upgrade2 | part_table_for_upgrade2_pkey | part_table_for_upgrade2_pkey | p
76+
(2 rows)
7277

73-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
74-
table_name | table_name | constraint_name | index_name | constraint_type
75-
------------+------------+-----------------+-----------------+-----------------
76-
like_table | like_table | like_table_pkey | like_table_pkey | p
77-
(1 row)
78+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('like_table', 'like_table2');
79+
table_name | table_name | constraint_name | index_name | constraint_type
80+
-------------+-------------+------------------+------------------+-----------------
81+
like_table | like_table | like_table_pkey | like_table_pkey | p
82+
like_table2 | like_table2 | like_table2_pkey | like_table2_pkey | p
83+
(2 rows)
7884

7985
-- Exchange the beta partition with like_table.
8086
-- Everything gets swapped, but the constraint index name of like_table does not match with part_table_for_upgrade_1_prt_beta.
8187
ALTER TABLE part_table_for_upgrade EXCHANGE PARTITION beta WITH TABLE like_table;
88+
ALTER TABLE part_table_for_upgrade2 EXCHANGE PARTITION beta WITH TABLE like_table2;
8289
-- show constraint and index names for each table
83-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='part_table_for_upgrade';
84-
table_name | table_name | constraint_name | index_name | constraint_type
85-
------------------------+------------------------+-----------------------------+-----------------------------+-----------------
86-
part_table_for_upgrade | part_table_for_upgrade | part_table_for_upgrade_pkey | part_table_for_upgrade_pkey | p
87-
(1 row)
90+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('part_table_for_upgrade', 'part_table_for_upgrade2');
91+
table_name | table_name | constraint_name | index_name | constraint_type
92+
-------------------------+-------------------------+------------------------------+------------------------------+-----------------
93+
part_table_for_upgrade | part_table_for_upgrade | part_table_for_upgrade_pkey | part_table_for_upgrade_pkey | p
94+
part_table_for_upgrade2 | part_table_for_upgrade2 | part_table_for_upgrade2_pkey | part_table_for_upgrade2_pkey | p
95+
(2 rows)
8896

89-
-- GPDB_12_MERGE_FIXME: only tables are renamed in exchange partition,
90-
-- constraints or indexes used to be renamed as well pre-GPDB7, not
91-
-- any more. Does it surprise users (functionally it doesn't affect
92-
-- anything)?
93-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
94-
table_name | table_name | constraint_name | index_name | constraint_type
95-
------------+------------+----------------------------------------+----------------------------------------+-----------------
96-
like_table | like_table | part_table_for_upgrade_1_prt_beta_pkey | part_table_for_upgrade_1_prt_beta_pkey | p
97-
(1 row)
97+
-- only tables are renamed in exchange partition
98+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('like_table', 'like_table2');
99+
table_name | table_name | constraint_name | index_name | constraint_type
100+
-------------+-------------+-----------------------------------------+-----------------------------------------+-----------------
101+
like_table | like_table | part_table_for_upgrade_1_prt_beta_pkey | part_table_for_upgrade_1_prt_beta_pkey | p
102+
like_table2 | like_table2 | part_table_for_upgrade2_1_prt_beta_pkey | part_table_for_upgrade2_1_prt_beta_pkey | p
103+
(2 rows)
98104

99-
-- Drop part_table_for_upgrade before upgrade since that is not where the issue is.
105+
-- Drop the first partition table, the constraint in like_table should NOT be dropped
100106
DROP TABLE part_table_for_upgrade CASCADE;
101-
-- Verify that the constraint in like_table was NOT dropped
102107
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
103108
table_name | table_name | constraint_name | index_name | constraint_type
104109
------------+------------+----------------------------------------+----------------------------------------+-----------------

src/test/regress/sql/index_constraint_naming_upgrade.sql

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,33 @@ DROP TYPE table_collision_a_b_key;
5555
-- *************************************************************
5656
-- Exchange Partition Scenario
5757

58-
-- Create a partition table with a primary key constraint
58+
-- Create two partition tables with primary key constraints.
59+
-- One to drop in this test, and one to be testd druing upgrade.
5960
CREATE TABLE part_table_for_upgrade (a INT, b INT) DISTRIBUTED BY (a) PARTITION BY RANGE(b) (PARTITION alpha END (3), PARTITION beta START (3));
61+
CREATE TABLE part_table_for_upgrade2 (a INT, b INT) DISTRIBUTED BY (a) PARTITION BY RANGE(b) (PARTITION alpha END (3), PARTITION beta START (3));
6062
ALTER TABLE part_table_for_upgrade ADD PRIMARY KEY(a, b);
63+
ALTER TABLE part_table_for_upgrade2 ADD PRIMARY KEY(a, b);
6164
-- Create a table to be used as a partition exchange.
6265
CREATE TABLE like_table (like part_table_for_upgrade INCLUDING CONSTRAINTS INCLUDING INDEXES) DISTRIBUTED BY (a) ;
66+
CREATE TABLE like_table2 (like part_table_for_upgrade INCLUDING CONSTRAINTS INCLUDING INDEXES) DISTRIBUTED BY (a) ;
6367

6468
-- show constraint and index names
65-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='part_table_for_upgrade';
66-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
69+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('part_table_for_upgrade', 'part_table_for_upgrade2');
70+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('like_table', 'like_table2');
6771

6872
-- Exchange the beta partition with like_table.
6973
-- Everything gets swapped, but the constraint index name of like_table does not match with part_table_for_upgrade_1_prt_beta.
7074
ALTER TABLE part_table_for_upgrade EXCHANGE PARTITION beta WITH TABLE like_table;
75+
ALTER TABLE part_table_for_upgrade2 EXCHANGE PARTITION beta WITH TABLE like_table2;
7176

7277
-- show constraint and index names for each table
73-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='part_table_for_upgrade';
78+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('part_table_for_upgrade', 'part_table_for_upgrade2');
7479

75-
-- GPDB_12_MERGE_FIXME: only tables are renamed in exchange partition,
76-
-- constraints or indexes used to be renamed as well pre-GPDB7, not
77-
-- any more. Does it surprise users (functionally it doesn't affect
78-
-- anything)?
79-
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
80+
-- only tables are renamed in exchange partition
81+
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text IN ('like_table', 'like_table2');
8082

81-
-- Drop part_table_for_upgrade before upgrade since that is not where the issue is.
83+
-- Drop the first partition table, the constraint in like_table should NOT be dropped
8284
DROP TABLE part_table_for_upgrade CASCADE;
83-
84-
-- Verify that the constraint in like_table was NOT dropped
8585
SELECT table_name,* FROM constraints_and_indices() WHERE table_name::text='like_table';
8686

8787
-- *************************************************************

0 commit comments

Comments
 (0)