-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing upgrade script and update schedule file
Signed-off-by: Rishabh Tanwar <[email protected]>
- Loading branch information
Showing
4 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
contrib/babelfishpg_tsql/sql/upgrades/babelfishpg_tsql--4.5.0--5.0.0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters