From 4fe8ec3e61585655c3a6b843129699e080b3a5f3 Mon Sep 17 00:00:00 2001 From: Burak Velioglu Date: Thu, 13 Jan 2022 12:12:36 +0300 Subject: [PATCH] Fix function create-drop scripts --- src/backend/distributed/sql/citus--10.2-4--11.0-1.sql | 8 +------- .../distributed/sql/downgrades/citus--11.0-1--10.2-4.sql | 1 + .../udfs/worker_drop_distributed_table_only/11.0-1.sql | 7 +++++++ .../udfs/worker_drop_distributed_table_only/latest.sql | 7 +++++++ src/test/regress/expected/multi_partitioning.out | 2 +- src/test/regress/sql/multi_extension.sql | 3 ++- 6 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/11.0-1.sql create mode 100644 src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/latest.sql diff --git a/src/backend/distributed/sql/citus--10.2-4--11.0-1.sql b/src/backend/distributed/sql/citus--10.2-4--11.0-1.sql index 941d59811..5a9f117dd 100644 --- a/src/backend/distributed/sql/citus--10.2-4--11.0-1.sql +++ b/src/backend/distributed/sql/citus--10.2-4--11.0-1.sql @@ -9,6 +9,7 @@ #include "udfs/citus_internal_add_object_metadata/11.0-1.sql" #include "udfs/citus_run_local_command/11.0-1.sql" #include "udfs/worker_drop_sequence_dependency/11.0-1.sql" +#include "udfs/worker_drop_distributed_table_only/11.0-1.sql" DROP FUNCTION IF EXISTS pg_catalog.master_apply_delete_command(text); @@ -33,13 +34,6 @@ BEGIN END; $$; -CREATE FUNCTION worker_drop_distributed_table_only(table_name text) - RETURNS VOID - LANGUAGE C STRICT - AS 'MODULE_PATHNAME', $$worker_drop_distributed_table_only$$; -COMMENT ON FUNCTION worker_drop_distributed_table_only(table_name text) - IS 'drop the distributed table only without the metadata'; - -- Here we keep track of partitioned tables that exists before Citus 11 -- where we need to call fix_all_partition_shard_index_names() before -- metadata is synced. Note that after citus-11, we automatically diff --git a/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-4.sql b/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-4.sql index df823be93..0b06633ac 100644 --- a/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-4.sql +++ b/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-4.sql @@ -46,3 +46,4 @@ DROP FUNCTION pg_catalog.citus_check_cluster_node_health (); DROP FUNCTION pg_catalog.citus_internal_add_object_metadata(text, text[], text[], integer, integer); DROP FUNCTION pg_catalog.citus_run_local_command(text); DROP FUNCTION pg_catalog.worker_drop_sequence_dependency(text); +DROP FUNCTION pg_catalog.worker_drop_distributed_table_only(table_name text); diff --git a/src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/11.0-1.sql b/src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/11.0-1.sql new file mode 100644 index 000000000..91a0bb4f5 --- /dev/null +++ b/src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/11.0-1.sql @@ -0,0 +1,7 @@ +CREATE FUNCTION pg_catalog.worker_drop_distributed_table_only(table_name text) + RETURNS VOID + LANGUAGE C STRICT + AS 'MODULE_PATHNAME', $$worker_drop_distributed_table_only$$; + +COMMENT ON FUNCTION worker_drop_distributed_table_only(table_name text) + IS 'drop the distributed table only without the metadata'; \ No newline at end of file diff --git a/src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/latest.sql b/src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/latest.sql new file mode 100644 index 000000000..91a0bb4f5 --- /dev/null +++ b/src/backend/distributed/sql/udfs/worker_drop_distributed_table_only/latest.sql @@ -0,0 +1,7 @@ +CREATE FUNCTION pg_catalog.worker_drop_distributed_table_only(table_name text) + RETURNS VOID + LANGUAGE C STRICT + AS 'MODULE_PATHNAME', $$worker_drop_distributed_table_only$$; + +COMMENT ON FUNCTION worker_drop_distributed_table_only(table_name text) + IS 'drop the distributed table only without the metadata'; \ No newline at end of file diff --git a/src/test/regress/expected/multi_partitioning.out b/src/test/regress/expected/multi_partitioning.out index 1b13f09f2..f65191e85 100644 --- a/src/test/regress/expected/multi_partitioning.out +++ b/src/test/regress/expected/multi_partitioning.out @@ -4304,7 +4304,7 @@ WHERE schemaname = 'partitioning_schema' AND tablename ilike '%part_table_with_% SELECT citus_activate_node('localhost', :worker_1_port); citus_activate_node --------------------------------------------------------------------- - 1 + 16 (1 row) \c - - - :worker_1_port diff --git a/src/test/regress/sql/multi_extension.sql b/src/test/regress/sql/multi_extension.sql index a5150d2c2..833fa35bd 100644 --- a/src/test/regress/sql/multi_extension.sql +++ b/src/test/regress/sql/multi_extension.sql @@ -212,9 +212,11 @@ SELECT * FROM multi_extension.print_extension_changes(); ALTER EXTENSION citus UPDATE TO '9.5-1'; BEGIN; + SET citus.enable_object_propagation TO on; SELECT master_add_node('localhost', :master_port, groupId=>0); CREATE TABLE citus_local_table (a int); SELECT create_citus_local_table('citus_local_table'); + RESET citus.enable_object_propagation; -- downgrade from 9.5-1 to 9.4-1 should fail as we have a citus local table ALTER EXTENSION citus UPDATE TO '9.4-1'; @@ -660,7 +662,6 @@ CREATE EXTENSION citus; CREATE EXTENSION citus; \c - - - :master_port -SET citus.enable_object_propagation TO off; -- prevent distributed transactions during add node SELECT FROM master_add_node('localhost', :worker_1_port); \c - - - :worker_1_port