Skip to content

Commit

Permalink
Initial commit for Babelfish v5.1 (#3304)
Browse files Browse the repository at this point in the history
This commit contains the following changes:

Add version info and upgrade test for 14.15, 15.10, 16.6 and 17.2.
Add upgrade schedule files for 14.16, 15.11, 16.7 and 17.3.
Update T-SQL extension version to 5.1.0 and add following upgrade scripts:
babelfishpg_common--3.8.0--4.0.0.sql
babelfishpg_common--4.5.0--5.0.0.sql
babelfishpg_tsql--4.5.0--5.0.0.sql
babelfishpg_tsql--5.0.0--5.1.0.sql
Update common extension version to 5.1.0 and add following upgrade scripts:
babelfish_common_helper--5.0.0--5.1.0.sql
spatial_types--5.0.0--5.1.0.sql
Task: NO-JIRA

Signed-off-by: Rishabh Tanwar [email protected]
  • Loading branch information
rishabhtanwar29 authored Dec 24, 2024
1 parent d408de5 commit 7d320ef
Show file tree
Hide file tree
Showing 18 changed files with 2,388 additions and 39 deletions.
44 changes: 20 additions & 24 deletions .github/configuration/upgrade-test-configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,6 @@ upgrade-version: [{
}
]
},
{
upgrade-path: [
{
version: 14.3,
upgrade-type: null
},
{
version: 14.6,
upgrade-type: minor
},
{
version: target.latest,
upgrade-type: major
}
]
},
{
upgrade-path: [
{
Expand Down Expand Up @@ -101,7 +85,7 @@ upgrade-version: [{
{
upgrade-path: [
{
version: '14.15',
version: '14.16',
upgrade-type: null
},
{
Expand Down Expand Up @@ -137,7 +121,7 @@ upgrade-version: [{
{
upgrade-path: [
{
version: 16.1,
version: '15.11',
upgrade-type: null
},
{
Expand All @@ -149,7 +133,7 @@ upgrade-version: [{
{
upgrade-path: [
{
version: 16.2,
version: 16.1,
upgrade-type: null
},
{
Expand All @@ -161,7 +145,7 @@ upgrade-version: [{
{
upgrade-path: [
{
version: 16.6,
version: 16.4,
upgrade-type: null
},
{
Expand All @@ -170,6 +154,18 @@ upgrade-version: [{
}
]
},
{
upgrade-path: [
{
version: 17.2,
upgrade-type: null
},
{
version: target.latest,
upgrade-type: minor
}
]
},
{
upgrade-path: [
{
Expand All @@ -181,7 +177,7 @@ upgrade-version: [{
upgrade-type: major
},
{
version: '15.10',
version: '15.11',
upgrade-type: major
},
{
Expand All @@ -207,7 +203,7 @@ upgrade-version: [{
{
upgrade-path: [
{
version: '15.10',
version: '15.11',
upgrade-type: null
},
{
Expand All @@ -220,7 +216,7 @@ upgrade-version: [{
{
upgrade-path: [
{
version: '15.10',
version: '15.11',
upgrade-type: null
},
{
Expand All @@ -237,7 +233,7 @@ upgrade-version: [{
upgrade-type: null
},
{
version: '15.10',
version: '15.11',
upgrade-type: minor
},
{
Expand Down
12 changes: 12 additions & 0 deletions .github/template/version-branch-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
'14.15':
engine_branch: BABEL_2_11_STABLE__PG_14_15
extension_branch: BABEL_2_11_STABLE
'14.16':
engine_branch: BABEL_2_X_DEV__PG_14_X
extension_branch: BABEL_2_X_DEV
'15.2':
engine_branch: BABEL_3_1_STABLE__PG_15_2
extension_branch: BABEL_3_1_STABLE
Expand All @@ -73,6 +76,9 @@
'15.10':
engine_branch: BABEL_3_8_STABLE__PG_15_10
extension_branch: BABEL_3_8_STABLE
'15.11':
engine_branch: BABEL_3_X_DEV__PG_15_X
extension_branch: BABEL_3_X_DEV
'16.1':
engine_branch: BABEL_4_0_STABLE__PG_16_1
extension_branch: BABEL_4_0_STABLE
Expand All @@ -88,6 +94,12 @@
'16.6':
engine_branch: BABEL_4_4_STABLE__PG_16_6
extension_branch: BABEL_4_4_STABLE
'16.7':
engine_branch: BABEL_4_X_DEV__PG_16_X
extension_branch: BABEL_4_X_DEV
'17.2':
engine_branch: BABEL_5_0_STABLE__PG_17_2
extension_branch: BABEL_5_0_STABLE
'source.latest':
engine_branch: latest
extension_branch: latest
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/minor-version-upgrade.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Minor Version Upgrade Tests for empty database
on: []
on: [push, pull_request]

jobs:
extension-tests:
env:
ENGINE_VER_FROM: BABEL_4_0_STABLE__PG_16_1
EXTENSION_VER_FROM: BABEL_4_0_STABLE
ENGINE_VER_FROM: BABEL_5_0_STABLE__PG_17_2
EXTENSION_VER_FROM: BABEL_5_0_STABLE
INSTALL_DIR: psql

name: Build and test
Expand All @@ -29,8 +29,6 @@ jobs:
id: compile-antlr
if: always() && steps.build-modified-postgres-older.outcome == 'success'
uses: ./.github/composite-actions/compile-antlr
with:
version: 4.9.3

- uses: actions/checkout@v2
with:
Expand Down Expand Up @@ -117,11 +115,6 @@ jobs:
id: build-modified-postgres-newer
if: always() && steps.install-extensions-older.outcome == 'success'
uses: ./.github/composite-actions/build-modified-postgres

- name: Compile new ANTLR
id: compile-new-antlr
if: always() && steps.build-modified-postgres-newer.outcome == 'success'
uses: ./.github/composite-actions/compile-antlr

- name: Set env variables and build extensions
id: build-extensions-newer
Expand Down
9 changes: 8 additions & 1 deletion contrib/babelfishpg_common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ GENERATED_UPGRADES = \
sql/$(EXTENSION)--4.1.0--4.2.0.sql \
sql/$(EXTENSION)--4.2.0--4.3.0.sql \
sql/$(EXTENSION)--4.3.0--4.4.0.sql \
sql/$(EXTENSION)--4.4.0--5.0.0.sql
sql/$(EXTENSION)--4.4.0--5.0.0.sql \
sql/$(EXTENSION)--5.0.0--5.1.0.sql

ifdef PREV_EXTVERSION
DATA = sql/$(EXTENSION)--$(PREV_EXTVERSION).sql
Expand Down Expand Up @@ -130,6 +131,9 @@ ifeq (,$(filter $(FLAG_TO_CHECK),$(PG_CPPFLAGS)))

sql/$(EXTENSION)--4.4.0--5.0.0.sql: sql/upgrades/babelfishpg_upgrades.in
cpp -D PREV_VERSION=4.4.0 -D CUR_VERSION=5.0.0 $< | sed 's/^# /-- /g' > $@

sql/$(EXTENSION)--5.0.0--5.1.0.sql: sql/upgrades/babelfishpg_upgrades.in
cpp -D PREV_VERSION=5.0.0 -D CUR_VERSION=5.1.0 $< | sed 's/^# /-- /g' > $@
else
# The flag is present build the .in file including the spatial type files
sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).in
Expand Down Expand Up @@ -159,6 +163,9 @@ else
sql/$(EXTENSION)--4.4.0--5.0.0.sql: sql/upgrades/babelfishpg_upgrades.in
cpp -D ENABLE_SPATIAL_TYPES=1 -D PREV_VERSION=4.4.0 -D CUR_VERSION=5.0.0 $< | sed 's/^# /-- /g' > $@

sql/$(EXTENSION)--5.0.0--5.1.0.sql: sql/upgrades/babelfishpg_upgrades.in
cpp -D ENABLE_SPATIAL_TYPES=1 -D PREV_VERSION=5.0.0 -D CUR_VERSION=5.1.0 $< | sed 's/^# /-- /g' > $@

endif

sql/babelfishpg_common--%.sql: sql/upgrades/babelfishpg_common--%.sql
Expand Down
2 changes: 1 addition & 1 deletion contrib/babelfishpg_common/Version.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BBFPGCMN_MAJOR_VERSION=5
BBFPGCMN_MINOR_VERSION=0
BBFPGCMN_MINOR_VERSION=1
BBFPGCMN_MICRO_VERSION=0

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
------------------------------------------------------------------------------
---- Include changes related to other datatypes except spatial types here ----
------------------------------------------------------------------------------

-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO '5.1.0'" to load this file. \quit

SELECT set_config('search_path', 'sys, '||current_setting('search_path'), false);

-- Please add your SQLs 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.
*/

-- Reset search_path to not affect any subsequent scripts
SELECT set_config('search_path', trim(leading 'sys, ' from current_setting('search_path')), false);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO '4.0.0'" to load this file. \quit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION ""babelfishpg_common"" UPDATE TO '5.0.0'" to load this file. \quit
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-------------------------------------------------------
---- Include changes related to spatial types here ----
-------------------------------------------------------
2 changes: 1 addition & 1 deletion contrib/babelfishpg_tsql/Version.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# places during the build process

PGTSQL_MAJOR_VERSION=5
PGTSQL_MINOR_VERSION=0
PGTSQL_MINOR_VERSION=1
PGTSQL_MICRO_VERSION=0

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);
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
\echo Use "ALTER EXTENSION ""babelfishpg_tsql"" UPDATE TO '5.1.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);

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;
$$;

-- Please add your SQLs 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.
*/

-- 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);
4 changes: 2 additions & 2 deletions contrib/babelfishpg_tsql/src/babelfish_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*-------------------------------------------------------------------------
*/

#define BABELFISH_VERSION_STR "5.0.0"
#define BABELFISH_INTERNAL_VERSION_STR "Babelfish 17.0.0.0"
#define BABELFISH_VERSION_STR "5.1.0"
#define BABELFISH_INTERNAL_VERSION_STR "Babelfish 17.3.0.0"
#define BABEL_COMPATIBILITY_VERSION "12.0.2000.8"
#define BABEL_COMPATIBILITY_MAJOR_VERSION "12"
Loading

0 comments on commit 7d320ef

Please sign in to comment.