From f52fdac198859fbcddc71fe9fcfa463464333993 Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Tue, 8 Mar 2022 19:16:35 +0300 Subject: [PATCH] Add more tests --- src/test/regress/sql/distributed_types.sql | 6 ++++++ src/test/regress/sql/function_propagation.sql | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/test/regress/sql/distributed_types.sql b/src/test/regress/sql/distributed_types.sql index e22533101..944bc9702 100644 --- a/src/test/regress/sql/distributed_types.sql +++ b/src/test/regress/sql/distributed_types.sql @@ -329,6 +329,12 @@ SELECT create_distributed_table('immediate_table', 'a'); SHOW citus.multi_shard_modify_mode; 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; + -- clear objects SET client_min_messages TO error; -- suppress cascading objects dropping DROP SCHEMA type_tests CASCADE; diff --git a/src/test/regress/sql/function_propagation.sql b/src/test/regress/sql/function_propagation.sql index f278269a1..0d7151e3f 100644 --- a/src/test/regress/sql/function_propagation.sql +++ b/src/test/regress/sql/function_propagation.sql @@ -813,6 +813,25 @@ $$; -- It should error out due to circular dependency 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)); + +-- 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; +$$; + +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'); + RESET search_path; SET client_min_messages TO WARNING; DROP SCHEMA function_propagation_schema CASCADE;