diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-05-10 11:53:59 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2022-05-10 14:01:23 +0200 |
commit | 3bc98a4ec4e7e7493ee93048dddfad87ceb3d8ff (patch) | |
tree | ad189995a78fdc6068059e65b8455d3d4e61e719 /sql/sql_select.cc | |
parent | f4d671bff2c4dcfe1bb2af6d40122576e4fcfa91 (diff) | |
parent | fe3d07cab82b2215dc64f52ac93122072c33d021 (diff) | |
download | mariadb-git-3bc98a4ec4e7e7493ee93048dddfad87ceb3d8ff.tar.gz |
Merge branch '10.5' into 10.6
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0a5225d2606..39673a0aaa7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -18408,14 +18408,17 @@ Field *Item_default_value::create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src, const Tmp_field_param *param) { - if (field->default_value && (field->flags & BLOB_FLAG)) + if (field->default_value || (field->flags & BLOB_FLAG)) { /* We have to use a copy function when using a blob with default value as the we have to calculate the default value before we can use it. */ get_tmp_field_src(src, param); - return tmp_table_field_from_field_type(root, table); + Field *result= tmp_table_field_from_field_type(root, table); + if (result && param->modify_item()) + result_field= result; + return result; } /* Same code as in Item_field::create_tmp_field_ex, except no default field @@ -18853,6 +18856,7 @@ TABLE *Create_tmp_table::start(THD *thd, table->copy_blobs= 1; table->in_use= thd; table->no_rows_with_nulls= param->force_not_null_cols; + table->expr_arena= thd; table->s= share; init_tmp_table_share(thd, share, "", 0, "(temporary)", tmpname); @@ -25065,8 +25069,8 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, if (find_order_in_list(thd, ref_pointer_array, tables, order, fields, all_fields, false, true, from_window_spec)) return 1; - if ((*order->item)->with_window_func() && - context_analysis_place != IN_ORDER_BY) + Item * const item= *order->item; + if (item->with_window_func() && context_analysis_place != IN_ORDER_BY) { my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; @@ -25077,20 +25081,18 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, an ORDER BY clause */ - if (for_union && - ((*order->item)->with_sum_func() || - (*order->item)->with_window_func())) + if (for_union && (item->with_sum_func() || item->with_window_func())) { my_error(ER_AGGREGATE_ORDER_FOR_UNION, MYF(0), number); return 1; } - if (!(*order->item)->with_sum_func()) - continue; - - if (from_window_spec && (*order->item)->type() != Item::SUM_FUNC_ITEM) - (*order->item)->split_sum_func(thd, ref_pointer_array, - all_fields, SPLIT_SUM_SELECT); + if ((from_window_spec && item->with_sum_func() && + item->type() != Item::SUM_FUNC_ITEM) || item->with_window_func()) + { + item->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); + } } return 0; } @@ -26040,15 +26042,17 @@ change_to_use_tmp_fields(THD *thd, Ref_ptr_array ref_pointer_array, for (uint i= 0; (item= it++); i++) { Field *field; - if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) || - item->with_window_func()) + enum Item::Type item_type= item->type(); + if ((item->with_sum_func() && item_type != Item::SUM_FUNC_ITEM) || + item->with_window_func()) item_field= item; - else if (item->type() == Item::FIELD_ITEM) + else if (item_type == Item::FIELD_ITEM || + item_type == Item::DEFAULT_VALUE_ITEM) { if (!(item_field= item->get_tmp_table_item(thd))) DBUG_RETURN(true); } - else if (item->type() == Item::FUNC_ITEM && + else if (item_type == Item::FUNC_ITEM && ((Item_func*)item)->functype() == Item_func::SUSERVAR_FUNC) { field= item->get_tmp_table_field(); @@ -27899,7 +27903,7 @@ static void print_table_array(THD *thd, too) */ -static bool is_eliminated_table(table_map eliminated_tables, TABLE_LIST *tbl) +bool is_eliminated_table(table_map eliminated_tables, TABLE_LIST *tbl) { return eliminated_tables && ((tbl->table && (tbl->table->map & eliminated_tables)) || |