diff --git a/src/backend/columnar/sql/udfs/alter_columnar_table_reset/11.1-1.sql b/src/backend/columnar/sql/udfs/alter_columnar_table_reset/11.1-1.sql index 7c636dd6e51..43e753ed502 100644 --- a/src/backend/columnar/sql/udfs/alter_columnar_table_reset/11.1-1.sql +++ b/src/backend/columnar/sql/udfs/alter_columnar_table_reset/11.1-1.sql @@ -5,7 +5,9 @@ CREATE OR REPLACE FUNCTION pg_catalog.alter_columnar_table_reset( compression bool DEFAULT false, compression_level bool DEFAULT false) RETURNS void - LANGUAGE plpgsql AS + LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp + AS $alter_columnar_table_reset$ declare noop BOOLEAN := true; diff --git a/src/backend/columnar/sql/udfs/alter_columnar_table_reset/latest.sql b/src/backend/columnar/sql/udfs/alter_columnar_table_reset/latest.sql index 7c636dd6e51..43e753ed502 100644 --- a/src/backend/columnar/sql/udfs/alter_columnar_table_reset/latest.sql +++ b/src/backend/columnar/sql/udfs/alter_columnar_table_reset/latest.sql @@ -5,7 +5,9 @@ CREATE OR REPLACE FUNCTION pg_catalog.alter_columnar_table_reset( compression bool DEFAULT false, compression_level bool DEFAULT false) RETURNS void - LANGUAGE plpgsql AS + LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp + AS $alter_columnar_table_reset$ declare noop BOOLEAN := true; diff --git a/src/backend/columnar/sql/udfs/alter_columnar_table_set/11.1-1.sql b/src/backend/columnar/sql/udfs/alter_columnar_table_set/11.1-1.sql index 9e9fe1be45c..09c2247f8e0 100644 --- a/src/backend/columnar/sql/udfs/alter_columnar_table_set/11.1-1.sql +++ b/src/backend/columnar/sql/udfs/alter_columnar_table_set/11.1-1.sql @@ -5,7 +5,9 @@ CREATE OR REPLACE FUNCTION pg_catalog.alter_columnar_table_set( compression name DEFAULT null, compression_level int DEFAULT NULL) RETURNS void - LANGUAGE plpgsql AS + LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp + AS $alter_columnar_table_set$ declare noop BOOLEAN := true; diff --git a/src/backend/columnar/sql/udfs/alter_columnar_table_set/latest.sql b/src/backend/columnar/sql/udfs/alter_columnar_table_set/latest.sql index 9e9fe1be45c..09c2247f8e0 100644 --- a/src/backend/columnar/sql/udfs/alter_columnar_table_set/latest.sql +++ b/src/backend/columnar/sql/udfs/alter_columnar_table_set/latest.sql @@ -5,7 +5,9 @@ CREATE OR REPLACE FUNCTION pg_catalog.alter_columnar_table_set( compression name DEFAULT null, compression_level int DEFAULT NULL) RETURNS void - LANGUAGE plpgsql AS + LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp + AS $alter_columnar_table_set$ declare noop BOOLEAN := true; diff --git a/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/11.2-1.sql b/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/11.2-1.sql index 101db17fbe0..22900f2351c 100644 --- a/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/11.2-1.sql +++ b/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/11.2-1.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION columnar_internal.columnar_ensure_am_depends_catalog() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $func$ BEGIN INSERT INTO pg_depend diff --git a/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/latest.sql b/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/latest.sql index 101db17fbe0..22900f2351c 100644 --- a/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/latest.sql +++ b/src/backend/columnar/sql/udfs/columnar_ensure_am_depends_catalog/latest.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION columnar_internal.columnar_ensure_am_depends_catalog() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $func$ BEGIN INSERT INTO pg_depend diff --git a/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/10.0-1.sql b/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/10.0-1.sql index f8d21103ad2..6766d8c5fd5 100644 --- a/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/10.0-1.sql +++ b/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/10.0-1.sql @@ -9,7 +9,7 @@ CREATE OR REPLACE FUNCTION citus_internal.columnar_ensure_objects_exist() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $ceoe$ BEGIN diff --git a/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/latest.sql b/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/latest.sql index f8d21103ad2..6766d8c5fd5 100644 --- a/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/latest.sql +++ b/src/backend/columnar/sql/udfs/columnar_ensure_objects_exist/latest.sql @@ -9,7 +9,7 @@ CREATE OR REPLACE FUNCTION citus_internal.columnar_ensure_objects_exist() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $ceoe$ BEGIN diff --git a/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/13.2-1.sql b/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/13.2-1.sql index 287deb7b676..f582d4f5733 100644 --- a/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/13.2-1.sql +++ b/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/13.2-1.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.columnar_finish_pg_upgrade() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ BEGIN -- set dependencies for columnar table access method diff --git a/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/latest.sql b/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/latest.sql index 287deb7b676..f582d4f5733 100644 --- a/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/latest.sql +++ b/src/backend/columnar/sql/udfs/columnar_finish_pg_upgrade/latest.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.columnar_finish_pg_upgrade() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ BEGIN -- set dependencies for columnar table access method diff --git a/src/backend/distributed/sql/citus--10.2-5--11.0-1.sql b/src/backend/distributed/sql/citus--10.2-5--11.0-1.sql index 539242545d6..ba203201366 100644 --- a/src/backend/distributed/sql/citus--10.2-5--11.0-1.sql +++ b/src/backend/distributed/sql/citus--10.2-5--11.0-1.sql @@ -87,7 +87,7 @@ DECLARE partitioned_table_exists bool :=false; BEGIN SELECT count(*) > 0 INTO partitioned_table_exists FROM pg_dist_partition p JOIN pg_class c ON p.logicalrelid = c.oid WHERE c.relkind = 'p'; - UPDATE pg_dist_node_metadata SET metadata=jsonb_set(metadata, '{partitioned_citus_table_exists_pre_11}', to_jsonb(partitioned_table_exists), true); + UPDATE pg_dist_node_metadata SET metadata=pg_catalog.jsonb_set(metadata, '{partitioned_citus_table_exists_pre_11}', pg_catalog.to_jsonb(partitioned_table_exists), true); END; $$; diff --git a/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-5.sql b/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-5.sql new file mode 100644 index 00000000000..6c1113c1411 --- /dev/null +++ b/src/backend/distributed/sql/downgrades/citus--11.0-1--10.2-5.sql @@ -0,0 +1,5 @@ +-- citus--11.0-1--10.2-5 +-- downgrade version to 10.2-5 + +#include "citus--11.0-1--10.2-4.sql" +#include "../udfs/citus_finish_pg_upgrade/10.2-5.sql" diff --git a/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/10.0-1.sql b/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/10.0-1.sql index bdacd3c0836..9df8ce0011d 100644 --- a/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/10.0-1.sql +++ b/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/10.0-1.sql @@ -6,7 +6,12 @@ LANGUAGE plpgsql AS $$ DECLARE r record; + parent_table_name_text text; BEGIN + SELECT pg_catalog.quote_ident(relname) + INTO parent_table_name_text + FROM pg_catalog.pg_class + WHERE oid = parent_table_name; -- first check whether we can convert all the to_value's to timestamptz BEGIN PERFORM @@ -16,20 +21,21 @@ BEGIN AND to_value::timestamptz <= older_than AND access_method <> new_access_method; EXCEPTION WHEN invalid_datetime_format THEN - RAISE 'partition column of % cannot be cast to a timestamptz', parent_table_name; + RAISE 'partition column of % cannot be cast to a timestamptz', parent_table_name_text; END; -- now convert the partitions in separate transactions FOR r IN - SELECT partition, from_value, to_value - FROM pg_catalog.time_partitions + SELECT partition, c.relname AS partition_name, from_value, to_value + FROM pg_catalog.time_partitions tp + JOIN pg_catalog.pg_class c ON tp.partition = c.oid WHERE parent_table = parent_table_name AND to_value IS NOT NULL AND to_value::timestamptz <= older_than AND access_method <> new_access_method ORDER BY to_value::timestamptz LOOP - RAISE NOTICE 'converting % with start time % and end time %', r.partition, r.from_value, r.to_value; + RAISE NOTICE 'converting % with start time % and end time %', pg_catalog.quote_ident(r.partition_name), r.from_value, r.to_value; PERFORM pg_catalog.alter_table_set_access_method(r.partition, new_access_method); COMMIT; END LOOP; diff --git a/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/latest.sql b/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/latest.sql index bdacd3c0836..9df8ce0011d 100644 --- a/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/latest.sql +++ b/src/backend/distributed/sql/udfs/alter_old_partitions_set_access_method/latest.sql @@ -6,7 +6,12 @@ LANGUAGE plpgsql AS $$ DECLARE r record; + parent_table_name_text text; BEGIN + SELECT pg_catalog.quote_ident(relname) + INTO parent_table_name_text + FROM pg_catalog.pg_class + WHERE oid = parent_table_name; -- first check whether we can convert all the to_value's to timestamptz BEGIN PERFORM @@ -16,20 +21,21 @@ BEGIN AND to_value::timestamptz <= older_than AND access_method <> new_access_method; EXCEPTION WHEN invalid_datetime_format THEN - RAISE 'partition column of % cannot be cast to a timestamptz', parent_table_name; + RAISE 'partition column of % cannot be cast to a timestamptz', parent_table_name_text; END; -- now convert the partitions in separate transactions FOR r IN - SELECT partition, from_value, to_value - FROM pg_catalog.time_partitions + SELECT partition, c.relname AS partition_name, from_value, to_value + FROM pg_catalog.time_partitions tp + JOIN pg_catalog.pg_class c ON tp.partition = c.oid WHERE parent_table = parent_table_name AND to_value IS NOT NULL AND to_value::timestamptz <= older_than AND access_method <> new_access_method ORDER BY to_value::timestamptz LOOP - RAISE NOTICE 'converting % with start time % and end time %', r.partition, r.from_value, r.to_value; + RAISE NOTICE 'converting % with start time % and end time %', pg_catalog.quote_ident(r.partition_name), r.from_value, r.to_value; PERFORM pg_catalog.alter_table_set_access_method(r.partition, new_access_method); COMMIT; END LOOP; diff --git a/src/backend/distributed/sql/udfs/citus_blocking_pids/13.1-1.sql b/src/backend/distributed/sql/udfs/citus_blocking_pids/13.1-1.sql index 4e747ff4fc9..8db010c7201 100644 --- a/src/backend/distributed/sql/udfs/citus_blocking_pids/13.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_blocking_pids/13.1-1.sql @@ -14,11 +14,11 @@ RETURNS int4[] AS $$ -- pg says we're not blocked locally; check whether we're blocked globally. SELECT global_pid INTO mLocalGlobalPid - FROM get_all_active_transactions() WHERE process_id = pBlockedPid; + FROM pg_catalog.get_all_active_transactions() WHERE process_id = pBlockedPid; SELECT array_agg(global_pid) INTO mRemoteBlockingPids FROM ( WITH activeTransactions AS ( - SELECT global_pid FROM get_all_active_transactions() + SELECT global_pid FROM pg_catalog.get_all_active_transactions() ), blockingTransactions AS ( SELECT blocking_global_pid FROM citus_internal.global_blocked_processes() WHERE waiting_global_pid = mLocalGlobalPid @@ -29,6 +29,7 @@ RETURNS int4[] AS $$ RETURN mRemoteBlockingPids; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; REVOKE ALL ON FUNCTION citus_blocking_pids(integer) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_blocking_pids/latest.sql b/src/backend/distributed/sql/udfs/citus_blocking_pids/latest.sql index 4e747ff4fc9..8db010c7201 100644 --- a/src/backend/distributed/sql/udfs/citus_blocking_pids/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_blocking_pids/latest.sql @@ -14,11 +14,11 @@ RETURNS int4[] AS $$ -- pg says we're not blocked locally; check whether we're blocked globally. SELECT global_pid INTO mLocalGlobalPid - FROM get_all_active_transactions() WHERE process_id = pBlockedPid; + FROM pg_catalog.get_all_active_transactions() WHERE process_id = pBlockedPid; SELECT array_agg(global_pid) INTO mRemoteBlockingPids FROM ( WITH activeTransactions AS ( - SELECT global_pid FROM get_all_active_transactions() + SELECT global_pid FROM pg_catalog.get_all_active_transactions() ), blockingTransactions AS ( SELECT blocking_global_pid FROM citus_internal.global_blocked_processes() WHERE waiting_global_pid = mLocalGlobalPid @@ -29,6 +29,7 @@ RETURNS int4[] AS $$ RETURN mRemoteBlockingPids; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; REVOKE ALL ON FUNCTION citus_blocking_pids(integer) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_drop_trigger/13.1-1.sql b/src/backend/distributed/sql/udfs/citus_drop_trigger/13.1-1.sql index b23788ca099..f4c500e9172 100644 --- a/src/backend/distributed/sql/udfs/citus_drop_trigger/13.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_drop_trigger/13.1-1.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_drop_trigger() RETURNS event_trigger LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cdbdt$ DECLARE constraint_event_count INTEGER; diff --git a/src/backend/distributed/sql/udfs/citus_drop_trigger/latest.sql b/src/backend/distributed/sql/udfs/citus_drop_trigger/latest.sql index b23788ca099..f4c500e9172 100644 --- a/src/backend/distributed/sql/udfs/citus_drop_trigger/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_drop_trigger/latest.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_drop_trigger() RETURNS event_trigger LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cdbdt$ DECLARE constraint_event_count INTEGER; diff --git a/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/11.0-3.sql b/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/11.0-3.sql index d6ba4a2b8f7..1124c14db09 100644 --- a/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/11.0-3.sql +++ b/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/11.0-3.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_finalize_upgrade_to_citus11(enforce_version_check bool default true) RETURNS bool LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $$ BEGIN @@ -80,7 +81,7 @@ END; IF primary_disabled_worker_node_count != 0 THEN RAISE EXCEPTION 'There are inactive primary worker nodes, you need to activate the nodes first.' - 'Use SELECT citus_activate_node() to activate the disabled nodes'; + 'Use SELECT pg_catalog.citus_activate_node() to activate the disabled nodes'; ELSE RAISE DEBUG 'There are no disabled worker nodes, continue to sync metadata'; END IF; @@ -92,12 +93,12 @@ END; DECLARE all_nodes_can_connect_to_each_other boolean := False; BEGIN - SELECT bool_and(coalesce(result, false)) INTO all_nodes_can_connect_to_each_other FROM citus_check_cluster_node_health(); + SELECT bool_and(coalesce(result, false)) INTO all_nodes_can_connect_to_each_other FROM pg_catalog.citus_check_cluster_node_health(); IF all_nodes_can_connect_to_each_other != True THEN RAISE EXCEPTION 'There are unhealth primary nodes, you need to ensure all ' 'nodes are up and running. Also, make sure that all nodes can connect ' - 'to each other. Use SELECT * FROM citus_check_cluster_node_health(); ' + 'to each other. Use SELECT * FROM pg_catalog.citus_check_cluster_node_health(); ' 'to check the cluster health'; ELSE RAISE DEBUG 'Cluster is healthy, all nodes can connect to each other'; @@ -119,7 +120,7 @@ END; SELECT count(distinct result) INTO worker_node_version_count FROM - run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'''); + pg_catalog.run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'''); IF enforce_version_check AND worker_node_version_count = 0 THEN RAISE DEBUG 'There are no worker nodes'; @@ -134,7 +135,7 @@ END; SELECT result INTO worker_node_version FROM - run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'';') + pg_catalog.run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'';') GROUP BY result; IF enforce_version_check AND coordinator_version != worker_node_version THEN diff --git a/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/latest.sql b/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/latest.sql index d6ba4a2b8f7..1124c14db09 100644 --- a/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_finalize_upgrade_to_citus11/latest.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_finalize_upgrade_to_citus11(enforce_version_check bool default true) RETURNS bool LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $$ BEGIN @@ -80,7 +81,7 @@ END; IF primary_disabled_worker_node_count != 0 THEN RAISE EXCEPTION 'There are inactive primary worker nodes, you need to activate the nodes first.' - 'Use SELECT citus_activate_node() to activate the disabled nodes'; + 'Use SELECT pg_catalog.citus_activate_node() to activate the disabled nodes'; ELSE RAISE DEBUG 'There are no disabled worker nodes, continue to sync metadata'; END IF; @@ -92,12 +93,12 @@ END; DECLARE all_nodes_can_connect_to_each_other boolean := False; BEGIN - SELECT bool_and(coalesce(result, false)) INTO all_nodes_can_connect_to_each_other FROM citus_check_cluster_node_health(); + SELECT bool_and(coalesce(result, false)) INTO all_nodes_can_connect_to_each_other FROM pg_catalog.citus_check_cluster_node_health(); IF all_nodes_can_connect_to_each_other != True THEN RAISE EXCEPTION 'There are unhealth primary nodes, you need to ensure all ' 'nodes are up and running. Also, make sure that all nodes can connect ' - 'to each other. Use SELECT * FROM citus_check_cluster_node_health(); ' + 'to each other. Use SELECT * FROM pg_catalog.citus_check_cluster_node_health(); ' 'to check the cluster health'; ELSE RAISE DEBUG 'Cluster is healthy, all nodes can connect to each other'; @@ -119,7 +120,7 @@ END; SELECT count(distinct result) INTO worker_node_version_count FROM - run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'''); + pg_catalog.run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'''); IF enforce_version_check AND worker_node_version_count = 0 THEN RAISE DEBUG 'There are no worker nodes'; @@ -134,7 +135,7 @@ END; SELECT result INTO worker_node_version FROM - run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'';') + pg_catalog.run_command_on_workers('SELECT extversion from pg_extension WHERE extname = ''citus'';') GROUP BY result; IF enforce_version_check AND coordinator_version != worker_node_version THEN diff --git a/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/14.0-1.sql b/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/14.0-1.sql index f45390069d8..f7ccbc65966 100644 --- a/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/14.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/14.0-1.sql @@ -1,6 +1,6 @@ CREATE OR REPLACE PROCEDURE pg_catalog.citus_finish_citus_upgrade() LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ DECLARE current_version_string text; diff --git a/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/latest.sql b/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/latest.sql index f45390069d8..f7ccbc65966 100644 --- a/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_finish_citus_upgrade/latest.sql @@ -1,6 +1,6 @@ CREATE OR REPLACE PROCEDURE pg_catalog.citus_finish_citus_upgrade() LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ DECLARE current_version_string text; diff --git a/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/14.0-1.sql b/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/14.0-1.sql index 4bad681ebfb..9b007b55ad9 100644 --- a/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/14.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/14.0-1.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_finish_pg_upgrade() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ DECLARE table_name regclass; diff --git a/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/latest.sql b/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/latest.sql index 4bad681ebfb..9b007b55ad9 100644 --- a/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/latest.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_finish_pg_upgrade() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ DECLARE table_name regclass; diff --git a/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/13.1-1.sql b/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/13.1-1.sql index 6f494fa74a5..72f81a4f69f 100644 --- a/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/13.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/13.1-1.sql @@ -13,14 +13,14 @@ RETURNS boolean AS $$ -- Note that worker process may be blocked or waiting for a lock. So we need to -- get transaction number for both of them. Following IF provides the transaction -- number when the worker process waiting for other session. - IF EXISTS (SELECT 1 FROM get_global_active_transactions() + IF EXISTS (SELECT 1 FROM pg_catalog.get_global_active_transactions() WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN - SELECT global_pid INTO mBlockedGlobalPid FROM get_global_active_transactions() + SELECT global_pid INTO mBlockedGlobalPid FROM pg_catalog.get_global_active_transactions() WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId; ELSE -- Check whether transactions initiated from the coordinator get locked SELECT global_pid INTO mBlockedGlobalPid - FROM get_all_active_transactions() WHERE process_id = pBlockedPid; + FROM pg_catalog.get_all_active_transactions() WHERE process_id = pBlockedPid; END IF; -- We convert the blocking_global_pid to a regular pid and only look at @@ -33,13 +33,14 @@ RETURNS boolean AS $$ SELECT 1 FROM citus_internal.global_blocked_processes() WHERE waiting_global_pid = mBlockedGlobalPid AND ( - citus_pid_for_gpid(blocking_global_pid) in ( + pg_catalog.citus_pid_for_gpid(blocking_global_pid) in ( select * from unnest(pInterestingPids) ) - OR citus_pid_for_gpid(blocking_global_pid) = workerProcessId + OR pg_catalog.citus_pid_for_gpid(blocking_global_pid) = workerProcessId ) ); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; REVOKE ALL ON FUNCTION citus_isolation_test_session_is_blocked(integer,integer[]) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/latest.sql b/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/latest.sql index 6f494fa74a5..72f81a4f69f 100644 --- a/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_isolation_test_session_is_blocked/latest.sql @@ -13,14 +13,14 @@ RETURNS boolean AS $$ -- Note that worker process may be blocked or waiting for a lock. So we need to -- get transaction number for both of them. Following IF provides the transaction -- number when the worker process waiting for other session. - IF EXISTS (SELECT 1 FROM get_global_active_transactions() + IF EXISTS (SELECT 1 FROM pg_catalog.get_global_active_transactions() WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId) THEN - SELECT global_pid INTO mBlockedGlobalPid FROM get_global_active_transactions() + SELECT global_pid INTO mBlockedGlobalPid FROM pg_catalog.get_global_active_transactions() WHERE process_id = workerProcessId AND pBlockedPid = coordinatorProcessId; ELSE -- Check whether transactions initiated from the coordinator get locked SELECT global_pid INTO mBlockedGlobalPid - FROM get_all_active_transactions() WHERE process_id = pBlockedPid; + FROM pg_catalog.get_all_active_transactions() WHERE process_id = pBlockedPid; END IF; -- We convert the blocking_global_pid to a regular pid and only look at @@ -33,13 +33,14 @@ RETURNS boolean AS $$ SELECT 1 FROM citus_internal.global_blocked_processes() WHERE waiting_global_pid = mBlockedGlobalPid AND ( - citus_pid_for_gpid(blocking_global_pid) in ( + pg_catalog.citus_pid_for_gpid(blocking_global_pid) in ( select * from unnest(pInterestingPids) ) - OR citus_pid_for_gpid(blocking_global_pid) = workerProcessId + OR pg_catalog.citus_pid_for_gpid(blocking_global_pid) = workerProcessId ) ); END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; REVOKE ALL ON FUNCTION citus_isolation_test_session_is_blocked(integer,integer[]) FROM PUBLIC; diff --git a/src/backend/distributed/sql/udfs/citus_lock_waits/11.0-1.sql b/src/backend/distributed/sql/udfs/citus_lock_waits/11.0-1.sql index b3de12632b5..0178c602d1f 100644 --- a/src/backend/distributed/sql/udfs/citus_lock_waits/11.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_lock_waits/11.0-1.sql @@ -1,5 +1,3 @@ -SET search_path = 'pg_catalog'; - CREATE VIEW citus.citus_lock_waits AS WITH unique_global_wait_edges_with_calculated_gpids AS ( @@ -43,5 +41,3 @@ FROM ALTER VIEW citus.citus_lock_waits SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_lock_waits TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/citus_lock_waits/13.1-1.sql b/src/backend/distributed/sql/udfs/citus_lock_waits/13.1-1.sql index 880306b992f..e63b54fc5ed 100644 --- a/src/backend/distributed/sql/udfs/citus_lock_waits/13.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_lock_waits/13.1-1.sql @@ -1,5 +1,3 @@ -SET search_path = 'pg_catalog'; - CREATE VIEW citus.citus_lock_waits AS WITH unique_global_wait_edges_with_calculated_gpids AS ( @@ -43,5 +41,3 @@ FROM ALTER VIEW citus.citus_lock_waits SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_lock_waits TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/citus_lock_waits/latest.sql b/src/backend/distributed/sql/udfs/citus_lock_waits/latest.sql index 880306b992f..e63b54fc5ed 100644 --- a/src/backend/distributed/sql/udfs/citus_lock_waits/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_lock_waits/latest.sql @@ -1,5 +1,3 @@ -SET search_path = 'pg_catalog'; - CREATE VIEW citus.citus_lock_waits AS WITH unique_global_wait_edges_with_calculated_gpids AS ( @@ -43,5 +41,3 @@ FROM ALTER VIEW citus.citus_lock_waits SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_lock_waits TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/citus_locks/11.1-1.sql b/src/backend/distributed/sql/udfs/citus_locks/11.1-1.sql index cfe269909a9..6908ee95a2e 100644 --- a/src/backend/distributed/sql/udfs/citus_locks/11.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_locks/11.1-1.sql @@ -27,6 +27,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_locks ( ) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN RETURN QUERY @@ -39,15 +40,15 @@ BEGIN jsonb_array_elements(run_command_on_all_nodes.result::jsonb)::jsonb || ('{"nodeid":' || run_command_on_all_nodes.nodeid || '}')::jsonb AS citus_locks_row_as_jsonb FROM - run_command_on_all_nodes ( + pg_catalog.run_command_on_all_nodes ( $$ SELECT coalesce(to_jsonb (array_agg(citus_locks_from_one_node.*)), '[{}]'::jsonb) FROM ( SELECT global_pid, pg_locks.relation::regclass::text AS relation_name, pg_locks.* - FROM pg_locks - LEFT JOIN get_all_active_transactions () ON process_id = pid) AS citus_locks_from_one_node; + FROM pg_catalog.pg_locks + LEFT JOIN pg_catalog.get_all_active_transactions () ON process_id = pid) AS citus_locks_from_one_node; $$, parallel:= TRUE, give_warning_for_connection_errors:= TRUE) diff --git a/src/backend/distributed/sql/udfs/citus_locks/latest.sql b/src/backend/distributed/sql/udfs/citus_locks/latest.sql index cfe269909a9..6908ee95a2e 100644 --- a/src/backend/distributed/sql/udfs/citus_locks/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_locks/latest.sql @@ -27,6 +27,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_locks ( ) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN RETURN QUERY @@ -39,15 +40,15 @@ BEGIN jsonb_array_elements(run_command_on_all_nodes.result::jsonb)::jsonb || ('{"nodeid":' || run_command_on_all_nodes.nodeid || '}')::jsonb AS citus_locks_row_as_jsonb FROM - run_command_on_all_nodes ( + pg_catalog.run_command_on_all_nodes ( $$ SELECT coalesce(to_jsonb (array_agg(citus_locks_from_one_node.*)), '[{}]'::jsonb) FROM ( SELECT global_pid, pg_locks.relation::regclass::text AS relation_name, pg_locks.* - FROM pg_locks - LEFT JOIN get_all_active_transactions () ON process_id = pid) AS citus_locks_from_one_node; + FROM pg_catalog.pg_locks + LEFT JOIN pg_catalog.get_all_active_transactions () ON process_id = pid) AS citus_locks_from_one_node; $$, parallel:= TRUE, give_warning_for_connection_errors:= TRUE) diff --git a/src/backend/distributed/sql/udfs/citus_nodes/13.1-1.sql b/src/backend/distributed/sql/udfs/citus_nodes/13.1-1.sql index 4d129d79e9c..b9d2e571de7 100644 --- a/src/backend/distributed/sql/udfs/citus_nodes/13.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_nodes/13.1-1.sql @@ -1,4 +1,3 @@ -SET search_path = 'pg_catalog'; DROP VIEW IF EXISTS pg_catalog.citus_nodes; CREATE OR REPLACE VIEW citus.citus_nodes AS @@ -14,5 +13,3 @@ FROM pg_dist_node; ALTER VIEW citus.citus_nodes SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_nodes TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/citus_nodes/latest.sql b/src/backend/distributed/sql/udfs/citus_nodes/latest.sql index 4d129d79e9c..b9d2e571de7 100644 --- a/src/backend/distributed/sql/udfs/citus_nodes/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_nodes/latest.sql @@ -1,4 +1,3 @@ -SET search_path = 'pg_catalog'; DROP VIEW IF EXISTS pg_catalog.citus_nodes; CREATE OR REPLACE VIEW citus.citus_nodes AS @@ -14,5 +13,3 @@ FROM pg_dist_node; ALTER VIEW citus.citus_nodes SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_nodes TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/14.0-1.sql b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/14.0-1.sql index ee5e98e1d9a..bc8b7cbd9bd 100644 --- a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/14.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/14.0-1.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_prepare_pg_upgrade() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ BEGIN diff --git a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql index ee5e98e1d9a..bc8b7cbd9bd 100644 --- a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/latest.sql @@ -1,7 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_prepare_pg_upgrade() RETURNS void LANGUAGE plpgsql - SET search_path = pg_catalog + SET search_path = pg_catalog, pg_temp AS $cppu$ BEGIN diff --git a/src/backend/distributed/sql/udfs/citus_run_local_command/11.0-1.sql b/src/backend/distributed/sql/udfs/citus_run_local_command/11.0-1.sql index 41a064ef478..aebee84762b 100644 --- a/src/backend/distributed/sql/udfs/citus_run_local_command/11.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_run_local_command/11.0-1.sql @@ -3,6 +3,7 @@ RETURNS void AS $$ BEGIN EXECUTE $1; END; -$$ LANGUAGE PLPGSQL; +$$ LANGUAGE PLPGSQL +SET search_path = pg_catalog, pg_temp; COMMENT ON FUNCTION pg_catalog.citus_run_local_command(text) IS 'citus_run_local_command executes the input command'; diff --git a/src/backend/distributed/sql/udfs/citus_run_local_command/latest.sql b/src/backend/distributed/sql/udfs/citus_run_local_command/latest.sql index 41a064ef478..aebee84762b 100644 --- a/src/backend/distributed/sql/udfs/citus_run_local_command/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_run_local_command/latest.sql @@ -3,6 +3,7 @@ RETURNS void AS $$ BEGIN EXECUTE $1; END; -$$ LANGUAGE PLPGSQL; +$$ LANGUAGE PLPGSQL +SET search_path = pg_catalog, pg_temp; COMMENT ON FUNCTION pg_catalog.citus_run_local_command(text) IS 'citus_run_local_command executes the input command'; diff --git a/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/9.2-1.sql b/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/9.2-1.sql index c930b6f10b6..53253553234 100644 --- a/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/9.2-1.sql +++ b/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/9.2-1.sql @@ -12,7 +12,8 @@ AS $$ UPDATE pg_dist_rebalance_strategy SET default_strategy = false WHERE default_strategy = true; UPDATE pg_dist_rebalance_strategy t SET default_strategy = true WHERE t.name = $1; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; COMMENT ON FUNCTION pg_catalog.citus_set_default_rebalance_strategy(text) IS 'changes the default rebalance strategy to the one with the specified name'; diff --git a/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/latest.sql b/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/latest.sql index c930b6f10b6..53253553234 100644 --- a/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_set_default_rebalance_strategy/latest.sql @@ -12,7 +12,8 @@ AS $$ UPDATE pg_dist_rebalance_strategy SET default_strategy = false WHERE default_strategy = true; UPDATE pg_dist_rebalance_strategy t SET default_strategy = true WHERE t.name = $1; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; COMMENT ON FUNCTION pg_catalog.citus_set_default_rebalance_strategy(text) IS 'changes the default rebalance strategy to the one with the specified name'; diff --git a/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/11.0-2.sql b/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/11.0-2.sql index fd4684b18de..edf63c2a5ed 100644 --- a/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/11.0-2.sql +++ b/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/11.0-2.sql @@ -6,6 +6,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_shard_indexes_on_worker( OUT shard_name name) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp SET citus.show_shards_for_app_name_prefixes = '*' AS $$ BEGIN diff --git a/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/latest.sql b/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/latest.sql index fd4684b18de..edf63c2a5ed 100644 --- a/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_shard_indexes_on_worker/latest.sql @@ -6,6 +6,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_shard_indexes_on_worker( OUT shard_name name) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp SET citus.show_shards_for_app_name_prefixes = '*' AS $$ BEGIN diff --git a/src/backend/distributed/sql/udfs/citus_shards_on_worker/11.0-2.sql b/src/backend/distributed/sql/udfs/citus_shards_on_worker/11.0-2.sql index dbb7498e888..c4a4d94266b 100644 --- a/src/backend/distributed/sql/udfs/citus_shards_on_worker/11.0-2.sql +++ b/src/backend/distributed/sql/udfs/citus_shards_on_worker/11.0-2.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_shards_on_worker( OUT owner_name name) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp SET citus.show_shards_for_app_name_prefixes = '*' AS $$ BEGIN diff --git a/src/backend/distributed/sql/udfs/citus_shards_on_worker/latest.sql b/src/backend/distributed/sql/udfs/citus_shards_on_worker/latest.sql index dbb7498e888..c4a4d94266b 100644 --- a/src/backend/distributed/sql/udfs/citus_shards_on_worker/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_shards_on_worker/latest.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_shards_on_worker( OUT owner_name name) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp SET citus.show_shards_for_app_name_prefixes = '*' AS $$ BEGIN diff --git a/src/backend/distributed/sql/udfs/citus_stat_activity/11.0-1.sql b/src/backend/distributed/sql/udfs/citus_stat_activity/11.0-1.sql index 5dea5a90378..1753a296a20 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_activity/11.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_activity/11.0-1.sql @@ -12,16 +12,17 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_activity(OUT global_pid bigint, OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query_id bigint, OUT query text, OUT backend_type text) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN RETURN QUERY SELECT * FROM jsonb_to_recordset(( SELECT jsonb_agg(all_csa_rows_as_jsonb.csa_row_as_jsonb)::JSONB FROM ( SELECT jsonb_array_elements(run_command_on_all_nodes.result::JSONB)::JSONB || ('{"nodeid":' || run_command_on_all_nodes.nodeid || '}')::JSONB AS csa_row_as_jsonb - FROM run_command_on_all_nodes($$ + FROM pg_catalog.run_command_on_all_nodes($$ SELECT coalesce(to_jsonb(array_agg(csa_from_one_node.*)), '[{}]'::JSONB) FROM ( SELECT global_pid, worker_query AS is_worker_query, pg_stat_activity.* FROM - pg_stat_activity LEFT JOIN get_all_active_transactions() ON process_id = pid + pg_catalog.pg_stat_activity LEFT JOIN pg_catalog.get_all_active_transactions() ON process_id = pid ) AS csa_from_one_node; $$, parallel:=true, give_warning_for_connection_errors:=true) WHERE success = 't' diff --git a/src/backend/distributed/sql/udfs/citus_stat_activity/latest.sql b/src/backend/distributed/sql/udfs/citus_stat_activity/latest.sql index 5dea5a90378..1753a296a20 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_activity/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_activity/latest.sql @@ -12,16 +12,17 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_activity(OUT global_pid bigint, OUT state text, OUT backend_xid xid, OUT backend_xmin xid, OUT query_id bigint, OUT query text, OUT backend_type text) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN RETURN QUERY SELECT * FROM jsonb_to_recordset(( SELECT jsonb_agg(all_csa_rows_as_jsonb.csa_row_as_jsonb)::JSONB FROM ( SELECT jsonb_array_elements(run_command_on_all_nodes.result::JSONB)::JSONB || ('{"nodeid":' || run_command_on_all_nodes.nodeid || '}')::JSONB AS csa_row_as_jsonb - FROM run_command_on_all_nodes($$ + FROM pg_catalog.run_command_on_all_nodes($$ SELECT coalesce(to_jsonb(array_agg(csa_from_one_node.*)), '[{}]'::JSONB) FROM ( SELECT global_pid, worker_query AS is_worker_query, pg_stat_activity.* FROM - pg_stat_activity LEFT JOIN get_all_active_transactions() ON process_id = pid + pg_catalog.pg_stat_activity LEFT JOIN pg_catalog.get_all_active_transactions() ON process_id = pid ) AS csa_from_one_node; $$, parallel:=true, give_warning_for_connection_errors:=true) WHERE success = 't' diff --git a/src/backend/distributed/sql/udfs/citus_stat_tenants/11.3-1.sql b/src/backend/distributed/sql/udfs/citus_stat_tenants/11.3-1.sql index 8eea78b5c14..cd4f2eef65d 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_tenants/11.3-1.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_tenants/11.3-1.sql @@ -14,6 +14,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants ( ) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN IF @@ -34,11 +35,11 @@ BEGIN jsonb_array_elements(run_command_on_all_nodes.result::jsonb)::jsonb || ('{"nodeid":' || run_command_on_all_nodes.nodeid || '}')::jsonb AS cst_row_as_jsonb FROM - run_command_on_all_nodes ( + pg_catalog.run_command_on_all_nodes ( $$ SELECT coalesce(to_jsonb (array_agg(cstl.*)), '[]'::jsonb) - FROM citus_stat_tenants_local($$||return_all_tenants||$$) cstl; + FROM pg_catalog.citus_stat_tenants_local($$||return_all_tenants||$$) cstl; $$, parallel:= TRUE, give_warning_for_connection_errors:= TRUE) diff --git a/src/backend/distributed/sql/udfs/citus_stat_tenants/latest.sql b/src/backend/distributed/sql/udfs/citus_stat_tenants/latest.sql index 8eea78b5c14..cd4f2eef65d 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_tenants/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_tenants/latest.sql @@ -14,6 +14,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants ( ) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN IF @@ -34,11 +35,11 @@ BEGIN jsonb_array_elements(run_command_on_all_nodes.result::jsonb)::jsonb || ('{"nodeid":' || run_command_on_all_nodes.nodeid || '}')::jsonb AS cst_row_as_jsonb FROM - run_command_on_all_nodes ( + pg_catalog.run_command_on_all_nodes ( $$ SELECT coalesce(to_jsonb (array_agg(cstl.*)), '[]'::jsonb) - FROM citus_stat_tenants_local($$||return_all_tenants||$$) cstl; + FROM pg_catalog.citus_stat_tenants_local($$||return_all_tenants||$$) cstl; $$, parallel:= TRUE, give_warning_for_connection_errors:= TRUE) diff --git a/src/backend/distributed/sql/udfs/citus_stat_tenants_local/12.0-1.sql b/src/backend/distributed/sql/udfs/citus_stat_tenants_local/12.0-1.sql index 65b398a0aa2..8d24576cd4f 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_tenants_local/12.0-1.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_tenants_local/12.0-1.sql @@ -26,6 +26,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_local( OUT score BIGINT) RETURNS SETOF RECORD LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $function$ BEGIN RETURN QUERY diff --git a/src/backend/distributed/sql/udfs/citus_stat_tenants_local/latest.sql b/src/backend/distributed/sql/udfs/citus_stat_tenants_local/latest.sql index 65b398a0aa2..8d24576cd4f 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_tenants_local/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_tenants_local/latest.sql @@ -26,6 +26,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_local( OUT score BIGINT) RETURNS SETOF RECORD LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $function$ BEGIN RETURN QUERY diff --git a/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/11.3-1.sql b/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/11.3-1.sql index aedd3ad991e..c857a23c62b 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/11.3-1.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/11.3-1.sql @@ -1,8 +1,9 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_reset() RETURNS VOID LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN - PERFORM run_command_on_all_nodes($$SELECT citus_stat_tenants_local_reset()$$); + PERFORM pg_catalog.run_command_on_all_nodes($$SELECT pg_catalog.citus_stat_tenants_local_reset()$$); END; $function$; diff --git a/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/latest.sql b/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/latest.sql index aedd3ad991e..c857a23c62b 100644 --- a/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_stat_tenants_reset/latest.sql @@ -1,8 +1,9 @@ CREATE OR REPLACE FUNCTION pg_catalog.citus_stat_tenants_reset() RETURNS VOID LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ BEGIN - PERFORM run_command_on_all_nodes($$SELECT citus_stat_tenants_local_reset()$$); + PERFORM pg_catalog.run_command_on_all_nodes($$SELECT pg_catalog.citus_stat_tenants_local_reset()$$); END; $function$; diff --git a/src/backend/distributed/sql/udfs/citus_stats/13.2-1.sql b/src/backend/distributed/sql/udfs/citus_stats/13.2-1.sql index bf8e4b15567..a9d74d00c07 100644 --- a/src/backend/distributed/sql/udfs/citus_stats/13.2-1.sql +++ b/src/backend/distributed/sql/udfs/citus_stats/13.2-1.sql @@ -1,10 +1,9 @@ -SET search_path = 'pg_catalog'; DROP VIEW IF EXISTS pg_catalog.citus_stats; CREATE OR REPLACE VIEW citus.citus_stats AS WITH most_common_vals_double_json AS ( - SELECT ( SELECT json_agg(row_to_json(f)) FROM ( SELECT * FROM run_command_on_shards(logicalrelid, + SELECT ( SELECT json_agg(row_to_json(f)) FROM ( SELECT * FROM pg_catalog.run_command_on_shards(logicalrelid, $$ SELECT json_agg(row_to_json(shard_stats)) FROM ( SELECT '$$ || logicalrelid || $$' AS citus_table, attname, s.null_frac, most_common_vals, most_common_freqs, c.reltuples AS reltuples @@ -13,7 +12,7 @@ WITH most_common_vals_double_json AS ( -- could never be the same FROM pg_stats s RIGHT JOIN pg_class c ON (s.tablename = c.relname) WHERE c.oid = '%s'::regclass) shard_stats $$ ))f) - FROM pg_dist_partition), + FROM pg_catalog.pg_dist_partition), most_common_vals_json AS ( SELECT (json_array_elements(json_agg)->>'result') AS result, @@ -78,5 +77,3 @@ GROUP BY nsp.nspname, c.citus_table, p.relname, c.attname; ALTER VIEW citus.citus_stats SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_stats TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/citus_stats/latest.sql b/src/backend/distributed/sql/udfs/citus_stats/latest.sql index bf8e4b15567..a9d74d00c07 100644 --- a/src/backend/distributed/sql/udfs/citus_stats/latest.sql +++ b/src/backend/distributed/sql/udfs/citus_stats/latest.sql @@ -1,10 +1,9 @@ -SET search_path = 'pg_catalog'; DROP VIEW IF EXISTS pg_catalog.citus_stats; CREATE OR REPLACE VIEW citus.citus_stats AS WITH most_common_vals_double_json AS ( - SELECT ( SELECT json_agg(row_to_json(f)) FROM ( SELECT * FROM run_command_on_shards(logicalrelid, + SELECT ( SELECT json_agg(row_to_json(f)) FROM ( SELECT * FROM pg_catalog.run_command_on_shards(logicalrelid, $$ SELECT json_agg(row_to_json(shard_stats)) FROM ( SELECT '$$ || logicalrelid || $$' AS citus_table, attname, s.null_frac, most_common_vals, most_common_freqs, c.reltuples AS reltuples @@ -13,7 +12,7 @@ WITH most_common_vals_double_json AS ( -- could never be the same FROM pg_stats s RIGHT JOIN pg_class c ON (s.tablename = c.relname) WHERE c.oid = '%s'::regclass) shard_stats $$ ))f) - FROM pg_dist_partition), + FROM pg_catalog.pg_dist_partition), most_common_vals_json AS ( SELECT (json_array_elements(json_agg)->>'result') AS result, @@ -78,5 +77,3 @@ GROUP BY nsp.nspname, c.citus_table, p.relname, c.attname; ALTER VIEW citus.citus_stats SET SCHEMA pg_catalog; GRANT SELECT ON pg_catalog.citus_stats TO PUBLIC; - -RESET search_path; diff --git a/src/backend/distributed/sql/udfs/create_time_partitions/13.0-1.sql b/src/backend/distributed/sql/udfs/create_time_partitions/13.0-1.sql index 566ba71633d..04210ab8051 100644 --- a/src/backend/distributed/sql/udfs/create_time_partitions/13.0-1.sql +++ b/src/backend/distributed/sql/udfs/create_time_partitions/13.0-1.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_time_partitions( start_from timestamptz DEFAULT now()) returns boolean LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $$ DECLARE -- partitioned table name diff --git a/src/backend/distributed/sql/udfs/create_time_partitions/latest.sql b/src/backend/distributed/sql/udfs/create_time_partitions/latest.sql index 566ba71633d..04210ab8051 100644 --- a/src/backend/distributed/sql/udfs/create_time_partitions/latest.sql +++ b/src/backend/distributed/sql/udfs/create_time_partitions/latest.sql @@ -5,6 +5,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.create_time_partitions( start_from timestamptz DEFAULT now()) returns boolean LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $$ DECLARE -- partitioned table name diff --git a/src/backend/distributed/sql/udfs/distributed_tables_colocated/9.0-2.sql b/src/backend/distributed/sql/udfs/distributed_tables_colocated/9.0-2.sql index ed6bb744489..03af645f6fb 100644 --- a/src/backend/distributed/sql/udfs/distributed_tables_colocated/9.0-2.sql +++ b/src/backend/distributed/sql/udfs/distributed_tables_colocated/9.0-2.sql @@ -6,6 +6,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.distributed_tables_colocated(table1 regcla table2 regclass) RETURNS bool LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $function$ DECLARE table1_colocationid int; diff --git a/src/backend/distributed/sql/udfs/distributed_tables_colocated/latest.sql b/src/backend/distributed/sql/udfs/distributed_tables_colocated/latest.sql index ed6bb744489..03af645f6fb 100644 --- a/src/backend/distributed/sql/udfs/distributed_tables_colocated/latest.sql +++ b/src/backend/distributed/sql/udfs/distributed_tables_colocated/latest.sql @@ -6,6 +6,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.distributed_tables_colocated(table1 regcla table2 regclass) RETURNS bool LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $function$ DECLARE table1_colocationid int; diff --git a/src/backend/distributed/sql/udfs/drop_old_time_partitions/12.0-1.sql b/src/backend/distributed/sql/udfs/drop_old_time_partitions/12.0-1.sql index a4bcd45a0ae..a0d271658d9 100644 --- a/src/backend/distributed/sql/udfs/drop_old_time_partitions/12.0-1.sql +++ b/src/backend/distributed/sql/udfs/drop_old_time_partitions/12.0-1.sql @@ -2,9 +2,11 @@ CREATE OR REPLACE PROCEDURE pg_catalog.drop_old_time_partitions( table_name regclass, older_than timestamptz) LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $$ DECLARE -- properties of the partitioned table + table_display_name text; number_of_partition_columns int; partition_column_index int; partition_column_type regtype; @@ -16,6 +18,11 @@ DECLARE r record; BEGIN + SELECT pg_catalog.quote_ident(relname) + INTO table_display_name + FROM pg_catalog.pg_class + WHERE oid = table_name; + -- check whether the table is time partitioned table, if not error out SELECT partnatts, partattrs[0] INTO number_of_partition_columns, partition_column_index @@ -23,7 +30,7 @@ BEGIN WHERE partrelid = table_name; IF NOT FOUND THEN - RAISE '% is not partitioned', table_name::text; + RAISE '% is not partitioned', table_display_name; ELSIF number_of_partition_columns <> 1 THEN RAISE 'partitioned tables with multiple partition columns are not supported'; END IF; @@ -44,7 +51,7 @@ BEGIN EXISTS(SELECT OID FROM pg_cast WHERE castsource = 'timestamptz'::regtype AND casttarget = partition_column_type) INTO is_partition_column_castable; IF not is_partition_column_castable THEN - RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_name; + RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_display_name; END IF; custom_cast = format('::%s', partition_column_type); END IF; @@ -57,7 +64,7 @@ BEGIN ORDER BY to_value%1$s::timestamptz', custom_cast); FOR r IN EXECUTE older_partitions_query USING table_name, older_than LOOP - RAISE NOTICE 'dropping % with start time % and end time %', r.partition, r.from_value, r.to_value; + RAISE NOTICE 'dropping % with start time % and end time %', pg_catalog.quote_ident(r.table_name), r.from_value, r.to_value; EXECUTE format('DROP TABLE %I.%I', r.schema_name, r.table_name); END LOOP; END; diff --git a/src/backend/distributed/sql/udfs/drop_old_time_partitions/latest.sql b/src/backend/distributed/sql/udfs/drop_old_time_partitions/latest.sql index a4bcd45a0ae..a0d271658d9 100644 --- a/src/backend/distributed/sql/udfs/drop_old_time_partitions/latest.sql +++ b/src/backend/distributed/sql/udfs/drop_old_time_partitions/latest.sql @@ -2,9 +2,11 @@ CREATE OR REPLACE PROCEDURE pg_catalog.drop_old_time_partitions( table_name regclass, older_than timestamptz) LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $$ DECLARE -- properties of the partitioned table + table_display_name text; number_of_partition_columns int; partition_column_index int; partition_column_type regtype; @@ -16,6 +18,11 @@ DECLARE r record; BEGIN + SELECT pg_catalog.quote_ident(relname) + INTO table_display_name + FROM pg_catalog.pg_class + WHERE oid = table_name; + -- check whether the table is time partitioned table, if not error out SELECT partnatts, partattrs[0] INTO number_of_partition_columns, partition_column_index @@ -23,7 +30,7 @@ BEGIN WHERE partrelid = table_name; IF NOT FOUND THEN - RAISE '% is not partitioned', table_name::text; + RAISE '% is not partitioned', table_display_name; ELSIF number_of_partition_columns <> 1 THEN RAISE 'partitioned tables with multiple partition columns are not supported'; END IF; @@ -44,7 +51,7 @@ BEGIN EXISTS(SELECT OID FROM pg_cast WHERE castsource = 'timestamptz'::regtype AND casttarget = partition_column_type) INTO is_partition_column_castable; IF not is_partition_column_castable THEN - RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_name; + RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_display_name; END IF; custom_cast = format('::%s', partition_column_type); END IF; @@ -57,7 +64,7 @@ BEGIN ORDER BY to_value%1$s::timestamptz', custom_cast); FOR r IN EXECUTE older_partitions_query USING table_name, older_than LOOP - RAISE NOTICE 'dropping % with start time % and end time %', r.partition, r.from_value, r.to_value; + RAISE NOTICE 'dropping % with start time % and end time %', pg_catalog.quote_ident(r.table_name), r.from_value, r.to_value; EXECUTE format('DROP TABLE %I.%I', r.schema_name, r.table_name); END LOOP; END; diff --git a/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/10.2-4.sql b/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/10.2-4.sql index debb5825cfa..f44df9c1068 100644 --- a/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/10.2-4.sql +++ b/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/10.2-4.sql @@ -1,6 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.fix_all_partition_shard_index_names() RETURNS SETOF regclass LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $$ DECLARE dist_partitioned_table_name regclass; diff --git a/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/latest.sql b/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/latest.sql index debb5825cfa..f44df9c1068 100644 --- a/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/latest.sql +++ b/src/backend/distributed/sql/udfs/fix_all_partition_shard_index_names/latest.sql @@ -1,6 +1,7 @@ CREATE OR REPLACE FUNCTION pg_catalog.fix_all_partition_shard_index_names() RETURNS SETOF regclass LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $$ DECLARE dist_partitioned_table_name regclass; diff --git a/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/10.0-1.sql b/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/10.0-1.sql index 464ca64707f..16752622151 100644 --- a/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/10.0-1.sql +++ b/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/10.0-1.sql @@ -8,6 +8,7 @@ COMMENT ON FUNCTION pg_catalog.fix_pre_citus10_partitioned_table_constraint_name CREATE OR REPLACE FUNCTION pg_catalog.fix_pre_citus10_partitioned_table_constraint_names() RETURNS SETOF regclass LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $$ DECLARE oid regclass; diff --git a/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/latest.sql b/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/latest.sql index 464ca64707f..16752622151 100644 --- a/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/latest.sql +++ b/src/backend/distributed/sql/udfs/fix_pre_citus10_partitioned_table_constraint_names/latest.sql @@ -8,6 +8,7 @@ COMMENT ON FUNCTION pg_catalog.fix_pre_citus10_partitioned_table_constraint_name CREATE OR REPLACE FUNCTION pg_catalog.fix_pre_citus10_partitioned_table_constraint_names() RETURNS SETOF regclass LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $$ DECLARE oid regclass; diff --git a/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/14.0-1.sql b/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/14.0-1.sql index 1b83ead8f47..ef81e3b234f 100644 --- a/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/14.0-1.sql +++ b/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/14.0-1.sql @@ -8,7 +8,7 @@ DECLARE v_table_to_move_out oid; v_first_table oid; BEGIN - SET LOCAL search_path TO pg_catalog; + SET LOCAL search_path TO pg_catalog, pg_temp; FOR v_colocationid, v_tables_to_move_out_grouped_by_collation IN @@ -78,6 +78,7 @@ BEGIN END LOOP; END; $func$ -LANGUAGE plpgsql; +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; COMMENT ON FUNCTION pg_catalog.fix_pre_citus14_colocation_group_collation_mismatches() IS 'Fix distributed tables whose colocation group collations do not match their distribution columns by moving them to new colocation groups'; diff --git a/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/latest.sql b/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/latest.sql index 1b83ead8f47..ef81e3b234f 100644 --- a/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/latest.sql +++ b/src/backend/distributed/sql/udfs/fix_pre_citus14_colocation_group_collation_mismatches/latest.sql @@ -8,7 +8,7 @@ DECLARE v_table_to_move_out oid; v_first_table oid; BEGIN - SET LOCAL search_path TO pg_catalog; + SET LOCAL search_path TO pg_catalog, pg_temp; FOR v_colocationid, v_tables_to_move_out_grouped_by_collation IN @@ -78,6 +78,7 @@ BEGIN END LOOP; END; $func$ -LANGUAGE plpgsql; +LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; COMMENT ON FUNCTION pg_catalog.fix_pre_citus14_colocation_group_collation_mismatches() IS 'Fix distributed tables whose colocation group collations do not match their distribution columns by moving them to new colocation groups'; diff --git a/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/12.0-1.sql b/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/12.0-1.sql index 4cdca999a6f..d284314f4d3 100644 --- a/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/12.0-1.sql +++ b/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/12.0-1.sql @@ -8,11 +8,13 @@ returns table( range_from_value text, range_to_value text) LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $$ DECLARE -- properties of the partitioned table table_name_text text; table_schema_text text; + table_display_name text; number_of_partition_columns int; partition_column_index int; partition_column_type regtype; @@ -25,6 +27,7 @@ DECLARE -- used to check whether there are misaligned (manually created) partitions manual_partition regclass; + manual_partition_name_text text; manual_partition_from_value_text text; manual_partition_to_value_text text; @@ -42,14 +45,21 @@ DECLARE partition_covers_query text; partition_exist_query text; BEGIN - -- check whether the table is time partitioned table, if not error out - SELECT relname, nspname, partnatts, partattrs[0] - INTO table_name_text, table_schema_text, number_of_partition_columns, partition_column_index - FROM pg_catalog.pg_partitioned_table, pg_catalog.pg_class c, pg_catalog.pg_namespace n - WHERE partrelid = c.oid AND c.oid = table_name + SELECT c.relname, n.nspname + INTO table_name_text, table_schema_text + FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n + WHERE c.oid = table_name AND c.relnamespace = n.oid; + + table_display_name := pg_catalog.quote_ident(table_name_text); + + -- check whether the table is time partitioned table, if not error out + SELECT partnatts, partattrs[0] + INTO number_of_partition_columns, partition_column_index + FROM pg_catalog.pg_partitioned_table + WHERE partrelid = table_name; IF NOT FOUND THEN - RAISE '% is not partitioned', table_name; + RAISE '% is not partitioned', table_display_name; ELSIF number_of_partition_columns <> 1 THEN RAISE 'partitioned tables with multiple partition columns are not supported'; END IF; @@ -73,7 +83,7 @@ BEGIN EXISTS(SELECT OID FROM pg_cast WHERE castsource = 'timestamptz'::regtype AND casttarget = partition_column_type) INTO is_partition_column_castable; IF not is_partition_column_castable THEN - RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_name; + RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_display_name; END IF; custom_cast = format('::%s', partition_column_type); END IF; @@ -196,8 +206,13 @@ BEGIN using current_range_from_value, current_range_to_value, table_name; IF manual_partition is not NULL THEN + SELECT pg_catalog.quote_ident(relname) + INTO manual_partition_name_text + FROM pg_catalog.pg_class + WHERE oid = manual_partition::oid; + RAISE 'partition % with the range from % to % does not align with the initial partition given the partition interval', - manual_partition::text, + manual_partition_name_text, manual_partition_from_value_text, manual_partition_to_value_text USING HINT = 'Only use partitions of the same size, without gaps between partitions.'; diff --git a/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/latest.sql b/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/latest.sql index 4cdca999a6f..d284314f4d3 100644 --- a/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/latest.sql +++ b/src/backend/distributed/sql/udfs/get_missing_time_partition_ranges/latest.sql @@ -8,11 +8,13 @@ returns table( range_from_value text, range_to_value text) LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp AS $$ DECLARE -- properties of the partitioned table table_name_text text; table_schema_text text; + table_display_name text; number_of_partition_columns int; partition_column_index int; partition_column_type regtype; @@ -25,6 +27,7 @@ DECLARE -- used to check whether there are misaligned (manually created) partitions manual_partition regclass; + manual_partition_name_text text; manual_partition_from_value_text text; manual_partition_to_value_text text; @@ -42,14 +45,21 @@ DECLARE partition_covers_query text; partition_exist_query text; BEGIN - -- check whether the table is time partitioned table, if not error out - SELECT relname, nspname, partnatts, partattrs[0] - INTO table_name_text, table_schema_text, number_of_partition_columns, partition_column_index - FROM pg_catalog.pg_partitioned_table, pg_catalog.pg_class c, pg_catalog.pg_namespace n - WHERE partrelid = c.oid AND c.oid = table_name + SELECT c.relname, n.nspname + INTO table_name_text, table_schema_text + FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n + WHERE c.oid = table_name AND c.relnamespace = n.oid; + + table_display_name := pg_catalog.quote_ident(table_name_text); + + -- check whether the table is time partitioned table, if not error out + SELECT partnatts, partattrs[0] + INTO number_of_partition_columns, partition_column_index + FROM pg_catalog.pg_partitioned_table + WHERE partrelid = table_name; IF NOT FOUND THEN - RAISE '% is not partitioned', table_name; + RAISE '% is not partitioned', table_display_name; ELSIF number_of_partition_columns <> 1 THEN RAISE 'partitioned tables with multiple partition columns are not supported'; END IF; @@ -73,7 +83,7 @@ BEGIN EXISTS(SELECT OID FROM pg_cast WHERE castsource = 'timestamptz'::regtype AND casttarget = partition_column_type) INTO is_partition_column_castable; IF not is_partition_column_castable THEN - RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_name; + RAISE 'type of the partition column of the table % must be date, timestamp or timestamptz', table_display_name; END IF; custom_cast = format('::%s', partition_column_type); END IF; @@ -196,8 +206,13 @@ BEGIN using current_range_from_value, current_range_to_value, table_name; IF manual_partition is not NULL THEN + SELECT pg_catalog.quote_ident(relname) + INTO manual_partition_name_text + FROM pg_catalog.pg_class + WHERE oid = manual_partition::oid; + RAISE 'partition % with the range from % to % does not align with the initial partition given the partition interval', - manual_partition::text, + manual_partition_name_text, manual_partition_from_value_text, manual_partition_to_value_text USING HINT = 'Only use partitions of the same size, without gaps between partitions.'; diff --git a/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/9.2-1.sql b/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/9.2-1.sql index 8e814c5bcd4..251665a4592 100644 --- a/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/9.2-1.sql +++ b/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/9.2-1.sql @@ -25,4 +25,5 @@ RETURNS TRIGGER AS $$ END IF; RETURN NEW; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; diff --git a/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/latest.sql b/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/latest.sql index 8e814c5bcd4..251665a4592 100644 --- a/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/latest.sql +++ b/src/backend/distributed/sql/udfs/pg_dist_rebalance_strategy_trigger_func/latest.sql @@ -25,4 +25,5 @@ RETURNS TRIGGER AS $$ END IF; RETURN NEW; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; diff --git a/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/9.0-1.sql b/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/9.0-1.sql index 178297c52d2..a8cc7056874 100644 --- a/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/9.0-1.sql +++ b/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/9.0-1.sql @@ -19,4 +19,5 @@ RETURNS TRIGGER AS $$ RETURN NEW; END IF; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; diff --git a/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/latest.sql b/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/latest.sql index 178297c52d2..a8cc7056874 100644 --- a/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/latest.sql +++ b/src/backend/distributed/sql/udfs/pg_dist_shard_placement_trigger_func/latest.sql @@ -19,4 +19,5 @@ RETURNS TRIGGER AS $$ RETURN NEW; END IF; END; -$$ LANGUAGE plpgsql; +$$ LANGUAGE plpgsql +SET search_path = pg_catalog, pg_temp; diff --git a/src/backend/distributed/sql/udfs/run_command_on_all_nodes/11.0-1.sql b/src/backend/distributed/sql/udfs/run_command_on_all_nodes/11.0-1.sql index 1361ef6aa7c..d51ffba5779 100644 --- a/src/backend/distributed/sql/udfs/run_command_on_all_nodes/11.0-1.sql +++ b/src/backend/distributed/sql/udfs/run_command_on_all_nodes/11.0-1.sql @@ -4,6 +4,7 @@ CREATE FUNCTION pg_catalog.run_command_on_all_nodes(command text, parallel bool OUT nodeid int, OUT success bool, OUT result text) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ DECLARE nodenames text[]; @@ -13,7 +14,7 @@ DECLARE command_result_of_current_node text; BEGIN WITH citus_nodes AS ( - SELECT * FROM pg_dist_node + SELECT * FROM pg_catalog.pg_dist_node WHERE isactive = 't' AND nodecluster = current_setting('citus.cluster_name') AND ( (current_setting('citus.use_secondary_nodes') = 'never' AND noderole = 'primary') @@ -26,10 +27,10 @@ BEGIN INTO nodenames, ports, commands FROM citus_nodes; - SELECT count(*) > 0 FROM pg_dist_node + SELECT count(*) > 0 FROM pg_catalog.pg_dist_node WHERE isactive = 't' AND nodecluster = current_setting('citus.cluster_name') - AND groupid IN (SELECT groupid FROM pg_dist_local_group) + AND groupid IN (SELECT groupid FROM pg_catalog.pg_dist_local_group) INTO current_node_is_in_metadata; -- This will happen when we call this function on coordinator and @@ -48,8 +49,8 @@ BEGIN FOR nodeid, success, result IN SELECT coalesce(pg_dist_node.nodeid, 0) AS nodeid, mrow.success, mrow.result - FROM master_run_on_worker(nodenames, ports, commands, parallel) mrow - LEFT JOIN pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport + FROM pg_catalog.master_run_on_worker(nodenames, ports, commands, parallel) mrow + LEFT JOIN pg_catalog.pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport LOOP IF give_warning_for_connection_errors AND NOT success THEN RAISE WARNING 'Error on node with node id %: %', nodeid, result; diff --git a/src/backend/distributed/sql/udfs/run_command_on_all_nodes/latest.sql b/src/backend/distributed/sql/udfs/run_command_on_all_nodes/latest.sql index 1361ef6aa7c..d51ffba5779 100644 --- a/src/backend/distributed/sql/udfs/run_command_on_all_nodes/latest.sql +++ b/src/backend/distributed/sql/udfs/run_command_on_all_nodes/latest.sql @@ -4,6 +4,7 @@ CREATE FUNCTION pg_catalog.run_command_on_all_nodes(command text, parallel bool OUT nodeid int, OUT success bool, OUT result text) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ DECLARE nodenames text[]; @@ -13,7 +14,7 @@ DECLARE command_result_of_current_node text; BEGIN WITH citus_nodes AS ( - SELECT * FROM pg_dist_node + SELECT * FROM pg_catalog.pg_dist_node WHERE isactive = 't' AND nodecluster = current_setting('citus.cluster_name') AND ( (current_setting('citus.use_secondary_nodes') = 'never' AND noderole = 'primary') @@ -26,10 +27,10 @@ BEGIN INTO nodenames, ports, commands FROM citus_nodes; - SELECT count(*) > 0 FROM pg_dist_node + SELECT count(*) > 0 FROM pg_catalog.pg_dist_node WHERE isactive = 't' AND nodecluster = current_setting('citus.cluster_name') - AND groupid IN (SELECT groupid FROM pg_dist_local_group) + AND groupid IN (SELECT groupid FROM pg_catalog.pg_dist_local_group) INTO current_node_is_in_metadata; -- This will happen when we call this function on coordinator and @@ -48,8 +49,8 @@ BEGIN FOR nodeid, success, result IN SELECT coalesce(pg_dist_node.nodeid, 0) AS nodeid, mrow.success, mrow.result - FROM master_run_on_worker(nodenames, ports, commands, parallel) mrow - LEFT JOIN pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport + FROM pg_catalog.master_run_on_worker(nodenames, ports, commands, parallel) mrow + LEFT JOIN pg_catalog.pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport LOOP IF give_warning_for_connection_errors AND NOT success THEN RAISE WARNING 'Error on node with node id %: %', nodeid, result; diff --git a/src/backend/distributed/sql/udfs/run_command_on_coordinator/11.0-2.sql b/src/backend/distributed/sql/udfs/run_command_on_coordinator/11.0-2.sql index d8fb3c35cf5..09227a25316 100644 --- a/src/backend/distributed/sql/udfs/run_command_on_coordinator/11.0-2.sql +++ b/src/backend/distributed/sql/udfs/run_command_on_coordinator/11.0-2.sql @@ -4,6 +4,7 @@ CREATE FUNCTION pg_catalog.run_command_on_coordinator(command text, give_warning OUT nodeid int, OUT success bool, OUT result text) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ DECLARE nodenames text[]; @@ -13,7 +14,7 @@ DECLARE parallel boolean := false; BEGIN WITH citus_nodes AS ( - SELECT * FROM pg_dist_node + SELECT * FROM pg_catalog.pg_dist_node WHERE isactive AND nodecluster = current_setting('citus.cluster_name') AND groupid = 0 AND ( (current_setting('citus.use_secondary_nodes') = 'never' AND noderole = 'primary') @@ -33,7 +34,7 @@ BEGIN -- But when the coordinator is not added to metadata and this function -- is called from a worker node, this will not be enough and we'll -- not be able run on all nodes. - IF citus_is_coordinator() THEN + IF pg_catalog.citus_is_coordinator() THEN SELECT array_append(nodenames, current_setting('citus.local_hostname')), array_append(ports, current_setting('port')::int), @@ -47,8 +48,8 @@ BEGIN FOR nodeid, success, result IN SELECT coalesce(pg_dist_node.nodeid, 0) AS nodeid, mrow.success, mrow.result - FROM master_run_on_worker(nodenames, ports, commands, parallel) mrow - LEFT JOIN pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport + FROM pg_catalog.master_run_on_worker(nodenames, ports, commands, parallel) mrow + LEFT JOIN pg_catalog.pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport LOOP IF give_warning_for_connection_errors AND NOT success THEN RAISE WARNING 'Error on node with node id %: %', nodeid, result; diff --git a/src/backend/distributed/sql/udfs/run_command_on_coordinator/latest.sql b/src/backend/distributed/sql/udfs/run_command_on_coordinator/latest.sql index d8fb3c35cf5..09227a25316 100644 --- a/src/backend/distributed/sql/udfs/run_command_on_coordinator/latest.sql +++ b/src/backend/distributed/sql/udfs/run_command_on_coordinator/latest.sql @@ -4,6 +4,7 @@ CREATE FUNCTION pg_catalog.run_command_on_coordinator(command text, give_warning OUT nodeid int, OUT success bool, OUT result text) RETURNS SETOF record LANGUAGE plpgsql + SET search_path = pg_catalog, pg_temp AS $function$ DECLARE nodenames text[]; @@ -13,7 +14,7 @@ DECLARE parallel boolean := false; BEGIN WITH citus_nodes AS ( - SELECT * FROM pg_dist_node + SELECT * FROM pg_catalog.pg_dist_node WHERE isactive AND nodecluster = current_setting('citus.cluster_name') AND groupid = 0 AND ( (current_setting('citus.use_secondary_nodes') = 'never' AND noderole = 'primary') @@ -33,7 +34,7 @@ BEGIN -- But when the coordinator is not added to metadata and this function -- is called from a worker node, this will not be enough and we'll -- not be able run on all nodes. - IF citus_is_coordinator() THEN + IF pg_catalog.citus_is_coordinator() THEN SELECT array_append(nodenames, current_setting('citus.local_hostname')), array_append(ports, current_setting('port')::int), @@ -47,8 +48,8 @@ BEGIN FOR nodeid, success, result IN SELECT coalesce(pg_dist_node.nodeid, 0) AS nodeid, mrow.success, mrow.result - FROM master_run_on_worker(nodenames, ports, commands, parallel) mrow - LEFT JOIN pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport + FROM pg_catalog.master_run_on_worker(nodenames, ports, commands, parallel) mrow + LEFT JOIN pg_catalog.pg_dist_node ON mrow.node_name = pg_dist_node.nodename AND mrow.node_port = pg_dist_node.nodeport LOOP IF give_warning_for_connection_errors AND NOT success THEN RAISE WARNING 'Error on node with node id %: %', nodeid, result; diff --git a/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/11.3-1.sql b/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/11.3-1.sql index 55236286c03..27c05cf0557 100644 --- a/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/11.3-1.sql +++ b/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/11.3-1.sql @@ -9,7 +9,7 @@ DECLARE table_name text; BEGIN -- drop shell tables within single or multiple transactions according to the flag singleTransaction - FOR table_name IN SELECT logicalrelid::regclass::text FROM pg_dist_partition + FOR table_name IN SELECT logicalrelid::regclass::text FROM pg_catalog.pg_dist_partition LOOP PERFORM pg_catalog.worker_drop_shell_table(table_name); IF not singleTransaction THEN diff --git a/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/latest.sql b/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/latest.sql index 55236286c03..27c05cf0557 100644 --- a/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/latest.sql +++ b/src/backend/distributed/sql/udfs/worker_drop_all_shell_tables/latest.sql @@ -9,7 +9,7 @@ DECLARE table_name text; BEGIN -- drop shell tables within single or multiple transactions according to the flag singleTransaction - FOR table_name IN SELECT logicalrelid::regclass::text FROM pg_dist_partition + FOR table_name IN SELECT logicalrelid::regclass::text FROM pg_catalog.pg_dist_partition LOOP PERFORM pg_catalog.worker_drop_shell_table(table_name); IF not singleTransaction THEN