Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/BABEL_5_X_DEV' into JIRA-BABEL…
Browse files Browse the repository at this point in the history
…-5479
  • Loading branch information
roshan0708 committed Jan 18, 2025
2 parents c029fa1 + 70ce501 commit a9fc896
Show file tree
Hide file tree
Showing 109 changed files with 719 additions and 296 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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ runs:
tar_dir: ${{ matrix.upgrade-path.last_version }}
run: |
cd test/JDBC/
export isUpgradeTestMode=false
export isUpgradeTestMode=true
if [[ ${{ inputs.server_collation_name }} != "default" ]]; then
export serverCollationName=${{ inputs.server_collation_name }}
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/composite-actions/run-verify-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ runs:
touch dummy_schedule
echo "all" > dummy_schedule
export scheduleFile=dummy_schedule
export isUpgradeTestMode=false
export isUpgradeTestMode=true
if [[ ${{ inputs.server_collation_name }} != "default" ]]; then
export serverCollationName=${{ inputs.server_collation_name }}
fi
Expand Down
2 changes: 1 addition & 1 deletion .github/composite-actions/setup-base-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ runs:
exit 1
fi
done
export isUpgradeTestMode=false
export isUpgradeTestMode=true
export inputFilesPath=input
for filename in $(grep -v "^ignore.*\|^#.*\|^cmd.*\|^all.*\|^$" upgrade/$base_dir/schedule); do
sed -i "s/\b$filename[ ]*\b$/$filename-vu-prepare/g" upgrade/$base_dir/schedule
Expand Down
2 changes: 1 addition & 1 deletion .github/composite-actions/upload-coredump/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ runs:


- name: Upload Coredumps
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: always()
with:
name: coredumps
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,28 @@ jobs:
lcov --list lcov.info
- name: Upload Coverage Report for babelfishpg_tsql extension
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage_tsql_${{github.ref_name}}
path: contrib/babelfishpg_tsql/coverage/

- name: Upload Coverage Report for babelfishpg_tds extension
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage_tds_${{github.ref_name}}
path: contrib/babelfishpg_tds/coverage/

- name: Upload Coverage Report for babelfishpg_common extension
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage_common_${{github.ref_name}}
path: contrib/babelfishpg_common/coverage/

- name: Upload Coverage Report for babelfishpg_money extension
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage_money_${{github.ref_name}}
path: contrib/babelfishpg_money/coverage/
Expand All @@ -163,7 +163,7 @@ jobs:

- name: Upload CSV report with latest coverage numbers
if: (github.event_name == 'schedule')
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: csv_${{github.ref_name}}
path: contrib/${{github.ref_name}}.csv
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Upload Coverage Report for Babelfish Extensions
if: always() && steps.code-coverage-summary.outcome == 'success'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-babelfish-extensions-dotnet
path: contrib/dotnet-lcov.info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/isolation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
- name: Upload Coverage Report for Babelfish Extensions
if: always() && steps.code-coverage-summary.outcome == 'success'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-babelfish-extensions-isolation
path: contrib/isolation-lcov.info
Expand Down
64 changes: 56 additions & 8 deletions .github/workflows/jdbc-tests-pgaudit-enable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:

jobs:
run-babelfish-jdbc-tests-with-pg-audit:
strategy:
matrix:
extension_branch: [BABEL_4_X_DEV,BABEL_5_X_DEV]

env:
INSTALL_DIR: psql
runs-on: ubuntu-20.04
Expand All @@ -15,14 +19,28 @@ jobs:
- name: Install Dependencies
id: install-dependencies
if: always()
uses: ./.github/composite-actions/install-dependencies
uses: ./.github/composite-actions/install-dependencies

- name: Determine Engine Branch
id: determine-engine-branch
run: |
if [[ "${{ matrix.extension_branch }}" == "BABEL_4_X_DEV" ]]; then
echo "ENGINE_BRANCH=BABEL_4_X_DEV__PG_16_X" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.extension_branch }}" == "BABEL_5_X_DEV" ]]; then
echo "ENGINE_BRANCH=BABEL_5_X_DEV__PG_17_X" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.extension_branch }}" == "latest" ]]; then
echo "ENGINE_BRANCH=BABEL_5_X_DEV__PG_17_X" >> $GITHUB_OUTPUT
else
echo "ENGINE_BRANCH=main" >> $GITHUB_OUTPUT
fi
- name: Build Modified Postgres
id: build-modified-postgres
if: always() && steps.install-dependencies.outcome == 'success'
uses: ./.github/composite-actions/build-modified-postgres
with:
install_dir: 'psql'
engine_branch: ${{ steps.determine-engine-branch.outputs.ENGINE_BRANCH }}

