diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-01-30 09:46:52 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-01-30 09:46:52 +0100 |
commit | a576a1cea5b0f06fb8fff0fbdb9035d89510b83a (patch) | |
tree | d25987402c55bdaec0897ab28c236acfa50116ef /sql/sql_select.cc | |
parent | 12cad0c3468d734e041d4ef0cd5a26d2a28606fc (diff) | |
parent | 41a163ac5ccf4ac5394edc84e40b3f47acea6b08 (diff) | |
download | mariadb-git-a576a1cea5b0f06fb8fff0fbdb9035d89510b83a.tar.gz |
Merge branch '10.3' into 10.4
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 69 |
1 files changed, 42 insertions, 27 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 9311eb4fa18..4b92c4cb7a6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3094,6 +3094,14 @@ setup_subq_exit: } if (make_aggr_tables_info()) DBUG_RETURN(1); + + /* + It could be that we've only done optimization stage 1 for + some of the derived tables, and never did stage 2. + Do it now, otherwise Explain data structure will not be complete. + */ + if (select_lex->handle_derived(thd->lex, DT_OPTIMIZE)) + DBUG_RETURN(1); } /* Even with zero matching rows, subqueries in the HAVING clause may @@ -10399,6 +10407,9 @@ bool JOIN::get_best_combination() hash_join= FALSE; fix_semijoin_strategies_for_picked_join_order(this); + + if (inject_splitting_cond_for_all_tables_with_split_opt()) + DBUG_RETURN(TRUE); JOIN_TAB_RANGE *root_range; if (!(root_range= new (thd->mem_root) JOIN_TAB_RANGE)) @@ -14434,8 +14445,6 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables, DBUG_RETURN(0); } - join->join_free(); - if (send_row) { /* @@ -14482,6 +14491,14 @@ return_zero_rows(JOIN *join, select_result *result, List<TABLE_LIST> &tables, if (likely(!send_error)) result->send_eof(); // Should be safe } + /* + JOIN::join_free() must be called after the virtual method + select::send_result_set_metadata() returned control since + implementation of this method could use data strutcures + that are released by the method JOIN::join_free(). + */ + join->join_free(); + DBUG_RETURN(0); } @@ -18589,8 +18606,15 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, The test for item->marker == 4 is ensure we don't create a group-by key over a bit field as heap tables can't handle that. */ - Field *new_field= (param->schema_table) ? - item->create_field_for_schema(thd, table) : + Field *new_field; + if (param->schema_table) + { + if ((new_field= item->create_field_for_schema(thd, table))) + new_field->flags|= NO_DEFAULT_VALUE_FLAG; + } + else + { + new_field= create_tmp_field(table, item, ©_func, tmp_from_field, &default_field[fieldnr], group != 0, @@ -18605,7 +18629,8 @@ create_tmp_table(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields, */ item->marker == 4 || param->bit_fields_as_long, force_copy_fields); - if (!new_field) + } + if (unlikely(!new_field)) { if (unlikely(thd->is_fatal_error)) goto err; // Got OOM @@ -20847,11 +20872,8 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, */ if (shortcut_for_distinct && found_records != join->found_records) DBUG_RETURN(NESTED_LOOP_NO_MORE_ROWS); - } - else - { - join->thd->get_stmt_da()->inc_current_row_for_warning(); - join_tab->read_record.unlock_row(join_tab); + + DBUG_RETURN(NESTED_LOOP_OK); } } else @@ -20861,9 +20883,11 @@ evaluate_join_record(JOIN *join, JOIN_TAB *join_tab, with the beginning coinciding with the current partial join. */ join->join_examined_rows++; - join->thd->get_stmt_da()->inc_current_row_for_warning(); - join_tab->read_record.unlock_row(join_tab); } + + join->thd->get_stmt_da()->inc_current_row_for_warning(); + join_tab->read_record.unlock_row(join_tab); + DBUG_RETURN(NESTED_LOOP_OK); } @@ -22603,21 +22627,6 @@ make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond, cond->marker=3; // Checked when read return (COND*) 0; } - /* - If cond is an equality injected for split optimization then - a. when retain_ref_cond == false : cond is removed unconditionally - (cond that supports ref access is removed by the preceding code) - b. when retain_ref_cond == true : cond is removed if it does not - support ref access - */ - if (left_item->type() == Item::FIELD_ITEM && - is_eq_cond_injected_for_split_opt((Item_func_eq *) cond) && - (!retain_ref_cond || - !test_if_ref(root_cond, (Item_field*) left_item,right_item))) - { - cond->marker=3; - return (COND*) 0; - } } cond->marker=2; cond->set_join_tab_idx(join_tab_idx_arg); @@ -28981,6 +28990,12 @@ AGGR_OP::end_send() table->reginfo.lock_type= TL_UNLOCK; bool in_first_read= true; + + /* + Reset the counter before copying rows from internal temporary table to + INSERT table. + */ + join_tab->join->thd->get_stmt_da()->reset_current_row_for_warning(); while (rc == NESTED_LOOP_OK) { int error; |