Skip to content

Commit

Permalink
Raw copy of Extensions in Engine
Browse files Browse the repository at this point in the history
Signed-off-by: 3manuek <[email protected]>
  • Loading branch information
3manuek committed Jun 20, 2022
1 parent beff6d5 commit a85a874
Show file tree
Hide file tree
Showing 1,784 changed files with 471,529 additions and 20 deletions.
174 changes: 154 additions & 20 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,168 @@
name: CI

name: JDBC Unit Tests
on:
push:
branches:
- _BABEL_1_X_DEV__PG_13_6_distro
pull_request:
branches:
- BABEL_1_X_DEV__13_4
- _BABEL_1_X_DEV__PG_13_6_distro

env:
ANTLR4_VERSION: 4.9.3
REPOSITORY: BABEL_1_X_DEV__PG_13_6
PG_SRC: /home/runner/work/${REPOSITORY}/${REPOSITORY}


jobs:
build-and-run-tests:
name: Build and run tests
extension-tests:
name: Build and test
runs-on: ubuntu-latest
steps:
- name: clone-repository
uses: actions/checkout@v2
- name: build-postgres
- uses: actions/checkout@v2
- name: Requirements
run: |
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - && \
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
sudo apt-get update && sudo apt install -y --no-install-recommends \
build-essential flex libxml2-dev libxml2-utils \
libxslt-dev libssl-dev \
libreadline-dev zlib1g-dev libldap2-dev libpam0g-dev gettext \
uuid uuid-dev cmake lld apt-utils \
libossp-uuid-dev gnulib bison \
xsltproc icu-devtools libicu66 libicu-dev gawk curl \
openjdk-8-jre openssl g++ \
libssl-dev python-dev libpq-dev \
pkg-config unzip libutfcpp-dev gnupg mssql-tools unixodbc-dev
export PATH=/opt/mssql-tools/bin:$PATH
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '8'
check-latest: true
- name: Copy ANTLR jar file
run: |
cd contrib/babelfishpg_tsql/antlr/thirdparty/antlr/
sudo cp antlr-${ANTLR4_VERSION}-complete.jar /usr/local/lib
- name: Compile ANTLR
run: |
cd ..
wget http://www.antlr.org/download/antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip
unzip -d antlr4 antlr4-cpp-runtime-${ANTLR4_VERSION}-source.zip
cd antlr4
mkdir build && cd build
cmake .. -D ANTLR_JAR_LOCATION=/usr/local/lib/antlr-${ANTLR4_VERSION}-complete.jar -DCMAKE_INSTALL_PREFIX=/usr/local -DWITH_DEMO=True
make -j 4
sudo make install
# cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION} ~/postgres/lib/
- name: Build, and binary installation
run: |
./configure
make world-bin -j8
- name: run-tests
# CFLAGS="${CFLAGS:--Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic}"
./configure CFLAGS="-ggdb" \
--prefix=$HOME/postgres/ \
--enable-debug \
--with-ldap \
--with-libxml \
--with-pam \
--with-uuid=ossp \
--enable-nls \
--with-libxslt \
--with-icu
# Removed due to incompatibility with BABEL-2785 test, as host_os function
# uses the version string to extract the OS.
#--with-extra-version=" Babelfish for PostgreSQL"
make clean && make DESTDIR=~/postgres/ -j 4 2>error.txt
# make check
sudo make install
cd contrib && make -j 4 && sudo make install
- name: Build antlr
run: |
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
#PG_SRC=~/work/${REPOSITORY}
export PG_SRC=/home/runner/work/${REPOSITORY}/${REPOSITORY}/
export PG_CONFIG=~/postgres/bin/pg_config
cmake=$(which cmake)
# Copy runtime in Postgres lib
sudo cp /usr/local/lib/libantlr4-runtime.so.${ANTLR4_VERSION} ~/postgres/lib
cd ${PG_SRC}/contrib/babelfishpg_tsql/antlr
cmake -Wno-dev .
make all
- name: Compile and Install Extensions
run: |
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
export PG_SRC=/home/runner/work/${REPOSITORY}/${REPOSITORY}/
export PG_CONFIG=~/postgres/bin/pg_config
# cmake=$(which cmake)
cd ${PG_SRC}/contrib
for ext in babelfishpg_common babelfishpg_money babelfishpg_tds babelfishpg_tsql
do
cd $ext
make -j ${JOBS}
sudo make PG_CONFIG=${PG_CONFIG} install
cd ..
done
- name: Install extensions
run: |
cd ~
sudo chown -R runner: ~/postgres
~/postgres/bin/initdb -D ~/postgres/data/ -E "UTF8"
~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile start
cd postgres/data
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" postgresql.conf
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = 'babelfishpg_tds'/g" postgresql.conf
ipaddress=$(ifconfig eth0 | grep 'inet ' | cut -d: -f2 | awk '{ print $2}')
sudo echo "host all all $ipaddress/32 trust" >> pg_hba.conf
~/postgres/bin/pg_ctl -D ~/postgres/data/ -l logfile restart
sudo ~/postgres/bin/psql -d postgres -U runner -c "CREATE USER jdbc_user WITH SUPERUSER CREATEDB CREATEROLE PASSWORD '12345678' INHERIT;"
sudo ~/postgres/bin/psql -d postgres -U runner -c "DROP DATABASE IF EXISTS jdbc_testdb;"
sudo ~/postgres/bin/psql -d postgres -U runner -c "CREATE DATABASE jdbc_testdb OWNER jdbc_user;"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "set allow_system_table_mods = on;"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "CREATE EXTENSION IF NOT EXISTS "babelfishpg_tds" CASCADE;"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "GRANT ALL ON SCHEMA sys to jdbc_user;"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "ALTER USER jdbc_user CREATEDB;"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "ALTER SYSTEM SET babelfishpg_tsql.database_name = 'jdbc_testdb';"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "SELECT pg_reload_conf();"
sudo ~/postgres/bin/psql -d jdbc_testdb -U runner -c "CALL sys.initialize_babelfish('jdbc_user');"
sqlcmd -S localhost -U jdbc_user -P 12345678 -Q "SELECT @@version GO"
- name: Run JDBC test framework
timeout-minutes: 15
run: |
export PG_SRC=/home/runner/work/${REPOSITORY}/${REPOSITORY}/
cd ${PG_SRC}/contrib/test/JDBC/
mvn test
- name: Upload log
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: postgres-log
path: ~/postgres/data/logfile
# The test summary files contain paths with ':' characters, which is not allowed with the upload-artifact actions
- name: Rename test summary files
if: ${{ failure() }}
run: |
make check -j8
- name: upload-test-summary
if: failure()
cd ${PG_SRC}/contrib/test/JDBC/Info
timestamp=`ls -Art | tail -n 1`
cd $timestamp
mv $timestamp.diff ../output-diff.diff
mv "$timestamp"_runSummary.log ../run-summary.log
- name: Upload run summary
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: regression-summary
path: src/test/regress/regression.out
- name: upload-test-differences
if: failure()
name: run-summary.log
path: contrib/test/JDBC/Info/run-summary.log
- name: Upload output diff
if: ${{ failure() }}
uses: actions/upload-artifact@v2
with:
name: regression-differences
path: src/test/regress/regression.diffs
name: output-diff.diff
path: contrib/test/JDBC/Info/output-diff.diff
89 changes: 89 additions & 0 deletions contrib/babelfishpg_common/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
include Version.config

