Improve test case.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
1016
src/test/regress/expected/hw_subpartition_add_drop_partition_1.out
Normal file
1016
src/test/regress/expected/hw_subpartition_add_drop_partition_1.out
Normal file
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
128
src/test/regress/expected/segment_subpartition_select_1.out
Normal file
128
src/test/regress/expected/segment_subpartition_select_1.out
Normal file
@ -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;
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
|
536
src/test/regress/sql/hw_subpartition_add_drop_partition_1.sql
Executable file
536
src/test/regress/sql/hw_subpartition_add_drop_partition_1.sql
Executable file
@ -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;
|
@ -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;
|
||||
|
82
src/test/regress/sql/segment_subpartition_select_1.sql
Executable file
82
src/test/regress/sql/segment_subpartition_select_1.sql
Executable file
@ -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;
|
@ -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
|
||||
|
Reference in New Issue
Block a user