Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/BABEL_5_X_DEV' into sharu-dev-…
Browse files Browse the repository at this point in the history
…cross-db-identity
  • Loading branch information
Sharu Goel committed Jan 22, 2025
2 parents ae9f145 + cd18f11 commit 7f9c816
Show file tree
Hide file tree
Showing 25 changed files with 1,318 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ body:
label: Version
description: Which version of Babelfish are you running?
options:
- BABEL_4_X_DEV (Default)
- BABEL_5_X_DEV (Default)
- BABEL_4_X_DEV
- BABEL_3_X_DEV
- BABEL_2_X_DEV
- BABEL_1_X_DEV
Expand Down
45 changes: 41 additions & 4 deletions .github/composite-actions/build-modified-postgres/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ inputs:
runs:
using: "composite"
steps:
- name: Checkout, Build, and Install the Modified PostgreSQL Instance and Run Tests
- name: Checkout Modified PostgreSQL for Babelfish
run: |
cd ..
rm -rf postgresql_modified_for_babelfish
if [[ $GITHUB_EVENT_NAME == "pull_request" ]]; then
if [[ ${{inputs.engine_branch}} == "latest" ]]; then
ENGINE_BRANCH=$GITHUB_HEAD_REF
Expand All @@ -44,10 +44,47 @@ runs:
fi
REPOSITORY_OWNER=$GITHUB_REPOSITORY_OWNER
fi
$GITHUB_WORKSPACE/.github/scripts/clone_engine_repo "$REPOSITORY_OWNER" "$ENGINE_BRANCH"
cd postgresql_modified_for_babelfish
git rev-parse HEAD
rm -rf ~/.ccache
if [[ ${{inputs.tap_tests}} == "yes" ]]; then
echo "CRESTORE_KEY=$(git rev-parse --short HEAD)-tapTest" >> $GITHUB_ENV
elif [[ ${{inputs.code_coverage}} == "yes" ]]; then
echo "CRESTORE_KEY=$(git rev-parse --short HEAD)-coverage" >> $GITHUB_ENV
elif [[ ${{inputs.release_mode}} == "yes" ]]; then
echo "CRESTORE_KEY=$(git rev-parse --short HEAD)-release" >> $GITHUB_ENV
else
echo "CRESTORE_KEY=$(git rev-parse --short HEAD)-default" >> $GITHUB_ENV
fi
shell: bash

- uses: actions/cache/restore@v4
id: restore-ccache
if: ${{ github.event_name == 'pull_request' }} || ${{ inputs.code_coverage == 'yes' }}
with:
path:
~/.ccache
key:
random-random
restore-keys:
ccache-${{ env.CRESTORE_KEY }}

- name: Save cache if cache hit fails in pull requests
if: ${{ github.event_name == 'pull_request' }}
run: |
if [[ '${{ steps.restore-ccache.outputs.cache-matched-key }}' == '' ]]; then
echo "SAVE_CCACHE=1" >> $GITHUB_ENV
elif [[ ${{ 'steps.restore-ccache.outputs.cache-matched-key' }} != '' ]]; then
echo "SAVE_CCACHE=" >> $GITHUB_ENV
fi
shell: bash

- name: Build and Install the Modified PostgreSQL Instance and Run Tests
run: |
echo "${{env.SAVE_CCACHE}}"
echo "${{ steps.restore-ccache.outputs.cache-matched-key }}"
cd ..
cd postgresql_modified_for_babelfish
if [[ ${{inputs.tap_tests}} == "yes" ]]; then
./configure CC='ccache gcc' --prefix=$HOME/${{ inputs.install_dir }}/ --with-python PYTHON=/usr/bin/python3.8 --enable-cassert CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu --enable-tap-tests --with-gssapi
elif [[ ${{inputs.code_coverage}} == "yes" ]]; then
Expand Down
4 changes: 4 additions & 0 deletions .github/composite-actions/dump-restore-util/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ runs:
sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO"
shell: bash

- name: Save cache
if: always()
uses: ./.github/composite-actions/save-ccache

- name: Run Verify Tests
if: always() && steps.run-pg_dump-restore.outcome == 'success' && inputs.is_final_ver == 'true'
uses: ./.github/composite-actions/run-verify-tests
Expand Down
10 changes: 0 additions & 10 deletions .github/composite-actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,4 @@ runs:
sudo /usr/sbin/update-ccache-symlinks
echo 'export PATH="/usr/lib/ccache:$PATH"' | tee -a ~/.bashrc
source ~/.bashrc && echo $PATH
echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
shell: bash

