diff --git a/src/backend/distributed/operations/node_protocol.c b/src/backend/distributed/operations/node_protocol.c index 8b064804d..3ae91611a 100644 --- a/src/backend/distributed/operations/node_protocol.c +++ b/src/backend/distributed/operations/node_protocol.c @@ -85,6 +85,7 @@ PG_FUNCTION_INFO_V1(master_get_table_ddl_events); PG_FUNCTION_INFO_V1(master_get_new_shardid); PG_FUNCTION_INFO_V1(master_get_new_placementid); PG_FUNCTION_INFO_V1(master_get_active_worker_nodes); +PG_FUNCTION_INFO_V1(citus_get_active_worker_nodes); PG_FUNCTION_INFO_V1(master_get_round_robin_candidate_nodes); PG_FUNCTION_INFO_V1(master_stage_shard_row); PG_FUNCTION_INFO_V1(master_stage_shard_placement_row); @@ -442,12 +443,12 @@ master_stage_shard_placement_row(PG_FUNCTION_ARGS) /* - * master_get_active_worker_nodes returns a set of active worker host names and + * citus_get_active_worker_nodes returns a set of active worker host names and * port numbers in deterministic order. Currently we assume that all worker * nodes in pg_dist_node are active. */ Datum -master_get_active_worker_nodes(PG_FUNCTION_ARGS) +citus_get_active_worker_nodes(PG_FUNCTION_ARGS) { FuncCallContext *functionContext = NULL; uint32 workerNodeIndex = 0; @@ -512,6 +513,16 @@ master_get_active_worker_nodes(PG_FUNCTION_ARGS) } +/* + * master_get_active_worker_nodes is a wrapper function for old UDF name. + */ +Datum +master_get_active_worker_nodes(PG_FUNCTION_ARGS) +{ + return citus_get_active_worker_nodes(fcinfo); +} + + /* Finds the relationId from a potentially qualified relation name. */ Oid ResolveRelationId(text *relationName, bool missingOk) diff --git a/src/backend/distributed/sql/citus--10.0-2--10.0-3.sql b/src/backend/distributed/sql/citus--10.0-2--10.0-3.sql index d4f1312fb..5df300145 100644 --- a/src/backend/distributed/sql/citus--10.0-2--10.0-3.sql +++ b/src/backend/distributed/sql/citus--10.0-2--10.0-3.sql @@ -8,3 +8,11 @@ RETURNS VOID AS 'MODULE_PATHNAME', $$citus_update_table_statistics$$; COMMENT ON FUNCTION pg_catalog.master_update_table_statistics(regclass) IS 'updates shard statistics of the given table'; + +CREATE OR REPLACE FUNCTION pg_catalog.citus_get_active_worker_nodes(OUT node_name text, OUT node_port bigint) + RETURNS SETOF record + LANGUAGE C STRICT ROWS 100 + AS 'MODULE_PATHNAME', $$citus_get_active_worker_nodes$$; +COMMENT ON FUNCTION pg_catalog.citus_get_active_worker_nodes() + IS 'fetch set of active worker nodes'; + diff --git a/src/backend/distributed/sql/downgrades/citus--10.0-3--10.0-2.sql b/src/backend/distributed/sql/downgrades/citus--10.0-3--10.0-2.sql index f75a4642f..24ebc5218 100644 --- a/src/backend/distributed/sql/downgrades/citus--10.0-3--10.0-2.sql +++ b/src/backend/distributed/sql/downgrades/citus--10.0-3--10.0-2.sql @@ -22,3 +22,5 @@ END; $$ LANGUAGE 'plpgsql'; COMMENT ON FUNCTION master_update_table_statistics(regclass) IS 'updates shard statistics of the given table and its colocated tables'; + +DROP FUNCTION pg_catalog.citus_get_active_worker_nodes(OUT text, OUT bigint); diff --git a/src/test/regress/expected/multi_extension.out b/src/test/regress/expected/multi_extension.out index 73080d418..a3f5a2210 100644 --- a/src/test/regress/expected/multi_extension.out +++ b/src/test/regress/expected/multi_extension.out @@ -531,6 +531,23 @@ SELECT * FROM print_extension_changes(); --------------------------------------------------------------------- (0 rows) +-- Test downgrade to 10.0-2 from 10.0-3 +ALTER EXTENSION citus UPDATE TO '10.0-3'; +ALTER EXTENSION citus UPDATE TO '10.0-2'; +-- Should be empty result since upgrade+downgrade should be a no-op +SELECT * FROM print_extension_changes(); + previous_object | current_object +--------------------------------------------------------------------- +(0 rows) + +-- Snapshot of state at 10.0-3 +ALTER EXTENSION citus UPDATE TO '10.0-3'; +SELECT * FROM print_extension_changes(); + previous_object | current_object +--------------------------------------------------------------------- + | function citus_get_active_worker_nodes() +(1 row) + DROP TABLE prev_objects, extension_diff; -- show running version SHOW citus.version; diff --git a/src/test/regress/expected/multi_extension_0.out b/src/test/regress/expected/multi_extension_0.out index e6c4603b7..74d2e1620 100644 --- a/src/test/regress/expected/multi_extension_0.out +++ b/src/test/regress/expected/multi_extension_0.out @@ -527,6 +527,23 @@ SELECT * FROM print_extension_changes(); --------------------------------------------------------------------- (0 rows) +-- Test downgrade to 10.0-2 from 10.0-3 +ALTER EXTENSION citus UPDATE TO '10.0-3'; +ALTER EXTENSION citus UPDATE TO '10.0-2'; +-- Should be empty result since upgrade+downgrade should be a no-op +SELECT * FROM print_extension_changes(); + previous_object | current_object +--------------------------------------------------------------------- +(0 rows) + +-- Snapshot of state at 10.0-3 +ALTER EXTENSION citus UPDATE TO '10.0-3'; +SELECT * FROM print_extension_changes(); + previous_object | current_object +--------------------------------------------------------------------- + | function citus_get_active_worker_nodes() +(1 row) + DROP TABLE prev_objects, extension_diff; -- show running version SHOW citus.version; diff --git a/src/test/regress/expected/upgrade_list_citus_objects.out b/src/test/regress/expected/upgrade_list_citus_objects.out index 01dc7e386..d25d2858e 100644 --- a/src/test/regress/expected/upgrade_list_citus_objects.out +++ b/src/test/regress/expected/upgrade_list_citus_objects.out @@ -55,6 +55,7 @@ ORDER BY 1; function citus_executor_name(integer) function citus_extradata_container(internal) function citus_finish_pg_upgrade() + function citus_get_active_worker_nodes() function citus_internal.columnar_ensure_objects_exist() function citus_internal.find_groupid_for_node(text,integer) function citus_internal.pg_dist_node_trigger_func() @@ -242,5 +243,5 @@ ORDER BY 1; view citus_worker_stat_activity view pg_dist_shard_placement view time_partitions -(226 rows) +(227 rows) diff --git a/src/test/regress/expected/upgrade_list_citus_objects_0.out b/src/test/regress/expected/upgrade_list_citus_objects_0.out index efec52af8..6df1b6a71 100644 --- a/src/test/regress/expected/upgrade_list_citus_objects_0.out +++ b/src/test/regress/expected/upgrade_list_citus_objects_0.out @@ -52,6 +52,7 @@ ORDER BY 1; function citus_executor_name(integer) function citus_extradata_container(internal) function citus_finish_pg_upgrade() + function citus_get_active_worker_nodes() function citus_internal.columnar_ensure_objects_exist() function citus_internal.find_groupid_for_node(text,integer) function citus_internal.pg_dist_node_trigger_func() @@ -238,5 +239,5 @@ ORDER BY 1; view citus_worker_stat_activity view pg_dist_shard_placement view time_partitions -(222 rows) +(223 rows) diff --git a/src/test/regress/sql/multi_extension.sql b/src/test/regress/sql/multi_extension.sql index 01ab71df5..105569456 100644 --- a/src/test/regress/sql/multi_extension.sql +++ b/src/test/regress/sql/multi_extension.sql @@ -208,6 +208,16 @@ SELECT * FROM print_extension_changes(); ALTER EXTENSION citus UPDATE TO '10.0-2'; SELECT * FROM print_extension_changes(); +-- Test downgrade to 10.0-2 from 10.0-3 +ALTER EXTENSION citus UPDATE TO '10.0-3'; +ALTER EXTENSION citus UPDATE TO '10.0-2'; +-- Should be empty result since upgrade+downgrade should be a no-op +SELECT * FROM print_extension_changes(); + +-- Snapshot of state at 10.0-3 +ALTER EXTENSION citus UPDATE TO '10.0-3'; +SELECT * FROM print_extension_changes(); + DROP TABLE prev_objects, extension_diff; -- show running version