diff --git a/.github/composite-actions/compile-antlr/action.yml b/.github/composite-actions/compile-antlr/action.yml index 6938167584..5e46480f94 100644 --- a/.github/composite-actions/compile-antlr/action.yml +++ b/.github/composite-actions/compile-antlr/action.yml @@ -1,6 +1,10 @@ name: 'Compile ANTLR' inputs: + version: + description: 'version of ANTLR to install' + required: no + default: 4.13.2 install_dir: description: 'Engine install directory' required: no @@ -12,9 +16,12 @@ runs: - name: Compile ANTLR run: | - ANTLR_VERSION=4.9.3 + ANTLR_VERSION=${{inputs.version}} cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ + if [ ! -f antlr-$ANTLR_VERSION-complete.jar ]; then + wget "http://www.antlr.org/download/antlr-$ANTLR_VERSION-complete.jar" + fi sudo cp "antlr-$ANTLR_VERSION-complete.jar" /usr/local/lib cd .. wget "http://www.antlr.org/download/antlr4-cpp-runtime-$ANTLR_VERSION-source.zip" diff --git a/.github/composite-actions/dump-restore-util/action.yml b/.github/composite-actions/dump-restore-util/action.yml index a2090c93a7..f2be167391 100644 --- a/.github/composite-actions/dump-restore-util/action.yml +++ b/.github/composite-actions/dump-restore-util/action.yml @@ -33,6 +33,10 @@ inputs: description: "Dump type full or combination of schema-only and data-only" required: false default: 'full' + antlr_version: + description: "ANTLR version to use (based on Extension Branch)" + required: false + default: 4.13.2 runs: using: "composite" @@ -45,6 +49,7 @@ runs: engine_branch: ${{ inputs.engine_branch }} extension_branch: ${{ inputs.extension_branch }} pg_new_dir: ${{ inputs.pg_new_dir }} + antlr_version: ${{ inputs.antlr_version }} - name: Build latest dump/restore utilities id: build-dump-utils diff --git a/.github/composite-actions/major-version-upgrade-util/action.yml b/.github/composite-actions/major-version-upgrade-util/action.yml index 5d969dcb5a..c7de884d34 100644 --- a/.github/composite-actions/major-version-upgrade-util/action.yml +++ b/.github/composite-actions/major-version-upgrade-util/action.yml @@ -22,6 +22,10 @@ inputs: description: "Server collation name" required: false default: "default" + antlr_version: + description: "ANTLR version to use (based on Extension Branch)" + required: false + default: 4.13.2 runs: using: "composite" @@ -34,6 +38,7 @@ runs: engine_branch: ${{ inputs.engine_branch }} extension_branch: ${{ inputs.extension_branch }} pg_new_dir: ${{ inputs.pg_new_dir }} + antlr_version: ${{ inputs.antlr_version }} - name: Run pg_upgrade id: run-pg_upgrade diff --git a/.github/composite-actions/minor-version-upgrade-util/action.yml b/.github/composite-actions/minor-version-upgrade-util/action.yml index 9987f20f65..4a4cd3241f 100644 --- a/.github/composite-actions/minor-version-upgrade-util/action.yml +++ b/.github/composite-actions/minor-version-upgrade-util/action.yml @@ -16,18 +16,33 @@ inputs: description: "Server collation name" required: false default: "default" + antlr_version: + description: "ANTLR version to use (based on Extension Branch)" + required: false + default: 4.13.2 runs: using: "composite" steps: - name: Build and run tests for Postgres engine using ${{ inputs.engine_branch }} + id: build-modified-postgres-new + if: always() uses: ./.github/composite-actions/build-modified-postgres with: engine_branch: ${{ inputs.engine_branch }} install_dir: ${{ inputs.install_dir }} + - name: Compile new ANTLR + id: compile-new-antlr + if: always() && steps.build-modified-postgres-new.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + with: + version: ${{ inputs.antlr_version }} + install_dir: ${{inputs.install_dir}} + - name: Set env variables and build extensions using ${{ inputs.extension_branch }} id: build-extensions-newer + if: always() && steps.compile-new-antlr.outcome == 'success' uses: ./.github/composite-actions/build-extensions with: install_dir: ${{ inputs.install_dir }} diff --git a/.github/composite-actions/setup-base-version/action.yml b/.github/composite-actions/setup-base-version/action.yml index 0aa7fe5d04..87f0a90446 100644 --- a/.github/composite-actions/setup-base-version/action.yml +++ b/.github/composite-actions/setup-base-version/action.yml @@ -20,6 +20,10 @@ inputs: description: "Whether it is version upgrade or dump/restore" required: false default: 'false' + antlr_version: + description: "ANTLR version to use (based on Extension Branch)" + required: false + default: 4.13.2 runs: using: "composite" @@ -42,6 +46,7 @@ runs: if: always() && steps.build-modified-postgres.outcome == 'success' uses: ./.github/composite-actions/compile-antlr with: + version: ${{ inputs.antlr_version }} install_dir: ${{ inputs.install_dir }} - name: Set env variables and build extensions diff --git a/.github/composite-actions/setup-dump-restore-ca/action.yml b/.github/composite-actions/setup-dump-restore-ca/action.yml index 1ed3e2dc88..770004d8e4 100644 --- a/.github/composite-actions/setup-dump-restore-ca/action.yml +++ b/.github/composite-actions/setup-dump-restore-ca/action.yml @@ -40,6 +40,12 @@ runs: is_final_ver=false; [[ i -eq $LEN-1 ]] && is_final_ver=true pg_old_dir=$(echo psql$(awk -F. '{print $1}' <<< $previous_installed_version)) pg_new_dir=$(echo psql$(awk -F. '{print $1}' <<< $dump_restore_version)) + if [[ "$dump_restore_version" == 'target.latest' || "$dump_restore_version" -ge 16.6 ]] + then + antlr_version=4.13.2 + else + antlr_version=4.9.3 + fi if [[ "$previous_installed_version" == "$dump_restore_version" ]]; then pg_new_dir=$(echo $pg_new_dir.$i) @@ -56,7 +62,7 @@ runs: type_var=".\"dump-restore-version\"[${{ matrix.upgrade-path.id }}][$i].\"type\"" type=$(yq $type_var ${{ github.workspace }}/.github/configuration/dump-restore-test-configuration.yml) - printf " - name: Dump and Restore to version $dump_restore_version\n id: dump-restore-version-$i\n if: always() $temp\n uses: ${uses_file}\n with: \n engine_branch: ${engine_branch}\n extension_branch: ${extension_branch}\n is_final_ver: ${is_final_ver}\n pg_old_dir: ${pg_old_dir}\n pg_new_dir: ${pg_new_dir}\n migration_mode: 'multi-db'\n database_level: ${database_level}\n dump_data_as: ${dump_data_as}\n dump_format: ${dump_format}\n type: ${type}\n\n" >> $dump_restore_version_dir_path/action.yml + printf " - name: Dump and Restore to version $dump_restore_version\n id: dump-restore-version-$i\n if: always() $temp\n uses: ${uses_file}\n with: \n engine_branch: ${engine_branch}\n extension_branch: ${extension_branch}\n is_final_ver: ${is_final_ver}\n pg_old_dir: ${pg_old_dir}\n pg_new_dir: ${pg_new_dir}\n migration_mode: 'multi-db'\n database_level: ${database_level}\n dump_data_as: ${dump_data_as}\n dump_format: ${dump_format}\n type: ${type}\n antlr_version: ${antlr_version}\n\n" >> $dump_restore_version_dir_path/action.yml previous_installed_version=$dump_restore_version done diff --git a/.github/composite-actions/setup-new-version/action.yml b/.github/composite-actions/setup-new-version/action.yml index 2b1378f4cc..2138d1cf41 100644 --- a/.github/composite-actions/setup-new-version/action.yml +++ b/.github/composite-actions/setup-new-version/action.yml @@ -9,6 +9,10 @@ inputs: pg_new_dir: description: "Install new version in this directory" required: true + antlr_version: + description: "ANTLR version to use (based on Extension Branch)" + required: false + default: 4.13.2 runs: using: "composite" @@ -21,15 +25,17 @@ runs: engine_branch: ${{ inputs.engine_branch }} install_dir: ${{ inputs.pg_new_dir }} - - name: Copy ANTLR - id: copy-antlr + - name: Compile new ANTLR + id: compile-new-antlr if: always() && steps.build-modified-postgres-new.outcome == 'success' - run: cp "/usr/local/lib/libantlr4-runtime.so.4.9.3" ~/${{ inputs.pg_new_dir }}/lib/ - shell: bash + uses: ./.github/composite-actions/compile-antlr + with: + version: ${{ inputs.antlr_version }} + install_dir: ${{inputs.pg_new_dir}} - name: Build Extensions id: build-extensions-new - if: always() && steps.copy-antlr.outcome == 'success' + if: always() && steps.compile-new-antlr.outcome == 'success' uses: ./.github/composite-actions/build-extensions with: install_dir: ${{ inputs.pg_new_dir }} diff --git a/.github/composite-actions/setup-upgrade-version-ca/action.yml b/.github/composite-actions/setup-upgrade-version-ca/action.yml index 9ebd3b7ba0..98598369f5 100644 --- a/.github/composite-actions/setup-upgrade-version-ca/action.yml +++ b/.github/composite-actions/setup-upgrade-version-ca/action.yml @@ -45,6 +45,12 @@ runs: is_final_ver=false; [[ i -eq $LEN-1 ]] && is_final_ver=true pg_old_dir=$(echo psql$(awk -F. '{print $1}' <<< $previous_installed_version)) pg_new_dir=$(echo psql$(awk -F. '{print $1}' <<< $upgrade_version)) + if [[ "$upgrade_version" == 'target.latest' || "$upgrade_version" -ge 16.6 ]] + then + antlr_version=4.13.2 + else + antlr_version=4.9.3 + fi upgrade_type_var=".\"upgrade-version\"[${{ matrix.upgrade-path.id }}]."upgrade-path"[$i].\"upgrade-type\"" upgrade_type=$(yq $upgrade_type_var ${{ github.workspace }}/.github/configuration/upgrade-test-configuration.yml) @@ -60,9 +66,9 @@ runs: # Appending upgrade step in upgrade-version composite action based on upgrade type if [[ $upgrade_type == 'major' ]] then - printf " - name: Upgrade Version to $upgrade_version\n id: upgrade-version-$i\n if: always() $temp\n uses: ${uses_file}\n with: \n engine_branch: ${engine_branch}\n extension_branch: ${extension_branch}\n is_final_ver: ${is_final_ver}\n pg_old_dir: ${pg_old_dir}\n pg_new_dir: ${pg_new_dir}\n migration_mode: 'multi-db'\n server_collation_name: ${{ inputs.server_collation_name }}\n\n" >> $upgrade_version_dir_path/action.yml + printf " - name: Upgrade Version to $upgrade_version\n id: upgrade-version-$i\n if: always() $temp\n uses: ${uses_file}\n with: \n engine_branch: ${engine_branch}\n extension_branch: ${extension_branch}\n is_final_ver: ${is_final_ver}\n pg_old_dir: ${pg_old_dir}\n pg_new_dir: ${pg_new_dir}\n migration_mode: 'multi-db'\n server_collation_name: ${{ inputs.server_collation_name }}\n antlr_version: ${antlr_version}\n\n" >> $upgrade_version_dir_path/action.yml else - printf " - name: Upgrade Version to $upgrade_version\n id: upgrade-version-$i\n if: always() $temp\n uses: ${uses_file}\n with: \n engine_branch: ${engine_branch}\n extension_branch: ${extension_branch}\n is_final_ver: ${is_final_ver}\n install_dir: ${pg_new_dir}\n server_collation_name: ${{ inputs.server_collation_name }}\n\n" >> $upgrade_version_dir_path/action.yml + printf " - name: Upgrade Version to $upgrade_version\n id: upgrade-version-$i\n if: always() $temp\n uses: ${uses_file}\n with: \n engine_branch: ${engine_branch}\n extension_branch: ${extension_branch}\n is_final_ver: ${is_final_ver}\n install_dir: ${pg_new_dir}\n server_collation_name: ${{ inputs.server_collation_name }}\n antlr_version: ${antlr_version}\n\n" >> $upgrade_version_dir_path/action.yml fi previous_installed_version=$upgrade_version diff --git a/.github/workflows/isolation-tests.yml b/.github/workflows/isolation-tests.yml index abbc98a984..af8c7d3916 100644 --- a/.github/workflows/isolation-tests.yml +++ b/.github/workflows/isolation-tests.yml @@ -53,12 +53,12 @@ jobs: curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list cd ~/work/babelfish_extensions/babelfish_extensions/test/python sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 python3-dev - pip3 install pyodbc pymssql pytest pytest-xdist antlr4-python3-runtime==4.9.3 + pip3 install pyodbc pymssql pytest pytest-xdist antlr4-python3-runtime==4.13.2 - name: Generate .spec file parser run: | cd ~/work/babelfish_extensions/babelfish_extensions/test/python/isolationtest/ - java -Xmx500M -cp /usr/local/lib/antlr-4.9.3-complete.jar org.antlr.v4.Tool -Dlanguage=Python3 ./parser/*.g4 -visitor -no-listener + java -Xmx500M -cp /usr/local/lib/antlr-4.13.2-complete.jar org.antlr.v4.Tool -Dlanguage=Python3 ./parser/*.g4 -visitor -no-listener - name: Run Isolation tests id: run-isolation-tests diff --git a/.github/workflows/major-version-upgrade.yml b/.github/workflows/major-version-upgrade.yml index 6ab90b1bd2..69dc58b3c0 100644 --- a/.github/workflows/major-version-upgrade.yml +++ b/.github/workflows/major-version-upgrade.yml @@ -38,6 +38,7 @@ jobs: if: always() && steps.build-modified-postgres-old.outcome == 'success' uses: ./.github/composite-actions/compile-antlr with: + version: 4.9.3 install_dir: ${{env.OLD_INSTALL_DIR}} - uses: actions/checkout@v2 @@ -136,13 +137,17 @@ jobs: with: install_dir: ${{env.NEW_INSTALL_DIR}} release_mode: 'yes' - - - name: Copy ANTLR - run: cp "/usr/local/lib/libantlr4-runtime.so.4.9.3" ~/${{env.NEW_INSTALL_DIR}}/lib/ + + - name: Compile new ANTLR + id: compile-new-antlr + if: always() && steps.build-modified-postgres-new.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + with: + install_dir: ${{env.NEW_INSTALL_DIR}} - name: Build Extensions using latest version id: build-extensions-new - if: always() && steps.build-modified-postgres-new.outcome == 'success' + if: always() && steps.compile-new-antlr.outcome == 'success' uses: ./.github/composite-actions/build-extensions with: install_dir: ${{env.NEW_INSTALL_DIR}} diff --git a/.github/workflows/minor-version-upgrade.yml b/.github/workflows/minor-version-upgrade.yml index 873354e4a6..e94fa56b08 100644 --- a/.github/workflows/minor-version-upgrade.yml +++ b/.github/workflows/minor-version-upgrade.yml @@ -29,6 +29,8 @@ 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: @@ -115,9 +117,15 @@ 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 + if: always() && steps.compile-new-antlr.outcome == 'success' uses: ./.github/composite-actions/build-extensions - name: Build PostGIS Extension diff --git a/.github/workflows/pg_dump-restore-test.yml b/.github/workflows/pg_dump-restore-test.yml index 0807cf3dc0..3c59a9eb1e 100644 --- a/.github/workflows/pg_dump-restore-test.yml +++ b/.github/workflows/pg_dump-restore-test.yml @@ -74,6 +74,7 @@ jobs: install_dir: ${{ steps.find-branch.outputs.base-dir }} migration_mode: 'multi-db' dump_restore: 'true' + antlr_version: ${{ (steps.read-base-and-final-version.outputs.base-version == 'source.latest' || fromJSON(steps.read-base-and-final-version.outputs.base-version) >= 16.6 ) && '4.13.2' || '4.9.3' }} - name: Setup Dump Restore Composite Action id: setup-dump-restore-ca diff --git a/.github/workflows/singledb-version-upgrade.yml b/.github/workflows/singledb-version-upgrade.yml index a35d90dc18..67bbfd9f94 100644 --- a/.github/workflows/singledb-version-upgrade.yml +++ b/.github/workflows/singledb-version-upgrade.yml @@ -23,6 +23,7 @@ jobs: extension_branch: ${{ env.EXTENSION_BRANCH_FROM }} install_dir: ${{ env.OLD_INSTALL_DIR }} migration_mode: 'single-db' + antlr_version: 4.9.3 - name: Check Babelfish metadata inconsistency before Major Version Upgrade id: check-babelfish-inconsistency diff --git a/.github/workflows/tap-tests.yml b/.github/workflows/tap-tests.yml index 368122de58..e0bc7704dc 100644 --- a/.github/workflows/tap-tests.yml +++ b/.github/workflows/tap-tests.yml @@ -59,6 +59,7 @@ jobs: if: always() && steps.build-modified-postgres-old.outcome == 'success' uses: ./.github/composite-actions/compile-antlr with: + version: 4.9.3 install_dir: ${{env.OLD_INSTALL_DIR}} - name: Build PostGIS Extension using ${{env.EXTENSION_BRANCH_OLD}} @@ -116,13 +117,17 @@ jobs: with: tap_tests: 'yes' install_dir: ${{env.NEW_INSTALL_DIR}} - - - name: Copy ANTLR - run: cp "/usr/local/lib/libantlr4-runtime.so.4.9.3" ~/${{env.NEW_INSTALL_DIR}}/lib/ + + - name: Compile new ANTLR + id: compile-new-antlr + if: always() && steps.build-modified-postgres-new.outcome == 'success' + uses: ./.github/composite-actions/compile-antlr + with: + install_dir: ${{env.NEW_INSTALL_DIR}} - name: Build Extensions using latest version id: build-extensions-new - if: always() && steps.build-modified-postgres-new.outcome == 'success' + if: always() && steps.compile-new-antlr.outcome == 'success' uses: ./.github/composite-actions/build-extensions with: install_dir: ${{env.NEW_INSTALL_DIR}} diff --git a/.github/workflows/upgrade-test.yml b/.github/workflows/upgrade-test.yml index 29b24c9715..97732b3789 100644 --- a/.github/workflows/upgrade-test.yml +++ b/.github/workflows/upgrade-test.yml @@ -67,6 +67,7 @@ jobs: install_dir: ${{ steps.find-branch.outputs.base-dir }} migration_mode: 'multi-db' server_collation_name: ${{ matrix.upgrade-path.server_collation_name }} + antlr_version: ${{ (steps.read-base-and-final-version.outputs.base-version == 'source.latest' || fromJSON(steps.read-base-and-final-version.outputs.base-version) >= 16.6 ) && '4.13.2' || '4.9.3' }} - name: Setup Upgrade Version Composite Action id: setup-upgrade-ver-ca diff --git a/INSTALLING.md.tmpl b/INSTALLING.md.tmpl index fbd0bcb795..3d2311ed94 100644 --- a/INSTALLING.md.tmpl +++ b/INSTALLING.md.tmpl @@ -55,19 +55,19 @@ export PG_SRC=$(realpath $PWD) ### Compile ANTLR 4 -Unfortunately, there are [no prebuilt C++ binaries for the Antlr 4.9.3 runtime version](https://www.antlr.org/download.html) for Linux. You will need to compile and install ANTLR manually. +Unfortunately, there are [no prebuilt C++ binaries for the Antlr 4.13.2 runtime version](https://www.antlr.org/download.html) for Linux. You will need to compile and install ANTLR manually. First, define the following variables in your environment: ```sh -export ANTLR4_VERSION=4.9.3 +export ANTLR4_VERSION=4.13.2 export ANTLR4_JAVA_BIN=/usr/bin/java export ANTLR4_RUNTIME_LIBRARIES=/usr/include/antlr4-runtime export ANTLR_EXECUTABLE=/usr/local/lib/antlr-${ANTLR4_VERSION}-complete.jar export ANTLR_RUNTIME=~/antlr4 ``` -The [Antlr 4.9.3 Runtime](https://www.antlr.org/) files are distributed with the Babelfish source code. Use the following commands to copy the files into place: +The [Antlr 4.13.2 Runtime](https://www.antlr.org/) files are distributed with the Babelfish source code. Use the following commands to copy the files into place: ```sh sudo cp ${PG_SRC}/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-${ANTLR4_VERSION}-complete.jar /usr/local/lib diff --git a/contrib/README.md b/contrib/README.md index c06c57a5ae..04b884c351 100644 --- a/contrib/README.md +++ b/contrib/README.md @@ -72,30 +72,30 @@ The following build instructions comply with Ubuntu 20.04 and Amazon Linux 2 env 2. Install ANTLR - The `babelfishpg_tsql` contrib has a plug-in parser generated by ANTLR, which depends on cmake and `antlr4-cpp-runtime-4.9.3`. Unfortunately, there aren't binaries for [C++ targets available](https://www.antlr.org/download.html). You'll also need have `uuid-devel` installed in order to install `antlr4-cpp-runtime-4.9.3`. + The `babelfishpg_tsql` contrib has a plug-in parser generated by ANTLR, which depends on cmake and `antlr4-cpp-runtime-4.13.2`. Unfortunately, there aren't binaries for [C++ targets available](https://www.antlr.org/download.html). You'll also need have `uuid-devel` installed in order to install `antlr4-cpp-runtime-4.13.2`. First copy the jar file in `contrib/babelfishpg_tsql/antlr/thirdparty/antlr/` to another location: ``` cd babelfish_extensions/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/ - sudo cp antlr-4.9.3-complete.jar /usr/local/lib + sudo cp antlr-4.13.2-complete.jar /usr/local/lib ``` Compile antlr4: ``` - wget http://www.antlr.org/download/antlr4-cpp-runtime-4.9.3-source.zip - unzip -d antlr4 antlr4-cpp-runtime-4.9.3-source.zip + wget http://www.antlr.org/download/antlr4-cpp-runtime-4.13.2-source.zip + unzip -d antlr4 antlr4-cpp-runtime-4.13.2-source.zip cd antlr4 mkdir build && cd build - cmake .. -DANTLR_JAR_LOCATION=/usr/local/lib/antlr-4.9.3-complete.jar -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True + cmake .. -DANTLR_JAR_LOCATION=/usr/local/lib/antlr-4.13.2-complete.jar -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True make sudo make install ``` Copy libantlr4-runtime to postgres/lib ``` - cp /usr/local/lib/libantlr4-runtime.so.4.9.3 ~/postgres/lib/ + cp /usr/local/lib/libantlr4-runtime.so.4.13.2 ~/postgres/lib/ ``` - If you come across the error diff --git a/contrib/babelfishpg_tsql/Makefile b/contrib/babelfishpg_tsql/Makefile index c78039e504..74cdd1097c 100644 --- a/contrib/babelfishpg_tsql/Makefile +++ b/contrib/babelfishpg_tsql/Makefile @@ -90,6 +90,7 @@ PG_CXXFLAGS += -Wno-deprecated -Wno-error=attributes -Wno-suggest-attribute=form PG_CXXFLAGS += -Wno-undef -Wall -Wcpp PG_CXXFLAGS += -Wno-register # otherwise C++17 gags on PostgreSQL headers PG_CXXFLAGS += -I$(ANTLR4_RUNTIME_INCLUDE_DIR) +PG_CXXFLAGS += -std=c++17 PG_CFLAGS += -g -Werror -Wfloat-conversion PG_CFLAGS += -fstack-protector-strong PG_CPPFLAGS += -I$(TSQLSRC) -I$(PG_SRC) -DFAULT_INJECTOR -Wfloat-conversion diff --git a/contrib/babelfishpg_tsql/antlr/CMakeLists.txt b/contrib/babelfishpg_tsql/antlr/CMakeLists.txt index 4a6517d231..f6aae70699 100644 --- a/contrib/babelfishpg_tsql/antlr/CMakeLists.txt +++ b/contrib/babelfishpg_tsql/antlr/CMakeLists.txt @@ -3,8 +3,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.7 FATAL_ERROR) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake-dir) -# compiler must be 11 or 14 -set(CMAKE_CXX_STANDARD 14) +# compiler must be 17+ to support ANTLR-4.13 +set(CMAKE_CXX_STANDARD 17) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -O2 -ggdb -w -Wno-deprecated") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -O2 -ggdb -w -Wno-deprecated") @@ -17,7 +17,7 @@ include_directories(${MYDIR}) # set variable pointing to the antlr tool that supports C++ # this is not required if the jar file can be found under PATH environment -set(ANTLR_EXECUTABLE ${PROJECT_SOURCE_DIR}/thirdparty/antlr/antlr-4.9.3-complete.jar) +set(ANTLR_EXECUTABLE ${PROJECT_SOURCE_DIR}/thirdparty/antlr/antlr-4.13.2-complete.jar) # add macros to generate ANTLR Cpp code from grammar find_package(ANTLR REQUIRED) diff --git a/contrib/babelfishpg_tsql/antlr/cmake-dir/FindANTLR.cmake b/contrib/babelfishpg_tsql/antlr/cmake-dir/FindANTLR.cmake index 968feded7a..185ea3cd2d 100644 --- a/contrib/babelfishpg_tsql/antlr/cmake-dir/FindANTLR.cmake +++ b/contrib/babelfishpg_tsql/antlr/cmake-dir/FindANTLR.cmake @@ -2,7 +2,7 @@ if(NOT ANTLR_EXECUTABLE) find_program(ANTLR_EXECUTABLE - NAMES antlr.jar antlr4.jar antlr-4.jar antlr-4.9.3-complete.jar) + NAMES antlr.jar antlr4.jar antlr-4.jar antlr-4.13.2-complete.jar) endif() set(Java_JAVA_EXECUTABLE $ENV{ANTLR4_JAVA_BIN}) @@ -18,7 +18,7 @@ if(ANTLR_EXECUTABLE AND Java_JAVA_EXECUTABLE) OUTPUT_STRIP_TRAILING_WHITESPACE) if(ANTLR_COMMAND_RESULT EQUAL 0) - string(REGEX MATCH "Version [0-9]+(\\.[0-9])*" ANTLR_VERSION ${ANTLR_COMMAND_OUTPUT}) + string(REGEX MATCH "Version [0-9]+(\\.[0-9]+)*" ANTLR_VERSION ${ANTLR_COMMAND_OUTPUT}) string(REPLACE "Version " "" ANTLR_VERSION ${ANTLR_VERSION}) else() message( diff --git a/contrib/babelfishpg_tsql/antlr/cmake-dir/README.md b/contrib/babelfishpg_tsql/antlr/cmake-dir/README.md index 0ebe1dd51e..3a4436258a 100644 --- a/contrib/babelfishpg_tsql/antlr/cmake-dir/README.md +++ b/contrib/babelfishpg_tsql/antlr/cmake-dir/README.md @@ -31,7 +31,7 @@ include_directories(${ANTLR4_INCLUDE_DIRS}) # set variable pointing to the antlr tool that supports C++ # this is not required if the jar file can be found under PATH environment -set(ANTLR_EXECUTABLE /home/user/antlr-4.9.3-complete.jar) +set(ANTLR_EXECUTABLE /home/user/antlr-4.13.2-complete.jar) # add macros to generate ANTLR Cpp code from grammar find_package(ANTLR REQUIRED) diff --git a/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-4.13.2-complete.jar b/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-4.13.2-complete.jar new file mode 100644 index 0000000000..75bfcc3976 Binary files /dev/null and b/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-4.13.2-complete.jar differ diff --git a/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-4.9.3-complete.jar b/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-4.9.3-complete.jar deleted file mode 100644 index 749296fe7b..0000000000 Binary files a/contrib/babelfishpg_tsql/antlr/thirdparty/antlr/antlr-4.9.3-complete.jar and /dev/null differ diff --git a/contrib/babelfishpg_tsql/src/tsqlIface.cpp b/contrib/babelfishpg_tsql/src/tsqlIface.cpp index 36a8ce4e22..4de42584ce 100644 --- a/contrib/babelfishpg_tsql/src/tsqlIface.cpp +++ b/contrib/babelfishpg_tsql/src/tsqlIface.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #pragma GCC diagnostic ignored "-Wattributes" @@ -10,6 +11,7 @@ #include "antlr4-runtime.h" // antlr4-cpp-runtime #include "tree/ParseTreeWalker.h" // antlr4-cpp-runtime #include "tree/ParseTreeProperty.h" // antlr4-cpp-runtime +#include "support/Utf8.h" #include "../antlr/antlr4cpp_generated_src/TSqlLexer/TSqlLexer.h" #include "../antlr/antlr4cpp_generated_src/TSqlParser/TSqlParser.h" @@ -568,7 +570,7 @@ format_errmsg(const char *fmt, const char *arg1, const char *arg2); inline std::u32string utf8_to_utf32(const char* s) { - return antlrcpp::utf8_to_utf32(s, s + strlen(s)); + return antlrcpp::Utf8::lenientDecode(std::string_view(s, strlen(s))); } class MyInputStream : public ANTLRInputStream @@ -582,7 +584,7 @@ class MyInputStream : public ANTLRInputStream void setText(size_t pos, const char *newText) { - UTF32String newText32 = utf8_to_utf32(newText); + std::u32string newText32 = utf8_to_utf32(newText); _data.replace(pos, newText32.size(), newText32); } @@ -723,7 +725,7 @@ void PLtsql_expr_query_mutator::run() rewritten_query += query.substr(cursor); // copy remaining expr->query // update query string - std::string new_query = antlrcpp::utf32_to_utf8(rewritten_query); + std::string new_query = antlrcpp::Utf8::lenientEncode(std::u32string_view(rewritten_query)); expr->query = pstrdup(new_query.c_str()); } diff --git a/dev-tools.sh b/dev-tools.sh index ab8681c2ab..c4ee7b3a84 100755 --- a/dev-tools.sh +++ b/dev-tools.sh @@ -187,7 +187,7 @@ init_pg() { make -j 4 make install cd contrib && make && sudo make install - cp "/usr/local/lib/libantlr4-runtime.so.4.9.3" $2/postgres/lib/ + cp "/usr/local/lib/libantlr4-runtime.so.4.13.2" $2/postgres/lib/ init_pghint $1 $2 } @@ -306,7 +306,7 @@ init_pg_coverage(){ make -j 4 make install cd contrib && make && sudo make install - sudo cp "/usr/local/lib/libantlr4-runtime.so.4.9.3" $2/postgres/lib/ + sudo cp "/usr/local/lib/libantlr4-runtime.so.4.13.2" $2/postgres/lib/ init_pghint $1 $2 } diff --git a/test/python/isolationtest/specParserVisitorImpl.py b/test/python/isolationtest/specParserVisitorImpl.py index b376331cb2..e40a063149 100644 --- a/test/python/isolationtest/specParserVisitorImpl.py +++ b/test/python/isolationtest/specParserVisitorImpl.py @@ -2,7 +2,7 @@ from .parser.specParserVisitor import specParserVisitor -# Generated from specParser.g4 by ANTLR 4.9.3 +# Generated from specParser.g4 by ANTLR 4.13.2 from antlr4 import * from .parser.specParser import specParser