diff options
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 2095f99d1ac..8e6eb4c815a 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -35,7 +35,6 @@ #include "probes_mysql.h" #include "debug_sync.h" #include "key.h" // is_key_used -#include "sql_acl.h" // *_ACL, check_grant #include "records.h" // init_read_record, // end_read_record #include "filesort.h" // filesort @@ -373,7 +372,7 @@ int mysql_update(THD *thd, bool need_sort= TRUE; bool reverse= FALSE; #ifndef NO_EMBEDDED_ACCESS_CHECKS - uint want_privilege; + privilege_t want_privilege(NO_ACL); #endif uint table_count= 0; ha_rows updated, found; @@ -441,7 +440,6 @@ int mysql_update(THD *thd, my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias.str, "UPDATE"); DBUG_RETURN(1); } - query_plan.updating_a_view= MY_TEST(table_list->view); /* Calculate "table->covering_keys" based on the WHERE */ table->covering_keys= table->s->keys_in_use; @@ -616,9 +614,11 @@ int mysql_update(THD *thd, else { ha_rows scanned_limit= query_plan.scanned_rows; + table->no_keyread= 1; query_plan.index= get_index_for_order(order, table, select, limit, &scanned_limit, &need_sort, &reverse); + table->no_keyread= 0; if (!need_sort) query_plan.scanned_rows= scanned_limit; @@ -671,7 +671,7 @@ int mysql_update(THD *thd, if (!(explain= query_plan.save_explain_update_data(query_plan.mem_root, thd))) goto err; - ANALYZE_START_TRACKING(&explain->command_tracker); + ANALYZE_START_TRACKING(thd, &explain->command_tracker); DBUG_EXECUTE_IF("show_explain_probe_update_exec_start", dbug_serve_apcs(thd, 1);); @@ -971,6 +971,9 @@ update_begin: can_compare_record= records_are_comparable(table); explain->tracker.on_scan_init(); + table->file->prepare_for_insert(1); + DBUG_ASSERT(table->file->inited != handler::NONE); + THD_STAGE_INFO(thd, stage_updating); while (!(error=info.read_record()) && !thd->killed) { @@ -1178,7 +1181,7 @@ update_begin: break; } } - ANALYZE_STOP_TRACKING(&explain->command_tracker); + ANALYZE_STOP_TRACKING(thd, &explain->command_tracker); table->auto_increment_field_not_null= FALSE; dup_key_found= 0; /* @@ -1499,8 +1502,8 @@ bool unsafe_key_update(List<TABLE_LIST> leaves, table_map tables_for_update) if (!tl->is_jtbm() && (tl->table->map & tables_for_update)) { TABLE *table1= tl->table; - bool primkey_clustered= (table1->file->primary_key_is_clustered() && - table1->s->primary_key != MAX_KEY); + bool primkey_clustered= (table1->file-> + pk_is_clustering_key(table1->s->primary_key)); bool table_partitioned= false; #ifdef WITH_PARTITION_STORAGE_ENGINE @@ -1851,9 +1854,8 @@ int mysql_multi_update_prepare(THD *thd) /* now lock and fill tables */ if (!thd->stmt_arena->is_stmt_prepare() && lock_tables(thd, table_list, table_count, 0)) - { DBUG_RETURN(TRUE); - } + (void) read_statistics_for_tables_if_needed(thd, table_list); /* @todo: downgrade the metadata locks here. */ @@ -1876,8 +1878,8 @@ int mysql_multi_update_prepare(THD *thd) (SELECT_ACL & ~tlist->grant.privilege); table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege); } - DBUG_PRINT("info", ("table: %s want_privilege: %u", tl->alias.str, - (uint) table->grant.want_privilege)); + DBUG_PRINT("info", ("table: %s want_privilege: %llx", tl->alias.str, + (longlong) table->grant.want_privilege)); } /* Set exclude_from_table_unique_test value back to FALSE. It is needed for @@ -1919,7 +1921,7 @@ bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List<Item> *fields, DBUG_RETURN(1); res= mysql_select(thd, - table_list, select_lex->with_wild, total_list, conds, + table_list, total_list, conds, select_lex->order_list.elements, select_lex->order_list.first, NULL, NULL, NULL, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | @@ -2029,13 +2031,14 @@ int multi_update::prepare(List<Item> ¬_used_values, { table->read_set= &table->def_read_set; bitmap_union(table->read_set, &table->tmp_set); + table->file->prepare_for_insert(1); } } if (unlikely(error)) DBUG_RETURN(1); /* - Save tables beeing updated in update_tables + Save tables being updated in update_tables update_table->shared is position for table Don't use key read on tables that are updated */ @@ -2353,7 +2356,7 @@ loop_end: tmp_param->field_count= temp_fields.elements; tmp_param->func_count= temp_fields.elements - 1; calc_group_buffer(tmp_param, &group); - /* small table, ignore SQL_BIG_TABLES */ + /* small table, ignore @@big_tables */ my_bool save_big_tables= thd->variables.big_tables; thd->variables.big_tables= FALSE; tmp_tables[cnt]=create_tmp_table(thd, tmp_param, temp_fields, |