EXTENSION = babelfishpg_common
EXTVERSION = $(BBFPGCMN_MAJOR_VERSION).$(BBFPGCMN_MINOR_VERSION).$(BBFPGCMN_MICRO_VERSION)

# Note:
# Set PREV_EXTVERSION after release, i.e after release of 2.0.0, set PREV_EXTVERSION to 1.0.0
# babel_upgrade test target should at the top of the src/test/regress/babel_schedule
# src/test/regress/sql/babel_upgrade.sql should be modified to include the PREV_EXTVERSION to test the upgrade path
# contrib/babelfishpg_tsql/sql/upgrades/$(EXTENSION)--$(PREV_EXTVERSION).sql should be present to test the upgrade path
PREV_EXTVERSION = 1.0.0
MODULEPATH = $$libdir/$(EXTENSION)-$(BBFPGCMN_MAJOR_VERSION)
MODULE_big = $(EXTENSION)

PG_CFLAGS += -g

ifdef PREV_EXTVERSION
DATA = sql/$(EXTENSION)--$(PREV_EXTVERSION).sql
endif

DATA_built = \
$(EXTENSION).control \
sql/$(EXTENSION)--$(EXTVERSION).sql

OBJS = src/babelfishpg_common.o
OBJS += src/varchar.o
OBJS += src/bit.o
OBJS += src/instr.o
OBJS += src/typecode.o
OBJS += src/numeric.o
OBJS += src/varbinary.o
OBJS += src/uniqueidentifier.o
OBJS += src/datetime.o
OBJS += src/datetime2.o
OBJS += src/smalldatetime.o
OBJS += src/datetimeoffset.o
OBJS += src/sqlvariant.o
OBJS += src/coerce.o

PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

MODULEPATH = $$libdir/$(EXTENSION)-$(BBFPGCMN_MAJOR_VERSION)

UPGRADES = $(patsubst sql/upgrades/%.sql,sql/%.sql,$(wildcard sql/upgrades/*.sql))

ifdef PREV_EXTVERSION
DATA = sql/$(EXTENSION)--$(PREV_EXTVERSION).sql
endif

DATA_built = \
$(EXTENSION).control \
sql/$(EXTENSION)--$(EXTVERSION).sql $(UPGRADES)

#include ../Makefile.common

# Get Postgres version, as well as major (9.4, etc) version. Remove '.' from MAJORVER.
VERSION = $(shell $(PG_CONFIG) --version | awk '{print $$2}' | sed -e 's/devel$$//')
MAJORVER = $(shell echo $(VERSION) | cut -d . -f1,2 | tr -d .)

# Function for testing a condition
test = $(shell test $(1) $(2) $(3) && echo yes || echo no)

GE91 = $(call test, $(MAJORVER), -ge, 91)

PGXS := $(shell $(PG_CONFIG) --pgxs)
include $(PGXS)

ifeq ($(GE91),yes)
all: sql/$(EXTENSION)--$(EXTVERSION).sql $(UPGRADES)
endif

$(EXTENSION).control: $(EXTENSION).control.in
cat $< \
| sed -e 's|@EXTVERSION@|$(EXTVERSION)|g' \
| sed -e 's|@EXTENSION@|$(EXTENSION)|g' \
| sed -e 's|@MODULEPATH@|$(MODULEPATH)|g' \
> $@

sql/$(EXTENSION)--$(EXTVERSION).sql: sql/$(EXTENSION).in
cpp $< | sed 's/^# /-- /g' > $@

sql/%.sql: sql/upgrades/%.sql
cp $< $@


CFLAGS = `$(PG_CONFIG) --includedir-server`

$(recurse)
4 changes: 4 additions & 0 deletions contrib/babelfishpg_common/Version.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BBFPGCMN_MAJOR_VERSION=1
BBFPGCMN_MINOR_VERSION=2
BBFPGCMN_MICRO_VERSION=1

7 changes: 7 additions & 0 deletions contrib/babelfishpg_common/babelfishpg_common.control.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# TSQL Datatype extension
comment = 'Transact SQL Datatype Support'
default_version = '@EXTVERSION@'
module_pathname = '@MODULEPATH@'
relocatable = true
superuser = true
requires = ''
Loading

0 comments on commit a85a874

Please sign in to comment.