summaryrefslogtreecommitdiff
path: root/sql/sql_tvc.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-03-29 11:13:18 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-03-29 11:13:18 +0300
commitae6e214fd851a8a9d079494eec9903c89dd10fb2 (patch)
treeb206f873d02a5a2027671bb1cd900b77d1a3b820 /sql/sql_tvc.cc
parent97f237e66dc58a617b6293d6a2624378333e8065 (diff)
parent020e7d89ebdcded3355c82cec93e0abef2898258 (diff)
downloadmariadb-git-ae6e214fd851a8a9d079494eec9903c89dd10fb2.tar.gz
Merge 10.3 into 10.4
Diffstat (limited to 'sql/sql_tvc.cc')
-rw-r--r--sql/sql_tvc.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc
index 9a4a64fa623..9a99224b26e 100644
--- a/sql/sql_tvc.cc
+++ b/sql/sql_tvc.cc
@@ -899,8 +899,6 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd,
if (!transform_into_subq)
return this;
- transform_into_subq= false;
-
List<List_item> values;
LEX *lex= thd->lex;
@@ -1057,15 +1055,38 @@ uint32 Item_func_in::max_length_of_left_expr()
bool Item_func_in::to_be_transformed_into_in_subq(THD *thd)
{
+ bool is_row_list= args[1]->type() == Item::ROW_ITEM;
uint values_count= arg_count-1;
- if (args[1]->type() == Item::ROW_ITEM)
+ if (is_row_list)
values_count*= ((Item_row *)(args[1]))->cols();
if (thd->variables.in_subquery_conversion_threshold == 0 ||
thd->variables.in_subquery_conversion_threshold > values_count)
return false;
+ if (!(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_PREPARE))
+ return true;
+
+ /* Occurence of '?' in IN list is checked only for PREPARE <stmt> commands */
+ for (uint i=1; i < arg_count; i++)
+ {
+ if (!is_row_list)
+ {
+ if (args[i]->type() == Item::PARAM_ITEM)
+ return false;
+ }
+ else
+ {
+ Item_row *row_list= (Item_row *)(args[i]);
+ for (uint j=0; j < row_list->cols(); j++)
+ {
+ if (row_list->element_index(j)->type() == Item::PARAM_ITEM)
+ return false;
+ }
+ }
+ }
+
return true;
}