From b1493e299e3ab9cc752e32d9c6a95cf6496dc4e4 Mon Sep 17 00:00:00 2001 From: Robin Thomas Date: Mon, 26 Sep 2016 14:35:06 -0400 Subject: [PATCH] Added test coverage for partial unique indexes and exclude constraints. --- .../multi_create_table_constraints.out | 73 +++++++++++++------ .../expected/multi_index_statements.out | 72 ++++++++++-------- .../sql/multi_create_table_constraints.sql | 15 +++- .../regress/sql/multi_index_statements.sql | 6 ++ 4 files changed, 111 insertions(+), 55 deletions(-) diff --git a/src/test/regress/expected/multi_create_table_constraints.out b/src/test/regress/expected/multi_create_table_constraints.out index 3fdaebc17..7f557edda 100644 --- a/src/test/regress/expected/multi_create_table_constraints.out +++ b/src/test/regress/expected/multi_create_table_constraints.out @@ -156,6 +156,31 @@ INSERT INTO ex_on_two_columns (partition_col, other_col) VALUES (1,1); ERROR: conflicting key value violates exclusion constraint "ex_on_two_columns_partition_col_other_col_excl_365008" DETAIL: Key (partition_col, other_col)=(1, 1) conflicts with existing key (partition_col, other_col)=(1, 1). CONTEXT: while executing command on localhost:57637 +CREATE TABLE ex_on_two_columns_prt +( + partition_col integer, + other_col integer, + EXCLUDE (partition_col WITH =, other_col WITH =) WHERE (other_col > 100) +); +SELECT master_create_distributed_table('ex_on_two_columns_prt', 'partition_col', 'hash'); + master_create_distributed_table +--------------------------------- + +(1 row) + +SELECT master_create_worker_shards('ex_on_two_columns_prt', '4', '2'); + master_create_worker_shards +----------------------------- + +(1 row) + +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,1); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,1); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,101); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,101); +ERROR: conflicting key value violates exclusion constraint "ex_on_two_columns_prt_partition_col_other_col_excl_365012" +DETAIL: Key (partition_col, other_col)=(1, 101) conflicts with existing key (partition_col, other_col)=(1, 101). +CONTEXT: while executing command on localhost:57637 CREATE TABLE ex_wrong_operator ( partition_col tsrange, @@ -185,7 +210,7 @@ SELECT master_create_worker_shards('ex_overlaps', '4', '2'); INSERT INTO ex_overlaps (partition_col, other_col) VALUES ('[2016-01-01 00:00:00, 2016-02-01 00:00:00]', '[2016-01-01 00:00:00, 2016-02-01 00:00:00]'); INSERT INTO ex_overlaps (partition_col, other_col) VALUES ('[2016-01-01 00:00:00, 2016-02-01 00:00:00]', '[2016-01-15 00:00:00, 2016-02-01 00:00:00]'); -ERROR: conflicting key value violates exclusion constraint "ex_overlaps_other_col_partition_col_excl_365015" +ERROR: conflicting key value violates exclusion constraint "ex_overlaps_other_col_partition_col_excl_365019" DETAIL: Key (other_col, partition_col)=(["2016-01-15 00:00:00","2016-02-01 00:00:00"], ["2016-01-01 00:00:00","2016-02-01 00:00:00"]) conflicts with existing key (other_col, partition_col)=(["2016-01-01 00:00:00","2016-02-01 00:00:00"], ["2016-01-01 00:00:00","2016-02-01 00:00:00"]). CONTEXT: while executing command on localhost:57638 -- now show that Citus can distribute unique and EXCLUDE constraints that @@ -235,7 +260,7 @@ SELECT master_create_worker_shards('uq_two_columns_named', '4', '2'); INSERT INTO uq_two_columns_named (partition_col, other_col) VALUES (1,1); INSERT INTO uq_two_columns_named (partition_col, other_col) VALUES (1,1); -ERROR: duplicate key value violates unique constraint "uq_two_columns_named_uniq_365016" +ERROR: duplicate key value violates unique constraint "uq_two_columns_named_uniq_365020" DETAIL: Key (partition_col, other_col)=(1, 1) already exists. CONTEXT: while executing command on localhost:57637 CREATE TABLE ex_on_part_col_named @@ -258,7 +283,7 @@ SELECT master_create_worker_shards('ex_on_part_col_named', '4', '2'); INSERT INTO ex_on_part_col_named (partition_col, other_col) VALUES (1,1); INSERT INTO ex_on_part_col_named (partition_col, other_col) VALUES (1,2); -ERROR: conflicting key value violates exclusion constraint "ex_on_part_col_named_exclude_365020" +ERROR: conflicting key value violates exclusion constraint "ex_on_part_col_named_exclude_365024" DETAIL: Key (partition_col)=(1) conflicts with existing key (partition_col)=(1). CONTEXT: while executing command on localhost:57637 CREATE TABLE ex_on_two_columns_named @@ -281,7 +306,7 @@ SELECT master_create_worker_shards('ex_on_two_columns_named', '4', '2'); INSERT INTO ex_on_two_columns_named (partition_col, other_col) VALUES (1,1); INSERT INTO ex_on_two_columns_named (partition_col, other_col) VALUES (1,1); -ERROR: conflicting key value violates exclusion constraint "ex_on_two_columns_named_exclude_365024" +ERROR: conflicting key value violates exclusion constraint "ex_on_two_columns_named_exclude_365028" DETAIL: Key (partition_col, other_col)=(1, 1) conflicts with existing key (partition_col, other_col)=(1, 1). CONTEXT: while executing command on localhost:57637 CREATE TABLE ex_multiple_excludes @@ -306,11 +331,11 @@ SELECT master_create_worker_shards('ex_multiple_excludes', '4', '2'); INSERT INTO ex_multiple_excludes (partition_col, other_col, other_other_col) VALUES (1,1,1); INSERT INTO ex_multiple_excludes (partition_col, other_col, other_other_col) VALUES (1,1,2); -ERROR: conflicting key value violates exclusion constraint "ex_multiple_excludes_excl1_365028" +ERROR: conflicting key value violates exclusion constraint "ex_multiple_excludes_excl1_365032" DETAIL: Key (partition_col, other_col)=(1, 1) conflicts with existing key (partition_col, other_col)=(1, 1). CONTEXT: while executing command on localhost:57637 INSERT INTO ex_multiple_excludes (partition_col, other_col, other_other_col) VALUES (1,2,1); -ERROR: conflicting key value violates exclusion constraint "ex_multiple_excludes_excl2_365028" +ERROR: conflicting key value violates exclusion constraint "ex_multiple_excludes_excl2_365032" DETAIL: Key (partition_col, other_other_col)=(1, 1) conflicts with existing key (partition_col, other_other_col)=(1, 1). CONTEXT: while executing command on localhost:57637 CREATE TABLE ex_wrong_operator_named @@ -342,7 +367,7 @@ SELECT master_create_worker_shards('ex_overlaps_named', '4', '2'); INSERT INTO ex_overlaps_named (partition_col, other_col) VALUES ('[2016-01-01 00:00:00, 2016-02-01 00:00:00]', '[2016-01-01 00:00:00, 2016-02-01 00:00:00]'); INSERT INTO ex_overlaps_named (partition_col, other_col) VALUES ('[2016-01-01 00:00:00, 2016-02-01 00:00:00]', '[2016-01-15 00:00:00, 2016-02-01 00:00:00]'); -ERROR: conflicting key value violates exclusion constraint "ex_overlaps_operator_named_exclude_365035" +ERROR: conflicting key value violates exclusion constraint "ex_overlaps_operator_named_exclude_365039" DETAIL: Key (other_col, partition_col)=(["2016-01-15 00:00:00","2016-02-01 00:00:00"], ["2016-01-01 00:00:00","2016-02-01 00:00:00"]) conflicts with existing key (other_col, partition_col)=(["2016-01-01 00:00:00","2016-02-01 00:00:00"], ["2016-01-01 00:00:00","2016-02-01 00:00:00"]). CONTEXT: while executing command on localhost:57638 -- now show that Citus allows unique constraints on range-partitioned tables. @@ -378,84 +403,84 @@ SELECT master_create_worker_shards('check_example', '2', '2'); \c - - - :worker_1_port \d check_example* - Table "public.check_example_365036" + Table "public.check_example_365040" Column | Type | Modifiers -----------------+---------+----------- partition_col | integer | other_col | integer | other_other_col | integer | Indexes: - "check_example_partition_col_key_365036" UNIQUE CONSTRAINT, btree (partition_col) + "check_example_partition_col_key_365040" UNIQUE CONSTRAINT, btree (partition_col) Check constraints: "check_example_other_col_check" CHECK (other_col >= 100) "check_example_other_other_col_check" CHECK (abs(other_other_col) >= 100) - Table "public.check_example_365037" + Table "public.check_example_365041" Column | Type | Modifiers -----------------+---------+----------- partition_col | integer | other_col | integer | other_other_col | integer | Indexes: - "check_example_partition_col_key_365037" UNIQUE CONSTRAINT, btree (partition_col) + "check_example_partition_col_key_365041" UNIQUE CONSTRAINT, btree (partition_col) Check constraints: "check_example_other_col_check" CHECK (other_col >= 100) "check_example_other_other_col_check" CHECK (abs(other_other_col) >= 100) -Index "public.check_example_partition_col_key_365036" +Index "public.check_example_partition_col_key_365040" Column | Type | Definition ---------------+---------+--------------- partition_col | integer | partition_col -unique, btree, for table "public.check_example_365036" +unique, btree, for table "public.check_example_365040" -Index "public.check_example_partition_col_key_365037" +Index "public.check_example_partition_col_key_365041" Column | Type | Definition ---------------+---------+--------------- partition_col | integer | partition_col -unique, btree, for table "public.check_example_365037" +unique, btree, for table "public.check_example_365041" \c - - - :worker_2_port \d check_example* - Table "public.check_example_365036" + Table "public.check_example_365040" Column | Type | Modifiers -----------------+---------+----------- partition_col | integer | other_col | integer | other_other_col | integer | Indexes: - "check_example_partition_col_key_365036" UNIQUE CONSTRAINT, btree (partition_col) + "check_example_partition_col_key_365040" UNIQUE CONSTRAINT, btree (partition_col) Check constraints: "check_example_other_col_check" CHECK (other_col >= 100) "check_example_other_other_col_check" CHECK (abs(other_other_col) >= 100) - Table "public.check_example_365037" + Table "public.check_example_365041" Column | Type | Modifiers -----------------+---------+----------- partition_col | integer | other_col | integer | other_other_col | integer | Indexes: - "check_example_partition_col_key_365037" UNIQUE CONSTRAINT, btree (partition_col) + "check_example_partition_col_key_365041" UNIQUE CONSTRAINT, btree (partition_col) Check constraints: "check_example_other_col_check" CHECK (other_col >= 100) "check_example_other_other_col_check" CHECK (abs(other_other_col) >= 100) -Index "public.check_example_partition_col_key_365036" +Index "public.check_example_partition_col_key_365040" Column | Type | Definition ---------------+---------+--------------- partition_col | integer | partition_col -unique, btree, for table "public.check_example_365036" +unique, btree, for table "public.check_example_365040" -Index "public.check_example_partition_col_key_365037" +Index "public.check_example_partition_col_key_365041" Column | Type | Definition ---------------+---------+--------------- partition_col | integer | partition_col -unique, btree, for table "public.check_example_365037" +unique, btree, for table "public.check_example_365041" \c - - - :master_port -- drop unnecessary tables DROP TABLE pk_on_non_part_col, uq_on_non_part_col CASCADE; DROP TABLE pk_on_part_col, uq_part_col, uq_two_columns CASCADE; -DROP TABLE ex_on_part_col, ex_on_two_columns, ex_multiple_excludes, ex_overlaps CASCADE; +DROP TABLE ex_on_part_col, ex_on_two_columns, ex_on_two_columns_prt, ex_multiple_excludes, ex_overlaps CASCADE; DROP TABLE ex_on_part_col_named, ex_on_two_columns_named, ex_overlaps_named CASCADE; DROP TABLE uq_range_tables, check_example CASCADE; diff --git a/src/test/regress/expected/multi_index_statements.out b/src/test/regress/expected/multi_index_statements.out index e1ed574ac..639d18ad0 100644 --- a/src/test/regress/expected/multi_index_statements.out +++ b/src/test/regress/expected/multi_index_statements.out @@ -77,23 +77,27 @@ CREATE UNIQUE INDEX index_test_range_index_a ON index_test_range(a); CREATE UNIQUE INDEX index_test_range_index_a_b ON index_test_range(a,b); CREATE UNIQUE INDEX index_test_hash_index_a ON index_test_hash(a); CREATE UNIQUE INDEX index_test_hash_index_a_b ON index_test_hash(a,b); +CREATE UNIQUE INDEX index_test_hash_index_a_b_partial ON index_test_hash(a,b) WHERE c IS NOT NULL; +CREATE UNIQUE INDEX index_test_range_index_a_b_partial ON index_test_range(a,b) WHERE c IS NOT NULL; RESET client_min_messages; -- Verify that all indexes got created on the master node and one of the workers SELECT * FROM pg_indexes WHERE tablename = 'lineitem' or tablename like 'index_test_%' ORDER BY indexname; - schemaname | tablename | indexname | tablespace | indexdef -------------+------------------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------ - public | index_test_hash | index_test_hash_index_a | | CREATE UNIQUE INDEX index_test_hash_index_a ON index_test_hash USING btree (a) - public | index_test_hash | index_test_hash_index_a_b | | CREATE UNIQUE INDEX index_test_hash_index_a_b ON index_test_hash USING btree (a, b) - public | index_test_range | index_test_range_index_a | | CREATE UNIQUE INDEX index_test_range_index_a ON index_test_range USING btree (a) - public | index_test_range | index_test_range_index_a_b | | CREATE UNIQUE INDEX index_test_range_index_a_b ON index_test_range USING btree (a, b) - public | lineitem | lineitem_colref_index | | CREATE INDEX lineitem_colref_index ON lineitem USING btree (record_ne(lineitem.*, NULL::record)) - public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey) - public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey) - public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date) - public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC) - public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) - public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) -(11 rows) + schemaname | tablename | indexname | tablespace | indexdef +------------+------------------+------------------------------------+------------+--------------------------------------------------------------------------------------------------------------------- + public | index_test_hash | index_test_hash_index_a | | CREATE UNIQUE INDEX index_test_hash_index_a ON index_test_hash USING btree (a) + public | index_test_hash | index_test_hash_index_a_b | | CREATE UNIQUE INDEX index_test_hash_index_a_b ON index_test_hash USING btree (a, b) + public | index_test_hash | index_test_hash_index_a_b_partial | | CREATE UNIQUE INDEX index_test_hash_index_a_b_partial ON index_test_hash USING btree (a, b) WHERE (c IS NOT NULL) + public | index_test_range | index_test_range_index_a | | CREATE UNIQUE INDEX index_test_range_index_a ON index_test_range USING btree (a) + public | index_test_range | index_test_range_index_a_b | | CREATE UNIQUE INDEX index_test_range_index_a_b ON index_test_range USING btree (a, b) + public | index_test_range | index_test_range_index_a_b_partial | | CREATE UNIQUE INDEX index_test_range_index_a_b_partial ON index_test_range USING btree (a, b) WHERE (c IS NOT NULL) + public | lineitem | lineitem_colref_index | | CREATE INDEX lineitem_colref_index ON lineitem USING btree (record_ne(lineitem.*, NULL::record)) + public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey) + public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey) + public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date) + public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC) + public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) + public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) +(13 rows) \c - - - :worker_1_port SELECT count(*) FROM pg_indexes WHERE tablename = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1); @@ -105,13 +109,13 @@ SELECT count(*) FROM pg_indexes WHERE tablename = (SELECT relname FROM pg_class SELECT count(*) FROM pg_indexes WHERE tablename LIKE 'index_test_hash%'; count ------- - 16 + 24 (1 row) SELECT count(*) FROM pg_indexes WHERE tablename LIKE 'index_test_range%'; count ------- - 4 + 6 (1 row) SELECT count(*) FROM pg_indexes WHERE tablename LIKE 'index_test_append%'; @@ -130,8 +134,12 @@ CREATE INDEX try_index ON lineitem (l_orderkey) TABLESPACE newtablespace; ERROR: specifying tablespaces with CREATE INDEX statements is currently unsupported CREATE UNIQUE INDEX try_unique_range_index ON index_test_range(b); ERROR: creating unique indexes on non-partition columns is currently unsupported +CREATE UNIQUE INDEX try_unique_range_index_partial ON index_test_range(b) WHERE c IS NOT NULL; +ERROR: creating unique indexes on non-partition columns is currently unsupported CREATE UNIQUE INDEX try_unique_hash_index ON index_test_hash(b); ERROR: creating unique indexes on non-partition columns is currently unsupported +CREATE UNIQUE INDEX try_unique_hash_index_partial ON index_test_hash(b) WHERE c IS NOT NULL; +ERROR: creating unique indexes on non-partition columns is currently unsupported CREATE UNIQUE INDEX try_unique_append_index ON index_test_append(b); ERROR: creating unique indexes on append-partitioned tables is currently unsupported CREATE UNIQUE INDEX try_unique_append_index ON index_test_append(a); @@ -157,20 +165,22 @@ CREATE INDEX ON lineitem (l_orderkey); ERROR: creating index without a name on a distributed table is currently unsupported -- Verify that none of failed indexes got created on the master node SELECT * FROM pg_indexes WHERE tablename = 'lineitem' or tablename like 'index_test_%' ORDER BY indexname; - schemaname | tablename | indexname | tablespace | indexdef -------------+------------------+------------------------------+------------+------------------------------------------------------------------------------------------------------------------ - public | index_test_hash | index_test_hash_index_a | | CREATE UNIQUE INDEX index_test_hash_index_a ON index_test_hash USING btree (a) - public | index_test_hash | index_test_hash_index_a_b | | CREATE UNIQUE INDEX index_test_hash_index_a_b ON index_test_hash USING btree (a, b) - public | index_test_range | index_test_range_index_a | | CREATE UNIQUE INDEX index_test_range_index_a ON index_test_range USING btree (a) - public | index_test_range | index_test_range_index_a_b | | CREATE UNIQUE INDEX index_test_range_index_a_b ON index_test_range USING btree (a, b) - public | lineitem | lineitem_colref_index | | CREATE INDEX lineitem_colref_index ON lineitem USING btree (record_ne(lineitem.*, NULL::record)) - public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey) - public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey) - public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date) - public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC) - public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) - public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) -(11 rows) + schemaname | tablename | indexname | tablespace | indexdef +------------+------------------+------------------------------------+------------+--------------------------------------------------------------------------------------------------------------------- + public | index_test_hash | index_test_hash_index_a | | CREATE UNIQUE INDEX index_test_hash_index_a ON index_test_hash USING btree (a) + public | index_test_hash | index_test_hash_index_a_b | | CREATE UNIQUE INDEX index_test_hash_index_a_b ON index_test_hash USING btree (a, b) + public | index_test_hash | index_test_hash_index_a_b_partial | | CREATE UNIQUE INDEX index_test_hash_index_a_b_partial ON index_test_hash USING btree (a, b) WHERE (c IS NOT NULL) + public | index_test_range | index_test_range_index_a | | CREATE UNIQUE INDEX index_test_range_index_a ON index_test_range USING btree (a) + public | index_test_range | index_test_range_index_a_b | | CREATE UNIQUE INDEX index_test_range_index_a_b ON index_test_range USING btree (a, b) + public | index_test_range | index_test_range_index_a_b_partial | | CREATE UNIQUE INDEX index_test_range_index_a_b_partial ON index_test_range USING btree (a, b) WHERE (c IS NOT NULL) + public | lineitem | lineitem_colref_index | | CREATE INDEX lineitem_colref_index ON lineitem USING btree (record_ne(lineitem.*, NULL::record)) + public | lineitem | lineitem_orderkey_hash_index | | CREATE INDEX lineitem_orderkey_hash_index ON lineitem USING hash (l_partkey) + public | lineitem | lineitem_orderkey_index | | CREATE INDEX lineitem_orderkey_index ON lineitem USING btree (l_orderkey) + public | lineitem | lineitem_partial_index | | CREATE INDEX lineitem_partial_index ON lineitem USING btree (l_shipdate) WHERE (l_shipdate < '01-01-1995'::date) + public | lineitem | lineitem_partkey_desc_index | | CREATE INDEX lineitem_partkey_desc_index ON lineitem USING btree (l_partkey DESC) + public | lineitem | lineitem_pkey | | CREATE UNIQUE INDEX lineitem_pkey ON lineitem USING btree (l_orderkey, l_linenumber) + public | lineitem | lineitem_time_index | | CREATE INDEX lineitem_time_index ON lineitem USING btree (l_shipdate) +(13 rows) -- -- DROP INDEX @@ -197,8 +207,10 @@ DROP INDEX lineitem_orderkey_hash_index; ERROR: index "lineitem_orderkey_hash_index" does not exist DROP INDEX index_test_range_index_a; DROP INDEX index_test_range_index_a_b; +DROP INDEX index_test_range_index_a_b_partial; DROP INDEX index_test_hash_index_a; DROP INDEX index_test_hash_index_a_b; +DROP INDEX index_test_hash_index_a_b_partial; -- Verify that all the indexes are dropped from the master and one worker node. -- As there's a primary key, so exclude those from this check. SELECT indrelid::regclass, indexrelid::regclass FROM pg_index WHERE indrelid = (SELECT relname FROM pg_class WHERE relname LIKE 'lineitem%' ORDER BY relname LIMIT 1)::regclass AND NOT indisprimary AND indexrelid::regclass::text NOT LIKE 'lineitem_time_index%'; diff --git a/src/test/regress/sql/multi_create_table_constraints.sql b/src/test/regress/sql/multi_create_table_constraints.sql index a467fd3f1..c8056c47c 100644 --- a/src/test/regress/sql/multi_create_table_constraints.sql +++ b/src/test/regress/sql/multi_create_table_constraints.sql @@ -100,6 +100,19 @@ SELECT master_create_worker_shards('ex_on_two_columns', '4', '2'); INSERT INTO ex_on_two_columns (partition_col, other_col) VALUES (1,1); INSERT INTO ex_on_two_columns (partition_col, other_col) VALUES (1,1); +CREATE TABLE ex_on_two_columns_prt +( + partition_col integer, + other_col integer, + EXCLUDE (partition_col WITH =, other_col WITH =) WHERE (other_col > 100) +); +SELECT master_create_distributed_table('ex_on_two_columns_prt', 'partition_col', 'hash'); +SELECT master_create_worker_shards('ex_on_two_columns_prt', '4', '2'); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,1); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,1); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,101); +INSERT INTO ex_on_two_columns_prt (partition_col, other_col) VALUES (1,101); + CREATE TABLE ex_wrong_operator ( partition_col tsrange, @@ -233,6 +246,6 @@ SELECT master_create_worker_shards('check_example', '2', '2'); -- drop unnecessary tables DROP TABLE pk_on_non_part_col, uq_on_non_part_col CASCADE; DROP TABLE pk_on_part_col, uq_part_col, uq_two_columns CASCADE; -DROP TABLE ex_on_part_col, ex_on_two_columns, ex_multiple_excludes, ex_overlaps CASCADE; +DROP TABLE ex_on_part_col, ex_on_two_columns, ex_on_two_columns_prt, ex_multiple_excludes, ex_overlaps CASCADE; DROP TABLE ex_on_part_col_named, ex_on_two_columns_named, ex_overlaps_named CASCADE; DROP TABLE uq_range_tables, check_example CASCADE; diff --git a/src/test/regress/sql/multi_index_statements.sql b/src/test/regress/sql/multi_index_statements.sql index 268fd90fb..1cb4916e5 100644 --- a/src/test/regress/sql/multi_index_statements.sql +++ b/src/test/regress/sql/multi_index_statements.sql @@ -51,6 +51,8 @@ CREATE UNIQUE INDEX index_test_range_index_a ON index_test_range(a); CREATE UNIQUE INDEX index_test_range_index_a_b ON index_test_range(a,b); CREATE UNIQUE INDEX index_test_hash_index_a ON index_test_hash(a); CREATE UNIQUE INDEX index_test_hash_index_a_b ON index_test_hash(a,b); +CREATE UNIQUE INDEX index_test_hash_index_a_b_partial ON index_test_hash(a,b) WHERE c IS NOT NULL; +CREATE UNIQUE INDEX index_test_range_index_a_b_partial ON index_test_range(a,b) WHERE c IS NOT NULL; RESET client_min_messages; -- Verify that all indexes got created on the master node and one of the workers @@ -69,7 +71,9 @@ CREATE UNIQUE INDEX try_index ON lineitem (l_orderkey); CREATE INDEX try_index ON lineitem (l_orderkey) TABLESPACE newtablespace; CREATE UNIQUE INDEX try_unique_range_index ON index_test_range(b); +CREATE UNIQUE INDEX try_unique_range_index_partial ON index_test_range(b) WHERE c IS NOT NULL; CREATE UNIQUE INDEX try_unique_hash_index ON index_test_hash(b); +CREATE UNIQUE INDEX try_unique_hash_index_partial ON index_test_hash(b) WHERE c IS NOT NULL; CREATE UNIQUE INDEX try_unique_append_index ON index_test_append(b); CREATE UNIQUE INDEX try_unique_append_index ON index_test_append(a); CREATE UNIQUE INDEX try_unique_append_index_a_b ON index_test_append(a,b); @@ -111,8 +115,10 @@ DROP INDEX lineitem_orderkey_hash_index; DROP INDEX index_test_range_index_a; DROP INDEX index_test_range_index_a_b; +DROP INDEX index_test_range_index_a_b_partial; DROP INDEX index_test_hash_index_a; DROP INDEX index_test_hash_index_a_b; +DROP INDEX index_test_hash_index_a_b_partial; -- Verify that all the indexes are dropped from the master and one worker node. -- As there's a primary key, so exclude those from this check.