Skip to content

Commit

Permalink
Add missing upgrade script and update schedule file
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Tanwar <[email protected]>
  • Loading branch information
ritanwar committed Dec 24, 2024
1 parent cf3bb85 commit a516600
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
12 changes: 0 additions & 12 deletions .github/configuration/upgrade-test-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,6 @@ upgrade-version: [{
}
]
},
{
upgrade-path: [
{
version: 16.7,
upgrade-type: null
},
{
version: target.latest,
upgrade-type: major
}
]
},
{
upgrade-path: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
3 changes: 1 addition & 2 deletions test/JDBC/upgrade/15_11/schedule
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -558,4 +558,3 @@ db_ddladmin
BABEL-5186
BABEL-2736
smalldatetime_date_cmp
db_owner
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a516600

Please sign in to comment.