- name: Compile ANTLR
id: compile-antlr
Expand All @@ -33,6 +51,9 @@ jobs:
id: build-extensions
if: always() && steps.compile-antlr.outcome == 'success'
uses: ./.github/composite-actions/build-extensions
with:
extension_branch: ${{ matrix.extension_branch }}


- name: Build tds_fdw Extension
id: build-tds_fdw-extension
Expand All @@ -57,9 +78,36 @@ jobs:
wal_level: logical

- name: Build and Install PgAudit
uses: ./.github/composite-actions/build-install-pgaudit-extension
with:
install_dir: 'psql'
run: |
cd ~
rm -rf pgaudit
# Determine PgAudit version based on Babelfish branch
if [[ "${{ matrix.extension_branch }}" == 'BABEL_5_X_DEV' ]]; then
git clone --depth 1 --branch REL_17_STABLE https://github.com/pgaudit/pgaudit.git
cd pgaudit
# adding the patch to fix BABEL-4600 to test in Github
sed -i '1517 s/^ else$/ else if (auditEventStack != NULL)/' pgaudit.c
make install USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config
elif [[ "${{ matrix.extension_branch }}" == 'BABEL_4_X_DEV' ]]; then
git clone --depth 1 --branch REL_16_STABLE https://github.com/pgaudit/pgaudit.git
cd pgaudit
# adding the patch to fix BABEL-4600 to test in Github
sed -i '1452 s/^ else$/ else if (auditEventStack != NULL)/' pgaudit.c
make install USE_PGXS=1 PG_CONFIG=~/psql/bin/pg_config
else
echo "Unsupported branch: ${{ matrix.extension_branch }}"
exit 1
fi
cd ~/${{ env.INSTALL_DIR }}
sudo sed -i 's/^shared_preload_libraries .*$/shared_preload_libraries = '\''babelfishpg_tds, pg_stat_statements,pgaudit'\''/g' data/postgresql.conf
echo "everything set"
~/${{ env.INSTALL_DIR }}/bin/pg_ctl -c -D ~/psql/data/ -l logfile restart
sudo PGPASSWORD=12345678 ~/${{ env.INSTALL_DIR }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "CREATE EXTENSION pgaudit;"
sudo PGPASSWORD=12345678 ~/${{ env.INSTALL_DIR }}/bin/psql -v ON_ERROR_STOP=1 -h localhost -d babelfish_db -U jdbc_user -c "ALTER SYSTEM SET pgaudit.log = 'all';"
shell: bash

- name: Ignore some JDBC files
run: |
Expand Down Expand Up @@ -120,7 +168,7 @@ jobs:
if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure')
uses: actions/upload-artifact@v4
with:
name: postgres-log-jdbc
name: postgres-log-jdbc-${{ matrix.extension_branch }}
path: |
~/psql/data/logfile
~/psql/data_5433/logfile
Expand All @@ -144,7 +192,7 @@ jobs:
mv $timestamp.diff ../replication-output-diff.diff
mv "$timestamp"_runSummary.log ../replication-run-summary.log
- name: Upload Run Summary
- name: Upload Run Summary-${{ matrix.extension_branch }}
if: always() && steps.test-file-rename.outcome == 'success'
uses: actions/upload-artifact@v4
with:
Expand All @@ -153,7 +201,7 @@ jobs:
test/JDBC/Info/run-summary.log
test/JDBC/Info/replication-run-summary.log
- name: Upload Output Diff
- name: Upload Output Diff-${{ matrix.extension_branch }}
if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure')
uses: actions/upload-artifact@v4
with:
Expand All @@ -162,7 +210,7 @@ jobs:
test/JDBC/Info/output-diff.diff
test/JDBC/Info/replication-output-diff.diff
- name: Check and upload coredumps
- name: Check and upload coredumps-${{ matrix.extension_branch }}
if: always() && (steps.jdbc.outcome == 'failure' || steps.replication.outcome == 'failure')
uses: ./.github/composite-actions/upload-coredump

2 changes: 1 addition & 1 deletion .github/workflows/jdbc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ jobs:
- name: Upload Coverage Report for Babelfish Extensions
if: always() && steps.code-coverage-summary.outcome == 'success'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-babelfish-extensions-jdbc
path: contrib/jdbc-lcov.info
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/odbc-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Upload Coverage Report for Babelfish Extensions
if: always() && steps.code-coverage-summary.outcome == 'success'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-babelfish-extensions-odbc
path: contrib/odbc-lcov.info
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pr-code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,31 @@ jobs:
run: |
sudo apt-get install lcov
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-jdbc-coverage
with:
name:  coverage-babelfish-extensions-jdbc
path: contrib/

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-dotnet-coverage
with:
name: coverage-babelfish-extensions-dotnet
path: contrib/

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-odbc-coverage
with:
name: coverage-babelfish-extensions-odbc
path: contrib/

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-python-coverage
with:
name: coverage-babelfish-extensions-python
path: contrib/

- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
id: download-isolation-coverage
with:
name: coverage-babelfish-extensions-isolation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
- name: Upload Coverage Report for Babelfish Extensions
if: always() && steps.code-coverage-summary.outcome == 'success'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-babelfish-extensions-python
path: contrib/python-lcov.info
Expand Down
10 changes: 5 additions & 5 deletions contrib/babelfishpg_tds/src/backend/tds/tdsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,9 @@ is_babelfish_role(const char *role)
if (OidIsValid(bbf_master_guest_oid)
&& OidIsValid(bbf_tempdb_guest_oid)
&& OidIsValid(bbf_msdb_guest_oid)
&& is_member_of_role(role_oid, bbf_master_guest_oid)
&& is_member_of_role(role_oid, bbf_tempdb_guest_oid)
&& is_member_of_role(role_oid, bbf_msdb_guest_oid))
&& (is_member_of_role(role_oid, bbf_master_guest_oid)
|| is_member_of_role(role_oid, bbf_tempdb_guest_oid)
|| is_member_of_role(role_oid, bbf_msdb_guest_oid)))
return true;

