summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_statistics.cc44
-rw-r--r--sql/table.cc10
-rw-r--r--sql/table.h9
-rw-r--r--storage/spider/spd_table.cc2
5 files changed, 29 insertions, 38 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 78102adfb98..62b461bd599 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2806,7 +2806,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
Make a copy of the table statistics shared pointer to increase the count
of references and thus lock the statistics
*/
- copy->stats_cb= new Shared_ptr<TABLE_STATISTICS_CB>(*table->stats_cb);
+ copy->stats_cb= table->stats_cb;
}
DBUG_RETURN(copy);
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 80c5d8c3baf..33e90b5d794 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2887,7 +2887,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables,
DBUG_ENTER("read_statistics_for_table");
- if (!force_reload && table_share->stats_cb->get()->stats_are_ready())
+ if (!force_reload && table_share->stats_cb->stats_are_ready())
{
/* Statistics has been already loaded, no need to read from stat tables */
DBUG_RETURN(0);
@@ -2897,25 +2897,18 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables,
Read data into a new TABLE_STATISTICS_CB object and replace
TABLE_SHARE::stats_cb with this new one once the reading is finished
*/
- auto new_stats_cb=
- new Shared_ptr<TABLE_STATISTICS_CB>(new TABLE_STATISTICS_CB);
- if (!new_stats_cb->get()->start_stats_load())
- {
- delete new_stats_cb;
- DBUG_RETURN(table_share->stats_cb->get()->stats_are_ready() ? 0 : 1);
- }
+ Shared_ptr<TABLE_STATISTICS_CB> new_stats_cb(new TABLE_STATISTICS_CB);
+ if (!new_stats_cb->start_stats_load())
+ DBUG_RETURN(table_share->stats_cb->stats_are_ready() ? 0 : 1);
- if (alloc_statistics_for_table_share(thd, table_share, new_stats_cb->get()))
- {
- delete new_stats_cb;
+ if (alloc_statistics_for_table_share(thd, table_share, new_stats_cb.get()))
DBUG_RETURN(1);
- }
/* Don't write warnings for internal field conversions */
Check_level_instant_set check_level_save(thd, CHECK_FIELD_IGNORE);
/* Read statistics from the statistical table table_stats */
- Table_statistics *read_stats= new_stats_cb->get()->table_stats;
+ Table_statistics *read_stats= new_stats_cb.get()->table_stats;
stat_table= stat_tables[TABLE_STAT].table;
Table_stat table_stat(stat_table, table);
table_stat.set_key_fields();
@@ -2932,7 +2925,7 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables,
column_stat.get_column_stat_values();
total_hist_size+= table_field->read_stats->histogram.get_size();
}
- new_stats_cb->get()->total_hist_size= total_hist_size;
+ new_stats_cb.get()->total_hist_size= total_hist_size;
/* Read statistics from the statistical table index_stats */
stat_table= stat_tables[INDEX_STAT].table;
@@ -2995,10 +2988,9 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables,
}
if (thd->variables.optimizer_use_condition_selectivity > 3)
(void) read_histograms_for_table(thd, table, stat_tables,
- new_stats_cb->get());
+ new_stats_cb.get());
- new_stats_cb->get()->end_stats_load();
- delete table_share->stats_cb;
+ new_stats_cb->end_stats_load();
table_share->stats_cb= new_stats_cb;
DBUG_RETURN(0);
@@ -3012,10 +3004,11 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables,
void delete_stat_values_for_table_share(TABLE_SHARE *table_share)
{
- auto stats_cb_copy= table_share->stats_cb;
- if (!stats_cb_copy || !stats_cb_copy->get())
+ //OLEGS: auto stats_cb_copy= table_share->stats_cb;
+ //if (!stats_cb_copy || !stats_cb_copy->get())
+ if (!table_share->stats_cb)
return;
- Table_statistics *table_stats= stats_cb_copy->get()->table_stats;
+ Table_statistics *table_stats= table_share->stats_cb->table_stats;
if (!table_stats)
return;
@@ -3169,8 +3162,7 @@ dump_stats_from_share_to_table(TABLE *table)
The mutex is acquired at read_statistics_for_tables() which calls this
function
*/
- delete table->stats_cb;
- table->stats_cb= new Shared_ptr<TABLE_STATISTICS_CB>(*table_share->stats_cb);
+ table->stats_cb= table_share->stats_cb;
KEY *key_info= table_share->key_info;
KEY *key_info_end= key_info + table_share->keys;
KEY *table_key_info= table->key_info;
@@ -3207,14 +3199,14 @@ read_statistics_for_tables(THD *thd, TABLE_LIST *tables, bool force_reload)
if (table_share->table_category == TABLE_CATEGORY_USER)
{
mysql_mutex_lock(&table_share->LOCK_share);
- if (!force_reload && table_share->stats_cb->get()->stats_are_ready())
+ if (!force_reload && table_share->stats_cb->stats_are_ready())
{
if (!tl->table->stats_is_read)
dump_stats_from_share_to_table(tl->table);
- if (table_share->stats_cb->get()->histograms_are_ready() ||
+ if (table_share->stats_cb->histograms_are_ready() ||
thd->variables.optimizer_use_condition_selectivity <= 3)
{
- mysql_mutex_unlock(&table_share->LOCK_share);
+ mysql_mutex_unlock(&table_share->LOCK_share);
continue;
}
}
@@ -3689,7 +3681,7 @@ void set_statistics_for_table(THD *thd, TABLE *table)
is running
*/
- Shared_ptr<TABLE_STATISTICS_CB> stats_cb(*table->s->stats_cb);
+ Shared_ptr<TABLE_STATISTICS_CB> stats_cb(table->s->stats_cb);
DBUG_ASSERT(stats_cb);
Table_statistics *read_stats= stats_cb->table_stats;
diff --git a/sql/table.cc b/sql/table.cc
index 12005d4ee18..25647060784 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -353,8 +353,7 @@ TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
table_alias_charset->strnncoll(key, 6, "mysql", 6) == 0)
share->not_usable_by_query_cache= 1;
- share->stats_cb=
- new Shared_ptr<TABLE_STATISTICS_CB>(new TABLE_STATISTICS_CB);
+ share->stats_cb.reset(new TABLE_STATISTICS_CB);
memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
mysql_mutex_init(key_TABLE_SHARE_LOCK_share,
@@ -432,7 +431,7 @@ void init_tmp_table_share(THD *thd, TABLE_SHARE *share, const char *key,
share->frm_version= FRM_VER_CURRENT;
share->not_usable_by_query_cache= 1;
share->can_do_row_logging= 0; // No row logging
- share->stats_cb= new Shared_ptr<TABLE_STATISTICS_CB>(new TABLE_STATISTICS_CB);
+ share->stats_cb.reset(new TABLE_STATISTICS_CB);
/*
table_map_id is also used for MERGE tables to suppress repeated
@@ -465,8 +464,9 @@ void TABLE_SHARE::destroy()
delete sequence;
sequence= NULL;
delete_stat_values_for_table_share(this);
- delete stats_cb;
- stats_cb= NULL;
+ // OLEGS: delete stats_cb;
+ //stats_cb= NULL;
+ stats_cb.reset();
/* The mutexes are initialized only for shares that are part of the TDC */
if (tmp_table == NO_TMP_TABLE)
diff --git a/sql/table.h b/sql/table.h
index fa4696651f0..8ee4426950f 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -762,7 +762,7 @@ struct TABLE_SHARE
uint *blob_field; /* Index to blobs in Field arrray*/
LEX_CUSTRING vcol_defs; /* definitions of generated columns */
- Shared_ptr<TABLE_STATISTICS_CB> *stats_cb= nullptr;
+ Shared_ptr<TABLE_STATISTICS_CB> stats_cb;
uchar *default_values; /* row with default values */
LEX_CSTRING comment; /* Comment about table */
@@ -1566,11 +1566,11 @@ public:
*/
Item *notnull_cond;
- Shared_ptr<TABLE_STATISTICS_CB> *stats_cb= nullptr;
+ Shared_ptr<TABLE_STATISTICS_CB> stats_cb;
inline void reset()
{
- delete stats_cb;
+ stats_cb.reset();
bzero((void *) this, sizeof(*this));
}
void init(THD *thd, TABLE_LIST *tl);
@@ -1797,8 +1797,7 @@ public:
/* Specific cleanup steps required during the TABLE destruction */
void destroy()
{
- delete stats_cb;
- stats_cb= nullptr;
+ stats_cb.reset();
}
ulonglong vers_start_id() const;
diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc
index 99eae45dcc1..a546127f413 100644
--- a/storage/spider/spd_table.cc
+++ b/storage/spider/spd_table.cc
@@ -6709,7 +6709,7 @@ int spider_open_all_tables(
free_root(&mem_root, MYF(0));
DBUG_RETURN(HA_ERR_OUT_OF_MEM);
}
- memcpy((void*)share, (void*) &tmp_share, sizeof(*share));
+ memcpy((void*)share, &tmp_share, sizeof(*share));
spider_set_tmp_share_pointer(share, connect_info,
connect_info_length, long_info, longlong_info);
memcpy(connect_info, &tmp_connect_info, sizeof(char *) *