- name: Restore ccache
id: cache-compiler
uses: actions/cache@v3
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-${{ env.NOW }}
restore-keys: |
ccache-${{ runner.os }}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ runs:
install_dir: ${{ inputs.install_dir }}
extension_branch: ${{ inputs.extension_branch }}

- name: Save cache
if: always() && steps.build-extensions-newer == 'success'
uses: ./.github/composite-actions/save-ccache

# Not created and used composite action update-extensions here since, in the previous step it has
# checked out a branch/tag which may not have the updated update-extension composite action
- name: Update extensions
Expand Down
39 changes: 39 additions & 0 deletions .github/composite-actions/save-ccache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: 'Save ccache on push'

runs:
using: "composite"
steps:

- name: Setup new cache key
if: always()
run: |
echo "CCACHE_KEY=${{env.CRESTORE_KEY}}-$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "Event : ${{ github.event_name }}"
echo "Save ccache : ${{ env.SAVE_CCACHE }}"
if [[ ${{ github.event_name != 'pull_request' || env.SAVE_CCACHE == 1 }} == true ]]; then
echo "Cache to be Saved"
echo "SAVE_CACHE_HERE=1" >> $GITHUB_ENV
else
echo "Cache shouldn't be Saved"
echo "SAVE_CACHE_HERE=0" >> $GITHUB_ENV
fi
shell: bash

- name: Save ccache
uses: actions/cache/save@v4
if: env.SAVE_CACHE_HERE == 1
with:
path:
~/.ccache
key:
ccache-${{ env.CCACHE_KEY }}

- name: Clean ccache directory and unset env variables
if: always()
shell: bash
run: |
rm -rf ~/.ccache
echo "CCACHE_KEY=" >> $GITHUB_ENV
echo "SAVE_CCACHE=" >> $GITHUB_ENV
echo "SAVE_CACHE_HERE=" >> $GITHUB_ENV
echo "CRESTORE_KEY=" >> $GITHUB_ENV
4 changes: 4 additions & 0 deletions .github/composite-actions/setup-base-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ runs:

- uses: actions/checkout@v2

- name: Save cache
if: always() && steps.jdbc-upgrade-tests.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Install Python
id: install-python
if: ${{ matrix.upgrade-path.path[0] == 'source_latest' && steps.jdbc-upgrade-tests.outcome == 'success' }}
Expand Down
4 changes: 4 additions & 0 deletions .github/composite-actions/setup-new-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ runs:
with:
install_dir: ${{ inputs.pg_new_dir }}

- name: Save cache
if: always() && steps.build-postgis-extension == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Setup new data directory
id: setup-new-datadir
if: always() && steps.build-postgis-extension.outcome == 'success'
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/dotnet-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ jobs:
id: install-extensions
if: always() && steps.build-postgis-extension.outcome == 'success'
uses: ./.github/composite-actions/install-extensions

- name: Save cache
if: always() && steps.install-extensions.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Run Dotnet Tests
id: run-dotnet-tests
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/jdbc-tests-single-db-mode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ jobs:
~/psql/data/logfile
~/psql/data_5433/logfile
- name: Save cache
if: always() && steps.replication.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

# The test summary files contain paths with ':' characters, which is not allowed with the upload-artifact actions
- name: Rename Test Summary Files
id: test-file-rename
Expand Down
23 changes: 12 additions & 11 deletions .github/workflows/major-version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,11 @@ jobs:

- name: Build Modified Postgres using ${{env.ENGINE_BRANCH_FROM}}
id: build-modified-postgres-old
uses: ./.github/composite-actions/build-modified-postgres
if: always() && steps.install-dependencies.outcome == 'success'
run: |
cd ..
git clone --branch ${{env.ENGINE_BRANCH_FROM}} https://github.com/babelfish-for-postgresql/postgresql_modified_for_babelfish.git
cd postgresql_modified_for_babelfish
./configure --prefix=$HOME/${{env.OLD_INSTALL_DIR}} --with-python PYTHON=/usr/bin/python3.8 --enable-cassert CFLAGS="-ggdb" --with-libxml --with-uuid=ossp --with-icu
make clean
make -j 4
make install
make check
cd contrib && make && sudo make install
shell: bash
with:
engine_branch: ${{ env.ENGINE_BRANCH_FROM }}
install_dir: ${{ env.OLD_INSTALL_DIR }}

- name: Compile ANTLR
id: compile-antlr
Expand Down Expand Up @@ -130,6 +123,10 @@ jobs:

- uses: actions/checkout@v2

