1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-17 09:41:06 +03:00

fix to compile with MDEV-32854 in 12.1

This commit is contained in:
Sergei Golubchik
2025-06-10 10:26:17 +02:00
parent 9763b12651
commit fba7e46a65
24 changed files with 493 additions and 14 deletions

View File

@@ -1,6 +1,8 @@
#include "functor_json.h"
#include "functioncolumn.h"
#include "constantcolumn.h"
#include "json_lib.h"
#include "my_sys.h"
using namespace execplan;
#include "rowgroup.h"
@@ -32,9 +34,19 @@ string Func_json_array_insert::getStrVal(rowgroup::Row& row, FunctionParm& fp, b
json_engine_t jsEg;
string retJS;
retJS.reserve(js.length() + 8);
#if MYSQL_VERSION_ID >= 120100
json_path_step_t p_steps[JSON_DEPTH_LIMIT];
int jsEg_stack[JSON_DEPTH_LIMIT];
#endif
initJSPaths(paths, fp, 1, 2);
#if MYSQL_VERSION_ID >= 120100
mem_root_dynamic_array_init(NULL, PSI_INSTRUMENT_MEM | MY_INIT_BUFFER_USED | MY_BUFFER_NO_RESIZE,
&jsEg.stack, sizeof(int), &jsEg_stack,
JSON_DEPTH_LIMIT, 0, MYF(0));
#endif
utils::NullString tmpJS(js);
for (size_t i = 1, j = 0; i < fp.size(); i += 2, j++)
{
@@ -43,19 +55,37 @@ string Func_json_array_insert::getStrVal(rowgroup::Row& row, FunctionParm& fp, b
JSONPath& path = paths[j];
if (!path.parsed)
{
if (parseJSPath(path, row, fp[i]) || path.p.last_step - 1 < path.p.steps ||
#if MYSQL_VERSION_ID >= 120100
mem_root_dynamic_array_init(NULL, PSI_INSTRUMENT_MEM | MY_INIT_BUFFER_USED | MY_BUFFER_NO_RESIZE,
&path.p.steps, sizeof(json_path_step_t), &p_steps,
JSON_DEPTH_LIMIT, 0, MYF(0));
json_path_step_t *last_step= (json_path_step_t*)(mem_root_dynamic_array_get_val(&path.p.steps, path.p.last_step_idx)),
*initial_step= (json_path_step_t*)path.p.steps.buffer;
#endif
#if MYSQL_VERSION_ID >= 120100
if (parseJSPath(path, row, fp[i]) || (last_step - 1) < initial_step ||
last_step->type != JSON_PATH_ARRAY)
#else
if (parseJSPath(path, row, fp[i]) || path.p.last_step - 1 < path.p.steps ||
path.p.last_step->type != JSON_PATH_ARRAY)
#endif
{
if (path.p.s.error == 0)
path.p.s.error = SHOULD_END_WITH_ARRAY;
goto error;
}
#if MYSQL_VERSION_ID >= 120100
path.p.last_step_idx--;
#else
path.p.last_step--;
#endif
}
initJSEngine(jsEg, cs, tmpJS);
#if MYSQL_VERSION_ID < 120100
path.currStep = path.p.steps;
#endif
int jsErr = 0;
if (locateJSPath(jsEg, path, &jsErr))
@@ -82,7 +112,13 @@ string Func_json_array_insert::getStrVal(rowgroup::Row& row, FunctionParm& fp, b
while (json_scan_next(&jsEg) == 0 && jsEg.state != JST_ARRAY_END)
{
DBUG_ASSERT(jsEg.state == JST_VALUE);
#if MYSQL_VERSION_ID >= 120100
if (itemSize == (((json_path_step_t*)
(mem_root_dynamic_array_get_val(&path.p.steps,
path.p.last_step_idx)))[1].n_item))
#else
if (itemSize == path.p.last_step[1].n_item)
#endif
{
itemPos = (const char*)jsEg.s.c_str;
break;