From 88ec61c41370d42e160671df8cdc7981d3e7f7bd Mon Sep 17 00:00:00 2001 From: Ahmet Gedemenli Date: Tue, 19 Jan 2021 14:01:18 +0300 Subject: [PATCH] Replace to update_distributed_table_colocation for tests --- .../regress/expected/citus_local_tables.out | 20 +- .../expected/multi_colocation_utils.out | 178 ++++++++++-------- .../regress/expected/multi_drop_extension.out | 1 - .../regress/expected/multi_metadata_sync.out | 17 +- src/test/regress/expected/multi_multiuser.out | 2 +- .../expected/multi_reference_table.out | 17 -- .../multi_unsupported_worker_operations.out | 8 +- src/test/regress/sql/citus_local_tables.sql | 10 +- .../regress/sql/multi_colocation_utils.sql | 32 ++-- src/test/regress/sql/multi_drop_extension.sql | 1 - src/test/regress/sql/multi_metadata_sync.sql | 11 +- src/test/regress/sql/multi_multiuser.sql | 2 +- .../regress/sql/multi_reference_table.sql | 13 -- .../multi_unsupported_worker_operations.sql | 8 +- 14 files changed, 141 insertions(+), 179 deletions(-) diff --git a/src/test/regress/expected/citus_local_tables.out b/src/test/regress/expected/citus_local_tables.out index fc2be7fb3..526b8c2a3 100644 --- a/src/test/regress/expected/citus_local_tables.out +++ b/src/test/regress/expected/citus_local_tables.out @@ -295,18 +295,18 @@ SELECT create_reference_table('reference_table'); -- show that colociation of citus local tables are not supported for now -- between citus local tables -SELECT mark_tables_colocated('citus_local_table_1', ARRAY['citus_local_table_2']); -ERROR: citus local tables cannot be colocated with other tables +SELECT update_distributed_table_colocation('citus_local_table_1', colocate_with => 'citus_local_table_2'); +ERROR: relation citus_local_table_1 should be a hash distributed table -- between citus local tables and reference tables -SELECT mark_tables_colocated('citus_local_table_1', ARRAY['reference_table']); -ERROR: citus local tables cannot be colocated with other tables -SELECT mark_tables_colocated('reference_table', ARRAY['citus_local_table_1']); -ERROR: citus local tables cannot be colocated with other tables +SELECT update_distributed_table_colocation('citus_local_table_1', colocate_with => 'reference_table'); +ERROR: relation citus_local_table_1 should be a hash distributed table +SELECT update_distributed_table_colocation('reference_table', colocate_with => 'citus_local_table_1'); +ERROR: relation reference_table should be a hash distributed table -- between citus local tables and distributed tables -SELECT mark_tables_colocated('citus_local_table_1', ARRAY['distributed_table']); -ERROR: citus local tables cannot be colocated with other tables -SELECT mark_tables_colocated('distributed_table', ARRAY['citus_local_table_1']); -ERROR: citus local tables cannot be colocated with other tables +SELECT update_distributed_table_colocation('citus_local_table_1', colocate_with => 'distributed_table'); +ERROR: relation citus_local_table_1 should be a hash distributed table +SELECT update_distributed_table_colocation('distributed_table', colocate_with => 'citus_local_table_1'); +ERROR: relation citus_local_table_1 should be a hash distributed table -- master_create_empty_shard is not supported SELECT master_create_empty_shard('citus_local_table_1'); ERROR: relation "citus_local_table_1" is a citus local table diff --git a/src/test/regress/expected/multi_colocation_utils.out b/src/test/regress/expected/multi_colocation_utils.out index cea7003e9..91101d2a5 100644 --- a/src/test/regress/expected/multi_colocation_utils.out +++ b/src/test/regress/expected/multi_colocation_utils.out @@ -833,7 +833,7 @@ ORDER BY table2_groupf | 1300081 | t | 57638 | | (108 rows) --- reset colocation ids to test mark_tables_colocated +-- reset colocation ids to test update_distributed_table_colocation ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 1; DELETE FROM pg_dist_colocation WHERE colocationid >= 1 AND colocationid < 1000; @@ -855,21 +855,20 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition (0 rows) -- first check failing cases -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupC']); -ERROR: cannot colocate tables table1_groupb and table1_groupc -DETAIL: Distribution column types don't match for table1_groupb and table1_groupc. -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupD']); -ERROR: cannot colocate tables table1_groupb and table1_groupd -DETAIL: Shard counts don't match for table1_groupb and table1_groupd. -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupE']); -ERROR: cannot colocate tables table1_groupb and table1_groupe -DETAIL: Shard 1300026 of table1_groupb and shard xxxxx of table1_groupe have different number of shard placements. -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupF']); -ERROR: cannot colocate tables table1_groupb and table1_groupf -DETAIL: Replication models don't match for table1_groupb and table1_groupf. -SELECT mark_tables_colocated('table1_groupB', ARRAY['table2_groupB', 'table1_groupD']); -ERROR: cannot colocate tables table1_groupb and table1_groupd -DETAIL: Shard counts don't match for table1_groupb and table1_groupd. +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupC'); +ERROR: cannot colocate tables table1_groupc and table1_groupb +DETAIL: Distribution column types don't match for table1_groupc and table1_groupb. +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupD'); +ERROR: cannot colocate tables table1_groupd and table1_groupb +DETAIL: Shard counts don't match for table1_groupd and table1_groupb. +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupE'); +ERROR: cannot colocate tables table1_groupe and table1_groupb +DETAIL: Shard 1300058 of table1_groupe and shard xxxxx of table1_groupb have different number of shard placements. +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupF'); +ERROR: relation table1_groupf should be a hash distributed table +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupD'); +ERROR: cannot colocate tables table1_groupd and table1_groupb +DETAIL: Shard counts don't match for table1_groupd and table1_groupb. -- check metadata to see failing calls didn't have any side effects SELECT * FROM pg_dist_colocation WHERE colocationid >= 1 AND colocationid < 1000 @@ -886,39 +885,39 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition (0 rows) -- check successfully cololated tables -SELECT mark_tables_colocated('table1_groupB', ARRAY['table2_groupB']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table2_groupB'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) -SELECT mark_tables_colocated('table1_groupC', ARRAY['table2_groupC']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_groupC', colocate_with => 'table2_groupC'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) -SELECT mark_tables_colocated('table1_groupD', ARRAY['table2_groupD']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_groupD', colocate_with => 'table2_groupD'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) -SELECT mark_tables_colocated('table1_groupE', ARRAY['table2_groupE', 'table3_groupE']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_groupE', colocate_with => 'table2_groupE'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) -SELECT mark_tables_colocated('table1_groupF', ARRAY['table2_groupF']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_groupE', colocate_with => 'table3_groupE'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) -- check to colocate with itself -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupB']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupB'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) @@ -944,40 +943,53 @@ SELECT * FROM pg_dist_colocation ORDER BY colocationid; colocationid | shardcount | replicationfactor | distributioncolumntype | distributioncolumncollation --------------------------------------------------------------------- - 2 | 2 | 1 | 23 | 0 - 3 | 2 | 2 | 25 | 100 - 4 | 8 | 2 | 23 | 0 + 1 | 2 | 1 | 23 | 0 + 2 | 2 | 2 | 25 | 100 + 3 | 8 | 2 | 23 | 0 + 4 | 2 | 2 | 23 | 0 5 | 2 | 2 | 23 | 0 -(4 rows) +(5 rows) SELECT logicalrelid, colocationid FROM pg_dist_partition WHERE colocationid >= 1 AND colocationid < 1000 ORDER BY colocationid, logicalrelid; logicalrelid | colocationid --------------------------------------------------------------------- - table1_groupb | 2 - table2_groupb | 2 - table1_groupc | 3 - table2_groupc | 3 - table1_groupd | 4 - table2_groupd | 4 + table1_groupb | 1 + table2_groupb | 1 + table1_groupc | 2 + table2_groupc | 2 + table1_groupd | 3 + table2_groupd | 3 + table2_groupe | 4 table1_groupe | 5 - table2_groupe | 5 table3_groupe | 5 table1_group_none | 6 table2_group_none | 7 (11 rows) -- move the all tables in colocation group 5 to colocation group 7 -SELECT mark_tables_colocated('table1_group_none', ARRAY['table1_groupE', 'table2_groupE', 'table3_groupE']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table1_groupE'); + update_distributed_table_colocation +--------------------------------------------------------------------- + +(1 row) + +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table2_groupE'); + update_distributed_table_colocation +--------------------------------------------------------------------- + +(1 row) + +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table3_groupE'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) -- move a table with a colocation id which is already not in pg_dist_colocation -SELECT mark_tables_colocated('table1_group_none', ARRAY['table2_group_none']); - mark_tables_colocated +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table2_group_none'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) @@ -988,27 +1000,29 @@ SELECT * FROM pg_dist_colocation ORDER BY colocationid; colocationid | shardcount | replicationfactor | distributioncolumntype | distributioncolumncollation --------------------------------------------------------------------- - 2 | 2 | 1 | 23 | 0 - 3 | 2 | 2 | 25 | 100 - 4 | 8 | 2 | 23 | 0 -(3 rows) + 1 | 2 | 1 | 23 | 0 + 2 | 2 | 2 | 25 | 100 + 3 | 8 | 2 | 23 | 0 + 4 | 2 | 2 | 23 | 0 + 5 | 2 | 2 | 23 | 0 +(5 rows) SELECT logicalrelid, colocationid FROM pg_dist_partition WHERE colocationid >= 1 AND colocationid < 1000 ORDER BY colocationid, logicalrelid; logicalrelid | colocationid --------------------------------------------------------------------- - table1_groupb | 2 - table2_groupb | 2 - table1_groupc | 3 - table2_groupc | 3 - table1_groupd | 4 - table2_groupd | 4 - table1_groupe | 6 - table2_groupe | 6 - table3_groupe | 6 - table1_group_none | 6 - table2_group_none | 6 + table1_groupb | 1 + table2_groupb | 1 + table1_groupc | 2 + table2_groupc | 2 + table1_groupd | 3 + table2_groupd | 3 + table2_groupe | 4 + table1_groupe | 5 + table3_groupe | 5 + table1_group_none | 7 + table2_group_none | 7 (11 rows) -- try to colocate different replication models @@ -1033,9 +1047,9 @@ SELECT create_distributed_table('table2_groupG', 'id', colocate_with => 'NONE'); (1 row) -SELECT mark_tables_colocated('table1_groupG', ARRAY['table2_groupG']); -ERROR: cannot colocate tables table1_groupg and table2_groupg -DETAIL: Replication models don't match for table1_groupg and table2_groupg. +SELECT update_distributed_table_colocation('table1_groupG', colocate_with => 'table2_groupG'); +ERROR: cannot colocate tables table2_groupg and table1_groupg +DETAIL: Replication models don't match for table2_groupg and table1_groupg. CREATE TABLE d1(a int, b int); CREATE TABLE d2(a int, b int); CREATE TABLE d3(a int, b int); @@ -1105,25 +1119,25 @@ SELECT create_reference_table('ref'); SELECT get_table_colocation_id('d1'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d2'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d3'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d4'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT tables_colocated('d1', 'd2'); @@ -1173,25 +1187,25 @@ SELECT update_distributed_table_colocation('d2', colocate_with => 'none'); SELECT get_table_colocation_id('d1'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d2'); get_table_colocation_id --------------------------------------------------------------------- - 11 + 10 (1 row) SELECT get_table_colocation_id('d3'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d4'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT tables_colocated('d1', 'd2'); @@ -1230,25 +1244,25 @@ SELECT update_distributed_table_colocation('d2', colocate_with => 'none'); SELECT get_table_colocation_id('d1'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d2'); get_table_colocation_id --------------------------------------------------------------------- - 12 + 11 (1 row) SELECT get_table_colocation_id('d3'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d4'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT tables_colocated('d1', 'd2'); @@ -1285,25 +1299,25 @@ SELECT update_distributed_table_colocation('d3', colocate_with => 'd2'); SELECT get_table_colocation_id('d1'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d2'); get_table_colocation_id --------------------------------------------------------------------- - 12 + 11 (1 row) SELECT get_table_colocation_id('d3'); get_table_colocation_id --------------------------------------------------------------------- - 12 + 11 (1 row) SELECT get_table_colocation_id('d4'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT tables_colocated('d1', 'd2'); @@ -1341,31 +1355,31 @@ SELECT update_distributed_table_colocation('d3', colocate_with => '"none"'); SELECT get_table_colocation_id('d1'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d2'); get_table_colocation_id --------------------------------------------------------------------- - 12 + 11 (1 row) SELECT get_table_colocation_id('d3'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('d4'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT get_table_colocation_id('none'); get_table_colocation_id --------------------------------------------------------------------- - 8 + 4 (1 row) SELECT tables_colocated('d1', 'd2'); diff --git a/src/test/regress/expected/multi_drop_extension.out b/src/test/regress/expected/multi_drop_extension.out index cd3098ee8..45ae5e9eb 100644 --- a/src/test/regress/expected/multi_drop_extension.out +++ b/src/test/regress/expected/multi_drop_extension.out @@ -16,7 +16,6 @@ SELECT create_distributed_table('testtableddl', 'distributecol', 'append'); -- around. SET client_min_messages TO 'WARNING'; DROP FUNCTION pg_catalog.master_create_worker_shards(text, integer, integer); -DROP FUNCTION pg_catalog.mark_tables_colocated(regclass, regclass[]); DROP EXTENSION citus CASCADE; RESET client_min_messages; BEGIN; diff --git a/src/test/regress/expected/multi_metadata_sync.out b/src/test/regress/expected/multi_metadata_sync.out index c457b5a6b..8d1452be9 100644 --- a/src/test/regress/expected/multi_metadata_sync.out +++ b/src/test/regress/expected/multi_metadata_sync.out @@ -808,13 +808,8 @@ SELECT "Constraint", "Definition" FROM table_fkeys WHERE relid='mx_test_schema_1 mx_fk_constraint_2 | FOREIGN KEY (col1) REFERENCES mx_test_schema_2.mx_table_2(col1) (1 row) --- Check that mark_tables_colocated call propagates the changes to the workers +-- Check that update_distributed_table_colocation call propagates the changes to the workers \c - - - :master_port --- this function is dropped in Citus10, added here for tests -CREATE OR REPLACE FUNCTION pg_catalog.mark_tables_colocated(source_table_name regclass, target_table_names regclass[]) - RETURNS void - LANGUAGE C STRICT - AS 'citus', $$mark_tables_colocated$$; SELECT nextval('pg_catalog.pg_dist_colocationid_seq') AS last_colocation_id \gset ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 10000; SET citus.shard_count TO 7; @@ -865,9 +860,9 @@ SET WHERE logicalrelid = 'mx_colocation_test_1'::regclass OR logicalrelid = 'mx_colocation_test_2'::regclass; --- Mark tables colocated and see the changes on the master and the worker -SELECT mark_tables_colocated('mx_colocation_test_1', ARRAY['mx_colocation_test_2']); - mark_tables_colocated +-- Update colocation and see the changes on the master and the worker +SELECT update_distributed_table_colocation('mx_colocation_test_1', colocate_with => 'mx_colocation_test_2'); + update_distributed_table_colocation --------------------------------------------------------------------- (1 row) @@ -881,8 +876,8 @@ WHERE OR logicalrelid = 'mx_colocation_test_2'::regclass; logicalrelid | colocationid --------------------------------------------------------------------- - mx_colocation_test_1 | 10001 mx_colocation_test_2 | 10001 + mx_colocation_test_1 | 10001 (2 rows) \c - - - :worker_1_port @@ -895,8 +890,8 @@ WHERE OR logicalrelid = 'mx_colocation_test_2'::regclass; logicalrelid | colocationid --------------------------------------------------------------------- - mx_colocation_test_1 | 10001 mx_colocation_test_2 | 10001 + mx_colocation_test_1 | 10001 (2 rows) \c - - - :master_port diff --git a/src/test/regress/expected/multi_multiuser.out b/src/test/regress/expected/multi_multiuser.out index daf86bad7..a0480d8a0 100644 --- a/src/test/regress/expected/multi_multiuser.out +++ b/src/test/regress/expected/multi_multiuser.out @@ -313,7 +313,7 @@ ABORT; SELECT * FROM citus_stat_statements_reset(); ERROR: permission denied for function citus_stat_statements_reset -- should not be allowed to co-located tables -SELECT mark_tables_colocated('test', ARRAY['test_coloc'::regclass]); +SELECT update_distributed_table_colocation('test', colocate_with => 'test_coloc'); ERROR: must be owner of table test -- should not be allowed to take any locks BEGIN; diff --git a/src/test/regress/expected/multi_reference_table.out b/src/test/regress/expected/multi_reference_table.out index e5b67705c..909ddc324 100644 --- a/src/test/regress/expected/multi_reference_table.out +++ b/src/test/regress/expected/multi_reference_table.out @@ -1196,23 +1196,6 @@ DEBUG: cannot perform distributed INSERT INTO ... SELECT because the partition DETAIL: The target table's partition column should correspond to a partition column in the subquery. DEBUG: performing repartitioned INSERT ... SELECT RESET client_min_messages; --- this function is dropped in Citus10, added here for tests -CREATE OR REPLACE FUNCTION pg_catalog.mark_tables_colocated(source_table_name regclass, target_table_names regclass[]) - RETURNS void - LANGUAGE C STRICT - AS 'citus', $$mark_tables_colocated$$; --- some tests for mark_tables_colocated --- should error out -SELECT mark_tables_colocated('colocated_table_test_2', ARRAY['reference_table_test']); -ERROR: cannot colocate tables colocated_table_test_2 and reference_table_test -DETAIL: Replication models don't match for colocated_table_test_2 and reference_table_test. --- should work sliently -SELECT mark_tables_colocated('reference_table_test', ARRAY['reference_table_test_fifth']); - mark_tables_colocated ---------------------------------------------------------------------- - -(1 row) - -- ensure that reference tables on -- different queries works as expected CREATE SCHEMA reference_schema; diff --git a/src/test/regress/expected/multi_unsupported_worker_operations.out b/src/test/regress/expected/multi_unsupported_worker_operations.out index 7ec8728bd..ceb34e252 100644 --- a/src/test/regress/expected/multi_unsupported_worker_operations.out +++ b/src/test/regress/expected/multi_unsupported_worker_operations.out @@ -220,14 +220,8 @@ SELECT master_remove_node('localhost', 5432); (1 row) \c - - - :worker_1_port --- mark_tables_colocated --- this function is dropped in Citus10, added here for tests -CREATE OR REPLACE FUNCTION pg_catalog.mark_tables_colocated(source_table_name regclass, target_table_names regclass[]) - RETURNS void - LANGUAGE C STRICT - AS 'citus', $$mark_tables_colocated$$; UPDATE pg_dist_partition SET colocationid = 0 WHERE logicalrelid='mx_table_2'::regclass; -SELECT mark_tables_colocated('mx_table', ARRAY['mx_table_2']); +SELECT update_distributed_table_colocation('mx_table', colocate_with => 'mx_table_2'); ERROR: operation is not allowed on this node HINT: Connect to the coordinator and run it again. SELECT colocationid FROM pg_dist_partition WHERE logicalrelid='mx_table_2'::regclass; diff --git a/src/test/regress/sql/citus_local_tables.sql b/src/test/regress/sql/citus_local_tables.sql index 9d0828e9d..0e9419504 100644 --- a/src/test/regress/sql/citus_local_tables.sql +++ b/src/test/regress/sql/citus_local_tables.sql @@ -220,15 +220,15 @@ SELECT create_reference_table('reference_table'); -- show that colociation of citus local tables are not supported for now -- between citus local tables -SELECT mark_tables_colocated('citus_local_table_1', ARRAY['citus_local_table_2']); +SELECT update_distributed_table_colocation('citus_local_table_1', colocate_with => 'citus_local_table_2'); -- between citus local tables and reference tables -SELECT mark_tables_colocated('citus_local_table_1', ARRAY['reference_table']); -SELECT mark_tables_colocated('reference_table', ARRAY['citus_local_table_1']); +SELECT update_distributed_table_colocation('citus_local_table_1', colocate_with => 'reference_table'); +SELECT update_distributed_table_colocation('reference_table', colocate_with => 'citus_local_table_1'); -- between citus local tables and distributed tables -SELECT mark_tables_colocated('citus_local_table_1', ARRAY['distributed_table']); -SELECT mark_tables_colocated('distributed_table', ARRAY['citus_local_table_1']); +SELECT update_distributed_table_colocation('citus_local_table_1', colocate_with => 'distributed_table'); +SELECT update_distributed_table_colocation('distributed_table', colocate_with => 'citus_local_table_1'); -- master_create_empty_shard is not supported SELECT master_create_empty_shard('citus_local_table_1'); diff --git a/src/test/regress/sql/multi_colocation_utils.sql b/src/test/regress/sql/multi_colocation_utils.sql index 55f563234..2a8f55a85 100644 --- a/src/test/regress/sql/multi_colocation_utils.sql +++ b/src/test/regress/sql/multi_colocation_utils.sql @@ -344,7 +344,7 @@ ORDER BY shardid, nodeport; --- reset colocation ids to test mark_tables_colocated +-- reset colocation ids to test update_distributed_table_colocation ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 1; DELETE FROM pg_dist_colocation WHERE colocationid >= 1 AND colocationid < 1000; @@ -361,11 +361,11 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition ORDER BY colocationid, logicalrelid; -- first check failing cases -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupC']); -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupD']); -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupE']); -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupF']); -SELECT mark_tables_colocated('table1_groupB', ARRAY['table2_groupB', 'table1_groupD']); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupC'); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupD'); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupE'); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupF'); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupD'); -- check metadata to see failing calls didn't have any side effects SELECT * FROM pg_dist_colocation @@ -377,14 +377,14 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition ORDER BY colocationid, logicalrelid; -- check successfully cololated tables -SELECT mark_tables_colocated('table1_groupB', ARRAY['table2_groupB']); -SELECT mark_tables_colocated('table1_groupC', ARRAY['table2_groupC']); -SELECT mark_tables_colocated('table1_groupD', ARRAY['table2_groupD']); -SELECT mark_tables_colocated('table1_groupE', ARRAY['table2_groupE', 'table3_groupE']); -SELECT mark_tables_colocated('table1_groupF', ARRAY['table2_groupF']); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table2_groupB'); +SELECT update_distributed_table_colocation('table1_groupC', colocate_with => 'table2_groupC'); +SELECT update_distributed_table_colocation('table1_groupD', colocate_with => 'table2_groupD'); +SELECT update_distributed_table_colocation('table1_groupE', colocate_with => 'table2_groupE'); +SELECT update_distributed_table_colocation('table1_groupE', colocate_with => 'table3_groupE'); -- check to colocate with itself -SELECT mark_tables_colocated('table1_groupB', ARRAY['table1_groupB']); +SELECT update_distributed_table_colocation('table1_groupB', colocate_with => 'table1_groupB'); SET citus.shard_count = 2; @@ -404,10 +404,12 @@ SELECT logicalrelid, colocationid FROM pg_dist_partition ORDER BY colocationid, logicalrelid; -- move the all tables in colocation group 5 to colocation group 7 -SELECT mark_tables_colocated('table1_group_none', ARRAY['table1_groupE', 'table2_groupE', 'table3_groupE']); +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table1_groupE'); +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table2_groupE'); +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table3_groupE'); -- move a table with a colocation id which is already not in pg_dist_colocation -SELECT mark_tables_colocated('table1_group_none', ARRAY['table2_group_none']); +SELECT update_distributed_table_colocation('table1_group_none', colocate_with => 'table2_group_none'); -- check metadata to see that unused colocation group is deleted SELECT * FROM pg_dist_colocation @@ -431,7 +433,7 @@ SELECT create_distributed_table('table2_groupG', 'id', colocate_with => 'table1_ CREATE TABLE table2_groupG ( id int ); SELECT create_distributed_table('table2_groupG', 'id', colocate_with => 'NONE'); -SELECT mark_tables_colocated('table1_groupG', ARRAY['table2_groupG']); +SELECT update_distributed_table_colocation('table1_groupG', colocate_with => 'table2_groupG'); CREATE TABLE d1(a int, b int); CREATE TABLE d2(a int, b int); diff --git a/src/test/regress/sql/multi_drop_extension.sql b/src/test/regress/sql/multi_drop_extension.sql index ec1bee234..0598d31ed 100644 --- a/src/test/regress/sql/multi_drop_extension.sql +++ b/src/test/regress/sql/multi_drop_extension.sql @@ -16,7 +16,6 @@ SELECT create_distributed_table('testtableddl', 'distributecol', 'append'); -- around. SET client_min_messages TO 'WARNING'; DROP FUNCTION pg_catalog.master_create_worker_shards(text, integer, integer); -DROP FUNCTION pg_catalog.mark_tables_colocated(regclass, regclass[]); DROP EXTENSION citus CASCADE; RESET client_min_messages; diff --git a/src/test/regress/sql/multi_metadata_sync.sql b/src/test/regress/sql/multi_metadata_sync.sql index a0ff53a7c..8a9b380af 100644 --- a/src/test/regress/sql/multi_metadata_sync.sql +++ b/src/test/regress/sql/multi_metadata_sync.sql @@ -354,13 +354,8 @@ NOT VALID; \c - - - :worker_1_port SELECT "Constraint", "Definition" FROM table_fkeys WHERE relid='mx_test_schema_1.mx_table_1'::regclass; --- Check that mark_tables_colocated call propagates the changes to the workers +-- Check that update_distributed_table_colocation call propagates the changes to the workers \c - - - :master_port --- this function is dropped in Citus10, added here for tests -CREATE OR REPLACE FUNCTION pg_catalog.mark_tables_colocated(source_table_name regclass, target_table_names regclass[]) - RETURNS void - LANGUAGE C STRICT - AS 'citus', $$mark_tables_colocated$$; SELECT nextval('pg_catalog.pg_dist_colocationid_seq') AS last_colocation_id \gset ALTER SEQUENCE pg_catalog.pg_dist_colocationid_seq RESTART 10000; SET citus.shard_count TO 7; @@ -400,8 +395,8 @@ WHERE logicalrelid = 'mx_colocation_test_1'::regclass OR logicalrelid = 'mx_colocation_test_2'::regclass; --- Mark tables colocated and see the changes on the master and the worker -SELECT mark_tables_colocated('mx_colocation_test_1', ARRAY['mx_colocation_test_2']); +-- Update colocation and see the changes on the master and the worker +SELECT update_distributed_table_colocation('mx_colocation_test_1', colocate_with => 'mx_colocation_test_2'); SELECT logicalrelid, colocationid FROM diff --git a/src/test/regress/sql/multi_multiuser.sql b/src/test/regress/sql/multi_multiuser.sql index 90cd28790..b88fadb03 100644 --- a/src/test/regress/sql/multi_multiuser.sql +++ b/src/test/regress/sql/multi_multiuser.sql @@ -193,7 +193,7 @@ ABORT; SELECT * FROM citus_stat_statements_reset(); -- should not be allowed to co-located tables -SELECT mark_tables_colocated('test', ARRAY['test_coloc'::regclass]); +SELECT update_distributed_table_colocation('test', colocate_with => 'test_coloc'); -- should not be allowed to take any locks BEGIN; diff --git a/src/test/regress/sql/multi_reference_table.sql b/src/test/regress/sql/multi_reference_table.sql index 34b9900db..cee76dab9 100644 --- a/src/test/regress/sql/multi_reference_table.sql +++ b/src/test/regress/sql/multi_reference_table.sql @@ -764,19 +764,6 @@ WHERE RESET client_min_messages; --- this function is dropped in Citus10, added here for tests -CREATE OR REPLACE FUNCTION pg_catalog.mark_tables_colocated(source_table_name regclass, target_table_names regclass[]) - RETURNS void - LANGUAGE C STRICT - AS 'citus', $$mark_tables_colocated$$; - --- some tests for mark_tables_colocated --- should error out -SELECT mark_tables_colocated('colocated_table_test_2', ARRAY['reference_table_test']); - --- should work sliently -SELECT mark_tables_colocated('reference_table_test', ARRAY['reference_table_test_fifth']); - -- ensure that reference tables on -- different queries works as expected CREATE SCHEMA reference_schema; diff --git a/src/test/regress/sql/multi_unsupported_worker_operations.sql b/src/test/regress/sql/multi_unsupported_worker_operations.sql index 69677d3c1..5b07f2cac 100644 --- a/src/test/regress/sql/multi_unsupported_worker_operations.sql +++ b/src/test/regress/sql/multi_unsupported_worker_operations.sql @@ -142,15 +142,9 @@ SELECT master_remove_node('localhost', 5432); \c - - - :worker_1_port --- mark_tables_colocated --- this function is dropped in Citus10, added here for tests -CREATE OR REPLACE FUNCTION pg_catalog.mark_tables_colocated(source_table_name regclass, target_table_names regclass[]) - RETURNS void - LANGUAGE C STRICT - AS 'citus', $$mark_tables_colocated$$; UPDATE pg_dist_partition SET colocationid = 0 WHERE logicalrelid='mx_table_2'::regclass; -SELECT mark_tables_colocated('mx_table', ARRAY['mx_table_2']); +SELECT update_distributed_table_colocation('mx_table', colocate_with => 'mx_table_2'); SELECT colocationid FROM pg_dist_partition WHERE logicalrelid='mx_table_2'::regclass; SELECT colocationid AS old_colocation_id