diff --git a/src/test/regress/expected/function_propagation.out b/src/test/regress/expected/function_propagation.out index 9070649b7..e1e00016b 100644 --- a/src/test/regress/expected/function_propagation.out +++ b/src/test/regress/expected/function_propagation.out @@ -1119,7 +1119,7 @@ SELECT create_distributed_function('func_to_colocate(int)', colocate_with:='tbl_ SELECT distribution_argument_index, colocationid, force_delegation FROM pg_catalog.pg_dist_object WHERE objid = 'func_to_colocate'::regproc; distribution_argument_index | colocationid | force_delegation --------------------------------------------------------------------- - | 161 | + | 163 | (1 row) -- convert to non-delegated @@ -1147,7 +1147,7 @@ SELECT create_distributed_function('func_to_colocate(int)','$1','tbl_to_colocate SELECT distribution_argument_index, colocationid, force_delegation FROM pg_catalog.pg_dist_object WHERE objid = 'func_to_colocate'::regproc; distribution_argument_index | colocationid | force_delegation --------------------------------------------------------------------- - 0 | 162 | + 0 | 164 | (1 row) -- try create or replace the same func @@ -1156,7 +1156,7 @@ CREATE OR REPLACE FUNCTION func_to_colocate (a int) returns int as $$select 1;$$ SELECT distribution_argument_index, colocationid, force_delegation FROM pg_catalog.pg_dist_object WHERE objid = 'func_to_colocate'::regproc; distribution_argument_index | colocationid | force_delegation --------------------------------------------------------------------- - 0 | 162 | + 0 | 164 | (1 row) -- convert to non-delegated @@ -1184,7 +1184,7 @@ SELECT create_distributed_function('func_to_colocate(int)','$1','tbl_to_colocate SELECT distribution_argument_index, colocationid, force_delegation FROM pg_catalog.pg_dist_object WHERE objid = 'func_to_colocate'::regproc; distribution_argument_index | colocationid | force_delegation --------------------------------------------------------------------- - 0 | 162 | t + 0 | 164 | t (1 row) -- convert to non-delegated diff --git a/src/test/regress/expected/multi_colocation_utils.out b/src/test/regress/expected/multi_colocation_utils.out index bf91256f9..c884b2631 100644 --- a/src/test/regress/expected/multi_colocation_utils.out +++ b/src/test/regress/expected/multi_colocation_utils.out @@ -1465,3 +1465,84 @@ DROP TABLE range_table; DROP TABLE none; DROP TABLE ref; DROP TABLE local_table; +CREATE TABLE tbl_1 (a INT, b INT); +CREATE TABLE tbl_2 (a INT, b INT); +CREATE TABLE tbl_3 (a INT, b INT); +SELECT create_distributed_table('tbl_1', 'a', shard_count:=4); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +SELECT create_distributed_table('tbl_2', 'a', shard_count:=4); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +SELECT create_distributed_table('tbl_3', 'a', shard_count:=4, colocate_with:='NONE'); + create_distributed_table +--------------------------------------------------------------------- + +(1 row) + +SELECT colocation_id AS col_id_1 FROM citus_tables WHERE table_name::text = 'tbl_1' \gset +SELECT colocation_id AS col_id_2 FROM citus_tables WHERE table_name::text = 'tbl_2' \gset +SELECT colocation_id AS col_id_3 FROM citus_tables WHERE table_name::text = 'tbl_3' \gset +-- check that tables are colocated correctly +SELECT :col_id_1 = :col_id_2; + ?column? +--------------------------------------------------------------------- + t +(1 row) + +SELECT :col_id_1 = :col_id_3; + ?column? +--------------------------------------------------------------------- + f +(1 row) + +-- check that there are separate rows for both colocation groups in pg_dist_colocation +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_1 +); + result +--------------------------------------------------------------------- + 1 + 1 + 1 +(3 rows) + +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_3 +); + result +--------------------------------------------------------------------- + 1 + 1 + 1 +(3 rows) + +DROP TABLE tbl_1, tbl_3; +-- check that empty colocation group is dropped and non-empty is not +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_1 +); + result +--------------------------------------------------------------------- + 1 + 1 + 1 +(3 rows) + +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_3 +); + result +--------------------------------------------------------------------- + 0 + 0 + 0 +(3 rows) + +DROP TABLE tbl_2; diff --git a/src/test/regress/sql/multi_colocation_utils.sql b/src/test/regress/sql/multi_colocation_utils.sql index 15bb4d739..57b7c366e 100644 --- a/src/test/regress/sql/multi_colocation_utils.sql +++ b/src/test/regress/sql/multi_colocation_utils.sql @@ -591,3 +591,40 @@ DROP TABLE range_table; DROP TABLE none; DROP TABLE ref; DROP TABLE local_table; + + +CREATE TABLE tbl_1 (a INT, b INT); +CREATE TABLE tbl_2 (a INT, b INT); +CREATE TABLE tbl_3 (a INT, b INT); + +SELECT create_distributed_table('tbl_1', 'a', shard_count:=4); +SELECT create_distributed_table('tbl_2', 'a', shard_count:=4); +SELECT create_distributed_table('tbl_3', 'a', shard_count:=4, colocate_with:='NONE'); + +SELECT colocation_id AS col_id_1 FROM citus_tables WHERE table_name::text = 'tbl_1' \gset +SELECT colocation_id AS col_id_2 FROM citus_tables WHERE table_name::text = 'tbl_2' \gset +SELECT colocation_id AS col_id_3 FROM citus_tables WHERE table_name::text = 'tbl_3' \gset + +-- check that tables are colocated correctly +SELECT :col_id_1 = :col_id_2; +SELECT :col_id_1 = :col_id_3; + +-- check that there are separate rows for both colocation groups in pg_dist_colocation +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_1 +); +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_3 +); + +DROP TABLE tbl_1, tbl_3; + +-- check that empty colocation group is dropped and non-empty is not +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_1 +); +SELECT result FROM run_command_on_all_nodes(' + SELECT count(*) FROM pg_dist_colocation WHERE colocationid = ' || :col_id_3 +); + +DROP TABLE tbl_2;