summaryrefslogtreecommitdiff
path: root/sql/item_jsonfunc.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2017-10-18 14:11:55 +0400
committerAlexander Barkov <bar@mariadb.org>2017-10-18 14:11:55 +0400
commit30e7d6709f7fb0f70a07c80a1a06614ca23da5f4 (patch)
tree9ba11fd32d82ac5c1364a537532ac896c4dd2058 /sql/item_jsonfunc.cc
parent75aabd03d57f85d63d57b25a239b4f930a3ae3c0 (diff)
parent3bc094d32a360b7d51600cf11bc4ce24117ecb78 (diff)
downloadmariadb-git-30e7d6709f7fb0f70a07c80a1a06614ca23da5f4.tar.gz
Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext
Diffstat (limited to 'sql/item_jsonfunc.cc')
-rw-r--r--sql/item_jsonfunc.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc
index 2f4c1ef8e46..b30d32c36ac 100644
--- a/sql/item_jsonfunc.cc
+++ b/sql/item_jsonfunc.cc
@@ -581,7 +581,8 @@ String *Item_func_json_quote::val_str(String *str)
void Item_func_json_unquote::fix_length_and_dec()
{
- collation.set(&my_charset_utf8_general_ci);
+ collation.set(&my_charset_utf8_general_ci,
+ DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
max_length= args[0]->max_length;
maybe_null= 1;
}
@@ -1011,6 +1012,8 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
case JSON_VALUE_ARRAY:
if (value->value_type != JSON_VALUE_ARRAY)
{
+ loc_js= *value;
+ set_js= FALSE;
while (json_scan_next(js) == 0 && js->state != JST_ARRAY_END)
{
int c_level, v_scalar;
@@ -1021,6 +1024,11 @@ static int check_contains(json_engine_t *js, json_engine_t *value)
if (!(v_scalar= json_value_scalar(js)))
c_level= json_get_level(js);
+ if (set_js)
+ *value= loc_js;
+ else
+ set_js= TRUE;
+
if (check_contains(js, value))
{
if (json_skip_level(js))
@@ -1452,7 +1460,8 @@ void Item_func_json_array::fix_length_and_dec()
if (arg_count == 0)
{
- collation.set(&my_charset_utf8_general_ci);
+ collation.set(&my_charset_utf8_general_ci,
+ DERIVATION_COERCIBLE, MY_REPERTOIRE_ASCII);
tmp_val.set_charset(&my_charset_utf8_general_ci);
max_length= 2;
return;
@@ -2126,6 +2135,7 @@ longlong Item_func_json_length::val_int()
json_engine_t je;
uint length= 0;
uint array_counters[JSON_DEPTH_LIMIT];
+ int err;
if ((null_value= args[0]->null_value))
return 0;
@@ -2167,7 +2177,7 @@ longlong Item_func_json_length::val_int()
if (json_value_scalar(&je))
return 1;
- while (json_scan_next(&je) == 0 &&
+ while (!(err= json_scan_next(&je)) &&
je.state != JST_OBJ_END && je.state != JST_ARRAY_END)
{
switch (je.state)
@@ -2186,6 +2196,12 @@ longlong Item_func_json_length::val_int()
};
}
+ if (!err)
+ {
+ /* Parse to the end of the JSON just to check it's valid. */
+ while (json_scan_next(&je) == 0) {}
+ }
+
if (!je.s.error)
return length;