From a516600558216049faa86f97374c4b0102ae5dea Mon Sep 17 00:00:00 2001 From: Rishabh Tanwar Date: Tue, 24 Dec 2024 11:15:26 +0000 Subject: [PATCH] Add missing upgrade script and update schedule file Signed-off-by: Rishabh Tanwar --- .../upgrade-test-configuration.yml | 12 ----- .../babelfishpg_tsql--4.5.0--5.0.0.sql | 48 +++++++++++++++++++ test/JDBC/upgrade/15_11/schedule | 3 +- .../expected_drop.out | 1 + 4 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.5.0--5.0.0.sql diff --git a/.github/configuration/upgrade-test-configuration.yml b/.github/configuration/upgrade-test-configuration.yml index 92d887003e..47912704d0 100644 --- a/.github/configuration/upgrade-test-configuration.yml +++ b/.github/configuration/upgrade-test-configuration.yml @@ -154,18 +154,6 @@ upgrade-version: [{ } ] }, -{ - upgrade-path: [ - { - version: 16.7, - upgrade-type: null - }, - { - version: target.latest, - upgrade-type: major - } - ] -}, { upgrade-path: [ { diff --git a/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.5.0--5.0.0.sql b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.5.0--5.0.0.sql new file mode 100644 index 0000000000..1a79296d51 --- /dev/null +++ b/contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.5.0--5.0.0.sql @@ -0,0 +1,48 @@ +-- complain if script is sourced in psql, rather than via ALTER EXTENSION +\echo Use "ALTER EXTENSION ""babelfishpg_tsql"" UPDATE TO '5.0.0'" to load this file. \quit + +-- add 'sys' to search path for the convenience +SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false); + +-- please add your SQL here +/* + * Note: These SQL statements may get executed multiple times specially when some features get backpatched. + * So make sure that any SQL statement (DDL/DML) being added here can be executed multiple times without affecting + * final behaviour. + */ + +CREATE OR REPLACE FUNCTION sys.babelfish_update_server_collation_name() RETURNS VOID +LANGUAGE C +AS 'babelfishpg_common', 'babelfish_update_server_collation_name'; + +DO +LANGUAGE plpgsql +$$ +BEGIN + -- Check if the GUC is empty + IF current_setting('babelfishpg_tsql.restored_server_collation_name', true) <> '' THEN + -- Call the function to update the collation + EXECUTE 'SELECT sys.babelfish_update_server_collation_name()'; + END IF; +END; +$$; + +DROP FUNCTION sys.babelfish_update_server_collation_name(); + +-- reset babelfishpg_tsql.restored_server_collation_name GUC +do +language plpgsql +$$ + declare + query text; + begin + query := pg_catalog.format('alter database %s reset babelfishpg_tsql.restored_server_collation_name', CURRENT_DATABASE()); + execute query; + end; +$$; + +-- After upgrade, always run analyze for all babelfish catalogs. +CALL sys.analyze_babelfish_catalogs(); + +-- Reset search_path to not affect any subsequent scripts +SELECT set_config('search_path', trim(leading 'sys, ' from current_setting('search_path')), false); diff --git a/test/JDBC/upgrade/15_11/schedule b/test/JDBC/upgrade/15_11/schedule index d3d8e36e9a..463f37e429 100644 --- a/test/JDBC/upgrade/15_11/schedule +++ b/test/JDBC/upgrade/15_11/schedule @@ -68,7 +68,7 @@ BABEL-3118 BABEL-3121 BABEL-3144 BABEL-3147 -BABEL-3166 +BABEL-3166-before-16_5-or-15_9 BABEL-3192 BABEL-3204 BABEL-3213 @@ -558,4 +558,3 @@ db_ddladmin BABEL-5186 BABEL-2736 smalldatetime_date_cmp -db_owner diff --git a/test/python/expected/sql_validation_framework/expected_drop.out b/test/python/expected/sql_validation_framework/expected_drop.out index 47990e85d9..0a4ae9b498 100644 --- a/test/python/expected/sql_validation_framework/expected_drop.out +++ b/test/python/expected/sql_validation_framework/expected_drop.out @@ -48,6 +48,7 @@ Unexpected drop found for function sys.babelfish_update_server_collation_name in Unexpected drop found for function sys.babelfish_update_server_collation_name in file babelfishpg_tsql--4.2.0--4.3.0.sql Unexpected drop found for function sys.babelfish_update_server_collation_name in file babelfishpg_tsql--4.3.0--4.4.0.sql Unexpected drop found for function sys.babelfish_update_server_collation_name in file babelfishpg_tsql--4.4.0--5.0.0.sql +Unexpected drop found for function sys.babelfish_update_server_collation_name in file babelfishpg_tsql--4.5.0--5.0.0.sql Unexpected drop found for function sys.babelfish_update_server_collation_name in file babelfishpg_tsql--5.0.0--5.1.0.sql Unexpected drop found for function sys.pg_extension_config_remove in file babelfishpg_tsql--3.1.0--3.2.0.sql Unexpected drop found for operator sys./ in file babelfishpg_common--1.1.0--1.2.0.sql