From f94e46560a16ef2ef6ef6bc4782d635520f1f9dc Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Wed, 9 Mar 2022 11:16:10 +0300 Subject: [PATCH] Fix tests --- .../regress/expected/distributed_types.out | 6 ++++++ .../regress/expected/function_propagation.out | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/test/regress/expected/distributed_types.out b/src/test/regress/expected/distributed_types.out index c20326820..69684c702 100644 --- a/src/test/regress/expected/distributed_types.out +++ b/src/test/regress/expected/distributed_types.out @@ -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; diff --git a/src/test/regress/expected/function_propagation.out b/src/test/regress/expected/function_propagation.out index 5231ff1d1..ba39dacb5 100644 --- a/src/test/regress/expected/function_propagation.out +++ b/src/test/regress/expected/function_propagation.out @@ -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;