diff --git a/mysql-test/r/stat_tables.result b/mysql-test/r/stat_tables.result index 09486d4ce0b..9d62ff357e2 100644 --- a/mysql-test/r/stat_tables.result +++ b/mysql-test/r/stat_tables.result @@ -369,6 +369,7 @@ revenue revenue 77949.91860000002 set use_stat_tables='preferably'; +set debug_sync='RESET'; select * from mysql.index_stat where table_name='lineitem' order by index_name; db_name table_name index_name prefix_arity avg_frequency dbt3_s001 lineitem PRIMARY 1 4.0033 @@ -436,6 +437,7 @@ set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; use dbt3_s001; set use_stat_tables='preferably'; analyze table lineitem persistent for columns() indexes (i_l_receiptdate); +set debug_sync='RESET'; select * from mysql.index_stat where table_name='lineitem' order by index_name; db_name table_name index_name prefix_arity avg_frequency dbt3_s001 lineitem PRIMARY 1 4.0033 diff --git a/mysql-test/r/stat_tables_innodb.result b/mysql-test/r/stat_tables_innodb.result index 4cb1261b689..59c1aa66790 100644 --- a/mysql-test/r/stat_tables_innodb.result +++ b/mysql-test/r/stat_tables_innodb.result @@ -396,6 +396,7 @@ revenue revenue 77949.91860000002 set use_stat_tables='preferably'; +set debug_sync='RESET'; select * from mysql.index_stat where table_name='lineitem' order by index_name; db_name table_name index_name prefix_arity avg_frequency dbt3_s001 lineitem PRIMARY 1 4.0033 @@ -509,6 +510,7 @@ set debug_sync='statistics_collection_start2 WAIT_FOR first_thread_working'; use dbt3_s001; set use_stat_tables='preferably'; analyze table lineitem persistent for columns() indexes (i_l_receiptdate); +set debug_sync='RESET'; select * from mysql.index_stat where table_name='lineitem' order by index_name; db_name table_name index_name prefix_arity avg_frequency dbt3_s001 lineitem PRIMARY 1 4.0033 diff --git a/mysql-test/t/stat_tables.test b/mysql-test/t/stat_tables.test index bdb689228b2..40c4c17c569 100644 --- a/mysql-test/t/stat_tables.test +++ b/mysql-test/t/stat_tables.test @@ -1,4 +1,5 @@ --source include/have_stat_tables.inc +--source include/have_debug_sync.inc set @save_use_stat_tables=@@use_stat_tables; @@ -192,6 +193,7 @@ connection default; set use_stat_tables='preferably'; disconnect con1; disconnect con2; +set debug_sync='RESET'; # # Test for parallel statistics collection @@ -251,6 +253,7 @@ connection con2; connection default; disconnect con1; disconnect con2; +set debug_sync='RESET'; select * from mysql.index_stat where table_name='lineitem' order by index_name; diff --git a/sql/mysqld.h b/sql/mysqld.h index 69348a45e9a..526f47d821d 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -430,6 +430,7 @@ enum enum_query_type typedef int64 query_id_t; extern query_id_t global_query_id; extern my_atomic_rwlock_t global_query_id_lock; +extern my_atomic_rwlock_t statistics_lock; void unireg_end(void) __attribute__((noreturn)); diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 3964b08019c..94503521628 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -85,7 +85,7 @@ inline void init_table_list_for_stat_tables(TABLE_LIST *tables, bool for_write) { uint i; - bzero((char *) &tables[0], sizeof(TABLE_LIST) * STATISTICS_TABLES); + memset((char *) &tables[0], 0, sizeof(TABLE_LIST) * STATISTICS_TABLES); for (i= 0; i < STATISTICS_TABLES; i++) { @@ -116,7 +116,7 @@ inline void init_table_list_for_single_stat_table(TABLE_LIST *tbl, const LEX_STRING *stat_tab_name, bool for_write) { - bzero((char *) tbl, sizeof(TABLE_LIST)); + memset((char *) tbl, 0, sizeof(TABLE_LIST)); tbl->db= stat_tables_db_name.str; tbl->db_length= stat_tables_db_name.length; @@ -1655,12 +1655,12 @@ int alloc_statistics_for_table(THD* thd, TABLE *table) table_stats->index_stats= index_stats; table_stats->idx_avg_frequency= idx_avg_frequency; - bzero(column_stats, sizeof(Column_statistics) * cnt); + memset(column_stats, 0, sizeof(Column_statistics) * cnt); for (field_ptr= table->field; *field_ptr; field_ptr++, column_stats++) (*field_ptr)->collected_stats= column_stats; - bzero(idx_avg_frequency, sizeof(ulong) * key_parts); + memset(idx_avg_frequency, 0, sizeof(ulong) * key_parts); KEY *key_info, *end; for (key_info= table->key_info, end= key_info + table->s->keys; @@ -1735,7 +1735,7 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share, sizeof(Table_statistics)); if (!table_stats) DBUG_RETURN(1); - bzero(table_stats, sizeof(Table_statistics)); + memset(table_stats, 0, sizeof(Table_statistics)); store_address_if_first((void **) &table_share->read_stats, (void **) &table_stats, is_safe); table_stats= table_share->read_stats; @@ -1746,7 +1746,7 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share, sizeof(Column_statistics) * cnt); if (!column_stats) DBUG_RETURN(1); - bzero(column_stats, sizeof(Column_statistics) * cnt); + memset(column_stats, 0, sizeof(Column_statistics) * cnt); store_address_if_first((void **) &table_stats->column_stats, (void **) &column_stats, is_safe); column_stats= table_stats->column_stats; @@ -1760,7 +1760,7 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share, sizeof(Index_statistics) * keys); if (!index_stats) DBUG_RETURN(1); - bzero(index_stats, sizeof(Index_statistics) * keys); + memset(index_stats, 0, sizeof(Index_statistics) * keys); store_address_if_first((void **) &table_stats->index_stats, (void **) &index_stats, is_safe); index_stats= table_stats->index_stats; @@ -1770,7 +1770,7 @@ int alloc_statistics_for_table_share(THD* thd, TABLE_SHARE *table_share, sizeof(ulong) * key_parts); if (!idx_avg_frequency) DBUG_RETURN(1); - bzero(idx_avg_frequency, sizeof(ulong) * key_parts); + memset(idx_avg_frequency, 0, sizeof(ulong) * key_parts); store_address_if_first((void **) &table_stats->idx_avg_frequency, (void **) &idx_avg_frequency, is_safe); idx_avg_frequency= table_stats->idx_avg_frequency;