Add tests

velioglu/cyclic_dep_with_tho
Burak Velioglu 2022-03-04 15:37:13 +03:00
parent 3668492e14
commit 6ebe673f5c
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
2 changed files with 64 additions and 0 deletions

View File

@ -1070,6 +1070,41 @@ SELECT create_distributed_table('table_non_for_func_dist', 'a');
(1 row)
-- Show that causing circular dependency via functions are not allowed
CREATE TABLE table_1_for_circ_dep(id int);
select create_distributed_table('table_1_for_circ_dep','id');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CREATE OR REPLACE FUNCTION func_1_for_circ_dep(col_1 table_1_for_circ_dep)
RETURNS int
LANGUAGE plpgsql AS
$$
BEGIN
return 1;
END;
$$;
CREATE TABLE table_2_for_circ_dep(id int, col_2 int default func_1_for_circ_dep(NULL::table_1_for_circ_dep));
select create_distributed_table('table_2_for_circ_dep','id');
create_distributed_table
---------------------------------------------------------------------
(1 row)
CREATE OR REPLACE FUNCTION func_2_for_circ_dep(col_3 table_2_for_circ_dep)
RETURNS int
LANGUAGE plpgsql AS
$$
BEGIN
return 1;
END;
$$;
-- It should error out due to circular dependency
ALTER TABLE table_1_for_circ_dep ADD COLUMN col_2 int default func_2_for_circ_dep(NULL::table_2_for_circ_dep);
ERROR: Citus can not handle circular dependencies between distributed objects
DETAIL: "table table_1_for_circ_dep" circularly depends itself, resolve circular dependency first
RESET search_path;
SET client_min_messages TO WARNING;
DROP SCHEMA function_propagation_schema CASCADE;

View File

@ -710,6 +710,35 @@ CREATE TABLE table_non_for_func_dist (
SELECT create_distributed_table('table_non_for_func_dist', 'a');
-- Show that causing circular dependency via functions are not allowed
CREATE TABLE table_1_for_circ_dep(id int);
select create_distributed_table('table_1_for_circ_dep','id');
CREATE OR REPLACE FUNCTION func_1_for_circ_dep(col_1 table_1_for_circ_dep)
RETURNS int
LANGUAGE plpgsql AS
$$
BEGIN
return 1;
END;
$$;
CREATE TABLE table_2_for_circ_dep(id int, col_2 int default func_1_for_circ_dep(NULL::table_1_for_circ_dep));
select create_distributed_table('table_2_for_circ_dep','id');
CREATE OR REPLACE FUNCTION func_2_for_circ_dep(col_3 table_2_for_circ_dep)
RETURNS int
LANGUAGE plpgsql AS
$$
BEGIN
return 1;
END;
$$;
-- It should error out due to circular dependency
ALTER TABLE table_1_for_circ_dep ADD COLUMN col_2 int default func_2_for_circ_dep(NULL::table_2_for_circ_dep);
RESET search_path;
SET client_min_messages TO WARNING;
DROP SCHEMA function_propagation_schema CASCADE;