diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-06 17:16:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-09-06 17:16:40 +0300 |
commit | 4081b7b27a40df6244e0525885cf70e48b7b35bc (patch) | |
tree | e9e6199730603d05090e0550e023e92c7a32f88d /sql/item_cmpfunc.cc | |
parent | 780d2bb8a7eca4fdbdf70fbd51c0bdbae5b0057e (diff) | |
parent | 244f0e6dd815b388282c15db4fe7f15533f4c8fc (diff) | |
download | mariadb-git-4081b7b27a40df6244e0525885cf70e48b7b35bc.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r-- | sql/item_cmpfunc.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4f950c0fefe..71bf5f431a6 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -425,6 +425,23 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp) } +/* + Comparison operators remove arguments' dependency on PAD_CHAR_TO_FULL_LENGTH + in case of PAD SPACE comparison collations: trailing spaces do not affect + the comparison result for such collations. +*/ +Sql_mode_dependency +Item_bool_rowready_func2::value_depends_on_sql_mode() const +{ + if (compare_collation()->state & MY_CS_NOPAD) + return Item_func::value_depends_on_sql_mode(); + return ((args[0]->value_depends_on_sql_mode() | + args[1]->value_depends_on_sql_mode()) & + Sql_mode_dependency(~0, ~MODE_PAD_CHAR_TO_FULL_LENGTH)). + soft_to_hard(); +} + + bool Item_bool_rowready_func2::fix_length_and_dec() { max_length= 1; // Function returns 0 or 1 @@ -5618,6 +5635,29 @@ bool Item_func_like::with_sargable_pattern() const } +/* + subject LIKE pattern + removes subject's dependency on PAD_CHAR_TO_FULL_LENGTH + if pattern ends with the '%' wildcard. +*/ +Sql_mode_dependency Item_func_like::value_depends_on_sql_mode() const +{ + if (!args[1]->value_depends_on_sql_mode_const_item()) + return Item_func::value_depends_on_sql_mode(); + StringBuffer<64> patternbuf; + String *pattern= args[1]->val_str_ascii(&patternbuf); + if (!pattern || !pattern->length()) + return Sql_mode_dependency(); // Will return NULL or 0 + DBUG_ASSERT(pattern->charset()->mbminlen == 1); + if (pattern->ptr()[pattern->length() - 1] != '%') + return Item_func::value_depends_on_sql_mode(); + return ((args[0]->value_depends_on_sql_mode() | + args[1]->value_depends_on_sql_mode()) & + Sql_mode_dependency(~0, ~MODE_PAD_CHAR_TO_FULL_LENGTH)). + soft_to_hard(); +} + + SEL_TREE *Item_func_like::get_mm_tree(RANGE_OPT_PARAM *param, Item **cond_ptr) { MEM_ROOT *tmp_root= param->mem_root; |