diff --git a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/12.1-1.sql b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/12.1-1.sql index b4bc653f2f3..4f07ce5c4b0 100644 --- a/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/12.1-1.sql +++ b/src/backend/distributed/sql/udfs/citus_prepare_pg_upgrade/12.1-1.sql @@ -18,13 +18,15 @@ BEGIN DROP AGGREGATE IF EXISTS array_cat_agg(anyarray); DROP AGGREGATE IF EXISTS array_cat_agg(anycompatiblearray); - -- We should drop any_value because PG16 has its own any_value function + -- We should drop any_value because PG16+ has its own any_value function -- We can remove this part when we drop support for PG16 - DELETE FROM pg_depend WHERE - objid IN (SELECT oid FROM pg_proc WHERE proname = 'any_value' OR proname = 'any_value_agg') AND - refobjid IN (select oid from pg_extension where extname = 'citus'); - DROP AGGREGATE IF EXISTS pg_catalog.any_value(anyelement); - DROP FUNCTION IF EXISTS pg_catalog.any_value_agg(anyelement, anyelement); + IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN + DELETE FROM pg_depend WHERE + objid IN (SELECT oid FROM pg_proc WHERE proname = 'any_value' OR proname = 'any_value_agg') AND + refobjid IN (select oid from pg_extension where extname = 'citus'); + DROP AGGREGATE IF EXISTS pg_catalog.any_value(anyelement); + DROP FUNCTION IF EXISTS pg_catalog.any_value_agg(anyelement, anyelement); + END IF; -- -- Drop existing backup tables 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 b4bc653f2f3..4f07ce5c4b0 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 @@ -18,13 +18,15 @@ BEGIN DROP AGGREGATE IF EXISTS array_cat_agg(anyarray); DROP AGGREGATE IF EXISTS array_cat_agg(anycompatiblearray); - -- We should drop any_value because PG16 has its own any_value function + -- We should drop any_value because PG16+ has its own any_value function -- We can remove this part when we drop support for PG16 - DELETE FROM pg_depend WHERE - objid IN (SELECT oid FROM pg_proc WHERE proname = 'any_value' OR proname = 'any_value_agg') AND - refobjid IN (select oid from pg_extension where extname = 'citus'); - DROP AGGREGATE IF EXISTS pg_catalog.any_value(anyelement); - DROP FUNCTION IF EXISTS pg_catalog.any_value_agg(anyelement, anyelement); + IF substring(current_Setting('server_version'), '\d+')::int < 16 THEN + DELETE FROM pg_depend WHERE + objid IN (SELECT oid FROM pg_proc WHERE proname = 'any_value' OR proname = 'any_value_agg') AND + refobjid IN (select oid from pg_extension where extname = 'citus'); + DROP AGGREGATE IF EXISTS pg_catalog.any_value(anyelement); + DROP FUNCTION IF EXISTS pg_catalog.any_value_agg(anyelement, anyelement); + END IF; -- -- Drop existing backup tables