diff options
author | Monty <monty@mariadb.org> | 2016-04-28 16:59:33 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2016-04-28 16:59:33 +0300 |
commit | 9c846373f02d6431d83add639e7560a69ba885a2 (patch) | |
tree | 101d110d3ec9a4796b4050779fb052120fd6d516 /sql | |
parent | fabeab781920dfcaf8e606708ba2c6812f6ae5d8 (diff) | |
parent | d5822a3ad0657040114cdc185c6387b9eb3a12b2 (diff) | |
download | mariadb-git-9c846373f02d6431d83add639e7560a69ba885a2.tar.gz |
Merge commit 'd5822a3ad0657040114cdc185c6387b9eb3a12b2' into 10.2
Diffstat (limited to 'sql')
-rw-r--r-- | sql/mysqld.cc | 100 | ||||
-rw-r--r-- | sql/opt_range.cc | 12 | ||||
-rw-r--r-- | sql/rpl_mi.cc | 81 | ||||
-rw-r--r-- | sql/slave.cc | 1 | ||||
-rw-r--r-- | sql/sql_base.cc | 9 | ||||
-rw-r--r-- | sql/sql_base.h | 4 | ||||
-rw-r--r-- | sql/sql_class.cc | 16 | ||||
-rw-r--r-- | sql/sql_class.h | 16 | ||||
-rw-r--r-- | sql/sql_insert.cc | 19 | ||||
-rw-r--r-- | sql/sql_parse.cc | 1 | ||||
-rw-r--r-- | sql/sql_show.cc | 21 | ||||
-rw-r--r-- | sql/sql_show.h | 2 | ||||
-rw-r--r-- | sql/table.h | 1 |
13 files changed, 190 insertions, 93 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc index a67cea47fc9..9843a1bf67c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4087,40 +4087,45 @@ extern "C" { static void my_malloc_size_cb_func(long long size, my_bool is_thread_specific) { THD *thd= current_thd; - /* If thread specific memory */ - if (likely(is_thread_specific)) + + if (likely(is_thread_specific)) /* If thread specific memory */ { - if (mysqld_server_initialized || thd) - { - /* - THD may not be set if we are called from my_net_init() before THD - thread has started. - However, this should never happen, so better to assert and - fix this. - */ - DBUG_ASSERT(thd); - if (thd) - { - DBUG_PRINT("info", ("memory_used: %lld size: %lld", - (longlong) thd->status_var.local_memory_used, - size)); - thd->status_var.local_memory_used+= size; - DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 || - !debug_assert_on_not_freed_memory); - } - } + /* + When thread specfic is set, both mysqld_server_initialized and thd + must be set + */ + DBUG_ASSERT(mysqld_server_initialized && thd); + + DBUG_PRINT("info", ("thd memory_used: %lld size: %lld", + (longlong) thd->status_var.local_memory_used, + size)); + thd->status_var.local_memory_used+= size; + DBUG_ASSERT((longlong) thd->status_var.local_memory_used >= 0 || + !debug_assert_on_not_freed_memory); } else if (likely(thd)) + { + DBUG_PRINT("info", ("global thd memory_used: %lld size: %lld", + (longlong) thd->status_var.global_memory_used, + size)); thd->status_var.global_memory_used+= size; + } else { - // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1) - int64 volatile * volatile ptr=&global_status_var.global_memory_used; - my_atomic_add64_explicit(ptr, size, MY_MEMORY_ORDER_RELAXED); + update_global_memory_status(size); +#ifndef EMBEDDED_LIBRARY + /* + Check if we have missed some mallocs. THis can't be done for embedded + server as the main code may have done calls to malloc before starting + the embedded library. + */ + DBUG_ASSERT(global_status_var.global_memory_used >= 0); +#endif } } } + /** Create a replication file name or base for file names. @@ -4157,6 +4162,22 @@ rpl_make_log_name(const char *opt, DBUG_RETURN(NULL); } +/* We have to setup my_malloc_size_cb_func early to catch all mallocs */ + +static int init_early_variables() +{ + if (pthread_key_create(&THR_THD, NULL)) + { + fprintf(stderr, "Fatal error: Can't create thread-keys\n"); + return 1; + } + set_current_thd(0); + set_malloc_size_cb(my_malloc_size_cb_func); + global_status_var.global_memory_used= 0; + return 0; +} + + static int init_common_variables() { umask(((~my_umask) & 0666)); @@ -4168,15 +4189,6 @@ static int init_common_variables() connection_errors_peer_addr= 0; my_decimal_set_zero(&decimal_zero); // set decimal_zero constant; - if (pthread_key_create(&THR_THD, NULL)) - { - sql_print_error("Can't create thread-keys"); - return 1; - } - - set_current_thd(0); - set_malloc_size_cb(my_malloc_size_cb_func); - init_libstrings(); tzset(); // Set tzname @@ -4713,6 +4725,7 @@ static int init_thread_environment() mysql_mutex_init(key_LOCK_global_system_variables, &LOCK_global_system_variables, MY_MUTEX_INIT_FAST); mysql_mutex_record_order(&LOCK_active_mi, &LOCK_global_system_variables); + mysql_mutex_record_order(&LOCK_status, &LOCK_thread_count); mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash, &LOCK_system_variables_hash); mysql_mutex_init(key_LOCK_prepared_stmt_count, @@ -5186,6 +5199,9 @@ static int init_server_components() variables even when a wsrep provider is not loaded. */ + /* It's now safe to use thread specific memory */ + mysqld_server_initialized= 1; + wsrep_thr_init(); if (WSREP_ON && !wsrep_recovery && !opt_abort) /* WSREP BEFORE SE */ @@ -5636,6 +5652,9 @@ int mysqld_main(int argc, char **argv) sf_leaking_memory= 1; // no safemalloc memory leak reports if we exit early mysqld_server_started= mysqld_server_initialized= 0; + if (init_early_variables()) + exit(1); + #ifdef HAVE_NPTL ld_assume_kernel_is_set= (getenv("LD_ASSUME_KERNEL") != 0); #endif @@ -5938,9 +5957,6 @@ int mysqld_main(int argc, char **argv) if (Events::init((THD*) 0, opt_noacl || opt_bootstrap)) unireg_abort(1); - /* It's now safe to use thread specific memory */ - mysqld_server_initialized= 1; - if (WSREP_ON) { if (opt_bootstrap) @@ -8309,15 +8325,16 @@ static int show_default_keycache(THD *thd, SHOW_VAR *var, char *buff, static int show_memory_used(THD *thd, SHOW_VAR *var, char *buff, + struct system_status_var *status_var, enum enum_var_type scope) { var->type= SHOW_LONGLONG; var->value= buff; if (scope == OPT_GLOBAL) - *(longlong*) buff= (global_status_var.local_memory_used + - global_status_var.global_memory_used); + *(longlong*) buff= (status_var->global_memory_used + + status_var->local_memory_used); else - *(longlong*) buff= thd->status_var.local_memory_used; + *(longlong*) buff= status_var->local_memory_used; return 0; } @@ -8746,7 +8763,9 @@ static int mysql_init_variables(void) prepared_stmt_count= 0; mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS; bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); - bzero((char *) &global_status_var, sizeof(global_status_var)); + /* Clear all except global_memory_used */ + bzero((char*) &global_status_var, offsetof(STATUS_VAR, + last_cleared_system_status_var)); opt_large_pages= 0; opt_super_large_pages= 0; #if defined(ENABLED_DEBUG_SYNC) @@ -9992,6 +10011,7 @@ void refresh_status(THD *thd) /* Reset thread's status variables */ thd->set_status_var_init(); + thd->status_var.global_memory_used= 0; bzero((uchar*) &thd->org_status_var, sizeof(thd->org_status_var)); thd->start_bytes_received= 0; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index af027ad6fdc..a69709bbf03 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -13105,7 +13105,17 @@ void cost_group_min_max(TABLE* table, KEY *index_info, uint used_key_parts, num_blocks= (ha_rows)(table_records / keys_per_block) + 1; /* Compute the number of keys in a group. */ - keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - 1); + if (!group_key_parts) + { + /* Summary over the whole table */ + keys_per_group= table_records; + } + else + { + keys_per_group= (ha_rows) index_info->actual_rec_per_key(group_key_parts - + 1); + } + if (keys_per_group == 0) /* If there is no statistics try to guess */ /* each group contains 10% of all records */ keys_per_group= (table_records / 10) + 1; diff --git a/sql/rpl_mi.cc b/sql/rpl_mi.cc index df721342d1d..02dbac46eb5 100644 --- a/sql/rpl_mi.cc +++ b/sql/rpl_mi.cc @@ -205,43 +205,56 @@ void init_master_log_pos(Master_info* mi) /** Parses the IO_CACHE for "key=" and returns the "key". + If no '=' found, returns the whole line (for END_MARKER). @param key [OUT] Key buffer @param max_size [IN] Maximum buffer size @param f [IN] IO_CACHE file + @param found_equal [OUT] Set true if a '=' was found. @retval 0 Either "key=" or '\n' found @retval 1 EOF */ -static int read_mi_key_from_file(char *key, int max_size, IO_CACHE *f) +static int +read_mi_key_from_file(char *key, int max_size, IO_CACHE *f, bool *found_equal) { int i= 0, c; - char *last_p; DBUG_ENTER("read_key_from_file"); - while (((c= my_b_get(f)) != '\n') && (c != my_b_EOF)) + *found_equal= false; + if (max_size <= 0) + DBUG_RETURN(1); + for (;;) { - last_p= key + i; - - if (i < max_size) + if (i >= max_size-1) { - if (c == '=') - { - /* We found '=', replace it by 0 and return. */ - *last_p= 0; - DBUG_RETURN(0); - } - else - *last_p= c; + key[i] = '\0'; + DBUG_RETURN(0); + } + c= my_b_get(f); + if (c == my_b_EOF) + { + DBUG_RETURN(1); + } + else if (c == '\n') + { + key[i]= '\0'; + DBUG_RETURN(0); + } + else if (c == '=') + { + key[i]= '\0'; + *found_equal= true; + DBUG_RETURN(0); + } + else + { + key[i]= c; + ++i; } - ++i; } - - if (c == my_b_EOF) - DBUG_RETURN(1); - - DBUG_RETURN(0); + /* NotReached */ } enum { @@ -539,6 +552,10 @@ file '%s')", fname); if (lines >= LINE_FOR_LAST_MYSQL_FUTURE) { uint i; + bool got_eq; + bool seen_using_gtid= false; + bool seen_do_domain_ids=false, seen_ignore_domain_ids=false; + /* Skip lines used by / reserved for MySQL >= 5.6. */ for (i= LINE_FOR_FIRST_MYSQL_5_6; i <= LINE_FOR_LAST_MYSQL_FUTURE; ++i) { @@ -551,11 +568,12 @@ file '%s')", fname); for "key=" and returns the "key" if found. The "value" can then the parsed on case by case basis. The "unknown" lines would be ignored to facilitate downgrades. + 10.0 does not have the END_MARKER before any left-overs at the end + of the file. So ignore any but the first occurrence of a key. */ - while (!read_mi_key_from_file(buf, sizeof(buf), &mi->file)) + while (!read_mi_key_from_file(buf, sizeof(buf), &mi->file, &got_eq)) { - /* using_gtid */ - if (!strncmp(buf, STRING_WITH_LEN("using_gtid"))) + if (got_eq && !seen_using_gtid && !strcmp(buf, "using_gtid")) { int val; if (!init_intvar_from_file(&val, &mi->file, 0)) @@ -566,15 +584,13 @@ file '%s')", fname); mi->using_gtid= Master_info::USE_GTID_SLAVE_POS; else mi->using_gtid= Master_info::USE_GTID_NO; - continue; + seen_using_gtid= true; } else { sql_print_error("Failed to initialize master info using_gtid"); goto errwithmsg; } } - - /* DO_DOMAIN_IDS */ - if (!strncmp(buf, STRING_WITH_LEN("do_domain_ids"))) + else if (got_eq && !seen_do_domain_ids && !strcmp(buf, "do_domain_ids")) { if (mi->domain_id_filter.init_ids(&mi->file, Domain_id_filter::DO_DOMAIN_IDS)) @@ -582,11 +598,10 @@ file '%s')", fname); sql_print_error("Failed to initialize master info do_domain_ids"); goto errwithmsg; } - continue; + seen_do_domain_ids= true; } - - /* IGNORE_DOMAIN_IDS */ - if (!strncmp(buf, STRING_WITH_LEN("ignore_domain_ids"))) + else if (got_eq && !seen_ignore_domain_ids && + !strcmp(buf, "ignore_domain_ids")) { if (mi->domain_id_filter.init_ids(&mi->file, Domain_id_filter::IGNORE_DOMAIN_IDS)) @@ -595,9 +610,9 @@ file '%s')", fname); "ignore_domain_ids"); goto errwithmsg; } - continue; + seen_ignore_domain_ids= true; } - else if (!strncmp(buf, STRING_WITH_LEN("END_MARKER"))) + else if (!got_eq && !strcmp(buf, "END_MARKER")) { /* Guard agaist extra left-overs at the end of file, in case a later diff --git a/sql/slave.cc b/sql/slave.cc index 93506bc2ccd..30a0018f490 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -4955,7 +4955,6 @@ err_during_init: delete serial_rgi; mysql_mutex_unlock(&LOCK_thread_count); - THD_CHECK_SENTRY(thd); delete thd; thread_safe_decrement32(&service_thread_count); signal_thd_deleted(); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6cc78a4c294..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)) diff --git a/sql/sql_base.h b/sql/sql_base.h index ecadd31d3f9..d6bd0e2ace7 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -107,6 +107,10 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update, table flush, wait on thr_lock.c locks) while opening and locking table. */ #define MYSQL_OPEN_IGNORE_KILLED 0x8000 +/** + Don't try to auto-repair table +*/ +#define MYSQL_OPEN_IGNORE_REPAIR 0x10000 /** Please refer to the internals manual. */ #define MYSQL_OPEN_REOPEN (MYSQL_OPEN_IGNORE_FLUSH |\ diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e3b70566597..e189fd7e582 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -908,7 +908,8 @@ THD::THD(bool is_wsrep_applier) */ THD *old_THR_THD= current_thd; set_current_thd(this); - status_var.local_memory_used= status_var.global_memory_used= 0; + status_var.local_memory_used= sizeof(THD); + status_var.global_memory_used= 0; main_da.init(); /* @@ -1641,6 +1642,8 @@ THD::~THD() that memory allocation counting is done correctly */ set_current_thd(this); + if (!status_in_global) + add_status_to_global(); /* Ensure that no one is using THD */ mysql_mutex_lock(&LOCK_thd_data); @@ -1703,6 +1706,7 @@ THD::~THD() if (xid_hash_pins) lf_hash_put_pins(xid_hash_pins); /* Ensure everything is freed */ + status_var.local_memory_used-= sizeof(THD); if (status_var.local_memory_used != 0) { DBUG_PRINT("error", ("memory_used: %lld", status_var.local_memory_used)); @@ -1710,7 +1714,7 @@ THD::~THD() DBUG_ASSERT(status_var.local_memory_used == 0 || !debug_assert_on_not_freed_memory); } - + update_global_memory_status(status_var.global_memory_used); set_current_thd(orig_thd == this ? 0 : orig_thd); DBUG_VOID_RETURN; } @@ -1729,6 +1733,7 @@ THD::~THD() other types are handled explicitely */ + void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) { ulong *end= (ulong*) ((uchar*) to_var + @@ -1748,12 +1753,17 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) to_var->binlog_bytes_written+= from_var->binlog_bytes_written; to_var->cpu_time+= from_var->cpu_time; to_var->busy_time+= from_var->busy_time; - to_var->local_memory_used+= from_var->local_memory_used; /* Update global_memory_used. We have to do this with atomic_add as the global value can change outside of LOCK_status. */ + if (to_var == &global_status_var) + { + DBUG_PRINT("info", ("global memory_used: %lld size: %lld", + (longlong) global_status_var.global_memory_used, + (longlong) from_var->global_memory_used)); + } // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1) int64 volatile * volatile ptr= &to_var->global_memory_used; my_atomic_add64_explicit(ptr, from_var->global_memory_used, diff --git a/sql/sql_class.h b/sql/sql_class.h index b68a6e5ebd9..e0792a4059f 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -824,6 +824,20 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var); void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, STATUS_VAR *dec_var); +/* + Update global_memory_used. We have to do this with atomic_add as the + global value can change outside of LOCK_status. +*/ +inline void update_global_memory_status(int64 size) +{ + DBUG_PRINT("info", ("global memory_used: %lld size: %lld", + (longlong) global_status_var.global_memory_used, + size)); + // workaround for gcc 4.2.4-1ubuntu4 -fPIE (from DEB_BUILD_HARDENING=1) + int64 volatile * volatile ptr= &global_status_var.global_memory_used; + my_atomic_add64_explicit(ptr, size, MY_MEMORY_ORDER_RELAXED); +} + /** Get collation by name, send error to client on failure. @param name Collation name @@ -3846,9 +3860,11 @@ public: void add_status_to_global() { + DBUG_ASSERT(status_in_global == 0); mysql_mutex_lock(&LOCK_status); add_to_status(&global_status_var, &status_var); /* Mark that this THD status has already been added in global status */ + status_var.global_memory_used= 0; status_in_global= 1; mysql_mutex_unlock(&LOCK_status); } diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 6e40ac02274..65af14b62f6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -2017,6 +2017,7 @@ public: mysql_cond_t cond, cond_client; volatile uint tables_in_use,stacked_inserts; volatile bool status; + bool retry; /** When the handler thread starts, it clones a metadata lock ticket which protects against GRL and ticket for the table to be inserted. @@ -2041,7 +2042,7 @@ public: Delayed_insert(SELECT_LEX *current_select) :locks_in_memory(0), table(0),tables_in_use(0),stacked_inserts(0), - status(0), handler_thread_initialized(FALSE), group_count(0) + status(0), retry(0), handler_thread_initialized(FALSE), group_count(0) { DBUG_ENTER("Delayed_insert constructor"); thd.security_ctx->user=(char*) delayed_user; @@ -2300,7 +2301,7 @@ bool delayed_get_table(THD *thd, MDL_request *grl_protection_request, } if (di->thd.killed) { - if (di->thd.is_error()) + if (di->thd.is_error() && ! di->retry) { /* Copy the error message. Note that we don't treat fatal @@ -2526,7 +2527,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) copy->vcol_set= copy->def_vcol_set; } copy->tmp_set.bitmap= 0; // To catch errors - bzero((char*) bitmap, share->column_bitmap_size + (share->vfields ? 3 : 2)); + bzero((char*) bitmap, share->column_bitmap_size * (share->vfields ? 3 : 2)); copy->read_set= ©->def_read_set; copy->write_set= ©->def_write_set; @@ -2535,7 +2536,6 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) /* Got fatal error */ error: tables_in_use--; - status=1; mysql_cond_signal(&cond); // Inform thread about abort DBUG_RETURN(0); } @@ -2777,13 +2777,20 @@ bool Delayed_insert::open_and_lock_table() /* Use special prelocking strategy to get ER_DELAYED_NOT_SUPPORTED error for tables with engines which don't support delayed inserts. + + We can't do auto-repair in insert delayed thread, as it would hang + when trying to an exclusive MDL_LOCK on the table during repair + as the connection thread has a SHARED_WRITE lock. */ if (!(table= open_n_lock_single_table(&thd, &table_list, TL_WRITE_DELAYED, - MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK, + MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | + MYSQL_OPEN_IGNORE_REPAIR, &prelocking_strategy))) { - thd.fatal_error(); // Abort waiting inserts + /* If table was crashed, then upper level should retry open+repair */ + retry= table_list.crashed; + thd.fatal_error(); // Abort waiting inserts return TRUE; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3389af5c147..a6bb89f05df 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5308,6 +5308,7 @@ end_with_restore_list: } case SQLCOM_SHUTDOWN: #ifndef EMBEDDED_LIBRARY + DBUG_EXECUTE_IF("crash_shutdown", DBUG_SUICIDE();); if (check_global_access(thd,SHUTDOWN_ACL)) goto error; kill_mysql(thd); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 1102050e29c..f41fb394b47 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -2960,8 +2960,7 @@ int fill_schema_processlist(THD* thd, TABLE_LIST* tables, COND* cond) thread in this thread. However it's better that we notice it eventually than hide it. */ - table->field[12]->store((longlong) (tmp->status_var.local_memory_used + - sizeof(THD)), + table->field[12]->store((longlong) tmp->status_var.local_memory_used, FALSE); table->field[12]->set_notnull(); table->field[13]->store((longlong) tmp->get_examined_row_count(), TRUE); @@ -3257,7 +3256,8 @@ static bool show_status_array(THD *thd, const char *wild, */ for (var=variables; var->type == SHOW_FUNC || var->type == SHOW_SIMPLE_FUNC; var= &tmp) - ((mysql_show_var_func)(var->value))(thd, &tmp, buff, scope); + ((mysql_show_var_func)(var->value))(thd, &tmp, buff, + status_var, scope); SHOW_TYPE show_type=var->type; if (show_type == SHOW_ARRAY) @@ -3389,10 +3389,14 @@ end: DBUG_RETURN(res); } -/* collect status for all running threads */ +/* + collect status for all running threads + Return number of threads used +*/ -void calc_sum_of_all_status(STATUS_VAR *to) +uint calc_sum_of_all_status(STATUS_VAR *to) { + uint count= 0; DBUG_ENTER("calc_sum_of_all_status"); /* Ensure that thread id not killed during loop */ @@ -3403,16 +3407,21 @@ void calc_sum_of_all_status(STATUS_VAR *to) /* Get global values as base */ *to= global_status_var; + to->local_memory_used= 0; /* Add to this status from existing threads */ while ((tmp= it++)) { + count++; if (!tmp->status_in_global) + { add_to_status(to, &tmp->status_var); + to->local_memory_used+= tmp->status_var.local_memory_used; + } } mysql_mutex_unlock(&LOCK_thread_count); - DBUG_VOID_RETURN; + DBUG_RETURN(count); } diff --git a/sql/sql_show.h b/sql/sql_show.h index 9dae78e7f0e..dbae2a42b39 100644 --- a/sql/sql_show.h +++ b/sql/sql_show.h @@ -102,7 +102,7 @@ bool mysqld_show_authors(THD *thd); bool mysqld_show_contributors(THD *thd); bool mysqld_show_privileges(THD *thd); char *make_backup_log_name(char *buff, const char *name, const char* log_ext); -void calc_sum_of_all_status(STATUS_VAR *to); +uint calc_sum_of_all_status(STATUS_VAR *to); void append_definer(THD *thd, String *buffer, const LEX_STRING *definer_user, const LEX_STRING *definer_host); int add_status_vars(SHOW_VAR *list); diff --git a/sql/table.h b/sql/table.h index aa7c11ba3d8..a105df31e93 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1964,6 +1964,7 @@ struct TABLE_LIST bool updating; /* for replicate-do/ignore table */ bool force_index; /* prefer index over table scan */ bool ignore_leaves; /* preload only non-leaf nodes */ + bool crashed; /* Table was found crashed */ table_map dep_tables; /* tables the table depends on */ table_map on_expr_dep_tables; /* tables on expression depends on */ struct st_nested_join *nested_join; /* if the element is a nested join */ |