1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-10-31 18:30:33 +03:00

MDEV-32854: Make JSON_DEPTH_LIMIT unlimited

This patch is the columnstore-part of the task. Columnstore wanted to have
previous 32 depth, so this patch aims at keeping the compatibility.
This commit is contained in:
Rucha Deodhar
2025-05-22 15:42:12 +05:30
committed by Leonid Fedorov
parent 9a2ebebaf9
commit 9fe37d5919
50 changed files with 1047 additions and 952 deletions

View File

@@ -20,12 +20,20 @@ namespace
static bool appendJSPath(std::string& ret, const json_path_t* p)
{
const json_path_step_t* c;
#if MYSQL_VERSION_ID >= 120200
const json_path_step_t* last_step= (const json_path_step_t*)
(mem_root_dynamic_array_get_val((MEM_ROOT_DYNAMIC_ARRAY*)&p->steps,
(size_t)p->last_step_idx));
#endif
try
{
ret.append("\"$");
#if MYSQL_VERSION_ID >= 120200
for (c = reinterpret_cast<json_path_step_t*>(p->steps.buffer)+1; c <= last_step; c++)
#else
for (c = p->steps + 1; c <= p->last_step; c++)
#endif
{
if (c->type & JSON_PATH_KEY)
{
@@ -132,8 +140,6 @@ std::string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bo
escape = isNullEscape ? '\\' : escapeStr.safeString("")[0];
}
json_engine_t jsEg;
json_path_t p, savPath;
const CHARSET_INFO* cs = getCharset(fp[0]);
#if MYSQL_VERSION_ID >= 100900
@@ -142,11 +148,10 @@ std::string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bo
#endif
int pathFound = 0;
initJSPaths(paths, fp, 4, 1);
for (size_t i = 4; i < fp.size(); i++)
{
JSONPath& path = paths[i - 4];
if (!path.parsed)
{
if (parseJSPath(path, row, fp[i]))
@@ -162,8 +167,13 @@ std::string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bo
while (json_get_path_next(&jsEg, &p) == 0)
{
#if MYSQL_VERSION_ID >= 100900
#if MYSQL_VERSION_ID >= 120200
if (hasNegPath && jsEg.value_type == JSON_VALUE_ARRAY &&
json_skip_array_and_count(&jsEg, arrayCounter + p.last_step_idx))
#else
if (hasNegPath && jsEg.value_type == JSON_VALUE_ARRAY &&
json_skip_array_and_count(&jsEg, arrayCounter + (p.last_step - p.steps)))
#endif
goto error;
#endif
@@ -180,7 +190,11 @@ std::string Func_json_search::getStrVal(rowgroup::Row& row, FunctionParm& fp, bo
if (pathFound == 1)
{
savPath = p;
#if MYSQL_VERSION_ID >= 120200
mem_root_dynamic_array_copy_values(&savPath.steps, &p.steps);
#else
savPath.last_step = savPath.steps + (p.last_step - p.steps);
#endif
}
else
{