1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-11856 json_search doesn't search for values with double quotes

character (").

        The my_wildcmp function doesn't expect the string parameter to
        have escapements, only the template. So the string
        should be unescaped if necessary.
This commit is contained in:
Alexey Botchkov
2017-03-14 15:25:02 +04:00
parent a77c2ea78f
commit 7c7c0696e7
6 changed files with 39 additions and 4 deletions

View File

@ -2800,9 +2800,28 @@ void Item_func_json_search::fix_length_and_dec()
int Item_func_json_search::compare_json_value_wild(json_engine_t *je,
const String *cmp_str)
{
return my_wildcmp(collation.collation,
(const char *) je->value, (const char *) (je->value + je->value_len),
cmp_str->ptr(), cmp_str->end(), escape, wild_one, wild_many) ? 0 : 1;
if (je->value_type != JSON_VALUE_STRING || !je->value_escaped)
return my_wildcmp(collation.collation,
(const char *) je->value, (const char *) (je->value + je->value_len),
cmp_str->ptr(), cmp_str->end(), escape, wild_one, wild_many) ? 0 : 1;
{
int esc_len;
if (esc_value.alloced_length() < (uint) je->value_len &&
esc_value.alloc((je->value_len / 1024 + 1) * 1024))
return 0;
esc_len= json_unescape(je->s.cs, je->value, je->value + je->value_len,
je->s.cs, (uchar *) esc_value.ptr(),
(uchar *) (esc_value.ptr() +
esc_value.alloced_length()));
if (esc_len <= 0)
return 0;
return my_wildcmp(collation.collation,
esc_value.ptr(), esc_value.ptr() + esc_len,
cmp_str->ptr(), cmp_str->end(), escape, wild_one, wild_many) ? 0 : 1;
}
}