summaryrefslogtreecommitdiff
path: root/sql/item_jsonfunc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r--sql/item_jsonfunc.cc44
1 files changed, 28 insertions, 16 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index aec3e1edcd3..8bd78d31602 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -247,15 +247,15 @@ error:
#define report_json_error(js, je, n_param) \
- report_json_error_ex(js, je, func_name(), n_param, \
+ report_json_error_ex(js->ptr(), je, func_name(), n_param, \
Sql_condition::WARN_LEVEL_WARN)
-void report_json_error_ex(String *js, json_engine_t *je,
+void report_json_error_ex(const char *js, json_engine_t *je,
const char *fname, int n_param,
Sql_condition::enum_warning_level lv)
{
THD *thd= current_thd;
- int position= (int)((const char *) je->s.c_str - js->ptr());
+ int position= (int)((const char *) je->s.c_str - js);
uint code;
n_param++;
@@ -285,34 +285,39 @@ void report_json_error_ex(String *js, json_engine_t *je,
case JE_DEPTH:
code= ER_JSON_DEPTH;
- push_warning_printf(thd, lv, code, ER_THD(thd, code), JSON_DEPTH_LIMIT,
- n_param, fname, position);
+ if (lv == Sql_condition::WARN_LEVEL_ERROR)
+ my_error(code, MYF(0), JSON_DEPTH_LIMIT, n_param, fname, position);
+ else
+ push_warning_printf(thd, lv, code, ER_THD(thd, code), JSON_DEPTH_LIMIT,
+ n_param, fname, position);
return;
default:
return;
}
- push_warning_printf(thd, lv, code, ER_THD(thd, code),
- n_param, fname, position);
+ if (lv == Sql_condition::WARN_LEVEL_ERROR)
+ my_error(code, MYF(0), n_param, fname, position);
+ else
+ push_warning_printf(thd, lv, code, ER_THD(thd, code),
+ n_param, fname, position);
}
-
#define NO_WILDCARD_ALLOWED 1
#define SHOULD_END_WITH_ARRAY 2
#define TRIVIAL_PATH_NOT_ALLOWED 3
#define report_path_error(js, je, n_param) \
- report_path_error_ex(js, je, func_name(), n_param,\
+ report_path_error_ex(js->ptr(), je, func_name(), n_param,\
Sql_condition::WARN_LEVEL_WARN)
-static void report_path_error_ex(String *ps, json_path_t *p,
- const char *fname, int n_param,
- Sql_condition::enum_warning_level lv)
+void report_path_error_ex(const char *ps, json_path_t *p,
+ const char *fname, int n_param,
+ Sql_condition::enum_warning_level lv)
{
THD *thd= current_thd;
- int position= (int)((const char *) p->s.c_str - ps->ptr() + 1);
+ int position= (int)((const char *) p->s.c_str - ps + 1);
uint code;
n_param++;
@@ -331,8 +336,11 @@ static void report_path_error_ex(String *ps, json_path_t *p,
case JE_DEPTH:
code= ER_JSON_PATH_DEPTH;
- push_warning_printf(thd, lv, code, ER_THD(thd, code),
- JSON_DEPTH_LIMIT, n_param, fname, position);
+ if (lv == Sql_condition::WARN_LEVEL_ERROR)
+ my_error(code, MYF(0), JSON_DEPTH_LIMIT, n_param, fname, position);
+ else
+ push_warning_printf(thd, lv, code, ER_THD(thd, code),
+ JSON_DEPTH_LIMIT, n_param, fname, position);
return;
case NO_WILDCARD_ALLOWED:
@@ -349,10 +357,14 @@ static void report_path_error_ex(String *ps, json_path_t *p,
}
push_warning_printf(thd, lv, code, ER_THD(thd, code),
n_param, fname, position);
+ if (lv == Sql_condition::WARN_LEVEL_ERROR)
+ my_error(code, MYF(0), n_param, fname, position);
+ else
+ push_warning_printf(thd, lv, code, ER_THD(thd, code),
+ n_param, fname, position);
}
-
/*
Checks if the path has '.*' '[*]' or '**' constructions
and sets the NO_WILDCARD_ALLOWED error if the case.