Add tests

new-record-failure-dnm
Halil Ozan Akgul 2022-04-19 11:15:41 +03:00
parent 4a3c978483
commit 421f17235f
3 changed files with 122 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;