From 222864ca42bb526a029f01451fb1761aaf77a485 Mon Sep 17 00:00:00 2001 From: totaj Date: Thu, 27 Apr 2023 21:13:07 +0800 Subject: [PATCH] Improve test case. --- .../hw_subpartition_add_drop_partition.out | 1009 ---------------- .../hw_subpartition_add_drop_partition_1.out | 1016 +++++++++++++++++ .../expected/segment_subpartition_select.out | 121 -- .../segment_subpartition_select_1.out | 128 +++ .../expected/test_astore_multixact.out | 16 +- .../input/component_view_enhancements.source | 4 +- .../output/component_view_enhancements.source | 4 +- src/test/regress/parallel_schedule0 | 4 +- .../hw_subpartition_add_drop_partition.sql | 527 --------- .../hw_subpartition_add_drop_partition_1.sql | 536 +++++++++ .../sql/segment_subpartition_select.sql | 74 -- .../sql/segment_subpartition_select_1.sql | 82 ++ .../regress/sql/test_astore_multixact.sql | 16 +- 13 files changed, 1784 insertions(+), 1753 deletions(-) create mode 100644 src/test/regress/expected/hw_subpartition_add_drop_partition_1.out create mode 100644 src/test/regress/expected/segment_subpartition_select_1.out create mode 100755 src/test/regress/sql/hw_subpartition_add_drop_partition_1.sql create mode 100755 src/test/regress/sql/segment_subpartition_select_1.sql diff --git a/src/test/regress/expected/hw_subpartition_add_drop_partition.out b/src/test/regress/expected/hw_subpartition_add_drop_partition.out index 70c66c2e6..55430300e 100644 --- a/src/test/regress/expected/hw_subpartition_add_drop_partition.out +++ b/src/test/regress/expected/hw_subpartition_add_drop_partition.out @@ -1415,1020 +1415,11 @@ Number of subpartitions: 9 (View pg_partition to check each subpartition range.) Has OIDs: no Options: orientation=row, compression=no --- -----list-hash table---- --- ---prepare -CREATE TABLE list_hash_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY LIST (channel_id) SUBPARTITION BY HASH (product_id) -( - PARTITION channel1 VALUES ('0', '1', '2') - ( - SUBPARTITION channel1_product1, - SUBPARTITION channel1_product2, - SUBPARTITION channel1_product3, - SUBPARTITION channel1_product4 - ), - PARTITION channel2 VALUES ('3', '4', '5') - ( - SUBPARTITION channel2_product1, - SUBPARTITION channel2_product2 - ), - PARTITION channel3 VALUES ('6', '7'), - PARTITION channel4 VALUES ('8', '9') - ( - SUBPARTITION channel4_product1 - ) -); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "list_hash_sales_pkey" for table "list_hash_sales" -INSERT INTO list_hash_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX list_hash_sales_idx ON list_hash_sales(product_id) LOCAL; ---check for add partition/subpartition ---success, add 4 subpartition -ALTER TABLE list_hash_sales ADD PARTITION channel5 VALUES ('X') - ( - SUBPARTITION channel5_product1, - SUBPARTITION channel5_product2, - SUBPARTITION channel5_product3, - SUBPARTITION channel5_product4 - ); ---fail, value conflict -ALTER TABLE list_hash_sales ADD PARTITION channel_temp1 VALUES ('0', 'Z', 'C'); -ERROR: list boundary of adding partition MUST NOT overlap with existing partition ---fail, value conflict -ALTER TABLE list_hash_sales ADD PARTITION channel_temp2 VALUES ('Z', 'Z', 'C'); -ERROR: list partition channel_temp2 has overlapped value ---fail, invalid format -ALTER TABLE list_hash_sales ADD PARTITION channel_temp3 VALUES LESS THAN ('Z'); -ERROR: can not add none-list partition to list partition table ---success, add 1 default subpartition -ALTER TABLE list_hash_sales ADD PARTITION channel6 VALUES (DEFAULT); ---fail, value conflict -ALTER TABLE list_hash_sales ADD PARTITION channel_temp4 VALUES ('M', 'X'); -ERROR: list boundary of adding partition MUST NOT overlap with existing partition ---fail, not support add hash -ALTER TABLE list_hash_sales MODIFY PARTITION channel1 ADD SUBPARTITION channel1_temp1; -ERROR: syntax error at or near ";" -LINE 1: ...s MODIFY PARTITION channel1 ADD SUBPARTITION channel1_temp1; - ^ ---fail, invalid format -ALTER TABLE list_hash_sales MODIFY PARTITION channel4 ADD SUBPARTITION channel4_temp1 VALUES LESS THAN (1500); -ERROR: can not add hash subpartition ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='list_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------ - channel1 | p | l | f | 0 | 1 | {0,1,2} - channel2 | p | l | f | 0 | 1 | {3,4,5} - channel3 | p | l | f | 0 | 1 | {6,7} - channel4 | p | l | f | 0 | 1 | {8,9} - channel5 | p | l | f | 0 | 1 | {X} - channel6 | p | l | f | 0 | 1 | {NULL} - list_hash_sales | r | l | f | 0 | 4 | - channel1_product1 | s | h | t | 0 | | {0} - channel1_product2 | s | h | t | 0 | | {1} - channel1_product3 | s | h | t | 0 | | {2} - channel1_product4 | s | h | t | 0 | | {3} - channel2_product1 | s | h | t | 0 | | {0} - channel2_product2 | s | h | t | 0 | | {1} - channel3_subpartdefault1 | s | h | t | 0 | | {0} - channel4_product1 | s | h | t | 0 | | {0} - channel5_product1 | s | h | t | 0 | | {0} - channel5_product2 | s | h | t | 0 | | {1} - channel5_product3 | s | h | t | 0 | | {2} - channel5_product4 | s | h | t | 0 | | {3} - channel6_subpartdefault1 | s | h | t | 0 | | {0} -(20 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - channel1_product1_product_id_idx | x | n | t | t - channel1_product2_product_id_idx | x | n | t | t - channel1_product3_product_id_idx | x | n | t | t - channel1_product4_product_id_idx | x | n | t | t - channel2_product1_product_id_idx | x | n | t | t - channel2_product2_product_id_idx | x | n | t | t - channel3_subpartdefault1_product_id_idx | x | n | t | t - channel4_product1_product_id_idx | x | n | t | t - channel5_product1_product_id_idx | x | n | t | t - channel5_product2_product_id_idx | x | n | t | t - channel5_product3_product_id_idx | x | n | t | t - channel5_product4_product_id_idx | x | n | t | t - channel6_subpartdefault1_product_id_idx | x | n | t | t -(13 rows) - -\d+ list_hash_sales - Table "hw_subpartition_add_drop_partition.list_hash_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "list_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default - "list_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By LIST(channel_id) Subpartition By HASH(product_id) -Number of partitions: 6 (View pg_partition to check each partition range.) -Number of subpartitions: 13 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - ---check for drop partition/subpartition (for) ---success, drop partition channel2 -ALTER TABLE list_hash_sales DROP PARTITION channel2; ---fail, not support drop hash -ALTER TABLE list_hash_sales DROP SUBPARTITION channel1_product1; -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---fail, not support drop hash -ALTER TABLE list_hash_sales DROP SUBPARTITION channel4_product1; -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---success, drop partition channel3 -ALTER TABLE list_hash_sales DROP PARTITION FOR ('6'); ---fail, number not equal to the number of partkey -ALTER TABLE list_hash_sales DROP PARTITION FOR ('6', '2010-01-01'); -ERROR: number of boundary items NOT EQUAL to number of partition keys ---fail, invalid type -ALTER TABLE list_hash_sales DROP PARTITION FOR (10); -ERROR: value too long for type character(1) ---fail, not support drop hash -ALTER TABLE list_hash_sales DROP SUBPARTITION FOR('X', 6); -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---check for ok after drop -SELECT count(*) FROM list_hash_sales; - count -------- - 500 -(1 row) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='list_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------ - channel1 | p | l | f | 0 | 1 | {0,1,2} - channel4 | p | l | f | 0 | 1 | {8,9} - channel5 | p | l | f | 0 | 1 | {X} - channel6 | p | l | f | 0 | 1 | {NULL} - list_hash_sales | r | l | f | 0 | 4 | - channel1_product1 | s | h | t | 0 | | {0} - channel1_product2 | s | h | t | 0 | | {1} - channel1_product3 | s | h | t | 0 | | {2} - channel1_product4 | s | h | t | 0 | | {3} - channel4_product1 | s | h | t | 0 | | {0} - channel5_product1 | s | h | t | 0 | | {0} - channel5_product2 | s | h | t | 0 | | {1} - channel5_product3 | s | h | t | 0 | | {2} - channel5_product4 | s | h | t | 0 | | {3} - channel6_subpartdefault1 | s | h | t | 0 | | {0} -(15 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - channel1_product1_product_id_idx | x | n | t | t - channel1_product2_product_id_idx | x | n | t | t - channel1_product3_product_id_idx | x | n | t | t - channel1_product4_product_id_idx | x | n | t | t - channel4_product1_product_id_idx | x | n | t | t - channel5_product1_product_id_idx | x | n | t | t - channel5_product2_product_id_idx | x | n | t | t - channel5_product3_product_id_idx | x | n | t | t - channel5_product4_product_id_idx | x | n | t | t - channel6_subpartdefault1_product_id_idx | x | n | t | t -(10 rows) - -\d+ list_hash_sales - Table "hw_subpartition_add_drop_partition.list_hash_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "list_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default UNUSABLE - "list_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By LIST(channel_id) Subpartition By HASH(product_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 10 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - --- -----hash-range table---- --- ---prepare -CREATE TABLE hash_range_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY HASH (product_id) SUBPARTITION BY RANGE (customer_id) -( - PARTITION product1 - ( - SUBPARTITION product1_customer1 VALUES LESS THAN (200), - SUBPARTITION product1_customer2 VALUES LESS THAN (500), - SUBPARTITION product1_customer3 VALUES LESS THAN (800), - SUBPARTITION product1_customer4 VALUES LESS THAN (1200) - ), - PARTITION product2 - ( - SUBPARTITION product2_customer1 VALUES LESS THAN (500), - SUBPARTITION product2_customer2 VALUES LESS THAN (MAXVALUE) - ), - PARTITION product3, - PARTITION product4 - ( - SUBPARTITION product4_customer1 VALUES LESS THAN (1200) - ) -); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hash_range_sales_pkey" for table "hash_range_sales" -INSERT INTO hash_range_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX hash_range_sales_idx ON hash_range_sales(product_id) LOCAL; ---check for add partition/subpartition ---fail, not support add hash -ALTER TABLE hash_range_sales ADD PARTITION product_temp1 - ( - SUBPARTITION product_temp1_customer1 VALUES LESS THAN (200), - SUBPARTITION product_temp1_customer2 VALUES LESS THAN (500), - SUBPARTITION product_temp1_customer3 VALUES LESS THAN (800), - SUBPARTITION product_temp1_customer4 VALUES LESS THAN (1200) - ); -ERROR: syntax error at or near "(" -LINE 2: ( - ^ ---fail, not support add hash -ALTER TABLE hash_range_sales ADD PARTITION product_temp2; -ERROR: syntax error at or near ";" -LINE 1: ALTER TABLE hash_range_sales ADD PARTITION product_temp2; - ^ ---success, add 1 subpartition -ALTER TABLE hash_range_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_customer5 VALUES LESS THAN (1800); ---fail, out of range -ALTER TABLE hash_range_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES LESS THAN (1800); -ERROR: upper boundary of adding partition MUST overtop last existing partition ---fail, invalid format -ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES (DEFAULT); -ERROR: can not add none-range subpartition to range subpartition table ---success, add 1 subpartition -ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_customer2 VALUES LESS THAN (MAXVALUE); ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_range_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------ - product1 | p | h | f | 0 | 2 | {0} - product2 | p | h | f | 0 | 2 | {1} - product3 | p | h | f | 0 | 2 | {2} - product4 | p | h | f | 0 | 2 | {3} - hash_range_sales | r | h | f | 0 | 1 | - product1_customer1 | s | r | t | 0 | | {200} - product1_customer2 | s | r | t | 0 | | {500} - product1_customer3 | s | r | t | 0 | | {800} - product1_customer4 | s | r | t | 0 | | {1200} - product1_customer5 | s | r | t | 0 | | {1800} - product2_customer1 | s | r | t | 0 | | {500} - product2_customer2 | s | r | t | 0 | | {NULL} - product3_subpartdefault1 | s | r | t | 0 | | {NULL} - product4_customer1 | s | r | t | 0 | | {1200} - product4_customer2 | s | r | t | 0 | | {NULL} -(15 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - product1_customer1_product_id_idx | x | n | t | t - product1_customer2_product_id_idx | x | n | t | t - product1_customer3_product_id_idx | x | n | t | t - product1_customer4_product_id_idx | x | n | t | t - product1_customer5_product_id_idx | x | n | t | t - product2_customer1_product_id_idx | x | n | t | t - product2_customer2_product_id_idx | x | n | t | t - product3_subpartdefault1_product_id_idx | x | n | t | t - product4_customer1_product_id_idx | x | n | t | t - product4_customer2_product_id_idx | x | n | t | t -(10 rows) - -\d+ hash_range_sales - Table "hw_subpartition_add_drop_partition.hash_range_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "hash_range_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default - "hash_range_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By HASH(product_id) Subpartition By RANGE(customer_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 10 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - ---check for drop partition/subpartition (for) ---fail, not support drop hash -ALTER TABLE hash_range_sales DROP PARTITION product2; -ERROR: Droping hash partition is unsupported. ---success, drop subpartition product1_customer1 -ALTER TABLE hash_range_sales DROP SUBPARTITION product1_customer1; ---success, drop subpartition product4_customer1 -ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer1; ---fail, the only subpartition in product4 -ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer2; -ERROR: Cannot drop the only subpartition of a partitioned table -DETAIL: N/A ---fail, not support drop hash -ALTER TABLE hash_range_sales DROP PARTITION FOR(0); -ERROR: Droping hash partition is unsupported. ---fail, not support drop hash -ALTER TABLE hash_range_sales DROP PARTITION FOR(0, 100); -ERROR: Droping hash partition is unsupported. ---fail, number not equal to the number of partkey -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0); -ERROR: Number of boundary items NOT EQUAL to number of partition keys -DETAIL: There must be 2 boundary items for DROP SUBPARTITION in a subpartitioned table ---fail, invalid type -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR('2010-01-01', 100); -ERROR: invalid input syntax for integer: "2010-01-01" ---success, drop subpartition product1_customer2, but not suggest to do this operation -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 100); ---fail, no subpartition find -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 2300); -ERROR: The subpartition number is invalid or out-of-range -DETAIL: N/A ---check for ok after drop -SELECT count(*) FROM hash_range_sales; - count -------- - 628 -(1 row) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_range_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------ - product1 | p | h | f | 0 | 2 | {0} - product2 | p | h | f | 0 | 2 | {1} - product3 | p | h | f | 0 | 2 | {2} - product4 | p | h | f | 0 | 2 | {3} - hash_range_sales | r | h | f | 0 | 1 | - product1_customer3 | s | r | t | 0 | | {800} - product1_customer4 | s | r | t | 0 | | {1200} - product1_customer5 | s | r | t | 0 | | {1800} - product2_customer1 | s | r | t | 0 | | {500} - product2_customer2 | s | r | t | 0 | | {NULL} - product3_subpartdefault1 | s | r | t | 0 | | {NULL} - product4_customer2 | s | r | t | 0 | | {NULL} -(12 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - product1_customer3_product_id_idx | x | n | t | t - product1_customer4_product_id_idx | x | n | t | t - product1_customer5_product_id_idx | x | n | t | t - product2_customer1_product_id_idx | x | n | t | t - product2_customer2_product_id_idx | x | n | t | t - product3_subpartdefault1_product_id_idx | x | n | t | t - product4_customer2_product_id_idx | x | n | t | t -(7 rows) - -\d+ hash_range_sales - Table "hw_subpartition_add_drop_partition.hash_range_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "hash_range_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default UNUSABLE - "hash_range_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By HASH(product_id) Subpartition By RANGE(customer_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 7 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - --- -----hash-list table---- --- ---prepare -CREATE TABLE hash_list_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY HASH (product_id) SUBPARTITION BY LIST (channel_id) -( - PARTITION product1 - ( - SUBPARTITION product1_channel1 VALUES ('0', '1', '2'), - SUBPARTITION product1_channel2 VALUES ('3', '4', '5'), - SUBPARTITION product1_channel3 VALUES ('6', '7', '8'), - SUBPARTITION product1_channel4 VALUES ('9') - ), - PARTITION product2 - ( - SUBPARTITION product2_channel1 VALUES ('0', '1', '2', '3', '4'), - SUBPARTITION product2_channel2 VALUES (DEFAULT) - ), - PARTITION product3, - PARTITION product4 - ( - SUBPARTITION product4_channel1 VALUES ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') - ) -); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hash_list_sales_pkey" for table "hash_list_sales" -INSERT INTO hash_list_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX hash_list_sales_idx ON hash_list_sales(product_id) LOCAL; ---check for add partition/subpartition ---fail, not support add hash -ALTER TABLE hash_list_sales ADD PARTITION product_temp1 - ( - SUBPARTITION product_temp1_channel1 VALUES ('0', '1', '2'), - SUBPARTITION product_temp1_channel2 VALUES ('3', '4', '5'), - SUBPARTITION product_temp1_channel3 VALUES ('6', '7', '8'), - SUBPARTITION product_temp1_channel4 VALUES ('9') - ); -ERROR: syntax error at or near "(" -LINE 2: ( - ^ ---fail, not support add hash -ALTER TABLE hash_list_sales ADD PARTITION product_temp2; -ERROR: syntax error at or near ";" -LINE 1: ALTER TABLE hash_list_sales ADD PARTITION product_temp2; - ^ ---success, add 1 subpartition -ALTER TABLE hash_list_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_channel5 VALUES ('X'); ---fail, out of range -ALTER TABLE hash_list_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES ('X'); -ERROR: list boundary of adding partition MUST NOT overlap with existing partition ---fail, out of range -ALTER TABLE hash_list_sales MODIFY PARTITION product3 ADD SUBPARTITION product3_temp1 VALUES ('X'); -ERROR: list boundary of adding partition MUST NOT overlap with existing partition ---fail, invalid format -ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES LESS THAN (MAXVALUE); -ERROR: can not add none-list subpartition to list subpartition table ---success, add 1 subpartition -ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_channel2 VALUES (DEFAULT); ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_list_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+----------------------- - product1 | p | h | f | 0 | 4 | {0} - product2 | p | h | f | 0 | 4 | {1} - product3 | p | h | f | 0 | 4 | {2} - product4 | p | h | f | 0 | 4 | {3} - hash_list_sales | r | h | f | 0 | 1 | - product1_channel1 | s | l | t | 0 | | {0,1,2} - product1_channel2 | s | l | t | 0 | | {3,4,5} - product1_channel3 | s | l | t | 0 | | {6,7,8} - product1_channel4 | s | l | t | 0 | | {9} - product1_channel5 | s | l | t | 0 | | {X} - product2_channel1 | s | l | t | 0 | | {0,1,2,3,4} - product2_channel2 | s | l | t | 0 | | {NULL} - product3_subpartdefault1 | s | l | t | 0 | | {NULL} - product4_channel1 | s | l | t | 0 | | {0,1,2,3,4,5,6,7,8,9} - product4_channel2 | s | l | t | 0 | | {NULL} -(15 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - product1_channel1_product_id_idx | x | n | t | t - product1_channel2_product_id_idx | x | n | t | t - product1_channel3_product_id_idx | x | n | t | t - product1_channel4_product_id_idx | x | n | t | t - product1_channel5_product_id_idx | x | n | t | t - product2_channel1_product_id_idx | x | n | t | t - product2_channel2_product_id_idx | x | n | t | t - product3_subpartdefault1_product_id_idx | x | n | t | t - product4_channel1_product_id_idx | x | n | t | t - product4_channel2_product_id_idx | x | n | t | t -(10 rows) - -\d+ hash_list_sales - Table "hw_subpartition_add_drop_partition.hash_list_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "hash_list_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default - "hash_list_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By HASH(product_id) Subpartition By LIST(channel_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 10 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - ---check for drop partition/subpartition (for) ---fail, not support drop hash -ALTER TABLE hash_list_sales DROP PARTITION product2; -ERROR: Droping hash partition is unsupported. ---success, drop subpartition product1_channel1 -ALTER TABLE hash_list_sales DROP SUBPARTITION product1_channel1; ---success, drop subpartition product4_channel1 -ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel1; ---fail, the only subpartition in product4 -ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel2; -ERROR: Cannot drop the only subpartition of a partitioned table -DETAIL: N/A ---fail, not support drop hash -ALTER TABLE hash_list_sales DROP PARTITION FOR(0); -ERROR: Droping hash partition is unsupported. ---fail, not support drop hash -ALTER TABLE hash_list_sales DROP PARTITION FOR(0, '4'); -ERROR: Droping hash partition is unsupported. ---fail, number not equal to the number of partkey -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0); -ERROR: Number of boundary items NOT EQUAL to number of partition keys -DETAIL: There must be 2 boundary items for DROP SUBPARTITION in a subpartitioned table ---fail, invalid type -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR('2010-01-01', '4'); -ERROR: invalid input syntax for integer: "2010-01-01" ---success, drop subpartition product1_channel2, but not suggest to do this operation -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, '4'); ---fail, no subpartition find -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, 'Z'); -ERROR: The subpartition number is invalid or out-of-range -DETAIL: N/A ---check for ok after drop -SELECT count(*) FROM hash_list_sales; - count -------- - 608 -(1 row) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_list_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------- - product1 | p | h | f | 0 | 4 | {0} - product2 | p | h | f | 0 | 4 | {1} - product3 | p | h | f | 0 | 4 | {2} - product4 | p | h | f | 0 | 4 | {3} - hash_list_sales | r | h | f | 0 | 1 | - product1_channel3 | s | l | t | 0 | | {6,7,8} - product1_channel4 | s | l | t | 0 | | {9} - product1_channel5 | s | l | t | 0 | | {X} - product2_channel1 | s | l | t | 0 | | {0,1,2,3,4} - product2_channel2 | s | l | t | 0 | | {NULL} - product3_subpartdefault1 | s | l | t | 0 | | {NULL} - product4_channel2 | s | l | t | 0 | | {NULL} -(12 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - product1_channel3_product_id_idx | x | n | t | t - product1_channel4_product_id_idx | x | n | t | t - product1_channel5_product_id_idx | x | n | t | t - product2_channel1_product_id_idx | x | n | t | t - product2_channel2_product_id_idx | x | n | t | t - product3_subpartdefault1_product_id_idx | x | n | t | t - product4_channel2_product_id_idx | x | n | t | t -(7 rows) - -\d+ hash_list_sales - Table "hw_subpartition_add_drop_partition.hash_list_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "hash_list_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default UNUSABLE - "hash_list_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By HASH(product_id) Subpartition By LIST(channel_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 7 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - --- -----hash-hash table---- --- ---prepare -CREATE TABLE hash_hash_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY HASH (product_id) SUBPARTITION BY HASH (customer_id) -( - PARTITION product1 - ( - SUBPARTITION product1_customer1, - SUBPARTITION product1_customer2, - SUBPARTITION product1_customer3, - SUBPARTITION product1_customer4 - ), - PARTITION product2 - ( - SUBPARTITION product2_customer1, - SUBPARTITION product2_customer2 - ), - PARTITION product3, - PARTITION product4 - ( - SUBPARTITION product4_customer1 - ) -); -NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hash_hash_sales_pkey" for table "hash_hash_sales" -INSERT INTO hash_hash_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX hash_hash_sales_idx ON hash_hash_sales(product_id) LOCAL; ---check for add partition/subpartition ---fail, not support add hash -ALTER TABLE hash_hash_sales ADD PARTITION product_temp1 - ( - SUBPARTITION product_temp1_customer1, - SUBPARTITION product_temp1_customer2, - SUBPARTITION product_temp1_customer3, - SUBPARTITION product_temp1_customer4 - ); -ERROR: syntax error at or near "(" -LINE 2: ( - ^ ---fail, not support add hash -ALTER TABLE hash_hash_sales ADD PARTITION product_temp2; -ERROR: syntax error at or near ";" -LINE 1: ALTER TABLE hash_hash_sales ADD PARTITION product_temp2; - ^ ---fail, not support add hash -ALTER TABLE hash_hash_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_temp1; -ERROR: syntax error at or near ";" -LINE 1: ...s MODIFY PARTITION product1 ADD SUBPARTITION product1_temp1; - ^ ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------ - product1 | p | h | f | 0 | 2 | {0} - product2 | p | h | f | 0 | 2 | {1} - product3 | p | h | f | 0 | 2 | {2} - product4 | p | h | f | 0 | 2 | {3} - hash_hash_sales | r | h | f | 0 | 1 | - product1_customer1 | s | h | t | 0 | | {0} - product1_customer2 | s | h | t | 0 | | {1} - product1_customer3 | s | h | t | 0 | | {2} - product1_customer4 | s | h | t | 0 | | {3} - product2_customer1 | s | h | t | 0 | | {0} - product2_customer2 | s | h | t | 0 | | {1} - product3_subpartdefault1 | s | h | t | 0 | | {0} - product4_customer1 | s | h | t | 0 | | {0} -(13 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - product1_customer1_product_id_idx | x | n | t | t - product1_customer2_product_id_idx | x | n | t | t - product1_customer3_product_id_idx | x | n | t | t - product1_customer4_product_id_idx | x | n | t | t - product2_customer1_product_id_idx | x | n | t | t - product2_customer2_product_id_idx | x | n | t | t - product3_subpartdefault1_product_id_idx | x | n | t | t - product4_customer1_product_id_idx | x | n | t | t -(8 rows) - -\d+ hash_hash_sales - Table "hw_subpartition_add_drop_partition.hash_hash_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "hash_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default - "hash_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By HASH(product_id) Subpartition By HASH(customer_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 8 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - ---check for drop partition/subpartition (for) ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP PARTITION product2; -ERROR: Droping hash partition is unsupported. ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION product1_customer1; -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION product4_customer1; -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP PARTITION FOR(0); -ERROR: Droping hash partition is unsupported. ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP PARTITION FOR(0, 0); -ERROR: Droping hash partition is unsupported. ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0, 0); -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0); -ERROR: Un-support feature -DETAIL: The syntax is unsupported for hash subpartition ---check for ok after drop -SELECT count(*) FROM hash_hash_sales; - count -------- - 1000 -(1 row) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; - relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries ---------------------------+----------+--------------+-------------+---------------+---------+------------ - product1 | p | h | f | 0 | 2 | {0} - product2 | p | h | f | 0 | 2 | {1} - product3 | p | h | f | 0 | 2 | {2} - product4 | p | h | f | 0 | 2 | {3} - hash_hash_sales | r | h | f | 0 | 1 | - product1_customer1 | s | h | t | 0 | | {0} - product1_customer2 | s | h | t | 0 | | {1} - product1_customer3 | s | h | t | 0 | | {2} - product1_customer4 | s | h | t | 0 | | {3} - product2_customer1 | s | h | t | 0 | | {0} - product2_customer2 | s | h | t | 0 | | {1} - product3_subpartdefault1 | s | h | t | 0 | | {0} - product4_customer1 | s | h | t | 0 | | {0} -(13 rows) - -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; - relname | parttype | partstrategy | hasfilenode | indisusable ------------------------------------------+----------+--------------+-------------+------------- - product1_customer1_product_id_idx | x | n | t | t - product1_customer2_product_id_idx | x | n | t | t - product1_customer3_product_id_idx | x | n | t | t - product1_customer4_product_id_idx | x | n | t | t - product2_customer1_product_id_idx | x | n | t | t - product2_customer2_product_id_idx | x | n | t | t - product3_subpartdefault1_product_id_idx | x | n | t | t - product4_customer1_product_id_idx | x | n | t | t -(8 rows) - -\d+ hash_hash_sales - Table "hw_subpartition_add_drop_partition.hash_hash_sales" - Column | Type | Modifiers | Storage | Stats target | Description ----------------+--------------------------------+-----------+----------+--------------+------------- - product_id | integer | not null | plain | | - customer_id | integer | not null | plain | | - time_id | timestamp(0) without time zone | | plain | | - channel_id | character(1) | | extended | | - type_id | integer | | plain | | - quantity_sold | numeric(3,0) | | main | | - amount_sold | numeric(10,2) | | main | | -Indexes: - "hash_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default - "hash_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default -Partition By HASH(product_id) Subpartition By HASH(customer_id) -Number of partitions: 4 (View pg_partition to check each partition range.) -Number of subpartitions: 8 (View pg_partition to check each subpartition range.) -Has OIDs: no -Options: orientation=row, compression=no - --finish DROP TABLE range_range_sales; DROP TABLE range_list_sales; DROP TABLE range_hash_sales; DROP TABLE list_range_sales; DROP TABLE list_list_sales; -DROP TABLE list_hash_sales; -DROP TABLE hash_range_sales; -DROP TABLE hash_list_sales; -DROP TABLE hash_hash_sales; DROP SCHEMA hw_subpartition_add_drop_partition CASCADE; RESET CURRENT_SCHEMA; diff --git a/src/test/regress/expected/hw_subpartition_add_drop_partition_1.out b/src/test/regress/expected/hw_subpartition_add_drop_partition_1.out new file mode 100644 index 000000000..0fc715f4b --- /dev/null +++ b/src/test/regress/expected/hw_subpartition_add_drop_partition_1.out @@ -0,0 +1,1016 @@ +DROP SCHEMA hw_subpartition_add_drop_partition_1 CASCADE; +ERROR: schema "hw_subpartition_add_drop_partition_1" does not exist +CREATE SCHEMA hw_subpartition_add_drop_partition_1; +SET CURRENT_SCHEMA TO hw_subpartition_add_drop_partition_1; +-- +----list-hash table---- +-- +--prepare +CREATE TABLE list_hash_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY LIST (channel_id) SUBPARTITION BY HASH (product_id) +( + PARTITION channel1 VALUES ('0', '1', '2') + ( + SUBPARTITION channel1_product1, + SUBPARTITION channel1_product2, + SUBPARTITION channel1_product3, + SUBPARTITION channel1_product4 + ), + PARTITION channel2 VALUES ('3', '4', '5') + ( + SUBPARTITION channel2_product1, + SUBPARTITION channel2_product2 + ), + PARTITION channel3 VALUES ('6', '7'), + PARTITION channel4 VALUES ('8', '9') + ( + SUBPARTITION channel4_product1 + ) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "list_hash_sales_pkey" for table "list_hash_sales" +INSERT INTO list_hash_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX list_hash_sales_idx ON list_hash_sales(product_id) LOCAL; +--check for add partition/subpartition +--success, add 4 subpartition +ALTER TABLE list_hash_sales ADD PARTITION channel5 VALUES ('X') + ( + SUBPARTITION channel5_product1, + SUBPARTITION channel5_product2, + SUBPARTITION channel5_product3, + SUBPARTITION channel5_product4 + ); +--fail, value conflict +ALTER TABLE list_hash_sales ADD PARTITION channel_temp1 VALUES ('0', 'Z', 'C'); +ERROR: list boundary of adding partition MUST NOT overlap with existing partition +--fail, value conflict +ALTER TABLE list_hash_sales ADD PARTITION channel_temp2 VALUES ('Z', 'Z', 'C'); +ERROR: list partition channel_temp2 has overlapped value +--fail, invalid format +ALTER TABLE list_hash_sales ADD PARTITION channel_temp3 VALUES LESS THAN ('Z'); +ERROR: can not add none-list partition to list partition table +--success, add 1 default subpartition +ALTER TABLE list_hash_sales ADD PARTITION channel6 VALUES (DEFAULT); +--fail, value conflict +ALTER TABLE list_hash_sales ADD PARTITION channel_temp4 VALUES ('M', 'X'); +ERROR: list boundary of adding partition MUST NOT overlap with existing partition +--fail, not support add hash +ALTER TABLE list_hash_sales MODIFY PARTITION channel1 ADD SUBPARTITION channel1_temp1; +ERROR: syntax error at or near ";" +LINE 1: ...s MODIFY PARTITION channel1 ADD SUBPARTITION channel1_temp1; + ^ +--fail, invalid format +ALTER TABLE list_hash_sales MODIFY PARTITION channel4 ADD SUBPARTITION channel4_temp1 VALUES LESS THAN (1500); +ERROR: can not add hash subpartition +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='list_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------ + channel1 | p | l | f | 0 | 1 | {0,1,2} + channel2 | p | l | f | 0 | 1 | {3,4,5} + channel3 | p | l | f | 0 | 1 | {6,7} + channel4 | p | l | f | 0 | 1 | {8,9} + channel5 | p | l | f | 0 | 1 | {X} + channel6 | p | l | f | 0 | 1 | {NULL} + list_hash_sales | r | l | f | 0 | 4 | + channel1_product1 | s | h | t | 0 | | {0} + channel1_product2 | s | h | t | 0 | | {1} + channel1_product3 | s | h | t | 0 | | {2} + channel1_product4 | s | h | t | 0 | | {3} + channel2_product1 | s | h | t | 0 | | {0} + channel2_product2 | s | h | t | 0 | | {1} + channel3_subpartdefault1 | s | h | t | 0 | | {0} + channel4_product1 | s | h | t | 0 | | {0} + channel5_product1 | s | h | t | 0 | | {0} + channel5_product2 | s | h | t | 0 | | {1} + channel5_product3 | s | h | t | 0 | | {2} + channel5_product4 | s | h | t | 0 | | {3} + channel6_subpartdefault1 | s | h | t | 0 | | {0} +(20 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + channel1_product1_product_id_idx | x | n | t | t + channel1_product2_product_id_idx | x | n | t | t + channel1_product3_product_id_idx | x | n | t | t + channel1_product4_product_id_idx | x | n | t | t + channel2_product1_product_id_idx | x | n | t | t + channel2_product2_product_id_idx | x | n | t | t + channel3_subpartdefault1_product_id_idx | x | n | t | t + channel4_product1_product_id_idx | x | n | t | t + channel5_product1_product_id_idx | x | n | t | t + channel5_product2_product_id_idx | x | n | t | t + channel5_product3_product_id_idx | x | n | t | t + channel5_product4_product_id_idx | x | n | t | t + channel6_subpartdefault1_product_id_idx | x | n | t | t +(13 rows) + +\d+ list_hash_sales + Table "hw_subpartition_add_drop_partition_1.list_hash_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "list_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default + "list_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By LIST(channel_id) Subpartition By HASH(product_id) +Number of partitions: 6 (View pg_partition to check each partition range.) +Number of subpartitions: 13 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +--check for drop partition/subpartition (for) +--success, drop partition channel2 +ALTER TABLE list_hash_sales DROP PARTITION channel2; +--fail, not support drop hash +ALTER TABLE list_hash_sales DROP SUBPARTITION channel1_product1; +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--fail, not support drop hash +ALTER TABLE list_hash_sales DROP SUBPARTITION channel4_product1; +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--success, drop partition channel3 +ALTER TABLE list_hash_sales DROP PARTITION FOR ('6'); +--fail, number not equal to the number of partkey +ALTER TABLE list_hash_sales DROP PARTITION FOR ('6', '2010-01-01'); +ERROR: number of boundary items NOT EQUAL to number of partition keys +--fail, invalid type +ALTER TABLE list_hash_sales DROP PARTITION FOR (10); +ERROR: value too long for type character(1) +--fail, not support drop hash +ALTER TABLE list_hash_sales DROP SUBPARTITION FOR('X', 6); +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--check for ok after drop +SELECT count(*) FROM list_hash_sales; + count +------- + 500 +(1 row) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='list_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------ + channel1 | p | l | f | 0 | 1 | {0,1,2} + channel4 | p | l | f | 0 | 1 | {8,9} + channel5 | p | l | f | 0 | 1 | {X} + channel6 | p | l | f | 0 | 1 | {NULL} + list_hash_sales | r | l | f | 0 | 4 | + channel1_product1 | s | h | t | 0 | | {0} + channel1_product2 | s | h | t | 0 | | {1} + channel1_product3 | s | h | t | 0 | | {2} + channel1_product4 | s | h | t | 0 | | {3} + channel4_product1 | s | h | t | 0 | | {0} + channel5_product1 | s | h | t | 0 | | {0} + channel5_product2 | s | h | t | 0 | | {1} + channel5_product3 | s | h | t | 0 | | {2} + channel5_product4 | s | h | t | 0 | | {3} + channel6_subpartdefault1 | s | h | t | 0 | | {0} +(15 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + channel1_product1_product_id_idx | x | n | t | t + channel1_product2_product_id_idx | x | n | t | t + channel1_product3_product_id_idx | x | n | t | t + channel1_product4_product_id_idx | x | n | t | t + channel4_product1_product_id_idx | x | n | t | t + channel5_product1_product_id_idx | x | n | t | t + channel5_product2_product_id_idx | x | n | t | t + channel5_product3_product_id_idx | x | n | t | t + channel5_product4_product_id_idx | x | n | t | t + channel6_subpartdefault1_product_id_idx | x | n | t | t +(10 rows) + +\d+ list_hash_sales + Table "hw_subpartition_add_drop_partition_1.list_hash_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "list_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default UNUSABLE + "list_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By LIST(channel_id) Subpartition By HASH(product_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 10 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +-- +----hash-range table---- +-- +--prepare +CREATE TABLE hash_range_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY HASH (product_id) SUBPARTITION BY RANGE (customer_id) +( + PARTITION product1 + ( + SUBPARTITION product1_customer1 VALUES LESS THAN (200), + SUBPARTITION product1_customer2 VALUES LESS THAN (500), + SUBPARTITION product1_customer3 VALUES LESS THAN (800), + SUBPARTITION product1_customer4 VALUES LESS THAN (1200) + ), + PARTITION product2 + ( + SUBPARTITION product2_customer1 VALUES LESS THAN (500), + SUBPARTITION product2_customer2 VALUES LESS THAN (MAXVALUE) + ), + PARTITION product3, + PARTITION product4 + ( + SUBPARTITION product4_customer1 VALUES LESS THAN (1200) + ) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hash_range_sales_pkey" for table "hash_range_sales" +INSERT INTO hash_range_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX hash_range_sales_idx ON hash_range_sales(product_id) LOCAL; +--check for add partition/subpartition +--fail, not support add hash +ALTER TABLE hash_range_sales ADD PARTITION product_temp1 + ( + SUBPARTITION product_temp1_customer1 VALUES LESS THAN (200), + SUBPARTITION product_temp1_customer2 VALUES LESS THAN (500), + SUBPARTITION product_temp1_customer3 VALUES LESS THAN (800), + SUBPARTITION product_temp1_customer4 VALUES LESS THAN (1200) + ); +ERROR: syntax error at or near "(" +LINE 2: ( + ^ +--fail, not support add hash +ALTER TABLE hash_range_sales ADD PARTITION product_temp2; +ERROR: syntax error at or near ";" +LINE 1: ALTER TABLE hash_range_sales ADD PARTITION product_temp2; + ^ +--success, add 1 subpartition +ALTER TABLE hash_range_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_customer5 VALUES LESS THAN (1800); +--fail, out of range +ALTER TABLE hash_range_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES LESS THAN (1800); +ERROR: upper boundary of adding partition MUST overtop last existing partition +--fail, invalid format +ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES (DEFAULT); +ERROR: can not add none-range subpartition to range subpartition table +--success, add 1 subpartition +ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_customer2 VALUES LESS THAN (MAXVALUE); +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_range_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------ + product1 | p | h | f | 0 | 2 | {0} + product2 | p | h | f | 0 | 2 | {1} + product3 | p | h | f | 0 | 2 | {2} + product4 | p | h | f | 0 | 2 | {3} + hash_range_sales | r | h | f | 0 | 1 | + product1_customer1 | s | r | t | 0 | | {200} + product1_customer2 | s | r | t | 0 | | {500} + product1_customer3 | s | r | t | 0 | | {800} + product1_customer4 | s | r | t | 0 | | {1200} + product1_customer5 | s | r | t | 0 | | {1800} + product2_customer1 | s | r | t | 0 | | {500} + product2_customer2 | s | r | t | 0 | | {NULL} + product3_subpartdefault1 | s | r | t | 0 | | {NULL} + product4_customer1 | s | r | t | 0 | | {1200} + product4_customer2 | s | r | t | 0 | | {NULL} +(15 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + product1_customer1_product_id_idx | x | n | t | t + product1_customer2_product_id_idx | x | n | t | t + product1_customer3_product_id_idx | x | n | t | t + product1_customer4_product_id_idx | x | n | t | t + product1_customer5_product_id_idx | x | n | t | t + product2_customer1_product_id_idx | x | n | t | t + product2_customer2_product_id_idx | x | n | t | t + product3_subpartdefault1_product_id_idx | x | n | t | t + product4_customer1_product_id_idx | x | n | t | t + product4_customer2_product_id_idx | x | n | t | t +(10 rows) + +\d+ hash_range_sales + Table "hw_subpartition_add_drop_partition_1.hash_range_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "hash_range_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default + "hash_range_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By HASH(product_id) Subpartition By RANGE(customer_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 10 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +--check for drop partition/subpartition (for) +--fail, not support drop hash +ALTER TABLE hash_range_sales DROP PARTITION product2; +ERROR: Droping hash partition is unsupported. +--success, drop subpartition product1_customer1 +ALTER TABLE hash_range_sales DROP SUBPARTITION product1_customer1; +--success, drop subpartition product4_customer1 +ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer1; +--fail, the only subpartition in product4 +ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer2; +ERROR: Cannot drop the only subpartition of a partitioned table +DETAIL: N/A +--fail, not support drop hash +ALTER TABLE hash_range_sales DROP PARTITION FOR(0); +ERROR: Droping hash partition is unsupported. +--fail, not support drop hash +ALTER TABLE hash_range_sales DROP PARTITION FOR(0, 100); +ERROR: Droping hash partition is unsupported. +--fail, number not equal to the number of partkey +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0); +ERROR: Number of boundary items NOT EQUAL to number of partition keys +DETAIL: There must be 2 boundary items for DROP SUBPARTITION in a subpartitioned table +--fail, invalid type +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR('2010-01-01', 100); +ERROR: invalid input syntax for integer: "2010-01-01" +--success, drop subpartition product1_customer2, but not suggest to do this operation +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 100); +--fail, no subpartition find +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 2300); +ERROR: The subpartition number is invalid or out-of-range +DETAIL: N/A +--check for ok after drop +SELECT count(*) FROM hash_range_sales; + count +------- + 628 +(1 row) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_range_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------ + product1 | p | h | f | 0 | 2 | {0} + product2 | p | h | f | 0 | 2 | {1} + product3 | p | h | f | 0 | 2 | {2} + product4 | p | h | f | 0 | 2 | {3} + hash_range_sales | r | h | f | 0 | 1 | + product1_customer3 | s | r | t | 0 | | {800} + product1_customer4 | s | r | t | 0 | | {1200} + product1_customer5 | s | r | t | 0 | | {1800} + product2_customer1 | s | r | t | 0 | | {500} + product2_customer2 | s | r | t | 0 | | {NULL} + product3_subpartdefault1 | s | r | t | 0 | | {NULL} + product4_customer2 | s | r | t | 0 | | {NULL} +(12 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + product1_customer3_product_id_idx | x | n | t | t + product1_customer4_product_id_idx | x | n | t | t + product1_customer5_product_id_idx | x | n | t | t + product2_customer1_product_id_idx | x | n | t | t + product2_customer2_product_id_idx | x | n | t | t + product3_subpartdefault1_product_id_idx | x | n | t | t + product4_customer2_product_id_idx | x | n | t | t +(7 rows) + +\d+ hash_range_sales + Table "hw_subpartition_add_drop_partition_1.hash_range_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "hash_range_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default UNUSABLE + "hash_range_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By HASH(product_id) Subpartition By RANGE(customer_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 7 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +-- +----hash-list table---- +-- +--prepare +CREATE TABLE hash_list_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY HASH (product_id) SUBPARTITION BY LIST (channel_id) +( + PARTITION product1 + ( + SUBPARTITION product1_channel1 VALUES ('0', '1', '2'), + SUBPARTITION product1_channel2 VALUES ('3', '4', '5'), + SUBPARTITION product1_channel3 VALUES ('6', '7', '8'), + SUBPARTITION product1_channel4 VALUES ('9') + ), + PARTITION product2 + ( + SUBPARTITION product2_channel1 VALUES ('0', '1', '2', '3', '4'), + SUBPARTITION product2_channel2 VALUES (DEFAULT) + ), + PARTITION product3, + PARTITION product4 + ( + SUBPARTITION product4_channel1 VALUES ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') + ) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hash_list_sales_pkey" for table "hash_list_sales" +INSERT INTO hash_list_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX hash_list_sales_idx ON hash_list_sales(product_id) LOCAL; +--check for add partition/subpartition +--fail, not support add hash +ALTER TABLE hash_list_sales ADD PARTITION product_temp1 + ( + SUBPARTITION product_temp1_channel1 VALUES ('0', '1', '2'), + SUBPARTITION product_temp1_channel2 VALUES ('3', '4', '5'), + SUBPARTITION product_temp1_channel3 VALUES ('6', '7', '8'), + SUBPARTITION product_temp1_channel4 VALUES ('9') + ); +ERROR: syntax error at or near "(" +LINE 2: ( + ^ +--fail, not support add hash +ALTER TABLE hash_list_sales ADD PARTITION product_temp2; +ERROR: syntax error at or near ";" +LINE 1: ALTER TABLE hash_list_sales ADD PARTITION product_temp2; + ^ +--success, add 1 subpartition +ALTER TABLE hash_list_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_channel5 VALUES ('X'); +--fail, out of range +ALTER TABLE hash_list_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES ('X'); +ERROR: list boundary of adding partition MUST NOT overlap with existing partition +--fail, out of range +ALTER TABLE hash_list_sales MODIFY PARTITION product3 ADD SUBPARTITION product3_temp1 VALUES ('X'); +ERROR: list boundary of adding partition MUST NOT overlap with existing partition +--fail, invalid format +ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES LESS THAN (MAXVALUE); +ERROR: can not add none-list subpartition to list subpartition table +--success, add 1 subpartition +ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_channel2 VALUES (DEFAULT); +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_list_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+----------------------- + product1 | p | h | f | 0 | 4 | {0} + product2 | p | h | f | 0 | 4 | {1} + product3 | p | h | f | 0 | 4 | {2} + product4 | p | h | f | 0 | 4 | {3} + hash_list_sales | r | h | f | 0 | 1 | + product1_channel1 | s | l | t | 0 | | {0,1,2} + product1_channel2 | s | l | t | 0 | | {3,4,5} + product1_channel3 | s | l | t | 0 | | {6,7,8} + product1_channel4 | s | l | t | 0 | | {9} + product1_channel5 | s | l | t | 0 | | {X} + product2_channel1 | s | l | t | 0 | | {0,1,2,3,4} + product2_channel2 | s | l | t | 0 | | {NULL} + product3_subpartdefault1 | s | l | t | 0 | | {NULL} + product4_channel1 | s | l | t | 0 | | {0,1,2,3,4,5,6,7,8,9} + product4_channel2 | s | l | t | 0 | | {NULL} +(15 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + product1_channel1_product_id_idx | x | n | t | t + product1_channel2_product_id_idx | x | n | t | t + product1_channel3_product_id_idx | x | n | t | t + product1_channel4_product_id_idx | x | n | t | t + product1_channel5_product_id_idx | x | n | t | t + product2_channel1_product_id_idx | x | n | t | t + product2_channel2_product_id_idx | x | n | t | t + product3_subpartdefault1_product_id_idx | x | n | t | t + product4_channel1_product_id_idx | x | n | t | t + product4_channel2_product_id_idx | x | n | t | t +(10 rows) + +\d+ hash_list_sales + Table "hw_subpartition_add_drop_partition_1.hash_list_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "hash_list_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default + "hash_list_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By HASH(product_id) Subpartition By LIST(channel_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 10 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +--check for drop partition/subpartition (for) +--fail, not support drop hash +ALTER TABLE hash_list_sales DROP PARTITION product2; +ERROR: Droping hash partition is unsupported. +--success, drop subpartition product1_channel1 +ALTER TABLE hash_list_sales DROP SUBPARTITION product1_channel1; +--success, drop subpartition product4_channel1 +ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel1; +--fail, the only subpartition in product4 +ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel2; +ERROR: Cannot drop the only subpartition of a partitioned table +DETAIL: N/A +--fail, not support drop hash +ALTER TABLE hash_list_sales DROP PARTITION FOR(0); +ERROR: Droping hash partition is unsupported. +--fail, not support drop hash +ALTER TABLE hash_list_sales DROP PARTITION FOR(0, '4'); +ERROR: Droping hash partition is unsupported. +--fail, number not equal to the number of partkey +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0); +ERROR: Number of boundary items NOT EQUAL to number of partition keys +DETAIL: There must be 2 boundary items for DROP SUBPARTITION in a subpartitioned table +--fail, invalid type +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR('2010-01-01', '4'); +ERROR: invalid input syntax for integer: "2010-01-01" +--success, drop subpartition product1_channel2, but not suggest to do this operation +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, '4'); +--fail, no subpartition find +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, 'Z'); +ERROR: The subpartition number is invalid or out-of-range +DETAIL: N/A +--check for ok after drop +SELECT count(*) FROM hash_list_sales; + count +------- + 608 +(1 row) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_list_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------- + product1 | p | h | f | 0 | 4 | {0} + product2 | p | h | f | 0 | 4 | {1} + product3 | p | h | f | 0 | 4 | {2} + product4 | p | h | f | 0 | 4 | {3} + hash_list_sales | r | h | f | 0 | 1 | + product1_channel3 | s | l | t | 0 | | {6,7,8} + product1_channel4 | s | l | t | 0 | | {9} + product1_channel5 | s | l | t | 0 | | {X} + product2_channel1 | s | l | t | 0 | | {0,1,2,3,4} + product2_channel2 | s | l | t | 0 | | {NULL} + product3_subpartdefault1 | s | l | t | 0 | | {NULL} + product4_channel2 | s | l | t | 0 | | {NULL} +(12 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + product1_channel3_product_id_idx | x | n | t | t + product1_channel4_product_id_idx | x | n | t | t + product1_channel5_product_id_idx | x | n | t | t + product2_channel1_product_id_idx | x | n | t | t + product2_channel2_product_id_idx | x | n | t | t + product3_subpartdefault1_product_id_idx | x | n | t | t + product4_channel2_product_id_idx | x | n | t | t +(7 rows) + +\d+ hash_list_sales + Table "hw_subpartition_add_drop_partition_1.hash_list_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "hash_list_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default UNUSABLE + "hash_list_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By HASH(product_id) Subpartition By LIST(channel_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 7 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +-- +----hash-hash table---- +-- +--prepare +CREATE TABLE hash_hash_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY HASH (product_id) SUBPARTITION BY HASH (customer_id) +( + PARTITION product1 + ( + SUBPARTITION product1_customer1, + SUBPARTITION product1_customer2, + SUBPARTITION product1_customer3, + SUBPARTITION product1_customer4 + ), + PARTITION product2 + ( + SUBPARTITION product2_customer1, + SUBPARTITION product2_customer2 + ), + PARTITION product3, + PARTITION product4 + ( + SUBPARTITION product4_customer1 + ) +); +NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "hash_hash_sales_pkey" for table "hash_hash_sales" +INSERT INTO hash_hash_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX hash_hash_sales_idx ON hash_hash_sales(product_id) LOCAL; +--check for add partition/subpartition +--fail, not support add hash +ALTER TABLE hash_hash_sales ADD PARTITION product_temp1 + ( + SUBPARTITION product_temp1_customer1, + SUBPARTITION product_temp1_customer2, + SUBPARTITION product_temp1_customer3, + SUBPARTITION product_temp1_customer4 + ); +ERROR: syntax error at or near "(" +LINE 2: ( + ^ +--fail, not support add hash +ALTER TABLE hash_hash_sales ADD PARTITION product_temp2; +ERROR: syntax error at or near ";" +LINE 1: ALTER TABLE hash_hash_sales ADD PARTITION product_temp2; + ^ +--fail, not support add hash +ALTER TABLE hash_hash_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_temp1; +ERROR: syntax error at or near ";" +LINE 1: ...s MODIFY PARTITION product1 ADD SUBPARTITION product1_temp1; + ^ +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------ + product1 | p | h | f | 0 | 2 | {0} + product2 | p | h | f | 0 | 2 | {1} + product3 | p | h | f | 0 | 2 | {2} + product4 | p | h | f | 0 | 2 | {3} + hash_hash_sales | r | h | f | 0 | 1 | + product1_customer1 | s | h | t | 0 | | {0} + product1_customer2 | s | h | t | 0 | | {1} + product1_customer3 | s | h | t | 0 | | {2} + product1_customer4 | s | h | t | 0 | | {3} + product2_customer1 | s | h | t | 0 | | {0} + product2_customer2 | s | h | t | 0 | | {1} + product3_subpartdefault1 | s | h | t | 0 | | {0} + product4_customer1 | s | h | t | 0 | | {0} +(13 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + product1_customer1_product_id_idx | x | n | t | t + product1_customer2_product_id_idx | x | n | t | t + product1_customer3_product_id_idx | x | n | t | t + product1_customer4_product_id_idx | x | n | t | t + product2_customer1_product_id_idx | x | n | t | t + product2_customer2_product_id_idx | x | n | t | t + product3_subpartdefault1_product_id_idx | x | n | t | t + product4_customer1_product_id_idx | x | n | t | t +(8 rows) + +\d+ hash_hash_sales + Table "hw_subpartition_add_drop_partition_1.hash_hash_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "hash_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default + "hash_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By HASH(product_id) Subpartition By HASH(customer_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 8 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +--check for drop partition/subpartition (for) +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP PARTITION product2; +ERROR: Droping hash partition is unsupported. +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION product1_customer1; +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION product4_customer1; +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP PARTITION FOR(0); +ERROR: Droping hash partition is unsupported. +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP PARTITION FOR(0, 0); +ERROR: Droping hash partition is unsupported. +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0, 0); +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0); +ERROR: Un-support feature +DETAIL: The syntax is unsupported for hash subpartition +--check for ok after drop +SELECT count(*) FROM hash_hash_sales; + count +------- + 1000 +(1 row) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; + relname | parttype | partstrategy | hasfilenode | reltablespace | partkey | boundaries +--------------------------+----------+--------------+-------------+---------------+---------+------------ + product1 | p | h | f | 0 | 2 | {0} + product2 | p | h | f | 0 | 2 | {1} + product3 | p | h | f | 0 | 2 | {2} + product4 | p | h | f | 0 | 2 | {3} + hash_hash_sales | r | h | f | 0 | 1 | + product1_customer1 | s | h | t | 0 | | {0} + product1_customer2 | s | h | t | 0 | | {1} + product1_customer3 | s | h | t | 0 | | {2} + product1_customer4 | s | h | t | 0 | | {3} + product2_customer1 | s | h | t | 0 | | {0} + product2_customer2 | s | h | t | 0 | | {1} + product3_subpartdefault1 | s | h | t | 0 | | {0} + product4_customer1 | s | h | t | 0 | | {0} +(13 rows) + +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; + relname | parttype | partstrategy | hasfilenode | indisusable +-----------------------------------------+----------+--------------+-------------+------------- + product1_customer1_product_id_idx | x | n | t | t + product1_customer2_product_id_idx | x | n | t | t + product1_customer3_product_id_idx | x | n | t | t + product1_customer4_product_id_idx | x | n | t | t + product2_customer1_product_id_idx | x | n | t | t + product2_customer2_product_id_idx | x | n | t | t + product3_subpartdefault1_product_id_idx | x | n | t | t + product4_customer1_product_id_idx | x | n | t | t +(8 rows) + +\d+ hash_hash_sales + Table "hw_subpartition_add_drop_partition_1.hash_hash_sales" + Column | Type | Modifiers | Storage | Stats target | Description +---------------+--------------------------------+-----------+----------+--------------+------------- + product_id | integer | not null | plain | | + customer_id | integer | not null | plain | | + time_id | timestamp(0) without time zone | | plain | | + channel_id | character(1) | | extended | | + type_id | integer | | plain | | + quantity_sold | numeric(3,0) | | main | | + amount_sold | numeric(10,2) | | main | | +Indexes: + "hash_hash_sales_pkey" PRIMARY KEY, btree (customer_id) TABLESPACE pg_default + "hash_hash_sales_idx" btree (product_id) LOCAL TABLESPACE pg_default +Partition By HASH(product_id) Subpartition By HASH(customer_id) +Number of partitions: 4 (View pg_partition to check each partition range.) +Number of subpartitions: 8 (View pg_partition to check each subpartition range.) +Has OIDs: no +Options: orientation=row, compression=no + +--finish +DROP TABLE list_hash_sales; +DROP TABLE hash_range_sales; +DROP TABLE hash_list_sales; +DROP TABLE hash_hash_sales; +DROP SCHEMA hw_subpartition_add_drop_partition_1 CASCADE; +RESET CURRENT_SCHEMA; diff --git a/src/test/regress/expected/segment_subpartition_select.out b/src/test/regress/expected/segment_subpartition_select.out index fe71a72cb..d834ce49b 100644 --- a/src/test/regress/expected/segment_subpartition_select.out +++ b/src/test/regress/expected/segment_subpartition_select.out @@ -1105,127 +1105,6 @@ select * from range_hash inner join range_range on range_hash.month_code = range 201903 | 2 | 1 | 1 | 201903 | 2 | 1 | 1 (9 rows) -drop table list_range_02; -ERROR: table "list_range_02" does not exist -CREATE TABLE IF NOT EXISTS list_range_02 -( - col_1 int , - col_2 int, - col_3 VARCHAR2 ( 30 ) , - col_4 int -) WITH (SEGMENT=ON) -PARTITION BY list (col_1) SUBPARTITION BY range (col_2) -( - PARTITION p_list_1 VALUES(-1,-2,-3,-4,-5,-6,-7,-8,-9,-10 ) - ( - SUBPARTITION p_range_1_1 VALUES LESS THAN( -10 ), - SUBPARTITION p_range_1_2 VALUES LESS THAN( 0 ), - SUBPARTITION p_range_1_3 VALUES LESS THAN( 10 ), - SUBPARTITION p_range_1_4 VALUES LESS THAN( 20 ), - SUBPARTITION p_range_1_5 VALUES LESS THAN( 50 ) - ), - PARTITION p_list_2 VALUES(1,2,3,4,5,6,7,8,9,10 ), - PARTITION p_list_3 VALUES(11,12,13,14,15,16,17,18,19,20) - ( - SUBPARTITION p_range_3_1 VALUES LESS THAN( 15 ), - SUBPARTITION p_range_3_2 VALUES LESS THAN( MAXVALUE ) - ), - PARTITION p_list_4 VALUES(21,22,23,24,25,26,27,28,29,30) - ( - SUBPARTITION p_range_4_1 VALUES LESS THAN( -10 ), - SUBPARTITION p_range_4_2 VALUES LESS THAN( 0 ), - SUBPARTITION p_range_4_3 VALUES LESS THAN( 10 ), - SUBPARTITION p_range_4_4 VALUES LESS THAN( 20 ), - SUBPARTITION p_range_4_5 VALUES LESS THAN( 50 ) - ), - PARTITION p_list_5 VALUES(31,32,33,34,35,36,37,38,39,40) - ( - SUBPARTITION p_range_5_1 VALUES LESS THAN( MAXVALUE ) - ), - PARTITION p_list_6 VALUES(41,42,43,44,45,46,47,48,49,50) - ( - SUBPARTITION p_range_6_1 VALUES LESS THAN( -10 ), - SUBPARTITION p_range_6_2 VALUES LESS THAN( 0 ), - SUBPARTITION p_range_6_3 VALUES LESS THAN( 10 ), - SUBPARTITION p_range_6_4 VALUES LESS THAN( 20 ), - SUBPARTITION p_range_6_5 VALUES LESS THAN( 50 ) - ), - PARTITION p_list_7 VALUES(default) -) ENABLE ROW MOVEMENT; -create index index_01 on list_range_02(col_2) local ; -INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 1000),GENERATE_SERIES(0, 99)); - explain (costs off, verbose on) select * from list_range_02 where col_2 >500 and col_2 <8000 order by col_1; - QUERY PLAN ------------------------------------------------------------------------------------------------- - Sort - Output: col_1, col_2, col_3, col_4 - Sort Key: list_range_02.col_1 - -> Partition Iterator - Output: col_1, col_2, col_3, col_4 - Iterations: 4, Sub Iterations: 4 - -> Partitioned Bitmap Heap Scan on segment_subpartition_select.list_range_02 - Output: col_1, col_2, col_3, col_4 - Recheck Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000)) - Selected Partitions: 2..3,5,7 - Selected Subpartitions: 2:1, 3:1, 5:1, 7:1 - -> Partitioned Bitmap Index Scan on index_01 - Index Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000)) - Selected Partitions: 2..3,5,7 - Selected Subpartitions: 2:1, 3:1, 5:1, 7:1 -(15 rows) - -drop index index_01; -drop table list_range_02; -create table pjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON) partition by range(jid) subpartition by range(jn) -( - partition hrp1 values less than(16)( - subpartition hrp1_1 values less than(16), - subpartition hrp1_2 values less than(maxvalue)), - partition hrp2 values less than(maxvalue)( - subpartition hrp3_1 values less than(16), - subpartition hrp3_3 values less than(maxvalue)) -); -create table cjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON); -insert into pjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); -insert into cjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); -select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; - jid | jn | name ------+----+------- - 6 | 8 | tom - 8 | 18 | jerry - 16 | 8 | jade - 18 | 20 | jack -(4 rows) - -select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; - jid | jn | name ------+----+------- - 6 | 8 | tom - 8 | 18 | jerry - 16 | 8 | jade - 18 | 20 | jack -(4 rows) - -select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; - jid | jn | name ------+----+------- - 6 | 8 | tom - 8 | 18 | jerry - 16 | 8 | jade - 18 | 20 | jack -(4 rows) - -select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; - jid | jn | name ------+----+------- - 6 | 8 | tom - 8 | 18 | jerry - 16 | 8 | jade - 18 | 20 | jack -(4 rows) - -drop table pjade; -drop table cjade; DROP SCHEMA segment_subpartition_select CASCADE; NOTICE: drop cascades to 4 other objects DETAIL: drop cascades to table t1 diff --git a/src/test/regress/expected/segment_subpartition_select_1.out b/src/test/regress/expected/segment_subpartition_select_1.out new file mode 100644 index 000000000..181e06915 --- /dev/null +++ b/src/test/regress/expected/segment_subpartition_select_1.out @@ -0,0 +1,128 @@ +--prepare +DROP SCHEMA segment_subpartition_select_1 CASCADE; +ERROR: schema "segment_subpartition_select_1" does not exist +CREATE SCHEMA segment_subpartition_select_1; +SET CURRENT_SCHEMA TO segment_subpartition_select_1; +drop table list_range_02; +ERROR: table "list_range_02" does not exist +CREATE TABLE IF NOT EXISTS list_range_02 +( + col_1 int , + col_2 int, + col_3 VARCHAR2 ( 30 ) , + col_4 int +) WITH (SEGMENT=ON) +PARTITION BY list (col_1) SUBPARTITION BY range (col_2) +( + PARTITION p_list_1 VALUES(-1,-2,-3,-4,-5,-6,-7,-8,-9,-10 ) + ( + SUBPARTITION p_range_1_1 VALUES LESS THAN( -10 ), + SUBPARTITION p_range_1_2 VALUES LESS THAN( 0 ), + SUBPARTITION p_range_1_3 VALUES LESS THAN( 10 ), + SUBPARTITION p_range_1_4 VALUES LESS THAN( 20 ), + SUBPARTITION p_range_1_5 VALUES LESS THAN( 50 ) + ), + PARTITION p_list_2 VALUES(1,2,3,4,5,6,7,8,9,10 ), + PARTITION p_list_3 VALUES(11,12,13,14,15,16,17,18,19,20) + ( + SUBPARTITION p_range_3_1 VALUES LESS THAN( 15 ), + SUBPARTITION p_range_3_2 VALUES LESS THAN( MAXVALUE ) + ), + PARTITION p_list_4 VALUES(21,22,23,24,25,26,27,28,29,30) + ( + SUBPARTITION p_range_4_1 VALUES LESS THAN( -10 ), + SUBPARTITION p_range_4_2 VALUES LESS THAN( 0 ), + SUBPARTITION p_range_4_3 VALUES LESS THAN( 10 ), + SUBPARTITION p_range_4_4 VALUES LESS THAN( 20 ), + SUBPARTITION p_range_4_5 VALUES LESS THAN( 50 ) + ), + PARTITION p_list_5 VALUES(31,32,33,34,35,36,37,38,39,40) + ( + SUBPARTITION p_range_5_1 VALUES LESS THAN( MAXVALUE ) + ), + PARTITION p_list_6 VALUES(41,42,43,44,45,46,47,48,49,50) + ( + SUBPARTITION p_range_6_1 VALUES LESS THAN( -10 ), + SUBPARTITION p_range_6_2 VALUES LESS THAN( 0 ), + SUBPARTITION p_range_6_3 VALUES LESS THAN( 10 ), + SUBPARTITION p_range_6_4 VALUES LESS THAN( 20 ), + SUBPARTITION p_range_6_5 VALUES LESS THAN( 50 ) + ), + PARTITION p_list_7 VALUES(default) +) ENABLE ROW MOVEMENT; +INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 100),GENERATE_SERIES(0, 99)); +create index index_01 on list_range_02(col_2) local ; + explain (costs off, verbose on) select * from list_range_02 where col_2 >500 and col_2 <8000 order by col_1; + QUERY PLAN +------------------------------------------------------------------------------------------------ + Sort + Output: col_1, col_2, col_3, col_4 + Sort Key: list_range_02.col_1 + -> Partition Iterator + Output: col_1, col_2, col_3, col_4 + Iterations: 4, Sub Iterations: 4 + -> Partitioned Bitmap Heap Scan on segment_subpartition_select_1.list_range_02 + Output: col_1, col_2, col_3, col_4 + Recheck Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000)) + Selected Partitions: 2..3,5,7 + Selected Subpartitions: 2:1, 3:1, 5:1, 7:1 + -> Partitioned Bitmap Index Scan on index_01 + Index Cond: ((list_range_02.col_2 > 500) AND (list_range_02.col_2 < 8000)) + Selected Partitions: 2..3,5,7 + Selected Subpartitions: 2:1, 3:1, 5:1, 7:1 +(15 rows) + +drop index index_01; +drop table list_range_02; +create table pjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON) partition by range(jid) subpartition by range(jn) +( + partition hrp1 values less than(16)( + subpartition hrp1_1 values less than(16), + subpartition hrp1_2 values less than(maxvalue)), + partition hrp2 values less than(maxvalue)( + subpartition hrp3_1 values less than(16), + subpartition hrp3_3 values less than(maxvalue)) +); +create table cjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON); +insert into pjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); +insert into cjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); +select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; + jid | jn | name +-----+----+------- + 6 | 8 | tom + 8 | 18 | jerry + 16 | 8 | jade + 18 | 20 | jack +(4 rows) + +select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; + jid | jn | name +-----+----+------- + 6 | 8 | tom + 8 | 18 | jerry + 16 | 8 | jade + 18 | 20 | jack +(4 rows) + +select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; + jid | jn | name +-----+----+------- + 6 | 8 | tom + 8 | 18 | jerry + 16 | 8 | jade + 18 | 20 | jack +(4 rows) + +select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; + jid | jn | name +-----+----+------- + 6 | 8 | tom + 8 | 18 | jerry + 16 | 8 | jade + 18 | 20 | jack +(4 rows) + +drop table pjade; +drop table cjade; +DROP SCHEMA segment_subpartition_select_1 CASCADE; +RESET CURRENT_SCHEMA; diff --git a/src/test/regress/expected/test_astore_multixact.out b/src/test/regress/expected/test_astore_multixact.out index 932acff55..a61e99d55 100644 --- a/src/test/regress/expected/test_astore_multixact.out +++ b/src/test/regress/expected/test_astore_multixact.out @@ -11,7 +11,7 @@ insert into astore_mult2 values (1, 1); \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for key share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / begin @@ -24,7 +24,7 @@ end; \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for key share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / begin @@ -36,7 +36,7 @@ end; \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for key share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / begin @@ -48,7 +48,7 @@ end; \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / begin @@ -60,7 +60,7 @@ end; \parallel on 2 begin update astore_mult1 set b = 2 where a = 1; -perform pg_sleep(3); +perform pg_sleep(1.5); end; / begin @@ -72,7 +72,7 @@ end; \parallel on 2 begin update astore_mult1 set b = 2 where a = 1; -perform pg_sleep(3); +perform pg_sleep(1.5); end; / begin @@ -84,13 +84,13 @@ insert into astore_mult1 values (2, 2); \parallel on 2 begin perform * from astore_mult1 where a = 2 for key share; -perform pg_sleep(2); +perform pg_sleep(1); delete from astore_mult1 where a = 2; end; / begin update astore_mult1 set b = 2 where a = 2; -perform pg_sleep(3); +perform pg_sleep(2); end; / \parallel off diff --git a/src/test/regress/input/component_view_enhancements.source b/src/test/regress/input/component_view_enhancements.source index 34943fad1..400cdedba 100644 --- a/src/test/regress/input/component_view_enhancements.source +++ b/src/test/regress/input/component_view_enhancements.source @@ -17,7 +17,7 @@ START TRANSACTION; CREATE TABLE test_ustore (a int, b int ,c int) with(storage_type=ustore); CREATE INDEX test_ustore_idx ON test_ustore(a); CREATE INDEX test_ustore_idx2 ON test_ustore(b,c); -INSERT INTO test_ustore values(generate_series(1,1000000),generate_series(1,1000000), generate_series(1,1000000)); +INSERT INTO test_ustore values(generate_series(1,100000),generate_series(1,100000), generate_series(1,100000)); CHECKPOINT; CREATE OR REPLACE FUNCTION proc_gs_index_verify(tablename in varchar2) RETURNS SETOF varchar @@ -49,7 +49,7 @@ START TRANSACTION; CREATE TABLE test_ustore (a int, b int ,c int) with(storage_type=ustore); CREATE INDEX test_ustore_idx ON test_ustore(a); CREATE INDEX test_ustore_idx2 ON test_ustore(b,c); -INSERT INTO test_ustore values(generate_series(1,1000000),generate_series(1,1000000), generate_series(1,1000000)); +INSERT INTO test_ustore values(generate_series(1,100000),generate_series(1,100000), generate_series(1,100000)); CHECKPOINT; CREATE OR REPLACE FUNCTION proc_gs_index_recycle_queue(tablename in varchar2) RETURNS SETOF varchar diff --git a/src/test/regress/output/component_view_enhancements.source b/src/test/regress/output/component_view_enhancements.source index c7a68c713..e4e2a3e56 100644 --- a/src/test/regress/output/component_view_enhancements.source +++ b/src/test/regress/output/component_view_enhancements.source @@ -46,7 +46,7 @@ START TRANSACTION; CREATE TABLE test_ustore (a int, b int ,c int) with(storage_type=ustore); CREATE INDEX test_ustore_idx ON test_ustore(a); CREATE INDEX test_ustore_idx2 ON test_ustore(b,c); -INSERT INTO test_ustore values(generate_series(1,1000000),generate_series(1,1000000), generate_series(1,1000000)); +INSERT INTO test_ustore values(generate_series(1,100000),generate_series(1,100000), generate_series(1,100000)); CHECKPOINT; CREATE OR REPLACE FUNCTION proc_gs_index_verify(tablename in varchar2) RETURNS SETOF varchar @@ -88,7 +88,7 @@ START TRANSACTION; CREATE TABLE test_ustore (a int, b int ,c int) with(storage_type=ustore); CREATE INDEX test_ustore_idx ON test_ustore(a); CREATE INDEX test_ustore_idx2 ON test_ustore(b,c); -INSERT INTO test_ustore values(generate_series(1,1000000),generate_series(1,1000000), generate_series(1,1000000)); +INSERT INTO test_ustore values(generate_series(1,100000),generate_series(1,100000), generate_series(1,100000)); CHECKPOINT; CREATE OR REPLACE FUNCTION proc_gs_index_recycle_queue(tablename in varchar2) RETURNS SETOF varchar diff --git a/src/test/regress/parallel_schedule0 b/src/test/regress/parallel_schedule0 index c0f3d93f7..8739b8bc3 100644 --- a/src/test/regress/parallel_schedule0 +++ b/src/test/regress/parallel_schedule0 @@ -93,13 +93,13 @@ test: hw_subpartition_createtable hw_subpartition_scan hw_subpartition_select hw test: hw_subpartition_vacuum_partition hw_subpartition_tablespace_global test: gs_dump_subpartition test: partition_dml_operations partition_minmax partition_pruning hw_partitionno hw_partition_parallel -test: partition_param_path +test: partition_param_path hw_subpartition_add_drop_partition_1 #test: partition_cost_model test: row_partition_iterator_elimination col_partition_iterator_elimination # test subpartition with segment=on test: segment_subpartition_createtable segment_subpartition_scan segment_subpartition_select segment_subpartition_split segment_subpartition_truncate segment_subpartition_update segment_subpartition_gpi segment_subpartition_analyze_vacuum segment_subpartition_alter_table segment_subpartition_add_drop_partition segment_subpartition_tablespace segment_subpartition_ddl_index -test: segment_subpartition_vacuum_partition +test: segment_subpartition_vacuum_partition segment_subpartition_select_1 test: get_instr_unique_sql diff --git a/src/test/regress/sql/hw_subpartition_add_drop_partition.sql b/src/test/regress/sql/hw_subpartition_add_drop_partition.sql index 41910971f..eaf4cb940 100644 --- a/src/test/regress/sql/hw_subpartition_add_drop_partition.sql +++ b/src/test/regress/sql/hw_subpartition_add_drop_partition.sql @@ -752,529 +752,6 @@ SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, ORDER BY p1.relname; \d+ list_list_sales --- -----list-hash table---- --- ---prepare -CREATE TABLE list_hash_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY LIST (channel_id) SUBPARTITION BY HASH (product_id) -( - PARTITION channel1 VALUES ('0', '1', '2') - ( - SUBPARTITION channel1_product1, - SUBPARTITION channel1_product2, - SUBPARTITION channel1_product3, - SUBPARTITION channel1_product4 - ), - PARTITION channel2 VALUES ('3', '4', '5') - ( - SUBPARTITION channel2_product1, - SUBPARTITION channel2_product2 - ), - PARTITION channel3 VALUES ('6', '7'), - PARTITION channel4 VALUES ('8', '9') - ( - SUBPARTITION channel4_product1 - ) -); -INSERT INTO list_hash_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX list_hash_sales_idx ON list_hash_sales(product_id) LOCAL; - ---check for add partition/subpartition ---success, add 4 subpartition -ALTER TABLE list_hash_sales ADD PARTITION channel5 VALUES ('X') - ( - SUBPARTITION channel5_product1, - SUBPARTITION channel5_product2, - SUBPARTITION channel5_product3, - SUBPARTITION channel5_product4 - ); ---fail, value conflict -ALTER TABLE list_hash_sales ADD PARTITION channel_temp1 VALUES ('0', 'Z', 'C'); ---fail, value conflict -ALTER TABLE list_hash_sales ADD PARTITION channel_temp2 VALUES ('Z', 'Z', 'C'); ---fail, invalid format -ALTER TABLE list_hash_sales ADD PARTITION channel_temp3 VALUES LESS THAN ('Z'); ---success, add 1 default subpartition -ALTER TABLE list_hash_sales ADD PARTITION channel6 VALUES (DEFAULT); ---fail, value conflict -ALTER TABLE list_hash_sales ADD PARTITION channel_temp4 VALUES ('M', 'X'); ---fail, not support add hash -ALTER TABLE list_hash_sales MODIFY PARTITION channel1 ADD SUBPARTITION channel1_temp1; ---fail, invalid format -ALTER TABLE list_hash_sales MODIFY PARTITION channel4 ADD SUBPARTITION channel4_temp1 VALUES LESS THAN (1500); - ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='list_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ list_hash_sales - ---check for drop partition/subpartition (for) ---success, drop partition channel2 -ALTER TABLE list_hash_sales DROP PARTITION channel2; ---fail, not support drop hash -ALTER TABLE list_hash_sales DROP SUBPARTITION channel1_product1; ---fail, not support drop hash -ALTER TABLE list_hash_sales DROP SUBPARTITION channel4_product1; ---success, drop partition channel3 -ALTER TABLE list_hash_sales DROP PARTITION FOR ('6'); ---fail, number not equal to the number of partkey -ALTER TABLE list_hash_sales DROP PARTITION FOR ('6', '2010-01-01'); ---fail, invalid type -ALTER TABLE list_hash_sales DROP PARTITION FOR (10); ---fail, not support drop hash -ALTER TABLE list_hash_sales DROP SUBPARTITION FOR('X', 6); - ---check for ok after drop -SELECT count(*) FROM list_hash_sales; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='list_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='list_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ list_hash_sales - --- -----hash-range table---- --- ---prepare -CREATE TABLE hash_range_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY HASH (product_id) SUBPARTITION BY RANGE (customer_id) -( - PARTITION product1 - ( - SUBPARTITION product1_customer1 VALUES LESS THAN (200), - SUBPARTITION product1_customer2 VALUES LESS THAN (500), - SUBPARTITION product1_customer3 VALUES LESS THAN (800), - SUBPARTITION product1_customer4 VALUES LESS THAN (1200) - ), - PARTITION product2 - ( - SUBPARTITION product2_customer1 VALUES LESS THAN (500), - SUBPARTITION product2_customer2 VALUES LESS THAN (MAXVALUE) - ), - PARTITION product3, - PARTITION product4 - ( - SUBPARTITION product4_customer1 VALUES LESS THAN (1200) - ) -); -INSERT INTO hash_range_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX hash_range_sales_idx ON hash_range_sales(product_id) LOCAL; - ---check for add partition/subpartition ---fail, not support add hash -ALTER TABLE hash_range_sales ADD PARTITION product_temp1 - ( - SUBPARTITION product_temp1_customer1 VALUES LESS THAN (200), - SUBPARTITION product_temp1_customer2 VALUES LESS THAN (500), - SUBPARTITION product_temp1_customer3 VALUES LESS THAN (800), - SUBPARTITION product_temp1_customer4 VALUES LESS THAN (1200) - ); ---fail, not support add hash -ALTER TABLE hash_range_sales ADD PARTITION product_temp2; ---success, add 1 subpartition -ALTER TABLE hash_range_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_customer5 VALUES LESS THAN (1800); ---fail, out of range -ALTER TABLE hash_range_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES LESS THAN (1800); ---fail, invalid format -ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES (DEFAULT); ---success, add 1 subpartition -ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_customer2 VALUES LESS THAN (MAXVALUE); - ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_range_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ hash_range_sales - ---check for drop partition/subpartition (for) ---fail, not support drop hash -ALTER TABLE hash_range_sales DROP PARTITION product2; ---success, drop subpartition product1_customer1 -ALTER TABLE hash_range_sales DROP SUBPARTITION product1_customer1; ---success, drop subpartition product4_customer1 -ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer1; ---fail, the only subpartition in product4 -ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer2; ---fail, not support drop hash -ALTER TABLE hash_range_sales DROP PARTITION FOR(0); ---fail, not support drop hash -ALTER TABLE hash_range_sales DROP PARTITION FOR(0, 100); ---fail, number not equal to the number of partkey -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0); ---fail, invalid type -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR('2010-01-01', 100); ---success, drop subpartition product1_customer2, but not suggest to do this operation -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 100); ---fail, no subpartition find -ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 2300); - ---check for ok after drop -SELECT count(*) FROM hash_range_sales; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_range_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_range_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ hash_range_sales - --- -----hash-list table---- --- ---prepare -CREATE TABLE hash_list_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY HASH (product_id) SUBPARTITION BY LIST (channel_id) -( - PARTITION product1 - ( - SUBPARTITION product1_channel1 VALUES ('0', '1', '2'), - SUBPARTITION product1_channel2 VALUES ('3', '4', '5'), - SUBPARTITION product1_channel3 VALUES ('6', '7', '8'), - SUBPARTITION product1_channel4 VALUES ('9') - ), - PARTITION product2 - ( - SUBPARTITION product2_channel1 VALUES ('0', '1', '2', '3', '4'), - SUBPARTITION product2_channel2 VALUES (DEFAULT) - ), - PARTITION product3, - PARTITION product4 - ( - SUBPARTITION product4_channel1 VALUES ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') - ) -); -INSERT INTO hash_list_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX hash_list_sales_idx ON hash_list_sales(product_id) LOCAL; - ---check for add partition/subpartition ---fail, not support add hash -ALTER TABLE hash_list_sales ADD PARTITION product_temp1 - ( - SUBPARTITION product_temp1_channel1 VALUES ('0', '1', '2'), - SUBPARTITION product_temp1_channel2 VALUES ('3', '4', '5'), - SUBPARTITION product_temp1_channel3 VALUES ('6', '7', '8'), - SUBPARTITION product_temp1_channel4 VALUES ('9') - ); ---fail, not support add hash -ALTER TABLE hash_list_sales ADD PARTITION product_temp2; ---success, add 1 subpartition -ALTER TABLE hash_list_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_channel5 VALUES ('X'); ---fail, out of range -ALTER TABLE hash_list_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES ('X'); ---fail, out of range -ALTER TABLE hash_list_sales MODIFY PARTITION product3 ADD SUBPARTITION product3_temp1 VALUES ('X'); ---fail, invalid format -ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES LESS THAN (MAXVALUE); ---success, add 1 subpartition -ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_channel2 VALUES (DEFAULT); - ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_list_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ hash_list_sales - ---check for drop partition/subpartition (for) ---fail, not support drop hash -ALTER TABLE hash_list_sales DROP PARTITION product2; ---success, drop subpartition product1_channel1 -ALTER TABLE hash_list_sales DROP SUBPARTITION product1_channel1; ---success, drop subpartition product4_channel1 -ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel1; ---fail, the only subpartition in product4 -ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel2; ---fail, not support drop hash -ALTER TABLE hash_list_sales DROP PARTITION FOR(0); ---fail, not support drop hash -ALTER TABLE hash_list_sales DROP PARTITION FOR(0, '4'); ---fail, number not equal to the number of partkey -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0); ---fail, invalid type -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR('2010-01-01', '4'); ---success, drop subpartition product1_channel2, but not suggest to do this operation -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, '4'); ---fail, no subpartition find -ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, 'Z'); - ---check for ok after drop -SELECT count(*) FROM hash_list_sales; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_list_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_list_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ hash_list_sales - --- -----hash-hash table---- --- ---prepare -CREATE TABLE hash_hash_sales -( - product_id INT4 NOT NULL, - customer_id INT4 PRIMARY KEY, - time_id DATE, - channel_id CHAR(1), - type_id INT4, - quantity_sold NUMERIC(3), - amount_sold NUMERIC(10,2) -) -PARTITION BY HASH (product_id) SUBPARTITION BY HASH (customer_id) -( - PARTITION product1 - ( - SUBPARTITION product1_customer1, - SUBPARTITION product1_customer2, - SUBPARTITION product1_customer3, - SUBPARTITION product1_customer4 - ), - PARTITION product2 - ( - SUBPARTITION product2_customer1, - SUBPARTITION product2_customer2 - ), - PARTITION product3, - PARTITION product4 - ( - SUBPARTITION product4_customer1 - ) -); -INSERT INTO hash_hash_sales SELECT generate_series(1,1000), - generate_series(1,1000), - date_pli('2008-01-01', generate_series(1,1000)), - generate_series(1,1000)%10, - generate_series(1,1000)%10, - generate_series(1,1000)%1000, - generate_series(1,1000); -CREATE INDEX hash_hash_sales_idx ON hash_hash_sales(product_id) LOCAL; - ---check for add partition/subpartition ---fail, not support add hash -ALTER TABLE hash_hash_sales ADD PARTITION product_temp1 - ( - SUBPARTITION product_temp1_customer1, - SUBPARTITION product_temp1_customer2, - SUBPARTITION product_temp1_customer3, - SUBPARTITION product_temp1_customer4 - ); ---fail, not support add hash -ALTER TABLE hash_hash_sales ADD PARTITION product_temp2; ---fail, not support add hash -ALTER TABLE hash_hash_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_temp1; - ---check for ok after add -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ hash_hash_sales - ---check for drop partition/subpartition (for) ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP PARTITION product2; ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION product1_customer1; ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION product4_customer1; ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP PARTITION FOR(0); ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP PARTITION FOR(0, 0); ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0, 0); ---fail, not support drop hash -ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0); - ---check for ok after drop -SELECT count(*) FROM hash_hash_sales; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid - OR p1.parentid IN ( - SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 - WHERE c2.relname='hash_hash_sales' - AND c2.relnamespace=n2.oid - AND n2.nspname=CURRENT_SCHEMA - AND (p2.parentid=c2.oid) - )) - ORDER BY p1.parttype, p1.relname; -SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable - FROM pg_class c1, pg_partition p1, pg_namespace n1 - WHERE c1.relname='hash_hash_sales_idx' - AND c1.relnamespace=n1.oid - AND n1.nspname=CURRENT_SCHEMA - AND (p1.parentid=c1.oid) - ORDER BY p1.relname; -\d+ hash_hash_sales --finish DROP TABLE range_range_sales; @@ -1282,10 +759,6 @@ DROP TABLE range_list_sales; DROP TABLE range_hash_sales; DROP TABLE list_range_sales; DROP TABLE list_list_sales; -DROP TABLE list_hash_sales; -DROP TABLE hash_range_sales; -DROP TABLE hash_list_sales; -DROP TABLE hash_hash_sales; DROP SCHEMA hw_subpartition_add_drop_partition CASCADE; RESET CURRENT_SCHEMA; diff --git a/src/test/regress/sql/hw_subpartition_add_drop_partition_1.sql b/src/test/regress/sql/hw_subpartition_add_drop_partition_1.sql new file mode 100755 index 000000000..7b3f778ce --- /dev/null +++ b/src/test/regress/sql/hw_subpartition_add_drop_partition_1.sql @@ -0,0 +1,536 @@ +DROP SCHEMA hw_subpartition_add_drop_partition_1 CASCADE; +CREATE SCHEMA hw_subpartition_add_drop_partition_1; +SET CURRENT_SCHEMA TO hw_subpartition_add_drop_partition_1; + +-- +----list-hash table---- +-- +--prepare +CREATE TABLE list_hash_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY LIST (channel_id) SUBPARTITION BY HASH (product_id) +( + PARTITION channel1 VALUES ('0', '1', '2') + ( + SUBPARTITION channel1_product1, + SUBPARTITION channel1_product2, + SUBPARTITION channel1_product3, + SUBPARTITION channel1_product4 + ), + PARTITION channel2 VALUES ('3', '4', '5') + ( + SUBPARTITION channel2_product1, + SUBPARTITION channel2_product2 + ), + PARTITION channel3 VALUES ('6', '7'), + PARTITION channel4 VALUES ('8', '9') + ( + SUBPARTITION channel4_product1 + ) +); +INSERT INTO list_hash_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX list_hash_sales_idx ON list_hash_sales(product_id) LOCAL; + +--check for add partition/subpartition +--success, add 4 subpartition +ALTER TABLE list_hash_sales ADD PARTITION channel5 VALUES ('X') + ( + SUBPARTITION channel5_product1, + SUBPARTITION channel5_product2, + SUBPARTITION channel5_product3, + SUBPARTITION channel5_product4 + ); +--fail, value conflict +ALTER TABLE list_hash_sales ADD PARTITION channel_temp1 VALUES ('0', 'Z', 'C'); +--fail, value conflict +ALTER TABLE list_hash_sales ADD PARTITION channel_temp2 VALUES ('Z', 'Z', 'C'); +--fail, invalid format +ALTER TABLE list_hash_sales ADD PARTITION channel_temp3 VALUES LESS THAN ('Z'); +--success, add 1 default subpartition +ALTER TABLE list_hash_sales ADD PARTITION channel6 VALUES (DEFAULT); +--fail, value conflict +ALTER TABLE list_hash_sales ADD PARTITION channel_temp4 VALUES ('M', 'X'); +--fail, not support add hash +ALTER TABLE list_hash_sales MODIFY PARTITION channel1 ADD SUBPARTITION channel1_temp1; +--fail, invalid format +ALTER TABLE list_hash_sales MODIFY PARTITION channel4 ADD SUBPARTITION channel4_temp1 VALUES LESS THAN (1500); + +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='list_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ list_hash_sales + +--check for drop partition/subpartition (for) +--success, drop partition channel2 +ALTER TABLE list_hash_sales DROP PARTITION channel2; +--fail, not support drop hash +ALTER TABLE list_hash_sales DROP SUBPARTITION channel1_product1; +--fail, not support drop hash +ALTER TABLE list_hash_sales DROP SUBPARTITION channel4_product1; +--success, drop partition channel3 +ALTER TABLE list_hash_sales DROP PARTITION FOR ('6'); +--fail, number not equal to the number of partkey +ALTER TABLE list_hash_sales DROP PARTITION FOR ('6', '2010-01-01'); +--fail, invalid type +ALTER TABLE list_hash_sales DROP PARTITION FOR (10); +--fail, not support drop hash +ALTER TABLE list_hash_sales DROP SUBPARTITION FOR('X', 6); + +--check for ok after drop +SELECT count(*) FROM list_hash_sales; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='list_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='list_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ list_hash_sales + +-- +----hash-range table---- +-- +--prepare +CREATE TABLE hash_range_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY HASH (product_id) SUBPARTITION BY RANGE (customer_id) +( + PARTITION product1 + ( + SUBPARTITION product1_customer1 VALUES LESS THAN (200), + SUBPARTITION product1_customer2 VALUES LESS THAN (500), + SUBPARTITION product1_customer3 VALUES LESS THAN (800), + SUBPARTITION product1_customer4 VALUES LESS THAN (1200) + ), + PARTITION product2 + ( + SUBPARTITION product2_customer1 VALUES LESS THAN (500), + SUBPARTITION product2_customer2 VALUES LESS THAN (MAXVALUE) + ), + PARTITION product3, + PARTITION product4 + ( + SUBPARTITION product4_customer1 VALUES LESS THAN (1200) + ) +); +INSERT INTO hash_range_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX hash_range_sales_idx ON hash_range_sales(product_id) LOCAL; + +--check for add partition/subpartition +--fail, not support add hash +ALTER TABLE hash_range_sales ADD PARTITION product_temp1 + ( + SUBPARTITION product_temp1_customer1 VALUES LESS THAN (200), + SUBPARTITION product_temp1_customer2 VALUES LESS THAN (500), + SUBPARTITION product_temp1_customer3 VALUES LESS THAN (800), + SUBPARTITION product_temp1_customer4 VALUES LESS THAN (1200) + ); +--fail, not support add hash +ALTER TABLE hash_range_sales ADD PARTITION product_temp2; +--success, add 1 subpartition +ALTER TABLE hash_range_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_customer5 VALUES LESS THAN (1800); +--fail, out of range +ALTER TABLE hash_range_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES LESS THAN (1800); +--fail, invalid format +ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES (DEFAULT); +--success, add 1 subpartition +ALTER TABLE hash_range_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_customer2 VALUES LESS THAN (MAXVALUE); + +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_range_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ hash_range_sales + +--check for drop partition/subpartition (for) +--fail, not support drop hash +ALTER TABLE hash_range_sales DROP PARTITION product2; +--success, drop subpartition product1_customer1 +ALTER TABLE hash_range_sales DROP SUBPARTITION product1_customer1; +--success, drop subpartition product4_customer1 +ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer1; +--fail, the only subpartition in product4 +ALTER TABLE hash_range_sales DROP SUBPARTITION product4_customer2; +--fail, not support drop hash +ALTER TABLE hash_range_sales DROP PARTITION FOR(0); +--fail, not support drop hash +ALTER TABLE hash_range_sales DROP PARTITION FOR(0, 100); +--fail, number not equal to the number of partkey +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0); +--fail, invalid type +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR('2010-01-01', 100); +--success, drop subpartition product1_customer2, but not suggest to do this operation +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 100); +--fail, no subpartition find +ALTER TABLE hash_range_sales DROP SUBPARTITION FOR(0, 2300); + +--check for ok after drop +SELECT count(*) FROM hash_range_sales; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_range_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_range_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ hash_range_sales + +-- +----hash-list table---- +-- +--prepare +CREATE TABLE hash_list_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY HASH (product_id) SUBPARTITION BY LIST (channel_id) +( + PARTITION product1 + ( + SUBPARTITION product1_channel1 VALUES ('0', '1', '2'), + SUBPARTITION product1_channel2 VALUES ('3', '4', '5'), + SUBPARTITION product1_channel3 VALUES ('6', '7', '8'), + SUBPARTITION product1_channel4 VALUES ('9') + ), + PARTITION product2 + ( + SUBPARTITION product2_channel1 VALUES ('0', '1', '2', '3', '4'), + SUBPARTITION product2_channel2 VALUES (DEFAULT) + ), + PARTITION product3, + PARTITION product4 + ( + SUBPARTITION product4_channel1 VALUES ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9') + ) +); +INSERT INTO hash_list_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX hash_list_sales_idx ON hash_list_sales(product_id) LOCAL; + +--check for add partition/subpartition +--fail, not support add hash +ALTER TABLE hash_list_sales ADD PARTITION product_temp1 + ( + SUBPARTITION product_temp1_channel1 VALUES ('0', '1', '2'), + SUBPARTITION product_temp1_channel2 VALUES ('3', '4', '5'), + SUBPARTITION product_temp1_channel3 VALUES ('6', '7', '8'), + SUBPARTITION product_temp1_channel4 VALUES ('9') + ); +--fail, not support add hash +ALTER TABLE hash_list_sales ADD PARTITION product_temp2; +--success, add 1 subpartition +ALTER TABLE hash_list_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_channel5 VALUES ('X'); +--fail, out of range +ALTER TABLE hash_list_sales MODIFY PARTITION product2 ADD SUBPARTITION product2_temp1 VALUES ('X'); +--fail, out of range +ALTER TABLE hash_list_sales MODIFY PARTITION product3 ADD SUBPARTITION product3_temp1 VALUES ('X'); +--fail, invalid format +ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_temp1 VALUES LESS THAN (MAXVALUE); +--success, add 1 subpartition +ALTER TABLE hash_list_sales MODIFY PARTITION product4 ADD SUBPARTITION product4_channel2 VALUES (DEFAULT); + +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_list_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ hash_list_sales + +--check for drop partition/subpartition (for) +--fail, not support drop hash +ALTER TABLE hash_list_sales DROP PARTITION product2; +--success, drop subpartition product1_channel1 +ALTER TABLE hash_list_sales DROP SUBPARTITION product1_channel1; +--success, drop subpartition product4_channel1 +ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel1; +--fail, the only subpartition in product4 +ALTER TABLE hash_list_sales DROP SUBPARTITION product4_channel2; +--fail, not support drop hash +ALTER TABLE hash_list_sales DROP PARTITION FOR(0); +--fail, not support drop hash +ALTER TABLE hash_list_sales DROP PARTITION FOR(0, '4'); +--fail, number not equal to the number of partkey +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0); +--fail, invalid type +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR('2010-01-01', '4'); +--success, drop subpartition product1_channel2, but not suggest to do this operation +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, '4'); +--fail, no subpartition find +ALTER TABLE hash_list_sales DROP SUBPARTITION FOR(0, 'Z'); + +--check for ok after drop +SELECT count(*) FROM hash_list_sales; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_list_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_list_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ hash_list_sales + +-- +----hash-hash table---- +-- +--prepare +CREATE TABLE hash_hash_sales +( + product_id INT4 NOT NULL, + customer_id INT4 PRIMARY KEY, + time_id DATE, + channel_id CHAR(1), + type_id INT4, + quantity_sold NUMERIC(3), + amount_sold NUMERIC(10,2) +) +PARTITION BY HASH (product_id) SUBPARTITION BY HASH (customer_id) +( + PARTITION product1 + ( + SUBPARTITION product1_customer1, + SUBPARTITION product1_customer2, + SUBPARTITION product1_customer3, + SUBPARTITION product1_customer4 + ), + PARTITION product2 + ( + SUBPARTITION product2_customer1, + SUBPARTITION product2_customer2 + ), + PARTITION product3, + PARTITION product4 + ( + SUBPARTITION product4_customer1 + ) +); +INSERT INTO hash_hash_sales SELECT generate_series(1,1000), + generate_series(1,1000), + date_pli('2008-01-01', generate_series(1,1000)), + generate_series(1,1000)%10, + generate_series(1,1000)%10, + generate_series(1,1000)%1000, + generate_series(1,1000); +CREATE INDEX hash_hash_sales_idx ON hash_hash_sales(product_id) LOCAL; + +--check for add partition/subpartition +--fail, not support add hash +ALTER TABLE hash_hash_sales ADD PARTITION product_temp1 + ( + SUBPARTITION product_temp1_customer1, + SUBPARTITION product_temp1_customer2, + SUBPARTITION product_temp1_customer3, + SUBPARTITION product_temp1_customer4 + ); +--fail, not support add hash +ALTER TABLE hash_hash_sales ADD PARTITION product_temp2; +--fail, not support add hash +ALTER TABLE hash_hash_sales MODIFY PARTITION product1 ADD SUBPARTITION product1_temp1; + +--check for ok after add +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ hash_hash_sales + +--check for drop partition/subpartition (for) +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP PARTITION product2; +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION product1_customer1; +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION product4_customer1; +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP PARTITION FOR(0); +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP PARTITION FOR(0, 0); +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0, 0); +--fail, not support drop hash +ALTER TABLE hash_hash_sales DROP SUBPARTITION FOR(0); + +--check for ok after drop +SELECT count(*) FROM hash_hash_sales; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.reltablespace, p1.partkey, p1.boundaries + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid + OR p1.parentid IN ( + SELECT p2.oid FROM pg_class c2, pg_partition p2, pg_namespace n2 + WHERE c2.relname='hash_hash_sales' + AND c2.relnamespace=n2.oid + AND n2.nspname=CURRENT_SCHEMA + AND (p2.parentid=c2.oid) + )) + ORDER BY p1.parttype, p1.relname; +SELECT p1.relname, p1.parttype, p1.partstrategy, p1.relfilenode!=0 hasfilenode, p1.indisusable + FROM pg_class c1, pg_partition p1, pg_namespace n1 + WHERE c1.relname='hash_hash_sales_idx' + AND c1.relnamespace=n1.oid + AND n1.nspname=CURRENT_SCHEMA + AND (p1.parentid=c1.oid) + ORDER BY p1.relname; +\d+ hash_hash_sales + +--finish +DROP TABLE list_hash_sales; +DROP TABLE hash_range_sales; +DROP TABLE hash_list_sales; +DROP TABLE hash_hash_sales; + +DROP SCHEMA hw_subpartition_add_drop_partition_1 CASCADE; +RESET CURRENT_SCHEMA; diff --git a/src/test/regress/sql/segment_subpartition_select.sql b/src/test/regress/sql/segment_subpartition_select.sql index a841ba26b..3def97741 100644 --- a/src/test/regress/sql/segment_subpartition_select.sql +++ b/src/test/regress/sql/segment_subpartition_select.sql @@ -224,79 +224,5 @@ select * from range_hash full join range_range on range_hash.month_code = range_ select * from range_hash inner join range_range on range_hash.month_code = range_range.month_code order by 1, 2, 3, 4, 5, 6, 7, 8; select * from range_hash inner join range_range on range_hash.month_code = range_range.month_code where range_hash.dept_code = 2 order by 1, 2, 3, 4, 5, 6, 7, 8; -drop table list_range_02; -CREATE TABLE IF NOT EXISTS list_range_02 -( - col_1 int , - col_2 int, - col_3 VARCHAR2 ( 30 ) , - col_4 int -) WITH (SEGMENT=ON) -PARTITION BY list (col_1) SUBPARTITION BY range (col_2) -( - PARTITION p_list_1 VALUES(-1,-2,-3,-4,-5,-6,-7,-8,-9,-10 ) - ( - SUBPARTITION p_range_1_1 VALUES LESS THAN( -10 ), - SUBPARTITION p_range_1_2 VALUES LESS THAN( 0 ), - SUBPARTITION p_range_1_3 VALUES LESS THAN( 10 ), - SUBPARTITION p_range_1_4 VALUES LESS THAN( 20 ), - SUBPARTITION p_range_1_5 VALUES LESS THAN( 50 ) - ), - PARTITION p_list_2 VALUES(1,2,3,4,5,6,7,8,9,10 ), - PARTITION p_list_3 VALUES(11,12,13,14,15,16,17,18,19,20) - ( - SUBPARTITION p_range_3_1 VALUES LESS THAN( 15 ), - SUBPARTITION p_range_3_2 VALUES LESS THAN( MAXVALUE ) - ), - PARTITION p_list_4 VALUES(21,22,23,24,25,26,27,28,29,30) - ( - SUBPARTITION p_range_4_1 VALUES LESS THAN( -10 ), - SUBPARTITION p_range_4_2 VALUES LESS THAN( 0 ), - SUBPARTITION p_range_4_3 VALUES LESS THAN( 10 ), - SUBPARTITION p_range_4_4 VALUES LESS THAN( 20 ), - SUBPARTITION p_range_4_5 VALUES LESS THAN( 50 ) - ), - PARTITION p_list_5 VALUES(31,32,33,34,35,36,37,38,39,40) - ( - SUBPARTITION p_range_5_1 VALUES LESS THAN( MAXVALUE ) - ), - PARTITION p_list_6 VALUES(41,42,43,44,45,46,47,48,49,50) - ( - SUBPARTITION p_range_6_1 VALUES LESS THAN( -10 ), - SUBPARTITION p_range_6_2 VALUES LESS THAN( 0 ), - SUBPARTITION p_range_6_3 VALUES LESS THAN( 10 ), - SUBPARTITION p_range_6_4 VALUES LESS THAN( 20 ), - SUBPARTITION p_range_6_5 VALUES LESS THAN( 50 ) - ), - PARTITION p_list_7 VALUES(default) -) ENABLE ROW MOVEMENT; -create index index_01 on list_range_02(col_2) local ; - -INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 1000),GENERATE_SERIES(0, 99)); - explain (costs off, verbose on) select * from list_range_02 where col_2 >500 and col_2 <8000 order by col_1; - -drop index index_01; -drop table list_range_02; - -create table pjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON) partition by range(jid) subpartition by range(jn) -( - partition hrp1 values less than(16)( - subpartition hrp1_1 values less than(16), - subpartition hrp1_2 values less than(maxvalue)), - partition hrp2 values less than(maxvalue)( - subpartition hrp3_1 values less than(16), - subpartition hrp3_3 values less than(maxvalue)) -); - -create table cjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON); -insert into pjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); -insert into cjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); -select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; -select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; -select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; -select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; -drop table pjade; -drop table cjade; - DROP SCHEMA segment_subpartition_select CASCADE; RESET CURRENT_SCHEMA; diff --git a/src/test/regress/sql/segment_subpartition_select_1.sql b/src/test/regress/sql/segment_subpartition_select_1.sql new file mode 100755 index 000000000..0df32f1da --- /dev/null +++ b/src/test/regress/sql/segment_subpartition_select_1.sql @@ -0,0 +1,82 @@ +--prepare +DROP SCHEMA segment_subpartition_select_1 CASCADE; +CREATE SCHEMA segment_subpartition_select_1; +SET CURRENT_SCHEMA TO segment_subpartition_select_1; + +drop table list_range_02; +CREATE TABLE IF NOT EXISTS list_range_02 +( + col_1 int , + col_2 int, + col_3 VARCHAR2 ( 30 ) , + col_4 int +) WITH (SEGMENT=ON) +PARTITION BY list (col_1) SUBPARTITION BY range (col_2) +( + PARTITION p_list_1 VALUES(-1,-2,-3,-4,-5,-6,-7,-8,-9,-10 ) + ( + SUBPARTITION p_range_1_1 VALUES LESS THAN( -10 ), + SUBPARTITION p_range_1_2 VALUES LESS THAN( 0 ), + SUBPARTITION p_range_1_3 VALUES LESS THAN( 10 ), + SUBPARTITION p_range_1_4 VALUES LESS THAN( 20 ), + SUBPARTITION p_range_1_5 VALUES LESS THAN( 50 ) + ), + PARTITION p_list_2 VALUES(1,2,3,4,5,6,7,8,9,10 ), + PARTITION p_list_3 VALUES(11,12,13,14,15,16,17,18,19,20) + ( + SUBPARTITION p_range_3_1 VALUES LESS THAN( 15 ), + SUBPARTITION p_range_3_2 VALUES LESS THAN( MAXVALUE ) + ), + PARTITION p_list_4 VALUES(21,22,23,24,25,26,27,28,29,30) + ( + SUBPARTITION p_range_4_1 VALUES LESS THAN( -10 ), + SUBPARTITION p_range_4_2 VALUES LESS THAN( 0 ), + SUBPARTITION p_range_4_3 VALUES LESS THAN( 10 ), + SUBPARTITION p_range_4_4 VALUES LESS THAN( 20 ), + SUBPARTITION p_range_4_5 VALUES LESS THAN( 50 ) + ), + PARTITION p_list_5 VALUES(31,32,33,34,35,36,37,38,39,40) + ( + SUBPARTITION p_range_5_1 VALUES LESS THAN( MAXVALUE ) + ), + PARTITION p_list_6 VALUES(41,42,43,44,45,46,47,48,49,50) + ( + SUBPARTITION p_range_6_1 VALUES LESS THAN( -10 ), + SUBPARTITION p_range_6_2 VALUES LESS THAN( 0 ), + SUBPARTITION p_range_6_3 VALUES LESS THAN( 10 ), + SUBPARTITION p_range_6_4 VALUES LESS THAN( 20 ), + SUBPARTITION p_range_6_5 VALUES LESS THAN( 50 ) + ), + PARTITION p_list_7 VALUES(default) +) ENABLE ROW MOVEMENT; + +INSERT INTO list_range_02 VALUES (GENERATE_SERIES(0, 19),GENERATE_SERIES(0, 100),GENERATE_SERIES(0, 99)); +create index index_01 on list_range_02(col_2) local ; + + explain (costs off, verbose on) select * from list_range_02 where col_2 >500 and col_2 <8000 order by col_1; + +drop index index_01; +drop table list_range_02; + +create table pjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON) partition by range(jid) subpartition by range(jn) +( + partition hrp1 values less than(16)( + subpartition hrp1_1 values less than(16), + subpartition hrp1_2 values less than(maxvalue)), + partition hrp2 values less than(maxvalue)( + subpartition hrp3_1 values less than(16), + subpartition hrp3_3 values less than(maxvalue)) +); + +create table cjade(jid int,jn int,name varchar2) WITH (SEGMENT=ON); +insert into pjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); +insert into cjade values(6,8,'tom'),(8,18,'jerry'),(16,8,'jade'),(18,20,'jack'); +select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; +select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; +select * from pjade subpartition(hrp1_1) union select * from cjade order by 1,2,3; +select * from pjade subpartition(hrp1_1) p union select * from cjade order by 1,2,3; +drop table pjade; +drop table cjade; + +DROP SCHEMA segment_subpartition_select_1 CASCADE; +RESET CURRENT_SCHEMA; diff --git a/src/test/regress/sql/test_astore_multixact.sql b/src/test/regress/sql/test_astore_multixact.sql index 90916e59e..32419b4b8 100644 --- a/src/test/regress/sql/test_astore_multixact.sql +++ b/src/test/regress/sql/test_astore_multixact.sql @@ -9,7 +9,7 @@ insert into astore_mult2 values (1, 1); \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for key share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / @@ -25,7 +25,7 @@ end; \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for key share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / @@ -39,7 +39,7 @@ end; \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for key share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / @@ -53,7 +53,7 @@ end; \parallel on 2 begin PERFORM * from astore_mult1 where a = 1 for share; -perform pg_sleep(2); +perform pg_sleep(1.5); end; / @@ -67,7 +67,7 @@ end; \parallel on 2 begin update astore_mult1 set b = 2 where a = 1; -perform pg_sleep(3); +perform pg_sleep(1.5); end; / @@ -81,7 +81,7 @@ end; \parallel on 2 begin update astore_mult1 set b = 2 where a = 1; -perform pg_sleep(3); +perform pg_sleep(1.5); end; / @@ -95,13 +95,13 @@ insert into astore_mult1 values (2, 2); \parallel on 2 begin perform * from astore_mult1 where a = 2 for key share; -perform pg_sleep(2); +perform pg_sleep(1); delete from astore_mult1 where a = 2; end; / begin update astore_mult1 set b = 2 where a = 2; -perform pg_sleep(3); +perform pg_sleep(2); end; / \parallel off