Skip to content

Commit

Permalink
Add OGR HANA database driver (#5107)
Browse files Browse the repository at this point in the history
- Add support for SAP HANA Spatial
- autoconf and CMake build suport
- Requires to link GDAL against https://github.com/SAP/odbc-cpp-wrapper
  • Loading branch information
mrylov authored Mar 31, 2022
1 parent 0aad946 commit 9ae51c6
Show file tree
Hide file tree
Showing 36 changed files with 7,734 additions and 6 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/asan/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ fi


sudo apt-get update
sudo apt-get install -y --allow-unauthenticated libpng-dev libjpeg-dev libgif-dev liblzma-dev libgeos-dev libcurl4-gnutls-dev libproj-dev libxml2-dev libexpat1-dev libxerces-c-dev libnetcdf-dev netcdf-bin libpoppler-dev libpoppler-private-dev libsqlite3-dev gpsbabel swig libhdf4-alt-dev libhdf5-dev libpodofo-dev poppler-utils libfreexl-dev unixodbc-dev libwebp-dev libepsilon-dev liblcms2-2 libpcre3-dev libcrypto++-dev libdap-dev libfyba-dev libmysqlclient-dev libogdi-dev libcfitsio-dev openjdk-8-jdk libzstd-dev ccache curl autoconf automake sqlite3 libspatialite-dev make g++ libssl-dev libsfcgal-dev libgeotiff-dev libopenjp2-7-dev libcairo2-dev python3-dev python3-setuptools python3-numpy python3-pip clang
sudo apt-get install -y --allow-unauthenticated libpng-dev libjpeg-dev libgif-dev liblzma-dev libgeos-dev libcurl4-gnutls-dev libproj-dev libxml2-dev libexpat1-dev libxerces-c-dev libnetcdf-dev netcdf-bin libpoppler-dev libpoppler-private-dev libsqlite3-dev gpsbabel swig libhdf4-alt-dev libhdf5-dev libpodofo-dev poppler-utils libfreexl-dev unixodbc-dev libwebp-dev libepsilon-dev liblcms2-2 libpcre3-dev libcrypto++-dev libdap-dev libfyba-dev libmysqlclient-dev libogdi-dev libcfitsio-dev openjdk-8-jdk libzstd-dev ccache curl autoconf automake sqlite3 libspatialite-dev make g++ libssl-dev libsfcgal-dev libgeotiff-dev libopenjp2-7-dev libcairo2-dev python3-dev python3-setuptools python3-numpy python3-pip clang git

# Workaround bug in ogdi packaging
sudo ln -s /usr/lib/ogdi/libvrf.so /usr/lib

# Build odbc-cpp library for HANA
(wget https://github.com/Kitware/CMake/releases/download/v3.12.4/cmake-3.12.4-Linux-x86_64.sh -O cmake.sh)
(sudo sh cmake.sh --prefix=/usr/local/ --exclude-subdir)
(git clone https://github.com/SAP/odbc-cpp-wrapper.git && mkdir odbc-cpp-wrapper/build && cd odbc-cpp-wrapper/build && cmake .. && make -j 2 && make install)

wget https://github.com/Esri/file-geodatabase-api/raw/master/FileGDB_API_1.5/FileGDB_API_1_5_64gcc51.tar.gz
tar xzf FileGDB_API_1_5_64gcc51.tar.gz
sudo cp FileGDB_API-64gcc51/lib/* /usr/lib
Expand Down Expand Up @@ -66,7 +71,7 @@ ccache -s

./autogen.sh
SANITIZE_FLAGS="-DMAKE_SANITIZE_HAPPY -fsanitize=undefined -fsanitize=address -fsanitize=unsigned-integer-overflow"
CFLAGS=$SANITIZE_FLAGS CXXFLAGS=$SANITIZE_FLAGS LDFLAGS="-fsanitize=undefined -fsanitize=address -lstdc++" ./configure --prefix=/usr --without-libtool --enable-debug --with-jpeg12 --with-poppler --without-podofo --with-spatialite --with-mysql --with-liblzma --with-webp --with-epsilon --with-libtiff=internal --with-rename-internal-libtiff-symbols --with-hide-internal-symbols --with-gnm --with-fgdb=$PWD/FileGDB_API-64gcc51
CFLAGS=$SANITIZE_FLAGS CXXFLAGS=$SANITIZE_FLAGS LDFLAGS="-fsanitize=undefined -fsanitize=address -lstdc++" ./configure --prefix=/usr --without-libtool --enable-debug --with-jpeg12 --with-poppler --without-podofo --with-spatialite --with-mysql --with-liblzma --with-webp --with-epsilon --with-libtiff=internal --with-rename-internal-libtiff-symbols --with-hide-internal-symbols --with-gnm --with-fgdb=$PWD/FileGDB_API-64gcc51 --with-hana
sed -i "s/-fsanitize=address/-fsanitize=address -shared-libasan/g" GDALmake.opt
sed -i "s/-fsanitize=unsigned-integer-overflow/-fsanitize=unsigned-integer-overflow -fno-sanitize-recover=unsigned-integer-overflow/g" GDALmake.opt
make USER_DEFS="-Werror" -j$NPROC
Expand Down Expand Up @@ -101,6 +106,7 @@ rm -f ogr/ogr_fgdb.py ogr/ogr_pgeo.py

# install test dependencies
sudo python3 -m pip install -U -r ./requirements.txt
sudo python3 -m pip install -U hdbcli

# Run each module in its own pytest process.
# This makes sure the output from the address sanitizer is relevant
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/cmake_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ jobs:
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 ACCEPT_EULA=Y apt-get install -y msodbcsql17 unixodbc-dev
# HANA: client side
# Install hdbsql tool
curl -v -j -k -s -L -H "Cookie: eula_3_1_agreed=tools.hana.ondemand.com/developer-license-3_1.txt" https://tools.hana.ondemand.com/additional/hanaclient-latest-linux-x64.tar.gz --output hanaclient-latest-linux-x64.tar.gz \
&& tar -xvf hanaclient-latest-linux-x64.tar.gz \
&& sudo mkdir /usr/sap \
&& sudo ./client/hdbinst -a client --sapmnt=/usr/sap \
&& rm -rf client \
&& rm hanaclient*
export PATH=/usr/sap/hdbclient:$PATH
# Download and compile odbc-cpp-wrapper
sudo apt-get install -y -q cmake
git clone https://github.com/SAP/odbc-cpp-wrapper.git \
&& mkdir odbc-cpp-wrapper/build \
&& cd odbc-cpp-wrapper/build \
&& /usr/bin/cmake .. \
&& make -j 2 \
&& sudo make install
sudo ldconfig
#
# Workaround bug in ogdi packaging
sudo ln -s /usr/lib/ogdi/libvrf.so /usr/lib
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/ubuntu_20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
ubuntu_20_04_build:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]')"
env:
HANA_CONNECTION_STR: "DRIVER=/usr/sap/hdbclient/libodbcHDB.so;HOST=917df316-4e01-4a10-be54-eac1b6ab15fb.hana.prod-us10.hanacloud.ondemand.com;PORT=443;USER=GDALCI;PASSWORD=Z2!.S-bN]vh62\\G"
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -81,7 +83,7 @@ jobs:

- name: Run pytest
# --security-opt seccomp=unconfined, so that the userfaulfd syscall is available
run: docker run -e CI -e TRAVIS=yes -e TRAVIS_BRANCH=ubuntu_2004 -e GITHUB_WORKFLOW --security-opt seccomp=unconfined --rm gdal sh -c "cd /build/autotest && pip3 install -U -r requirements.txt && pytest"
run: docker run -e CI -e TRAVIS=yes -e TRAVIS_BRANCH=ubuntu_2004 -e GITHUB_WORKFLOW -e OGR_HANA_CONNECTION_STRING=${HANA_CONNECTION_STR} --security-opt seccomp=unconfined --rm gdal sh -c "cd /build/autotest && pip3 install -U -r requirements.txt && pip3 install -U hdbcli && pytest"

- name: Build fake ossfuzz fuzzers
run: docker run --rm gdal sh -c "cd /build/fuzzers && make dummyfuzzers_dynamic"
18 changes: 18 additions & 0 deletions .github/workflows/ubuntu_20.04/build-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,22 @@ wget -q https://github.com/rouault/pdfium_build_gdal_3_5/releases/download/v1_pd
&& apt-get install -y --fix-missing --no-install-recommends liblcms2-dev \
&& rm -rf /var/lib/apt/lists/*

# HANA: client side
# Install hdbsql tool
curl -v -j -k -s -L -H "Cookie: eula_3_1_agreed=tools.hana.ondemand.com/developer-license-3_1.txt" https://tools.hana.ondemand.com/additional/hanaclient-latest-linux-x64.tar.gz --output hanaclient-latest-linux-x64.tar.gz \
&& tar -xvf hanaclient-latest-linux-x64.tar.gz \
&& mkdir /usr/sap \
&& ./client/hdbinst -a client --sapmnt=/usr/sap \
&& rm -rf client \
&& rm hanaclient*
export PATH=/usr/sap/hdbclient:$PATH

# Download and compile odbc-cpp-wrapper
git clone https://github.com/SAP/odbc-cpp-wrapper.git \
&& mkdir odbc-cpp-wrapper/build \
&& cd odbc-cpp-wrapper/build \
&& cmake .. \
&& make -j 2 \
&& make install

ldconfig
1 change: 1 addition & 0 deletions .github/workflows/ubuntu_20.04/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ cd /build
--with-poppler \
--with-spatialite \
--with-mysql \
--with-hana \
--with-liblzma \
--with-webp \
--with-epsilon \
Expand Down
8 changes: 8 additions & 0 deletions GDALmake.opt.in
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ MYSQL_LIB = @MYSQL_LIB@
MYSQL_INC = @MYSQL_INC@
LIBS += $(MYSQL_LIB)

#
# SAP HANA support
#
HAVE_HANA = @HAVE_HANA@
ODBCCPP_LIB = @ODBCCPP_LIB@
ODBCCPP_INC = @ODBCCPP_INC@
LIBS += $(ODBCCPP_LIB)

#
# HDF4 Support.
#
Expand Down
Loading

0 comments on commit 9ae51c6

Please sign in to comment.