- name: Save cache
if: always() && steps.build-extensions-old.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Build Modified Postgres using latest version
id: build-modified-postgres-new
if: always() && steps.install-extensions-old.outcome == 'success'
Expand Down Expand Up @@ -172,6 +169,10 @@ jobs:
uses: ./.github/composite-actions/build-postgis-extension
with:
install_dir: ${{env.NEW_INSTALL_DIR}}

- name: Save cache
if: always() && steps.build-postgis-extension.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Setup new data directory
id: setup-new-datadir
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/minor-version-upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ jobs:

- uses: actions/checkout@v2

- name: Save cache
if: always() && steps.build-extensions-older.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Build and run tests for Postgres engine using latest engine
id: build-modified-postgres-newer
if: always() && steps.install-extensions-older.outcome == 'success'
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/tap-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ jobs:
with:
engine_branch: ${{env.ENGINE_BRANCH_16}}
install_dir: ${{env.INSTALL_DIR_16}}



- name: Build Modified Postgres using ${{env.ENGINE_BRANCH_OLD}}
id: build-modified-postgres-old
if: always() && steps.build-modified-postgres-16.outcome == 'success'
Expand Down Expand Up @@ -100,6 +101,8 @@ jobs:
sudo make USE_PGXS=1 PG_CONFIG=~/psql_source/bin/pg_config install
shell: bash



- name: Build Extensions using ${{env.EXTENSION_BRANCH_OLD}}
id: build-extensions-old
if: always() && steps.build-postgis-extension-old.outcome == 'success'
Expand All @@ -110,13 +113,19 @@ jobs:

- uses: actions/checkout@v2

- name: Save cache
if: always() && steps.build-extensions-old.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Build Modified Postgres using latest version
id: build-modified-postgres-new
if: always() && steps.build-extensions-old.outcome == 'success'
uses: ./.github/composite-actions/build-modified-postgres
with:
tap_tests: 'yes'
install_dir: ${{env.NEW_INSTALL_DIR}}



- name: Compile new ANTLR
id: compile-new-antlr
Expand All @@ -139,6 +148,10 @@ jobs:
with:
install_dir: ${{env.NEW_INSTALL_DIR}}

- name: Save cache
if: always() && steps.build-extensions-old.outcome == 'success'
uses: ./.github/composite-actions/save-ccache

- name: Run TAP Tests
id: tap
if: always() && steps.build-postgis-extension.outcome == 'success'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2005,3 +2005,13 @@ CREATE FUNCTION sys.smallmoneysmaller(sys.SMALLMONEY, sys.SMALLMONEY)
RETURNS sys.SMALLMONEY
AS 'babelfishpg_money', 'fixeddecimalsmaller'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE FUNCTION sys.moneylarger(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimallarger'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE FUNCTION sys.moneysmaller(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimalsmaller'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,17 @@ CREATE AGGREGATE sys.max(sys.smallmoney) (
COMBINEFUNC = sys.smallmoneylarger,
PARALLEL = SAFE
);

CREATE AGGREGATE sys.min(sys.money) (
SFUNC = sys.moneysmaller,
STYPE = sys.money,
COMBINEFUNC = sys.moneysmaller,
PARALLEL = SAFE
);

CREATE AGGREGATE sys.max(sys.money) (
SFUNC = sys.moneylarger,
STYPE = sys.money,
COMBINEFUNC = sys.moneylarger,
PARALLEL = SAFE
);
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,29 @@ CREATE OPERATOR sys.% (
END IF;
END $$;

CREATE OR REPLACE FUNCTION sys.moneylarger(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimallarger'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE OR REPLACE FUNCTION sys.moneysmaller(sys.MONEY, sys.MONEY)
RETURNS sys.MONEY
AS 'babelfishpg_money', 'fixeddecimalsmaller'
LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE;

CREATE OR REPLACE AGGREGATE sys.min(sys.money) (
SFUNC = sys.moneysmaller,
STYPE = sys.money,
COMBINEFUNC = sys.moneysmaller,
PARALLEL = SAFE
);

CREATE OR REPLACE AGGREGATE sys.max(sys.money) (
SFUNC = sys.moneylarger,
STYPE = sys.money,
COMBINEFUNC = sys.moneylarger,
PARALLEL = SAFE
);

-- 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 test/JDBC/expected/BABEL-3006.out
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ select cast(pg_typeof(m) as varchar(20)) d from (select min(d) as m from t3006_m
go
~~START~~
varchar
fixeddecimal
money
~~END~~

~~START~~
Expand All @@ -173,7 +173,7 @@ select cast(pg_typeof(m) as varchar(20)) d from (select max(d) as m from t3006_m
go
~~START~~
varchar
fixeddecimal
money
~~END~~

~~START~~
Expand Down
Loading

0 comments on commit 7f9c816

Please sign in to comment.