diff options
author | Alexey Botchkov <holyfoot@askmonty.org> | 2017-08-11 00:50:29 +0400 |
---|---|---|
committer | Alexey Botchkov <holyfoot@askmonty.org> | 2017-08-11 09:02:55 +0400 |
commit | 2ebb1380d69524ef7aa042530d3d38a8805000ff (patch) | |
tree | 6414e93287b1fcc5e40e7fabc2e0cd1024c8fbe7 /sql/item_cmpfunc.cc | |
parent | e22375247272564b55bb45a3c711fda86923aa3c (diff) | |
download | mariadb-git-2ebb1380d69524ef7aa042530d3d38a8805000ff.tar.gz |
MDEV-12604 Comparison of JSON_EXTRACT result differs with Mysql.
JSON_EXTRACT behaves specifically in the comparison,
so we have to implement specific method for that in
Arg_comparator.
Conflicts:
sql/item_cmpfunc.cc
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 64f2a447bad..4bcb7397e52 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -544,15 +544,21 @@ bool Arg_comparator::set_cmp_func_string() */ if (owner->agg_arg_charsets_for_comparison(&m_compare_collation, a, b)) return true; - } - if ((*a)->is_json_type() ^ (*b)->is_json_type()) - { - Item **j_item= (*a)->is_json_type() ? a : b; - Item *uf= new(thd->mem_root) Item_func_json_unquote(thd, *j_item); - if (!uf || uf->fix_fields(thd, &uf)) - return 1; - *j_item= uf; + if ((*a)->type() == Item::FUNC_ITEM && + ((Item_func *) (*a))->functype() == Item_func::JSON_EXTRACT_FUNC) + { + func= is_owner_equal_func() ? &Arg_comparator::compare_e_json_str: + &Arg_comparator::compare_json_str; + return false; + } + else if ((*b)->type() == Item::FUNC_ITEM && + ((Item_func *) (*b))->functype() == Item_func::JSON_EXTRACT_FUNC) + { + func= is_owner_equal_func() ? &Arg_comparator::compare_e_json_str: + &Arg_comparator::compare_str_json; + return false; + } } a= cache_converted_constant(thd, a, &a_cache, compare_type_handler()); @@ -1144,6 +1150,30 @@ int Arg_comparator::compare_e_row() } +int Arg_comparator::compare_json_str() +{ + return compare_json_str_basic(*a, *b); +} + + +int Arg_comparator::compare_str_json() +{ + return -compare_json_str_basic(*b, *a); +} + + +int Arg_comparator::compare_e_json_str() +{ + return compare_e_json_str_basic(*a, *b); +} + + +int Arg_comparator::compare_e_str_json() +{ + return compare_e_json_str_basic(*b, *a); +} + + void Item_func_truth::fix_length_and_dec() { maybe_null= 0; |