diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-01 18:15:00 +0000 |
commit | a2a2e32c02643a0cec111511220227703fda1cd5 (patch) | |
tree | 69cc2b631234c2a8e026b9cd4d72676c61c594df /sql/sql_tvc.cc | |
parent | Releasing progress-linux version 1:10.11.8-1~progress7.99u1. (diff) | |
download | mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.tar.xz mariadb-a2a2e32c02643a0cec111511220227703fda1cd5.zip |
Merging upstream version 1:11.4.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sql/sql_tvc.cc')
-rw-r--r-- | sql/sql_tvc.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/sql/sql_tvc.cc b/sql/sql_tvc.cc index fc1db382..487f7cc9 100644 --- a/sql/sql_tvc.cc +++ b/sql/sql_tvc.cc @@ -711,12 +711,12 @@ st_select_lex *wrap_tvc(THD *thd, st_select_lex *tvc_sl, goto err; wrapper_sl->select_number= ++thd->lex->stmt_lex->current_select_number; wrapper_sl->parent_lex= lex; /* Used in init_query. */ - wrapper_sl->init_query(); - wrapper_sl->init_select(); + wrapper_sl->make_empty_select(); wrapper_sl->is_tvc_wrapper= true; wrapper_sl->nest_level= tvc_sl->nest_level; wrapper_sl->parsing_place= tvc_sl->parsing_place; + wrapper_sl->distinct= tvc_sl->distinct; wrapper_sl->set_linkage(tvc_sl->get_linkage()); wrapper_sl->exclude_from_table_unique_test= tvc_sl->exclude_from_table_unique_test; @@ -744,6 +744,7 @@ st_select_lex *wrap_tvc(THD *thd, st_select_lex *tvc_sl, derived_unit->init_query(); derived_unit->thd= thd; derived_unit->include_down(wrapper_sl); + derived_unit->distinct= tvc_sl->distinct; /* Attach the select used of TVC as the only slave to the unit for @@ -960,8 +961,10 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, if (!length || length > tmp_table_max_key_length() || args[0]->cols() > tmp_table_max_key_parts()) { - trace_conv.add("done", false); - trace_conv.add("reason", "key is too long"); + if (unlikely(trace_conv.trace_started())) + trace_conv. + add("done", false). + add("reason", "key is too long"); return this; } @@ -969,15 +972,19 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, { if (!args[i]->const_item()) { - trace_conv.add("done", false); - trace_conv.add("reason", "non-constant element in the IN-list"); + if (unlikely(trace_conv.trace_started())) + trace_conv. + add("done", false). + add("reason", "non-constant element in the IN-list"); return this; } if (cmp_row_types(args[i], args[0])) { - trace_conv.add("done", false); - trace_conv.add("reason", "type mismatch"); + if (unlikely(trace_conv.trace_started())) + trace_conv. + add("done", false). + add("reason", "type mismatch"); return this; } } @@ -1012,7 +1019,9 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, lex->init_select(); tvc_select= lex->current_select; derived_unit= tvc_select->master_unit(); + derived_unit->distinct= 1; tvc_select->set_linkage(DERIVED_TABLE_TYPE); + tvc_select->distinct= 1; /* Create TVC used in the transformation */ if (create_value_list_for_tvc(thd, &values)) @@ -1045,7 +1054,9 @@ Item *Item_func_in::in_predicate_to_in_subs_transformer(THD *thd, sq_select->add_where_field(derived_unit->first_select()); sq_select->context.table_list= sq_select->table_list.first; sq_select->context.first_name_resolution_table= sq_select->table_list.first; - sq_select->table_list.first->derived_type= DTYPE_TABLE | DTYPE_MATERIALIZE; + sq_select->table_list.first->derived_type= (DTYPE_TABLE | + DTYPE_MATERIALIZE | + DTYPE_IN_PREDICATE); lex->derived_tables|= DERIVED_SUBQUERY; sq_select->where= 0; |