diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2021-03-17 09:03:45 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2021-04-21 10:21:43 +0400 |
commit | e9fd327ee313088b9a8f497f1c1409990ce6c1cd (patch) | |
tree | 377a1dc735b35e99d56915d71077730c8cbebfb9 /sql/item_jsonfunc.cc | |
parent | a3099a3b4a394da360b5c1e7ae6dc985ae2f7f2f (diff) | |
download | mariadb-git-e9fd327ee313088b9a8f497f1c1409990ce6c1cd.tar.gz |
MDEV-17399 Add support for JSON_TABLE.
The specific table handler for the table functions was introduced,
and used to implement JSON_TABLE.
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r-- | sql/item_jsonfunc.cc | 45 |
1 files changed, 28 insertions, 17 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index 44ce69a482f..af14734eae3 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,16 +285,22 @@ 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); } @@ -304,15 +310,15 @@ void report_json_error_ex(String *js, json_engine_t *je, #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 +337,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: @@ -347,12 +356,14 @@ static void report_path_error_ex(String *ps, json_path_t *p, 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); } - /* Checks if the path has '.*' '[*]' or '**' constructions and sets the NO_WILDCARD_ALLOWED error if the case. |