1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-08-04 05:02:11 +03:00
Files
mariadb-columnstore-engine/utils/funcexp/func_json_exists.cpp
Rucha Deodhar 53870ac06f json_depth
2025-06-03 15:56:47 +05:30

63 lines
1.6 KiB
C++

#include "functor_json.h"
#include "functioncolumn.h"
#include "constantcolumn.h"
#include "json_lib.h"
#include "rowgroup.h"
using namespace execplan;
using namespace rowgroup;
#include "dataconvert.h"
#include "jsonhelpers.h"
using namespace funcexp::helpers;
namespace funcexp
{
CalpontSystemCatalog::ColType Func_json_exists::operationType(FunctionParm& fp,
CalpontSystemCatalog::ColType& /*resultType*/)
{
return fp[0]->data()->resultType();
}
/**
* getBoolVal API definition
*/
bool Func_json_exists::getBoolVal(Row& row, FunctionParm& fp, bool& isNull,
CalpontSystemCatalog::ColType& /*type*/)
{
const auto js = fp[0]->data()->getStrVal(row, isNull);
if (isNull)
return false;
int jsErr = 0;
json_engine_t jsEg;
int jsEg_stack[JSON_DEPTH_LIMIT];
json_path_step_t p_steps[JSON_DEPTH_LIMIT];
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));
initJSEngine(jsEg, getCharset(fp[0]), js);
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));
if (!path.parsed && parseJSPath(path, row, fp[1]))
goto error;
if (locateJSPath(jsEg, path, &jsErr))
{
if (jsErr)
goto error;
return false;
}
return true;
error:
isNull = true;
return false;
}
} // namespace funcexp