return false;
Expand Down Expand Up @@ -1242,7 +1242,7 @@ handle_grant_role(GrantRoleStmt *grant_stmt)
continue;

roleid = get_role_oid(rolename, false);
if (OidIsValid(roleid) && IS_DEFAULT_BBF_SERVER_ROLE(rolename))
if (OidIsValid(roleid) && is_babelfish_role(rolename))
check_babelfish_alterrole_restictions(false);
}

Expand All @@ -1254,7 +1254,7 @@ handle_grant_role(GrantRoleStmt *grant_stmt)
Oid roleid;

roleid = get_rolespec_oid(rolespec, false);
if (OidIsValid(roleid) && IS_DEFAULT_BBF_SERVER_ROLE(rolespec->rolename))
if (OidIsValid(roleid) && is_babelfish_role(rolespec->rolename))
check_babelfish_alterrole_restictions(false);
}

Expand Down
6 changes: 0 additions & 6 deletions contrib/babelfishpg_tds/src/include/tds_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,6 @@ extern ProcessUtility_hook_type next_ProcessUtility;
#define BABELFISH_SECURITYADMIN "securityadmin"
#define BABELFISH_DBCREATOR "dbcreator"

#define IS_DEFAULT_BBF_SERVER_ROLE(rolename) \
((strlen(rolename) == 13 && strncmp(rolename, BABELFISH_SECURITYADMIN, 13) == 0) || \
(strlen(rolename) == 14 && strncmp(rolename, BABELFISH_ROLE_ADMIN, 14) == 0) || \
(strlen(rolename) == 9 && strncmp(rolename, BABELFISH_DBCREATOR, 9) == 0) || \
(strlen(rolename) == 8 && strncmp(rolename, BABELFISH_SYSADMIN, 8) == 0))

/* Functions in backend/tds/tdscomm.c */
extern void TdsSetMessageType(uint8_t msgType);
extern void TdsCommInit(uint32_t bufferSize,
Expand Down
Loading

0 comments on commit a9fc896

Please sign in to comment.