diff options
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 55 |
1 files changed, 41 insertions, 14 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 08509a0e2bf..18e7ee950e6 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2551,8 +2551,13 @@ retry_share: (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER, table_list); else if (share->crashed) - (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR, - table_list); + { + if (!(flags & MYSQL_OPEN_IGNORE_REPAIR)) + (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR, + table_list); + else + table_list->crashed= 1; /* Mark that table was crashed */ + } goto err_lock; } if (open_table_entry_fini(thd, share, table)) @@ -6824,6 +6829,8 @@ find_field_in_tables(THD *thd, Item_ident *item, or as a field name without alias, or as a field hidden by alias, or ignoring alias) + limit How many items in the list to check + (if limit==0 then all items are to be checked) RETURN VALUES 0 Item is not found or item is not unique, @@ -6841,9 +6848,10 @@ Item **not_found_item= (Item**) 0x1; Item ** find_item_in_list(Item *find, List<Item> &items, uint *counter, find_item_error_report_type report_error, - enum_resolution_type *resolution) + enum_resolution_type *resolution, uint limit) { List_iterator<Item> li(items); + uint n_items= limit == 0 ? items.elements : limit; Item **found=0, **found_unaliased= 0, *item; const char *db_name=0; const char *field_name=0; @@ -6867,8 +6875,9 @@ find_item_in_list(Item *find, List<Item> &items, uint *counter, db_name= ((Item_ident*) find)->db_name; } - for (uint i= 0; (item=li++); i++) + for (uint i= 0; i < n_items; i++) { + item= li++; if (field_name && (item->real_item()->type() == Item::FIELD_ITEM || ((item->type() == Item::REF_ITEM) && @@ -7749,11 +7758,13 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, List<Item> *sum_func_list, uint wild_num) { + if (!wild_num) + return(0); + Item *item; List_iterator<Item> it(fields); Query_arena *arena, backup; DBUG_ENTER("setup_wild"); - DBUG_ASSERT(wild_num != 0); /* Don't use arena if we are not in prepared statements or stored procedures @@ -7832,7 +7843,7 @@ int setup_wild(THD *thd, TABLE_LIST *tables, List<Item> &fields, ** Check that all given fields exists and fill struct with current data ****************************************************************************/ -bool setup_fields(THD *thd, Item **ref_pointer_array, +bool setup_fields(THD *thd, Ref_ptr_array ref_pointer_array, List<Item> &fields, enum_mark_columns mark_used_columns, List<Item> *sum_func_list, bool allow_sum_func) { @@ -7842,7 +7853,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, List_iterator<Item> it(fields); bool save_is_item_list_lookup; DBUG_ENTER("setup_fields"); - DBUG_PRINT("enter", ("ref_pointer_array: %p", ref_pointer_array)); + DBUG_PRINT("enter", ("ref_pointer_array: %p", ref_pointer_array.array())); thd->mark_used_columns= mark_used_columns; DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns)); @@ -7864,8 +7875,11 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, TODO: remove it when (if) we made one list for allfields and ref_pointer_array */ - if (ref_pointer_array) - bzero(ref_pointer_array, sizeof(Item *) * fields.elements); + if (!ref_pointer_array.is_null()) + { + DBUG_ASSERT(ref_pointer_array.size() >= fields.elements); + memset(ref_pointer_array.array(), 0, sizeof(Item *) * fields.elements); + } /* We call set_entry() there (before fix_fields() of the whole list of field @@ -7883,7 +7897,7 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, while ((var= li++)) var->set_entry(thd, FALSE); - Item **ref= ref_pointer_array; + Ref_ptr_array ref= ref_pointer_array; thd->lex->current_select->cur_pos_in_select_list= 0; while ((item= it++)) { @@ -7896,12 +7910,20 @@ bool setup_fields(THD *thd, Item **ref_pointer_array, DBUG_PRINT("info", ("thd->mark_used_columns: %d", thd->mark_used_columns)); DBUG_RETURN(TRUE); /* purecov: inspected */ } - if (ref) - *(ref++)= item; - if (item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && - sum_func_list) + if (!ref.is_null()) + { + ref[0]= item; + ref.pop_front(); + } + /* + split_sum_func() must be called for Window Function items, see + Item_window_func::split_sum_func. + */ + if ((item->with_sum_func && item->type() != Item::SUM_FUNC_ITEM && + sum_func_list) || item->with_window_func) item->split_sum_func(thd, ref_pointer_array, *sum_func_list, SPLIT_SUM_SELECT); + thd->lex->current_select->select_list_tables|= item->used_tables(); thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->cur_pos_in_select_list++; } @@ -8320,7 +8342,10 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, views and natural joins this update is performed inside the loop below. */ if (table) + { thd->lex->used_tables|= table->map; + thd->lex->current_select->select_list_tables|= table->map; + } /* Initialize a generic field iterator for the current table reference. @@ -8412,6 +8437,8 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, if (field_table) { thd->lex->used_tables|= field_table->map; + thd->lex->current_select->select_list_tables|= + field_table->map; field_table->covering_keys.intersect(field->part_of_key); field_table->merge_keys.merge(field->part_of_key); field_table->used_fields++; |