Fix tests

velioglu/cyclic_dep_2
Burak Velioglu 2022-03-09 11:16:10 +03:00
parent 6437e4ce25
commit f94e46560a
No known key found for this signature in database
GPG Key ID: F6827E620F6549C6
2 changed files with 25 additions and 0 deletions

View File

@ -560,6 +560,12 @@ SHOW citus.multi_shard_modify_mode;
(1 row)
COMMIT;
-- Show that PG does not allow adding a circular dependency btw types
-- We added here to make sure we can catch it if PG changes it's behaviour
CREATE TYPE circ_type1 AS (a int);
CREATE TYPE circ_type2 AS (a int, b circ_type1);
ALTER TYPE circ_type1 ADD ATTRIBUTE b circ_type2;
ERROR: composite type circ_type1 cannot be made a member of itself
-- clear objects
SET client_min_messages TO error; -- suppress cascading objects dropping
DROP SCHEMA type_tests CASCADE;

View File

@ -1258,6 +1258,25 @@ $$;
ALTER TABLE table_1_for_circ_dep_2 ADD CONSTRAINT check_const_for_circ check (func_2_for_circ_dep_2(col_1, NULL::table_2_for_circ_dep_2));
ERROR: Citus can not handle circular dependencies between distributed objects
DETAIL: "table table_1_for_circ_dep_2" circularly depends itself, resolve circular dependency first
-- Show that causing circular dependency via functions and create_distributed_table are not allowed
CREATE TABLE table_1_for_circ_dep_3(id int, col_1 int);
CREATE OR REPLACE FUNCTION func_for_circ_dep_3(param_1 int, param_2 table_1_for_circ_dep_3)
RETURNS boolean
LANGUAGE plpgsql AS
$$
BEGIN
return param_1 > 5;
END;
$$;
WARNING: Citus can't distribute function "func_for_circ_dep_3" having dependency on non-distributed relation "table_1_for_circ_dep_3"
DETAIL: Function will be created only locally
HINT: To distribute function, distribute dependent relations first. Then, re-create the function
CREATE TABLE table_2_for_circ_dep_3(id int, col_1 int check (func_for_circ_dep_3(col_1, NULL::table_1_for_circ_dep_3)));
ALTER TABLE table_1_for_circ_dep_3 ADD COLUMN col_2 table_2_for_circ_dep_3;
-- It should error out due to circular dependency
SELECT create_distributed_table('table_1_for_circ_dep_3','id');
ERROR: Citus can not handle circular dependencies between distributed objects
DETAIL: "table table_1_for_circ_dep_3" circularly depends itself, resolve circular dependency first
RESET search_path;
SET client_min_messages TO WARNING;
DROP SCHEMA function_propagation_schema CASCADE;