From a8fe54b7b9cfd069b0eabd05ba52ca2b6ff9bbc4 Mon Sep 17 00:00:00 2001 From: HappenLee Date: Fri, 21 Aug 2020 21:26:14 +0800 Subject: [PATCH] [ODBC SCAN NODE] 1/4 Add unix odbc library. (#4377) --- be/CMakeLists.txt | 6 +++++- be/test/exec/CMakeLists.txt | 1 + be/test/exec/unix_odbc_test.cpp | 28 ++++++++++++++++++++++++++++ thirdparty/build-thirdparty.sh | 14 ++++++++++++++ thirdparty/vars.sh | 8 +++++++- 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 be/test/exec/unix_odbc_test.cpp diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 531dcaeb57..d56da2a7e1 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -130,6 +130,9 @@ set_target_properties(glog PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib/li add_library(re2 STATIC IMPORTED) set_target_properties(re2 PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib/libre2.a) +add_library(odbc STATIC IMPORTED) +set_target_properties(odbc PROPERTIES IMPORTED_LOCATION ${THIRDPARTY_DIR}/lib/libodbc.a) + add_library(pprof STATIC IMPORTED) set_target_properties(pprof PROPERTIES IMPORTED_LOCATION ${GPERFTOOLS_HOME}/lib/libprofiler.a) @@ -416,6 +419,7 @@ set(DORIS_DEPENDENCIES arrow parquet orc + odbc cctz ${WL_END_GROUP} ) @@ -462,7 +466,7 @@ else() endif() set(DORIS_LINK_LIBS ${DORIS_LINK_LIBS} - -lrt -lbfd -liberty -lc -lm -ldl -pthread + -lrt -lbfd -liberty -lc -lm -ldl -lltdl -pthread ) # Set libraries for test diff --git a/be/test/exec/CMakeLists.txt b/be/test/exec/CMakeLists.txt index 9c496671eb..809927e11c 100644 --- a/be/test/exec/CMakeLists.txt +++ b/be/test/exec/CMakeLists.txt @@ -58,6 +58,7 @@ ADD_BE_TEST(es_predicate_test) ADD_BE_TEST(es_query_builder_test) ADD_BE_TEST(es_scan_reader_test) #ADD_BE_TEST(schema_scan_node_test) +ADD_BE_TEST(unix_odbc_test) #ADD_BE_TEST(schema_scanner_test) ##ADD_BE_TEST(set_executor_test) #ADD_BE_TEST(schema_scanner/schema_authors_scanner_test) diff --git a/be/test/exec/unix_odbc_test.cpp b/be/test/exec/unix_odbc_test.cpp new file mode 100644 index 0000000000..a9d3f9708a --- /dev/null +++ b/be/test/exec/unix_odbc_test.cpp @@ -0,0 +1,28 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#include + +int main(int argc, char* argv[]) { + SQLRETURN ret; + SQLHENV env; + + /* Allocate an environment handle */ + ret = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env); + + return ret; +} diff --git a/thirdparty/build-thirdparty.sh b/thirdparty/build-thirdparty.sh index 9db58204cf..2058606c34 100755 --- a/thirdparty/build-thirdparty.sh +++ b/thirdparty/build-thirdparty.sh @@ -520,6 +520,19 @@ build_librdkafka() { make -j$PARALLEL && make install } +# libunixodbc +build_libunixodbc() { + check_if_source_exist $ODBC_SOURCE + + cd $TP_SOURCE_DIR/$ODBC_SOURCE + + CPPFLAGS="-I${TP_INCLUDE_DIR}" \ + LDFLAGS="-L${TP_LIB_DIR}" \ + CFLAGS="-fPIC" \ + ./configure --prefix=$TP_INSTALL_DIR --enable-static=yes + make -j$PARALLEL && make install +} + # flatbuffers build_flatbuffers() { check_if_source_exist $FLATBUFFERS_SOURCE @@ -692,6 +705,7 @@ build_cctz() { # we just comment it, instead of remove it. # build_llvm +build_libunixodbc build_libevent build_zlib build_lz4 diff --git a/thirdparty/vars.sh b/thirdparty/vars.sh index 36e64f59fb..7da6dc150c 100644 --- a/thirdparty/vars.sh +++ b/thirdparty/vars.sh @@ -188,6 +188,12 @@ BOOST_FOR_MYSQL_NAME=boost_1_59_0.tar.gz BOOST_FOR_MYSQL_SOURCE=boost_1_59_0 BOOST_FOR_MYSQL_MD5SUM="51528a0e3b33d9e10aaa311d9eb451e3" +# unix odbc +ODBC_DOWNLOAD="http://www.unixodbc.org/unixODBC-2.3.7.tar.gz" +ODBC_NAME=unixODBC-2.3.7.tar.gz +ODBC_SOURCE=unixODBC-2.3.7 +ODBC_MD5SUM="274a711b0c77394e052db6493840c6f9" + # leveldb LEVELDB_DOWNLOAD="https://github.com/google/leveldb/archive/v1.20.tar.gz" LEVELDB_NAME=leveldb-1.20.tar.gz @@ -278,5 +284,5 @@ CCTZ_SOURCE="cctz-2.3" CCTZ_MD5SUM="209348e50b24dbbdec6d961059c2fc92" # all thirdparties which need to be downloaded is set in array TP_ARCHIVES -export TP_ARCHIVES="LIBEVENT OPENSSL THRIFT LLVM CLANG COMPILER_RT PROTOBUF GFLAGS GLOG GTEST RAPIDJSON SNAPPY GPERFTOOLS ZLIB LZ4 BZIP LZO2 CURL RE2 BOOST MYSQL BOOST_FOR_MYSQL LEVELDB BRPC ROCKSDB LIBRDKAFKA FLATBUFFERS ARROW BROTLI DOUBLE_CONVERSION ZSTD S2 BITSHUFFLE CROARINGBITMAP ORC JEMALLOC CCTZ" +export TP_ARCHIVES="LIBEVENT OPENSSL THRIFT LLVM CLANG COMPILER_RT PROTOBUF GFLAGS GLOG GTEST RAPIDJSON SNAPPY GPERFTOOLS ZLIB LZ4 BZIP LZO2 CURL RE2 BOOST MYSQL BOOST_FOR_MYSQL ODBC LEVELDB BRPC ROCKSDB LIBRDKAFKA FLATBUFFERS ARROW BROTLI DOUBLE_CONVERSION ZSTD S2 BITSHUFFLE CROARINGBITMAP ORC JEMALLOC CCTZ"