summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2019-09-06 11:53:10 +0200
committerSergei Golubchik <serg@mariadb.org>2019-09-06 11:53:10 +0200
commit244f0e6dd815b388282c15db4fe7f15533f4c8fc (patch)
treeaf138f2b3739a742c0c38173cdc86ec176fc0edd /sql/item_cmpfunc.cc
parent18af13b88ba580562981a190c25da128a2e9db26 (diff)
parent2842c369851a8afc2a944ce6f4f60fa052f20969 (diff)
downloadmariadb-git-244f0e6dd815b388282c15db4fe7f15533f4c8fc.tar.gz
Merge branch '10.3' into 10.4
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc40
1 files changed, 40 insertions, 0 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 02fc7719fbc..e656b23b8ee 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
@@ -5501,6 +5518,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;