summaryrefslogtreecommitdiffstats
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:39:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 13:39:13 +0000
commit86fbb58c3ac0865482819c10a3e81f2eea001c36 (patch)
tree28c9e526ea739c6f9b89e36115e1e2698bddf981 /sql/item_cmpfunc.cc
parentReleasing progress-linux version 1:10.11.6-2~progress7.99u1. (diff)
downloadmariadb-86fbb58c3ac0865482819c10a3e81f2eea001c36.tar.xz
mariadb-86fbb58c3ac0865482819c10a3e81f2eea001c36.zip
Merging upstream version 1:10.11.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc94
1 files changed, 46 insertions, 48 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index bfe03e1c..c1654bfd 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -457,40 +457,6 @@ void Item_bool_func::raise_note_if_key_become_unused(THD *thd, const Item_args &
}
-bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp)
-{
- DBUG_ASSERT(arg_count >= 2); // Item_func_nullif has arg_count == 3
-
- if (args[0]->cmp_type() == STRING_RESULT &&
- args[1]->cmp_type() == STRING_RESULT)
- {
- CHARSET_INFO *tmp;
- /*
- Use charset narrowing only for equalities, as that would allow
- to construct ref access.
- Non-equality comparisons with constants work without charset narrowing,
- the constant gets converted.
- Non-equality comparisons with non-constants would need narrowing to
- enable range optimizer to handle e.g.
- t1.mb3key_col <= const_table.mb4_col
- But this doesn't look important.
- */
- bool allow_narrowing= MY_TEST(functype()==Item_func::EQ_FUNC ||
- functype()==Item_func::EQUAL_FUNC);
-
- if (agg_arg_charsets_for_comparison(&tmp, &args[0], &args[1],
- allow_narrowing))
- return true;
- cmp->m_compare_collation= tmp;
- }
- // Convert constants when compared to int/year field
- DBUG_ASSERT(functype() != LIKE_FUNC);
- convert_const_compared_to_int_field(thd);
-
- return cmp->set_cmp_func(thd, this, &args[0], &args[1], true);
-}
-
-
/*
Comparison operators remove arguments' dependency on PAD_CHAR_TO_FULL_LENGTH
in case of PAD SPACE comparison collations: trailing spaces do not affect
@@ -519,8 +485,15 @@ bool Item_bool_rowready_func2::fix_length_and_dec(THD *thd)
if (!args[0] || !args[1])
return FALSE;
Item_args old_args(args[0], args[1]);
- if (setup_args_and_comparator(thd, &cmp))
+ convert_const_compared_to_int_field(thd);
+ Type_handler_hybrid_field_type tmp;
+ if (tmp.aggregate_for_comparison(func_name_cstring(), args, 2, false) ||
+ tmp.type_handler()->Item_bool_rowready_func2_fix_length_and_dec(thd,
+ this))
+ {
+ DBUG_ASSERT(thd->is_error());
return true;
+ }
raise_note_if_key_become_unused(thd, old_args);
return false;
}
@@ -540,21 +513,14 @@ bool Item_bool_rowready_func2::fix_length_and_dec(THD *thd)
*/
int Arg_comparator::set_cmp_func(THD *thd, Item_func_or_sum *owner_arg,
+ const Type_handler *compare_handler,
Item **a1, Item **a2)
{
owner= owner_arg;
set_null= set_null && owner_arg;
a= a1;
b= a2;
- Item *tmp_args[2]= {*a1, *a2};
- Type_handler_hybrid_field_type tmp;
- if (tmp.aggregate_for_comparison(owner_arg->func_name_cstring(), tmp_args, 2,
- false))
- {
- DBUG_ASSERT(thd->is_error());
- return 1;
- }
- m_compare_handler= tmp.type_handler();
+ m_compare_handler= compare_handler;
return m_compare_handler->set_comparator_func(thd, this);
}
@@ -605,6 +571,14 @@ bool Arg_comparator::set_cmp_func_string(THD *thd)
We must set cmp_collation here as we may be called from for an automatic
generated item, like in natural join.
Allow reinterpted superset as subset.
+ Use charset narrowing only for equalities, as that would allow
+ to construct ref access.
+ Non-equality comparisons with constants work without charset narrowing,
+ the constant gets converted.
+ Non-equality comparisons with non-constants would need narrowing to
+ enable range optimizer to handle e.g.
+ t1.mb3key_col <= const_table.mb4_col
+ But this doesn't look important.
*/
bool allow_narrowing= false;
if (owner->type() == Item::FUNC_ITEM)
@@ -1509,6 +1483,23 @@ bool Item_in_optimizer::invisible_mode()
}
+bool Item_in_optimizer::walk(Item_processor processor,
+ bool walk_subquery,
+ void *arg)
+{
+ bool res= FALSE;
+ if (args[1]->type() == Item::SUBSELECT_ITEM &&
+ ((Item_subselect *)args[1])->substype() != Item_subselect::EXISTS_SUBS &&
+ !(((Item_subselect *)args[1])->substype() == Item_subselect::IN_SUBS &&
+ ((Item_in_subselect *)args[1])->test_strategy(SUBS_IN_TO_EXISTS)))
+ res= args[0]->walk(processor, walk_subquery, arg);
+ if (!res)
+ res= args[1]->walk(processor, walk_subquery, arg);
+
+ return res || (this->*processor)(arg);
+}
+
+
/**
Add an expression cache for this subquery if it is needed
@@ -2812,8 +2803,9 @@ Item_func_nullif::fix_length_and_dec(THD *thd)
fix_char_length(args[2]->max_char_length());
set_maybe_null();
m_arg0= args[0];
- if (setup_args_and_comparator(thd, &cmp))
- return TRUE;
+ convert_const_compared_to_int_field(thd);
+ if (cmp.set_cmp_func(thd, this, &args[0], &args[1], true/*set_null*/))
+ return true;
/*
A special code for EXECUTE..PREPARE.
@@ -3484,7 +3476,13 @@ void Item_func_case_simple::print(String *str, enum_query_type query_type)
void Item_func_decode_oracle::print(String *str, enum_query_type query_type)
{
- str->append(func_name_cstring());
+ if (query_type & QT_FOR_FRM)
+ {
+ // 10.3 downgrade compatibility for FRM
+ str->append(STRING_WITH_LEN("decode_oracle"));
+ }
+ else
+ print_sql_mode_qualified_name(str, query_type);
str->append('(');
args[0]->print(str, query_type);
for (uint i= 1, count= when_count() ; i <= count; i++)
@@ -6092,7 +6090,7 @@ void Regexp_processor_pcre::init(CHARSET_INFO *data_charset, int extra_flags)
// Convert text data to utf-8.
m_library_charset= data_charset == &my_charset_bin ?
- &my_charset_bin : &my_charset_utf8mb3_general_ci;
+ &my_charset_bin : &my_charset_utf8mb4_general_ci;
m_conversion_is_needed= (data_charset != &my_charset_bin) &&
!my_charset_same(data_charset, m_library_charset);