From bb833ac9f6f0a8155aa74fe7ea00a88e98c3ec71 Mon Sep 17 00:00:00 2001 From: Leonid Fedorov Date: Fri, 30 May 2025 12:34:17 +0000 Subject: [PATCH] chore(build) : fix debug build with MYSQL_VERSION_ID >= 10090 --- dbcon/mysql/ha_mcs.cpp | 8 ++++---- utils/funcexp/func_json_contains_path.cpp | 8 ++++---- utils/funcexp/func_json_extract.cpp | 10 +++++----- utils/funcexp/func_json_search.cpp | 8 ++++---- utils/funcexp/funcexp.cpp | 4 ++-- utils/funcexp/functor_json.h | 7 ------- utils/funcexp/jsonhelpers.cpp | 6 +++--- utils/funcexp/jsonhelpers.h | 2 +- 8 files changed, 23 insertions(+), 30 deletions(-) diff --git a/dbcon/mysql/ha_mcs.cpp b/dbcon/mysql/ha_mcs.cpp index 96bc29b80..8c8e4563e 100644 --- a/dbcon/mysql/ha_mcs.cpp +++ b/dbcon/mysql/ha_mcs.cpp @@ -1830,14 +1830,14 @@ static int columnstore_init_func(void* p) LEX_CSTRING name = {STRING_WITH_LEN("INNODB")}; auto* plugin_innodb = ha_resolve_by_name(0, &name, 0); -#ifdef MYSQL_GE_1009 - if (!plugin_innodb || (*plugin_innodb)->state != PLUGIN_IS_READY) +#if !defined(DBUG_OFF) || MYSQL_VERSION_ID >= 100900 + if (!plugin_innodb || (*plugin_innodb)->state != PLUGIN_IS_READY) #else - if (!plugin_innodb || plugin_innodb->state != PLUGIN_IS_READY) + if (!plugin_innodb || plugin_innodb->state != PLUGIN_IS_READY) #endif { DBUG_RETURN(HA_ERR_RETRY_INIT); - } + } strncpy(cs_version, columnstore_version.c_str(), sizeof(cs_version) - 1); cs_version[sizeof(cs_version) - 1] = 0; diff --git a/utils/funcexp/func_json_contains_path.cpp b/utils/funcexp/func_json_contains_path.cpp index 35106ac2f..65cd28ada 100644 --- a/utils/funcexp/func_json_contains_path.cpp +++ b/utils/funcexp/func_json_contains_path.cpp @@ -34,7 +34,7 @@ bool Func_json_contains_path::getBoolVal(Row& row, FunctionParm& fp, bool& isNul const string_view js = js_ns.unsafeStringRef(); -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 int arrayCounters[JSON_DEPTH_LIMIT]; bool hasNegPath = false; #endif @@ -76,7 +76,7 @@ bool Func_json_contains_path::getBoolVal(Row& row, FunctionParm& fp, bool& isNul isNull = true; return false; } -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 hasNegPath |= path.p.types_used & JSON_PATH_NEGATIVE_INDEX; #endif } @@ -98,7 +98,7 @@ bool Func_json_contains_path::getBoolVal(Row& row, FunctionParm& fp, bool& isNul while (json_get_path_next(&jsEg, &p) == 0) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 if (hasNegPath && jsEg.value_type == JSON_VALUE_ARRAY && json_skip_array_and_count(&jsEg, arrayCounters + (p.last_step - p.steps))) { @@ -110,7 +110,7 @@ bool Func_json_contains_path::getBoolVal(Row& row, FunctionParm& fp, bool& isNul for (int restSize = argSize, curr = 0; restSize > 0; restSize--, curr++) { JSONPath& path = paths[curr]; -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 int cmp = cmpJSPath(&path.p, &p, jsEg.value_type, arrayCounters); #else int cmp = cmpJSPath(&path.p, &p, jsEg.value_type); diff --git a/utils/funcexp/func_json_extract.cpp b/utils/funcexp/func_json_extract.cpp index f2975a8ee..5e6e9dfa9 100644 --- a/utils/funcexp/func_json_extract.cpp +++ b/utils/funcexp/func_json_extract.cpp @@ -29,7 +29,7 @@ int Func_json_extract::doExtract(Row& row, FunctionParm& fp, json_value_types* t bool mayMulVal; int wildcards; bool isMatch; -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 int arrayCounter[JSON_DEPTH_LIMIT]; bool hasNegPath = false; #endif @@ -45,12 +45,12 @@ int Func_json_extract::doExtract(Row& row, FunctionParm& fp, json_value_types* t if (!path.parsed && parseJSPath(path, row, fp[i])) return 1; -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 hasNegPath |= path.p.types_used & JSON_PATH_NEGATIVE_INDEX; #endif } -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 wildcards = (JSON_PATH_WILD | JSON_PATH_DOUBLE_WILD | JSON_PATH_ARRAY_RANGE); #else wildcards = (JSON_PATH_WILD | JSON_PATH_DOUBLE_WILD); @@ -70,13 +70,13 @@ int Func_json_extract::doExtract(Row& row, FunctionParm& fp, json_value_types* t while (json_get_path_next(&jsEg, &p) == 0) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 if (hasNegPath && jsEg.value_type == JSON_VALUE_ARRAY && json_skip_array_and_count(&jsEg, arrayCounter + (p.last_step - p.steps))) return 1; #endif -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 isMatch = matchJSPath(paths, &p, jsEg.value_type, arrayCounter, false); #else isMatch = matchJSPath(paths, &p, jsEg.value_type, nullptr, false); diff --git a/utils/funcexp/func_json_search.cpp b/utils/funcexp/func_json_search.cpp index dea9214ab..efad86fa5 100644 --- a/utils/funcexp/func_json_search.cpp +++ b/utils/funcexp/func_json_search.cpp @@ -136,7 +136,7 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i json_path_t p, savPath; const CHARSET_INFO* cs = getCharset(fp[0]); -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 int arrayCounter[JSON_DEPTH_LIMIT]; bool hasNegPath = 0; #endif @@ -151,7 +151,7 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i { if (parseJSPath(path, row, fp[i])) goto error; -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 hasNegPath |= path.p.types_used & JSON_PATH_NEGATIVE_INDEX; #endif } @@ -161,7 +161,7 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i while (json_get_path_next(&jsEg, &p) == 0) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 if (hasNegPath && jsEg.value_type == JSON_VALUE_ARRAY && json_skip_array_and_count(&jsEg, arrayCounter + (p.last_step - p.steps))) goto error; @@ -169,7 +169,7 @@ string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bool& i if (json_value_scalar(&jsEg)) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 bool isMatch = matchJSPath(paths, &p, jsEg.value_type, arrayCounter); #else bool isMatch = matchJSPath(paths, &p, jsEg.value_type); diff --git a/utils/funcexp/funcexp.cpp b/utils/funcexp/funcexp.cpp index 82f6003d8..7656a3562 100644 --- a/utils/funcexp/funcexp.cpp +++ b/utils/funcexp/funcexp.cpp @@ -163,7 +163,7 @@ FuncExp::FuncExp() fFuncMap["json_merge_preserve"] = new Func_json_merge(); fFuncMap["json_normalize"] = new Func_json_normalize(); fFuncMap["json_object"] = new Func_json_object(); -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 fFuncMap["json_overlaps"] = new Func_json_overlaps(); #endif fFuncMap["json_query"] = new Func_json_query(); @@ -218,7 +218,7 @@ FuncExp::FuncExp() fFuncMap["regexp"] = new Func_regexp(); fFuncMap["regexp_instr"] = new Func_regexp_instr(); fFuncMap["regexp_replace"] = new Func_regexp_replace(); - fFuncMap["regexp_substr"] = new Func_regexp_substr(); // dlh + fFuncMap["regexp_substr"] = new Func_regexp_substr(); // dlh fFuncMap["repeat"] = new Func_repeat(); // dlh fFuncMap["replace"] = new Func_replace(); // dlh fFuncMap["replace_oracle"] = new Func_replace_oracle(); // dlh diff --git a/utils/funcexp/functor_json.h b/utils/funcexp/functor_json.h index 0c1b0d9a2..55c4d1b5f 100644 --- a/utils/funcexp/functor_json.h +++ b/utils/funcexp/functor_json.h @@ -12,13 +12,6 @@ #include "functor_int.h" #include "functor_str.h" -// Check if mariadb version >= 10.9 -#if MYSQL_VERSION_ID >= 100900 -#ifndef MYSQL_GE_1009 -#define MYSQL_GE_1009 -#endif -#endif - namespace funcexp { // The json_path_t wrapper include some flags diff --git a/utils/funcexp/jsonhelpers.cpp b/utils/funcexp/jsonhelpers.cpp index 99862d184..760a0c3d1 100644 --- a/utils/funcexp/jsonhelpers.cpp +++ b/utils/funcexp/jsonhelpers.cpp @@ -13,7 +13,7 @@ int setupJSPath(json_path_t* path, CHARSET_INFO* cs, const utils::NullString& st if (!err) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 bool support = (path->types_used & (JSON_PATH_WILD | JSON_PATH_DOUBLE_WILD | JSON_PATH_ARRAY_RANGE)) == 0; #else bool support = (path->types_used & (JSON_PATH_WILD | JSON_PATH_DOUBLE_WILD)) == 0; @@ -252,7 +252,7 @@ int cmpPartJSPath(const json_path_step_t* a, const json_path_step_t* aEnd, const { if (b->type & JSON_PATH_ARRAY) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 int ret = 0, corrected_n_item_a = 0; if (arraySize) corrected_n_item_a = a->n_item < 0 ? arraySize[b - tmpB] + a->n_item : a->n_item; @@ -360,7 +360,7 @@ bool matchJSPath(const vector& paths, const json_path_t* p, j { for (size_t curr = 0; curr < paths.size(); curr++) { -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 int cmp = cmpJSPath(&paths[curr].p, p, valType, arrayCounter); #else int cmp = cmpJSPath(&paths[curr].p, p, valType); diff --git a/utils/funcexp/jsonhelpers.h b/utils/funcexp/jsonhelpers.h index 7e11c574f..2756925b8 100644 --- a/utils/funcexp/jsonhelpers.h +++ b/utils/funcexp/jsonhelpers.h @@ -49,7 +49,7 @@ static const int TRIVIAL_PATH_NOT_ALLOWED = 3; bool findKeyInObject(json_engine_t* jsEg, json_string_t* key); -#ifdef MYSQL_GE_1009 +#if MYSQL_VERSION_ID >= 100900 using IntType = int; #else using IntType = uint;