From 4063c929a720ab0c379743a2073b69497964ed9f Mon Sep 17 00:00:00 2001 From: "kangrong.cn" Date: Mon, 28 Apr 2025 20:52:39 +0800 Subject: [PATCH] [feat] be compatible with MySQL 8.0.42, a temporary yet compilable version --- src/mysql/videx/CMakeLists.txt | 17 ++++++++++++++++- src/mysql/videx/ha_videx.cc | 25 ++++++++++++++++++------- src/mysql/videx/ha_videx.h | 17 ++++++++++------- 3 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/mysql/videx/CMakeLists.txt b/src/mysql/videx/CMakeLists.txt index 36286c2..8a2c327 100644 --- a/src/mysql/videx/CMakeLists.txt +++ b/src/mysql/videx/CMakeLists.txt @@ -24,13 +24,28 @@ DISABLE_MISSING_PROFILE_WARNING() ADD_DEFINITIONS(-DMYSQL_SERVER) ADD_DEFINITIONS(-DMUTEX_FUTEX) +find_library(CURL_LIBRARY + NAMES curl + PATHS /usr/lib/x86_64-linux-gnu + NO_DEFAULT_PATH + ) + +if (NOT TARGET CURL::libcurl) + add_library(CURL::libcurl UNKNOWN IMPORTED GLOBAL) + set_target_properties(CURL::libcurl PROPERTIES + IMPORTED_LOCATION "${CURL_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/extra/curl/${CURL_VERSION_DIR}/include" + ) +endif () + INCLUDE_DIRECTORIES( ${CMAKE_SOURCE_DIR}/sql ${CMAKE_SOURCE_DIR}/sql/auth ${CMAKE_SOURCE_DIR}/extra/rapidjson/include - ${CMAKE_SOURCE_DIR}/extra/curl/curl-8.1.2/include + ${CMAKE_SOURCE_DIR}/extra/curl/${CURL_VERSION_DIR}/include ) + IF (WITH_VIDEX_STORAGE_ENGINE AND NOT WITHOUT_VIDEX_STORAGE_ENGINE) # Check if the dynamic library is explicitly specified IF (PLUGIN_VIDEX STREQUAL "DYNAMIC") diff --git a/src/mysql/videx/ha_videx.cc b/src/mysql/videx/ha_videx.cc index 194026c..3f3c4fe 100644 --- a/src/mysql/videx/ha_videx.cc +++ b/src/mysql/videx/ha_videx.cc @@ -107,9 +107,14 @@ int ask_from_videx_http(VidexJsonItem &request, VidexStringMap &res_json, THD* t curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L); trace_http.add_utf8("request", request_str.c_str()); + auto start_time = std::chrono::high_resolution_clock::now(); res_code = curl_easy_perform(curl); + auto end_time = std::chrono::high_resolution_clock::now(); + ulong duration = std::chrono::duration_cast(end_time - start_time).count(); + if (res_code != CURLE_OK) { trace_http.add("success", false) + .add("elapsed_time", duration) .add_utf8("reason", "res_code != CURLE_OK") .add_utf8("detail", curl_easy_strerror(res_code)); trace_http.end(); @@ -123,18 +128,20 @@ int ask_from_videx_http(VidexJsonItem &request, VidexStringMap &res_json, THD* t if (error) { std::cout << "!__!__!__!__!__! JSON parse error: " << message << '\n'; trace_http.add("success", false) + .add("elapsed_time", duration) .add_utf8("reason", "res_json.HasParseError") .add_utf8("detail", readBuffer.c_str()); trace_http.end(); return 1; } else { if (message == "OK") { - trace_http.add("success", true).add_utf8("detail", readBuffer.c_str()); + trace_http.add("success", true).add("elapsed_time", duration).add_utf8("detail", readBuffer.c_str()); trace_http.end(); std::cout << "access videx_server success: " << host_ip << std::endl; return 0; } else { trace_http.add("success", false) + .add("elapsed_time", duration) .add_utf8("reason", "msg != OK") .add_utf8("detail", readBuffer.c_str()); trace_http.end(); @@ -145,6 +152,7 @@ int ask_from_videx_http(VidexJsonItem &request, VidexStringMap &res_json, THD* t } } trace_http.add("success", false) + .add("elapsed_time", -1) .add_utf8("reason", "curl = false"); trace_http.end(); std::cout << "access videx_server failed curl = false: " << host_ip << std::endl; @@ -266,7 +274,7 @@ static int videx_init_func(void *p) { HTON_SUPPORTS_SECONDARY_ENGINE | // Supports secondary storage engine // HTON_SUPPORTS_TABLE_ENCRYPTION | // Supports table encryption (commented out) // HTON_SUPPORTS_ONLINE_BACKUPS | // Supports online backups (commented out) - HTON_SUPPORTS_COMPRESSED_COLUMNS | // Supports compressed columns +// HTON_SUPPORTS_COMPRESSED_COLUMNS | // Supports compressed columns HTON_SUPPORTS_GENERATED_INVISIBLE_PK; // Supports generated invisible primary keys // Set the is_supported_system_table function pointer to videx_is_supported_system_table. @@ -1109,11 +1117,14 @@ int ha_videx::multi_range_read_next(char **range_info) { return (m_ds_mrr.dsmrr_next(range_info)); } -ha_rows ha_videx::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, - void *seq_init_param, - uint n_ranges, uint *bufsz, - uint *flags, - Cost_estimate *cost) { +//ha_rows ha_videx::multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, +// void *seq_init_param, +// uint n_ranges, uint *bufsz, +// uint *flags, +// Cost_estimate *cost) { +ha_rows ha_videx::multi_range_read_info_const( + uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, + uint *bufsz, uint *flags, bool *force_default_mrr, Cost_estimate *cost){ videx_log_ins.markHaFuncPassby(FUNC_FILE_LINE); /* See comments in ha_myisam::multi_range_read_info_const */ m_ds_mrr.init(table); diff --git a/src/mysql/videx/ha_videx.h b/src/mysql/videx/ha_videx.h index bb89cbb..0d1248e 100644 --- a/src/mysql/videx/ha_videx.h +++ b/src/mysql/videx/ha_videx.h @@ -171,10 +171,13 @@ class ha_videx : public handler { /** Initialize multi range read and get information. @see ha_myisam::multi_range_read_info_const @see DsMrr_impl::dsmrr_info_const */ - ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, - void *seq_init_param, uint n_ranges, - uint *bufsz, uint *flags, - Cost_estimate *cost) override; +// ha_rows multi_range_read_info_const(uint keyno, RANGE_SEQ_IF *seq, +// void *seq_init_param, uint n_ranges, +// uint *bufsz, uint *flags, +// Cost_estimate *cost) override; + virtual ha_rows multi_range_read_info_const( + uint keyno, RANGE_SEQ_IF *seq, void *seq_init_param, uint n_ranges, + uint *bufsz, uint *flags, bool *force_default_mrr, Cost_estimate *cost) override; /** Initialize multi range read and get information. @see DsMrr_impl::dsmrr_info */ @@ -345,9 +348,9 @@ uint max_supported_key_part_length( */ int index_last(uchar *buf) override; - bool has_gap_locks() const noexcept override { - videx_log_ins.markPassbyUnexpected(FUNC_FILE_LINE); - return true; } +// bool has_gap_locks() const noexcept override { +// videx_log_ins.markPassbyUnexpected(FUNC_FILE_LINE); +// return true; } /** @brief Unlike index_init(), rnd_init() can be called two consecutive times