This is an automated email from the ASF dual-hosted git repository. panxiaolei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new 39186fafe11 [Chore](build) remove libmysql libodbc link (#50494) 39186fafe11 is described below commit 39186fafe11e411ac652b01aeabd37162e96ea8a Author: Pxl <x...@selectdb.com> AuthorDate: Mon Apr 28 22:57:42 2025 +0800 [Chore](build) remove libmysql libodbc link (#50494) ### What problem does this PR solve? remove libmysql libodbc link but do not remove those from thirdparty (coz 2.1/3.0 may used) ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [x] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [x] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [x] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [x] No. - [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into --> --- be/CMakeLists.txt | 10 -- be/cmake/thirdparty.cmake | 4 - be/src/pipeline/CMakeLists.txt | 4 - be/src/vec/CMakeLists.txt | 4 - be/src/vec/exec/scan/mysql_scanner.cpp | 197 --------------------------------- be/src/vec/exec/scan/mysql_scanner.h | 75 ------------- build.sh | 5 - run-be-ut.sh | 1 - 8 files changed, 300 deletions(-) diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 2d981705aa8..26b86b12659 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -140,8 +140,6 @@ message(STATUS "make test: ${MAKE_TEST}") option(BUILD_BENCHMARK "ON for make google benchmark or OFF for not" OFF) message(STATUS "make benchmark: ${BUILD_BENCHMARK}") -option(WITH_MYSQL "Support access MySQL" ON) - option(BUILD_FS_BENCHMARK "ON for building fs benchmark tool or OFF for not" OFF) message(STATUS "build fs benchmark tool: ${BUILD_FS_BENCHMARK}") @@ -361,10 +359,6 @@ if (ARCH_ARM) endif() # -if (WITH_MYSQL) - add_definitions(-DDORIS_WITH_MYSQL) -endif() - if (ENABLE_INJECTION_POINT) set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -DENABLE_INJECTION_POINT") endif() @@ -612,10 +606,6 @@ set(DORIS_DEPENDENCIES ${KRB5_LIBS} ) -if (WITH_MYSQL) - set(DORIS_DEPENDENCIES ${DORIS_DEPENDENCIES} mysql) -endif() - if (USE_UNWIND) set(DORIS_DEPENDENCIES ${DORIS_DEPENDENCIES} libunwind) endif() diff --git a/be/cmake/thirdparty.cmake b/be/cmake/thirdparty.cmake index b3d9202d5b0..ace9a3a2d43 100644 --- a/be/cmake/thirdparty.cmake +++ b/be/cmake/thirdparty.cmake @@ -82,10 +82,6 @@ else() add_thirdparty(tcmalloc WHOLELIBPATH ${GPERFTOOLS_HOME}/lib/libtcmalloc.a NOTADD) endif() -if (WITH_MYSQL) - add_thirdparty(mysql LIBNAME "lib/libmysqlclient.a") -endif() - if (USE_UNWIND) add_thirdparty(libunwind LIBNAME "lib64/libunwind.a") endif() diff --git a/be/src/pipeline/CMakeLists.txt b/be/src/pipeline/CMakeLists.txt index fc69608d7af..32230077ab4 100644 --- a/be/src/pipeline/CMakeLists.txt +++ b/be/src/pipeline/CMakeLists.txt @@ -23,10 +23,6 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/pipeline") file(GLOB_RECURSE PIPELINE_FILES CONFIGURE_DEPENDS *.cpp) -if (NOT WITH_MYSQL) - list(REMOVE_ITEM PIPELINE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/exec/mysql_scan_operator.cpp) -endif () - add_library(Pipeline STATIC ${PIPELINE_FILES} ) diff --git a/be/src/vec/CMakeLists.txt b/be/src/vec/CMakeLists.txt index b40e24f7ea0..b43e1192d8c 100644 --- a/be/src/vec/CMakeLists.txt +++ b/be/src/vec/CMakeLists.txt @@ -21,10 +21,6 @@ set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/vec") file(GLOB_RECURSE VEC_FILES CONFIGURE_DEPENDS *.cpp) -if (NOT WITH_MYSQL) - list(REMOVE_ITEM VEC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/exec/vmysql_scan_node.cpp ${CMAKE_CURRENT_SOURCE_DIR}/exec/scan/mysql_scanner.cpp) -endif () - add_library(Vec STATIC ${VEC_FILES} ) diff --git a/be/src/vec/exec/scan/mysql_scanner.cpp b/be/src/vec/exec/scan/mysql_scanner.cpp deleted file mode 100644 index 3638d917f3c..00000000000 --- a/be/src/vec/exec/scan/mysql_scanner.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// 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 <mysql/mysql.h> - -#define __DorisMysql MYSQL -#define __DorisMysqlRes MYSQL_RES -#include "common/config.h" -#include "common/logging.h" -#include "mysql_scanner.h" -#include "util/md5.h" - -namespace doris::vectorized { - -MysqlScanner::MysqlScanner(const MysqlScannerParam& param) - : _my_param(param), - _my_conn(nullptr), - _my_result(nullptr), - _is_open(false), - _field_num(0) {} - -MysqlScanner::~MysqlScanner() { - if (_my_result) { - mysql_free_result(_my_result); - _my_result = nullptr; - } - - if (_my_conn) { - mysql_close(_my_conn); - _my_conn = nullptr; - } -} - -Status MysqlScanner::open() { - if (_is_open) { - LOG(INFO) << "this scanner already opened"; - return Status::OK(); - } - - _my_conn = mysql_init(nullptr); - - if (nullptr == _my_conn) { - return Status::InternalError("mysql init failed."); - } - - VLOG_CRITICAL << "MysqlScanner::Connect"; - - unsigned int mysql_ct = config::external_table_connect_timeout_sec; - mysql_options(_my_conn, MYSQL_OPT_CONNECT_TIMEOUT, &mysql_ct); - mysql_options(_my_conn, MYSQL_OPT_READ_TIMEOUT, &mysql_ct); - if (nullptr == mysql_real_connect(_my_conn, _my_param.host.c_str(), _my_param.user.c_str(), - _my_param.passwd.c_str(), _my_param.db.c_str(), - atoi(_my_param.port.c_str()), nullptr, - _my_param.client_flag)) { - Md5Digest pwd; - pwd.update(static_cast<const void*>(_my_param.passwd.c_str()), _my_param.passwd.length()); - pwd.digest(); - LOG(WARNING) << "connect Mysql: " - << "Host: " << _my_param.host << " user: " << _my_param.user - << " passwd: " << pwd.hex() << " db: " << _my_param.db - << " port: " << _my_param.port; - - return _error_status("mysql real connect failed."); - } - - if (mysql_set_character_set(_my_conn, _my_param.charset.c_str())) { - return Status::InternalError("mysql set character set failed."); - } - - _is_open = true; - - return Status::OK(); -} - -Status MysqlScanner::query(const std::string& query) { - if (!_is_open) { - return Status::InternalError("Query before open."); - } - - int sql_result = mysql_query(_my_conn, query.c_str()); - - if (0 != sql_result) { - LOG(WARNING) << "mysql query failed. query =" << query; - return _error_status("mysql query failed."); - } else { - LOG(INFO) << "mysql query success. query =" << query; - } - - // clean the last query result - if (_my_result) { - mysql_free_result(_my_result); - } - - // use store result because mysql table is small, can load in memory avoid of many RPC - _my_result = mysql_store_result(_my_conn); - - if (nullptr == _my_result) { - return _error_status("mysql store result failed."); - } - - _field_num = mysql_num_fields(_my_result); - - return Status::OK(); -} - -Status MysqlScanner::query(const std::string& table, const std::vector<std::string>& fields, - const std::vector<std::string>& filters, const uint64_t limit) { - if (!_is_open) { - return Status::InternalError("Query before open."); - } - - _sql_str = "SELECT"; - - for (int i = 0; i < fields.size(); ++i) { - if (0 != i) { - _sql_str += ","; - } - - _sql_str += " " + fields[i]; - } - - _sql_str += " FROM " + table; - - if (!filters.empty()) { - _sql_str += " WHERE "; - - for (int i = 0; i < filters.size(); ++i) { - if (0 != i) { - _sql_str += " AND"; - } - - _sql_str += " (" + filters[i] + ") "; - } - } - - if (limit != -1) { - _sql_str += " LIMIT " + std::to_string(limit); - } - - return query(_sql_str); -} - -Status MysqlScanner::get_next_row(char*** buf, unsigned long** lengths, bool* eos) { - if (!_is_open) { - return Status::InternalError("GetNextRow before open."); - } - - if (nullptr == buf || nullptr == lengths || nullptr == eos) { - return Status::InternalError("input parameter invalid."); - } - - if (nullptr == _my_result) { - return Status::InternalError("get next row before query."); - } - - *buf = mysql_fetch_row(_my_result); - - if (nullptr == *buf) { - *eos = true; - return Status::OK(); - } - - *lengths = mysql_fetch_lengths(_my_result); - - if (nullptr == *lengths) { - return _error_status("mysql fetch row failed."); - } - - *eos = false; - - return Status::OK(); -} - -Status MysqlScanner::_error_status(const std::string& prefix) { - std::stringstream msg; - msg << prefix << " Err: " << mysql_error(_my_conn); - LOG(INFO) << msg.str(); - return Status::InternalError(msg.str()); -} - -} // namespace doris::vectorized - -/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */ diff --git a/be/src/vec/exec/scan/mysql_scanner.h b/be/src/vec/exec/scan/mysql_scanner.h deleted file mode 100644 index 63c688460b8..00000000000 --- a/be/src/vec/exec/scan/mysql_scanner.h +++ /dev/null @@ -1,75 +0,0 @@ -// 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. - -#pragma once - -#include <stdlib.h> - -#include <string> -#include <vector> - -#include "common/status.h" - -#ifndef __DorisMysql -#define __DorisMysql void -#endif - -#ifndef __DorisMysqlRes -#define __DorisMysqlRes void -#endif - -namespace doris::vectorized { - -struct MysqlScannerParam { - std::string host; - std::string port; - std::string user; - std::string passwd; - std::string db; - std::string charset; - unsigned long client_flag; - MysqlScannerParam() : client_flag(0) {} -}; - -// Mysql Scanner for scan data from mysql -class MysqlScanner { -public: - MysqlScanner(const MysqlScannerParam& param); - ~MysqlScanner(); - - Status open(); - Status query(const std::string& query); - - // query for DORIS - Status query(const std::string& table, const std::vector<std::string>& fields, - const std::vector<std::string>& filters, const uint64_t limit); - Status get_next_row(char*** buf, unsigned long** lengths, bool* eos); - - int field_num() const { return _field_num; } - -private: - Status _error_status(const std::string& prefix); - - const MysqlScannerParam& _my_param; - __DorisMysql* _my_conn = nullptr; - __DorisMysqlRes* _my_result = nullptr; - std::string _sql_str; - bool _is_open; - int _field_num; -}; - -} // namespace doris::vectorized diff --git a/build.sh b/build.sh index 05a45294e79..aacd7214b38 100755 --- a/build.sh +++ b/build.sh @@ -362,9 +362,6 @@ if [[ "${CLEAN}" -eq 1 && "${BUILD_BE}" -eq 0 && "${BUILD_FE}" -eq 0 && "${BUILD exit 0 fi -if [[ -z "${WITH_MYSQL}" ]]; then - WITH_MYSQL='OFF' -fi if [[ -z "${GLIBC_COMPATIBILITY}" ]]; then if [[ "${TARGET_SYSTEM}" != 'Darwin' ]]; then GLIBC_COMPATIBILITY='ON' @@ -527,7 +524,6 @@ echo "Get params: BUILD_HIVE_UDF -- ${BUILD_HIVE_UDF} PARALLEL -- ${PARALLEL} CLEAN -- ${CLEAN} - WITH_MYSQL -- ${WITH_MYSQL} GLIBC_COMPATIBILITY -- ${GLIBC_COMPATIBILITY} USE_AVX2 -- ${USE_AVX2} USE_LIBCPP -- ${USE_LIBCPP} @@ -627,7 +623,6 @@ if [[ "${BUILD_BE}" -eq 1 ]]; then -DBUILD_BENCHMARK="${BUILD_BENCHMARK}" \ -DBUILD_FS_BENCHMARK="${BUILD_FS_BENCHMARK}" \ ${CMAKE_USE_CCACHE:+${CMAKE_USE_CCACHE}} \ - -DWITH_MYSQL="${WITH_MYSQL}" \ -DUSE_LIBCPP="${USE_LIBCPP}" \ -DBUILD_META_TOOL="${BUILD_META_TOOL}" \ -DBUILD_FILE_CACHE_MICROBENCH_TOOL="${BUILD_FILE_CACHE_MICROBENCH_TOOL}" \ diff --git a/run-be-ut.sh b/run-be-ut.sh index 9a5c1516a8c..3e50089fe5e 100755 --- a/run-be-ut.sh +++ b/run-be-ut.sh @@ -245,7 +245,6 @@ cd "${CMAKE_BUILD_DIR}" -DUSE_LIBCPP="${USE_LIBCPP}" \ -DBUILD_META_TOOL=OFF \ -DBUILD_FILE_CACHE_MICROBENCH_TOOL=OFF \ - -DWITH_MYSQL=ON \ -DUSE_DWARF="${USE_DWARF}" \ -DUSE_UNWIND="${USE_UNWIND}" \ -DUSE_MEM_TRACKER="${USE_MEM_TRACKER}" \ --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org