From 63ee3277a5467e09b3d082ce9653deef2da35c4e Mon Sep 17 00:00:00 2001 From: Sait Talha Nisanci Date: Fri, 24 Sep 2021 12:43:29 +0300 Subject: [PATCH] wip --- .../udfs/citus_finish_pg_upgrade/10.2-1.sql | 68 +++++++++--------- .../udfs/citus_finish_pg_upgrade/latest.sql | 71 ++++++++++--------- 2 files changed, 73 insertions(+), 66 deletions(-) diff --git a/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/10.2-1.sql b/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/10.2-1.sql index b66ee76cc..6c119fc0d 100644 --- a/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/10.2-1.sql +++ b/src/backend/distributed/sql/udfs/citus_finish_pg_upgrade/10.2-1.sql @@ -10,39 +10,6 @@ DECLARE BEGIN - IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN - EXECUTE $cmd$ - CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray); - COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray) - IS 'concatenate input arrays into a single array'; - $cmd$; - ELSE - EXECUTE $cmd$ - CREATE AGGREGATE array_cat_agg(anyarray) (SFUNC = array_cat, STYPE = anyarray); - COMMENT ON AGGREGATE array_cat_agg(anyarray) - IS 'concatenate input arrays into a single array'; - $cmd$; - END IF; - - -- - -- Citus creates the array_cat_agg but because of a compatibility - -- issue between pg13-pg14, we drop and create it during upgrade. - -- And as Citus creates it, there needs to be a dependency to the - -- Citus extension, so we create that dependency here. - -- We are not using: - -- ALTER EXENSION citus DROP/CREATE AGGREGATE array_cat_agg - -- because we don't have an easy way to check if the aggregate - -- exists with anyarray type or anycompatiblearray type. - - INSERT INTO pg_depend - SELECT - 'pg_proc'::regclass::oid as classid, - (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') as objid, - 0 as objsubid, - 'pg_extension'::regclass::oid as refclassid, - (select oid from pg_extension where extname = 'citus') as refobjid, - 0 as refobjsubid , - 'e' as deptype; -- -- restore citus catalog tables @@ -106,6 +73,41 @@ BEGIN EXECUTE command; END LOOP; + + IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN + EXECUTE $cmd$ + CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray); + COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray) + IS 'concatenate input arrays into a single array'; + $cmd$; + ELSE + EXECUTE $cmd$ + CREATE AGGREGATE array_cat_agg(anyarray) (SFUNC = array_cat, STYPE = anyarray); + COMMENT ON AGGREGATE array_cat_agg(anyarray) + IS 'concatenate input arrays into a single array'; + $cmd$; + END IF; + + -- + -- Citus creates the array_cat_agg but because of a compatibility + -- issue between pg13-pg14, we drop and create it during upgrade. + -- And as Citus creates it, there needs to be a dependency to the + -- Citus extension, so we create that dependency here. + -- We are not using: + -- ALTER EXENSION citus DROP/CREATE AGGREGATE array_cat_agg + -- because we don't have an easy way to check if the aggregate + -- exists with anyarray type or anycompatiblearray type. + + INSERT INTO pg_depend + SELECT + 'pg_proc'::regclass::oid as classid, + (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') as objid, + 0 as objsubid, + 'pg_extension'::regclass::oid as refclassid, + (select oid from pg_extension where extname = 'citus') as refobjid, + 0 as refobjsubid , + 'e' as deptype; + -- -- set dependencies -- 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 b66ee76cc..b63e37dcc 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 @@ -10,39 +10,6 @@ DECLARE BEGIN - IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN - EXECUTE $cmd$ - CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray); - COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray) - IS 'concatenate input arrays into a single array'; - $cmd$; - ELSE - EXECUTE $cmd$ - CREATE AGGREGATE array_cat_agg(anyarray) (SFUNC = array_cat, STYPE = anyarray); - COMMENT ON AGGREGATE array_cat_agg(anyarray) - IS 'concatenate input arrays into a single array'; - $cmd$; - END IF; - - -- - -- Citus creates the array_cat_agg but because of a compatibility - -- issue between pg13-pg14, we drop and create it during upgrade. - -- And as Citus creates it, there needs to be a dependency to the - -- Citus extension, so we create that dependency here. - -- We are not using: - -- ALTER EXENSION citus DROP/CREATE AGGREGATE array_cat_agg - -- because we don't have an easy way to check if the aggregate - -- exists with anyarray type or anycompatiblearray type. - - INSERT INTO pg_depend - SELECT - 'pg_proc'::regclass::oid as classid, - (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') as objid, - 0 as objsubid, - 'pg_extension'::regclass::oid as refclassid, - (select oid from pg_extension where extname = 'citus') as refobjid, - 0 as refobjsubid , - 'e' as deptype; -- -- restore citus catalog tables @@ -106,6 +73,44 @@ BEGIN EXECUTE command; END LOOP; + + + IF substring(current_Setting('server_version'), '\d+')::int >= 14 THEN + EXECUTE $cmd$ + CREATE AGGREGATE array_cat_agg(anycompatiblearray) (SFUNC = array_cat, STYPE = anycompatiblearray); + COMMENT ON AGGREGATE array_cat_agg(anycompatiblearray) + IS 'concatenate input arrays into a single array'; + $cmd$; + ELSE + EXECUTE $cmd$ + CREATE AGGREGATE array_cat_agg(anyarray) (SFUNC = array_cat, STYPE = anyarray); + COMMENT ON AGGREGATE array_cat_agg(anyarray) + IS 'concatenate input arrays into a single array'; + $cmd$; + END IF; + + + -- + -- Citus creates the array_cat_agg but because of a compatibility + -- issue between pg13-pg14, we drop and create it during upgrade. + -- And as Citus creates it, there needs to be a dependency to the + -- Citus extension, so we create that dependency here. + -- We are not using: + -- ALTER EXENSION citus DROP/CREATE AGGREGATE array_cat_agg + -- because we don't have an easy way to check if the aggregate + -- exists with anyarray type or anycompatiblearray type. + + INSERT INTO pg_depend + SELECT + 'pg_proc'::regclass::oid as classid, + (SELECT oid FROM pg_proc WHERE proname = 'array_cat_agg') as objid, + 0 as objsubid, + 'pg_extension'::regclass::oid as refclassid, + (select oid from pg_extension where extname = 'citus') as refobjid, + 0 as refobjsubid , + 'e' as deptype; + + -- -- set dependencies --