MDEV-34143: Server crashes when executing JSON_EXTRACT after setting
non-default collation_connection Analysis: Due to different collation, the string has nothing to chop off. Fix: Got rid of chop(), only append " ," only when we have more elements to add to the result.
This commit is contained in:
parent
ce9efb4e02
commit
0406b2a4ed
@ -1717,5 +1717,16 @@ SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
|
|||||||
JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D')
|
JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D')
|
||||||
{"A": {"B": 1}}
|
{"A": {"B": 1}}
|
||||||
#
|
#
|
||||||
|
# MDEV-34143: Server crashes when executing JSON_EXTRACT after setting non-default collation_connection
|
||||||
|
#
|
||||||
|
SET @save_collation_connection= @@collation_connection;
|
||||||
|
SET collation_connection='utf16_bin';
|
||||||
|
SELECT JSON_EXTRACT('{"a": 1,"b": 2}','$.a');
|
||||||
|
JSON_EXTRACT('{"a": 1,"b": 2}','$.a')
|
||||||
|
NULL
|
||||||
|
Warnings:
|
||||||
|
Warning 4036 Character disallowed in JSON in argument 1 to function 'json_extract' at position 2
|
||||||
|
SET @@collation_connection= @save_collation_connection;
|
||||||
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
@ -1147,6 +1147,18 @@ SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('
|
|||||||
SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
|
SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-34143: Server crashes when executing JSON_EXTRACT after setting non-default collation_connection
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
SET @save_collation_connection= @@collation_connection;
|
||||||
|
|
||||||
|
SET collation_connection='utf16_bin';
|
||||||
|
SELECT JSON_EXTRACT('{"a": 1,"b": 2}','$.a');
|
||||||
|
|
||||||
|
SET @@collation_connection= @save_collation_connection;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
--echo #
|
--echo #
|
||||||
|
@ -1003,11 +1003,18 @@ String *Item_func_json_extract::read_json(String *str,
|
|||||||
je= sav_je;
|
je= sav_je;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int count= 0; count < count_path; count++)
|
if ((not_first_value && str->append(", ", 2)))
|
||||||
|
goto error;
|
||||||
|
while(count_path)
|
||||||
{
|
{
|
||||||
if (str->append((const char *) value, v_len) ||
|
if (str->append((const char *) value, v_len))
|
||||||
str->append(", ", 2))
|
goto error;
|
||||||
goto error; /* Out of memory. */
|
count_path--;
|
||||||
|
if (count_path)
|
||||||
|
{
|
||||||
|
if (str->append(", ", 2))
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
not_first_value= 1;
|
not_first_value= 1;
|
||||||
@ -1029,11 +1036,6 @@ String *Item_func_json_extract::read_json(String *str,
|
|||||||
goto return_null;
|
goto return_null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str->length()>2)
|
|
||||||
{
|
|
||||||
str->chop();
|
|
||||||
str->chop();
|
|
||||||
}
|
|
||||||
if (possible_multiple_values && str->append("]", 1))
|
if (possible_multiple_values && str->append("]", 1))
|
||||||
goto error; /* Out of memory. */
|
goto error; /* Out of memory. */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user