summaryrefslogtreecommitdiff
path: root/storage/xtradb/dict
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2014-05-06 10:21:34 +0200
committerSergei Golubchik <sergii@pisem.net>2014-05-06 10:21:34 +0200
commitb968363aac2bf75d014482f8405e6a9fed73ccd6 (patch)
tree7f2aa9432e293ffe4dfcc772c06991d0b604ca24 /storage/xtradb/dict
parente2e5d07b2807706fb9187f00c049474a01ab15da (diff)
parent05fd3e63665597d3bcdf1094bb111df014087936 (diff)
downloadmariadb-git-b968363aac2bf75d014482f8405e6a9fed73ccd6.tar.gz
MDEV-6184 10.0.11 merge
XtraDB 5.6.16-64.2
Diffstat (limited to 'storage/xtradb/dict')
-rw-r--r--storage/xtradb/dict/dict0boot.cc12
-rw-r--r--storage/xtradb/dict/dict0crea.cc8
-rw-r--r--storage/xtradb/dict/dict0dict.cc101
-rw-r--r--storage/xtradb/dict/dict0load.cc33
-rw-r--r--storage/xtradb/dict/dict0mem.cc40
-rw-r--r--storage/xtradb/dict/dict0stats.cc130
6 files changed, 168 insertions, 156 deletions
diff --git a/storage/xtradb/dict/dict0boot.cc b/storage/xtradb/dict/dict0boot.cc
index 94a3af2852b..b57a8873bd5 100644
--- a/storage/xtradb/dict/dict0boot.cc
+++ b/storage/xtradb/dict/dict0boot.cc
@@ -302,7 +302,8 @@ dict_boot(void)
/* Insert into the dictionary cache the descriptions of the basic
system tables */
/*-------------------------*/
- table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0);
+ table = dict_mem_table_create("SYS_TABLES", DICT_HDR_SPACE, 8, 0, 0,
+ false);
dict_mem_table_add_col(table, heap, "NAME", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -356,7 +357,8 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0);
+ table = dict_mem_table_create("SYS_COLUMNS", DICT_HDR_SPACE, 7, 0, 0,
+ false);
dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
@@ -389,7 +391,8 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0);
+ table = dict_mem_table_create("SYS_INDEXES", DICT_HDR_SPACE, 7, 0, 0,
+ false);
dict_mem_table_add_col(table, heap, "TABLE_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "ID", DATA_BINARY, 0, 0);
@@ -422,7 +425,8 @@ dict_boot(void)
ut_a(error == DB_SUCCESS);
/*-------------------------*/
- table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0);
+ table = dict_mem_table_create("SYS_FIELDS", DICT_HDR_SPACE, 3, 0, 0,
+ false);
dict_mem_table_add_col(table, heap, "INDEX_ID", DATA_BINARY, 0, 0);
dict_mem_table_add_col(table, heap, "POS", DATA_INT, 0, 4);
diff --git a/storage/xtradb/dict/dict0crea.cc b/storage/xtradb/dict/dict0crea.cc
index eba5417dc76..ff892749d4f 100644
--- a/storage/xtradb/dict/dict0crea.cc
+++ b/storage/xtradb/dict/dict0crea.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
-Copyright (c) 1996, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 1996, 2013, Oracle and/or its affiliates. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -270,6 +270,12 @@ dict_build_table_def_step(
thr_get_trx(thr)->table_id = table->id;
+ /* Always set this bit for all new created tables */
+ DICT_TF2_FLAG_SET(table, DICT_TF2_FTS_AUX_HEX_NAME);
+ DBUG_EXECUTE_IF("innodb_test_wrong_fts_aux_table_name",
+ DICT_TF2_FLAG_UNSET(table,
+ DICT_TF2_FTS_AUX_HEX_NAME););
+
if (use_tablespace) {
/* This table will not use the system tablespace.
Get a new space id. */
diff --git a/storage/xtradb/dict/dict0dict.cc b/storage/xtradb/dict/dict0dict.cc
index 0aaec42cd2f..5cc013b7d6b 100644
--- a/storage/xtradb/dict/dict0dict.cc
+++ b/storage/xtradb/dict/dict0dict.cc
@@ -121,19 +121,6 @@ UNIV_INTERN mysql_pfs_key_t dict_foreign_err_mutex_key;
/** Identifies generated InnoDB foreign key names */
static char dict_ibfk[] = "_ibfk_";
-/** array of rw locks protecting
-dict_table_t::stat_initialized
-dict_table_t::stat_n_rows (*)
-dict_table_t::stat_clustered_index_size
-dict_table_t::stat_sum_of_other_index_sizes
-dict_table_t::stat_modified_counter (*)
-dict_table_t::indexes*::stat_n_diff_key_vals[]
-dict_table_t::indexes*::stat_index_size
-dict_table_t::indexes*::stat_n_leaf_pages
-(*) those are not always protected for performance reasons */
-#define DICT_TABLE_STATS_LATCHES_SIZE 64
-static rw_lock_t dict_table_stats_latches[DICT_TABLE_STATS_LATCHES_SIZE];
-
/*******************************************************************//**
Tries to find column names for the index and sets the col field of the
index.
@@ -332,32 +319,31 @@ dict_mutex_exit_for_mysql(void)
mutex_exit(&(dict_sys->mutex));
}
-/** Get the latch that protects the stats of a given table */
-#define GET_TABLE_STATS_LATCH(table) \
- (&dict_table_stats_latches[ut_fold_ull((ib_uint64_t) table) \
- % DICT_TABLE_STATS_LATCHES_SIZE])
-
/**********************************************************************//**
-Lock the appropriate latch to protect a given table's statistics.
-table->id is used to pick the corresponding latch from a global array of
-latches. */
+Lock the appropriate latch to protect a given table's statistics. */
UNIV_INTERN
void
dict_table_stats_lock(
/*==================*/
- const dict_table_t* table, /*!< in: table */
- ulint latch_mode) /*!< in: RW_S_LATCH or
- RW_X_LATCH */
+ dict_table_t* table, /*!< in: table */
+ ulint latch_mode) /*!< in: RW_S_LATCH or RW_X_LATCH */
{
ut_ad(table != NULL);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
+ if (table->stats_latch == NULL) {
+ /* This is a dummy table object that is private in the current
+ thread and is not shared between multiple threads, thus we
+ skip any locking. */
+ return;
+ }
+
switch (latch_mode) {
case RW_S_LATCH:
- rw_lock_s_lock(GET_TABLE_STATS_LATCH(table));
+ rw_lock_s_lock(table->stats_latch);
break;
case RW_X_LATCH:
- rw_lock_x_lock(GET_TABLE_STATS_LATCH(table));
+ rw_lock_x_lock(table->stats_latch);
break;
case RW_NO_LATCH:
/* fall through */
@@ -372,19 +358,26 @@ UNIV_INTERN
void
dict_table_stats_unlock(
/*====================*/
- const dict_table_t* table, /*!< in: table */
- ulint latch_mode) /*!< in: RW_S_LATCH or
+ dict_table_t* table, /*!< in: table */
+ ulint latch_mode) /*!< in: RW_S_LATCH or
RW_X_LATCH */
{
ut_ad(table != NULL);
ut_ad(table->magic_n == DICT_TABLE_MAGIC_N);
+ if (table->stats_latch == NULL) {
+ /* This is a dummy table object that is private in the current
+ thread and is not shared between multiple threads, thus we
+ skip any locking. */
+ return;
+ }
+
switch (latch_mode) {
case RW_S_LATCH:
- rw_lock_s_unlock(GET_TABLE_STATS_LATCH(table));
+ rw_lock_s_unlock(table->stats_latch);
break;
case RW_X_LATCH:
- rw_lock_x_unlock(GET_TABLE_STATS_LATCH(table));
+ rw_lock_x_unlock(table->stats_latch);
break;
case RW_NO_LATCH:
/* fall through */
@@ -880,8 +873,6 @@ void
dict_init(void)
/*===========*/
{
- int i;
-
dict_sys = static_cast<dict_sys_t*>(mem_zalloc(sizeof(*dict_sys)));
mutex_create(dict_sys_mutex_key, &dict_sys->mutex, SYNC_DICT);
@@ -902,11 +893,6 @@ dict_init(void)
mutex_create(dict_foreign_err_mutex_key,
&dict_foreign_err_mutex, SYNC_NO_ORDER_CHECK);
}
-
- for (i = 0; i < DICT_TABLE_STATS_LATCHES_SIZE; i++) {
- rw_lock_create(dict_table_stats_latch_key,
- &dict_table_stats_latches[i], SYNC_INDEX_TREE);
- }
}
/**********************************************************************//**
@@ -5770,7 +5756,8 @@ dict_ind_init(void)
dict_table_t* table;
/* create dummy table and index for REDUNDANT infimum and supremum */
- table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0);
+ table = dict_mem_table_create("SYS_DUMMY1", DICT_HDR_SPACE, 1, 0, 0,
+ true);
dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8);
@@ -5783,7 +5770,7 @@ dict_ind_init(void)
/* create dummy table and index for COMPACT infimum and supremum */
table = dict_mem_table_create("SYS_DUMMY2",
DICT_HDR_SPACE, 1,
- DICT_TF_COMPACT, 0);
+ DICT_TF_COMPACT, 0, true);
dict_mem_table_add_col(table, NULL, NULL, DATA_CHAR,
DATA_ENGLISH | DATA_NOT_NULL, 8);
dict_ind_compact = dict_mem_index_create("SYS_DUMMY2", "SYS_DUMMY2",
@@ -6010,6 +5997,17 @@ dict_table_check_for_dup_indexes(
}
#endif /* UNIV_DEBUG */
+/** Auxiliary macro used inside dict_table_schema_check(). */
+#define CREATE_TYPES_NAMES() \
+ dtype_sql_name((unsigned) req_schema->columns[i].mtype, \
+ (unsigned) req_schema->columns[i].prtype_mask, \
+ (unsigned) req_schema->columns[i].len, \
+ req_type, sizeof(req_type)); \
+ dtype_sql_name(table->cols[j].mtype, \
+ table->cols[j].prtype, \
+ table->cols[j].len, \
+ actual_type, sizeof(actual_type))
+
/*********************************************************************//**
Checks whether a table exists and whether it has the given structure.
The table must have the same number of columns with the same names and
@@ -6029,6 +6027,8 @@ dict_table_schema_check(
size_t errstr_sz) /*!< in: errstr size */
{
char buf[MAX_FULL_NAME_LEN];
+ char req_type[64];
+ char actual_type[64];
dict_table_t* table;
ulint i;
@@ -6080,9 +6080,6 @@ dict_table_schema_check(
for (i = 0; i < req_schema->n_cols; i++) {
ulint j;
- char req_type[64];
- char actual_type[64];
-
/* check if i'th column is the same in both arrays */
if (innobase_strcasecmp(req_schema->columns[i].name,
dict_table_get_col_name(table, i)) == 0) {
@@ -6124,19 +6121,11 @@ dict_table_schema_check(
/* we found a column with the same name on j'th position,
compare column types and flags */
- dtype_sql_name(req_schema->columns[i].mtype,
- req_schema->columns[i].prtype_mask,
- req_schema->columns[i].len,
- req_type, sizeof(req_type));
-
- dtype_sql_name(table->cols[j].mtype,
- table->cols[j].prtype,
- table->cols[j].len,
- actual_type, sizeof(actual_type));
-
/* check length for exact match */
if (req_schema->columns[i].len != table->cols[j].len) {
+ CREATE_TYPES_NAMES();
+
ut_snprintf(errstr, errstr_sz,
"Column %s in table %s is %s "
"but should be %s (length mismatch).",
@@ -6151,6 +6140,8 @@ dict_table_schema_check(
/* check mtype for exact match */
if (req_schema->columns[i].mtype != table->cols[j].mtype) {
+ CREATE_TYPES_NAMES();
+
ut_snprintf(errstr, errstr_sz,
"Column %s in table %s is %s "
"but should be %s (type mismatch).",
@@ -6168,6 +6159,8 @@ dict_table_schema_check(
& req_schema->columns[i].prtype_mask)
!= req_schema->columns[i].prtype_mask) {
+ CREATE_TYPES_NAMES();
+
ut_snprintf(errstr, errstr_sz,
"Column %s in table %s is %s "
"but should be %s (flags mismatch).",
@@ -6326,10 +6319,6 @@ dict_close(void)
mem_free(dict_sys);
dict_sys = NULL;
-
- for (i = 0; i < DICT_TABLE_STATS_LATCHES_SIZE; i++) {
- rw_lock_free(&dict_table_stats_latches[i]);
- }
}
#ifdef UNIV_DEBUG
diff --git a/storage/xtradb/dict/dict0load.cc b/storage/xtradb/dict/dict0load.cc
index 5c97b5aba7c..9add88c0ea5 100644
--- a/storage/xtradb/dict/dict0load.cc
+++ b/storage/xtradb/dict/dict0load.cc
@@ -1092,10 +1092,34 @@ loop:
case DICT_CHECK_ALL_LOADED:
/* All tablespaces should have been found in
fil_load_single_table_tablespaces(). */
-
- fil_space_for_table_exists_in_mem(
+ if (fil_space_for_table_exists_in_mem(
space_id, name, TRUE, !(is_temp || discarded),
- false, NULL, 0);
+ false, NULL, 0)
+ && !(is_temp || discarded)) {
+ /* If user changes the path of .ibd files in
+ *.isl files before doing crash recovery ,
+ then this leads to inconsistency in
+ SYS_DATAFILES system table because the
+ tables are loaded from the updated path
+ but the SYS_DATAFILES still points to the
+ old path.Therefore after crash recovery
+ update SYS_DATAFILES with the updated path.*/
+ ut_ad(space_id);
+ ut_ad(recv_needed_recovery);
+ char *dict_path = dict_get_first_path(space_id,
+ name);
+ char *remote_path = fil_read_link_file(name);
+ if(dict_path && remote_path) {
+ if(strcmp(dict_path,remote_path)) {
+ dict_update_filepath(space_id,
+ remote_path);
+ }
+ }
+ if(dict_path)
+ mem_free(dict_path);
+ if(remote_path)
+ mem_free(remote_path);
+ }
break;
case DICT_CHECK_SOME_LOADED:
@@ -2151,7 +2175,8 @@ err_len:
/* See if the tablespace is available. */
*table = dict_mem_table_create(
- name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2);
+ name, space, n_cols & ~DICT_N_COLS_COMPACT, flags, flags2,
+ false);
field = rec_get_nth_field_old(rec, DICT_FLD__SYS_TABLES__ID, &len);
ut_ad(len == 8); /* this was checked earlier */
diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc
index f69e6cc47ae..7ce42fa8efc 100644
--- a/storage/xtradb/dict/dict0mem.cc
+++ b/storage/xtradb/dict/dict0mem.cc
@@ -65,7 +65,10 @@ dict_mem_table_create(
the table is placed */
ulint n_cols, /*!< in: number of columns */
ulint flags, /*!< in: table flags */
- ulint flags2) /*!< in: table flags2 */
+ ulint flags2, /*!< in: table flags2 */
+ bool nonshared)/*!< in: whether the table object is a dummy
+ one that does not need the initialization of
+ locking-related fields. */
{
dict_table_t* table;
mem_heap_t* heap;
@@ -95,12 +98,27 @@ dict_mem_table_create(
ut_d(table->magic_n = DICT_TABLE_MAGIC_N);
+ if (!nonshared) {
+ table->stats_latch = new rw_lock_t;
+ rw_lock_create(dict_table_stats_latch_key, table->stats_latch,
+ SYNC_INDEX_TREE);
+ } else {
+ table->stats_latch = NULL;
+ }
+
#ifndef UNIV_HOTBACKUP
- table->autoinc_lock = static_cast<ib_lock_t*>(
- mem_heap_alloc(heap, lock_get_size()));
- mutex_create(autoinc_mutex_key,
- &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
+ if (!nonshared) {
+
+ table->autoinc_lock = static_cast<ib_lock_t*>(
+ mem_heap_alloc(heap, lock_get_size()));
+
+ mutex_create(autoinc_mutex_key,
+ &table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
+ } else {
+
+ table->autoinc_lock = NULL;
+ }
table->autoinc = 0;
@@ -150,8 +168,18 @@ dict_mem_table_free(
}
}
#ifndef UNIV_HOTBACKUP
- mutex_free(&(table->autoinc_mutex));
+ if (table->stats_latch) {
+
+ mutex_free(&(table->autoinc_mutex));
+ }
#endif /* UNIV_HOTBACKUP */
+
+ if (table->stats_latch) {
+
+ rw_lock_free(table->stats_latch);
+ delete table->stats_latch;
+ }
+
ut_free(table->name);
mem_heap_free(table->heap);
}
diff --git a/storage/xtradb/dict/dict0stats.cc b/storage/xtradb/dict/dict0stats.cc
index 8bf02f9785c..68c02a301cd 100644
--- a/storage/xtradb/dict/dict0stats.cc
+++ b/storage/xtradb/dict/dict0stats.cc
@@ -400,6 +400,11 @@ dict_stats_table_clone_create(
t->corrupted = table->corrupted;
+ /* This private object "t" is not shared with other threads, so
+ we do not need the stats_latch. The lock/unlock routines will do
+ nothing if stats_latch is NULL. */
+ t->stats_latch = NULL;
+
UT_LIST_INIT(t->indexes);
for (index = dict_table_get_first_index(table);
@@ -731,7 +736,7 @@ static
dict_table_t*
dict_stats_snapshot_create(
/*=======================*/
- const dict_table_t* table) /*!< in: table whose stats to copy */
+ dict_table_t* table) /*!< in: table whose stats to copy */
{
mutex_enter(&dict_sys->mutex);
@@ -2131,8 +2136,16 @@ dict_stats_save_index_stat(
ret = dict_stats_exec_sql(
pinfo,
- "PROCEDURE INDEX_STATS_SAVE_INSERT () IS\n"
+ "PROCEDURE INDEX_STATS_SAVE () IS\n"
"BEGIN\n"
+
+ "DELETE FROM \"" INDEX_STATS_NAME "\"\n"
+ "WHERE\n"
+ "database_name = :database_name AND\n"
+ "table_name = :table_name AND\n"
+ "index_name = :index_name AND\n"
+ "stat_name = :stat_name;\n"
+
"INSERT INTO \"" INDEX_STATS_NAME "\"\n"
"VALUES\n"
"(\n"
@@ -2147,47 +2160,6 @@ dict_stats_save_index_stat(
");\n"
"END;");
- if (ret == DB_DUPLICATE_KEY) {
-
- pinfo = pars_info_create();
- pars_info_add_str_literal(pinfo, "database_name", db_utf8);
- pars_info_add_str_literal(pinfo, "table_name", table_utf8);
- UNIV_MEM_ASSERT_RW_ABORT(index->name, strlen(index->name));
- pars_info_add_str_literal(pinfo, "index_name", index->name);
- UNIV_MEM_ASSERT_RW_ABORT(&last_update, 4);
- pars_info_add_int4_literal(pinfo, "last_update", last_update);
- UNIV_MEM_ASSERT_RW_ABORT(stat_name, strlen(stat_name));
- pars_info_add_str_literal(pinfo, "stat_name", stat_name);
- UNIV_MEM_ASSERT_RW_ABORT(&stat_value, 8);
- pars_info_add_ull_literal(pinfo, "stat_value", stat_value);
- if (sample_size != NULL) {
- UNIV_MEM_ASSERT_RW_ABORT(sample_size, 8);
- pars_info_add_ull_literal(pinfo, "sample_size", *sample_size);
- } else {
- pars_info_add_literal(pinfo, "sample_size", NULL,
- UNIV_SQL_NULL, DATA_FIXBINARY, 0);
- }
- UNIV_MEM_ASSERT_RW_ABORT(stat_description, strlen(stat_description));
- pars_info_add_str_literal(pinfo, "stat_description",
- stat_description);
-
- ret = dict_stats_exec_sql(
- pinfo,
- "PROCEDURE INDEX_STATS_SAVE_UPDATE () IS\n"
- "BEGIN\n"
- "UPDATE \"" INDEX_STATS_NAME "\" SET\n"
- "last_update = :last_update,\n"
- "stat_value = :stat_value,\n"
- "sample_size = :sample_size,\n"
- "stat_description = :stat_description\n"
- "WHERE\n"
- "database_name = :database_name AND\n"
- "table_name = :table_name AND\n"
- "index_name = :index_name AND\n"
- "stat_name = :stat_name;\n"
- "END;");
- }
-
if (ret != DB_SUCCESS) {
char buf_table[MAX_FULL_NAME_LEN];
char buf_index[MAX_FULL_NAME_LEN];
@@ -2205,14 +2177,18 @@ dict_stats_save_index_stat(
return(ret);
}
-/*********************************************************************//**
-Save the table's statistics into the persistent statistics storage.
+/** Save the table's statistics into the persistent statistics storage.
+@param[in] table_orig table whose stats to save
+@param[in] only_for_index if this is non-NULL, then stats for indexes
+that are not equal to it will not be saved, if NULL, then all
+indexes' stats are saved
@return DB_SUCCESS or error code */
static
dberr_t
dict_stats_save(
/*============*/
- dict_table_t* table_orig) /*!< in: table */
+ dict_table_t* table_orig,
+ const index_id_t* only_for_index)
{
pars_info_t* pinfo;
lint now;
@@ -2234,26 +2210,27 @@ dict_stats_save(
lint */
now = (lint) ut_time();
-#define PREPARE_PINFO_FOR_TABLE_SAVE(p, t, n) \
- do { \
- pars_info_add_str_literal((p), "database_name", db_utf8); \
- pars_info_add_str_literal((p), "table_name", table_utf8); \
- pars_info_add_int4_literal((p), "last_update", (n)); \
- pars_info_add_ull_literal((p), "n_rows", (t)->stat_n_rows); \
- pars_info_add_ull_literal((p), "clustered_index_size", \
- (t)->stat_clustered_index_size); \
- pars_info_add_ull_literal((p), "sum_of_other_index_sizes", \
- (t)->stat_sum_of_other_index_sizes); \
- } while(false);
-
pinfo = pars_info_create();
- PREPARE_PINFO_FOR_TABLE_SAVE(pinfo, table, now);
+ pars_info_add_str_literal(pinfo, "database_name", db_utf8);
+ pars_info_add_str_literal(pinfo, "table_name", table_utf8);
+ pars_info_add_int4_literal(pinfo, "last_update", now);
+ pars_info_add_ull_literal(pinfo, "n_rows", table->stat_n_rows);
+ pars_info_add_ull_literal(pinfo, "clustered_index_size",
+ table->stat_clustered_index_size);
+ pars_info_add_ull_literal(pinfo, "sum_of_other_index_sizes",
+ table->stat_sum_of_other_index_sizes);
ret = dict_stats_exec_sql(
pinfo,
- "PROCEDURE TABLE_STATS_SAVE_INSERT () IS\n"
+ "PROCEDURE TABLE_STATS_SAVE () IS\n"
"BEGIN\n"
+
+ "DELETE FROM \"" TABLE_STATS_NAME "\"\n"
+ "WHERE\n"
+ "database_name = :database_name AND\n"
+ "table_name = :table_name;\n"
+
"INSERT INTO \"" TABLE_STATS_NAME "\"\n"
"VALUES\n"
"(\n"
@@ -2266,27 +2243,6 @@ dict_stats_save(
");\n"
"END;");
- if (ret == DB_DUPLICATE_KEY) {
- pinfo = pars_info_create();
-
- PREPARE_PINFO_FOR_TABLE_SAVE(pinfo, table, now);
-
- ret = dict_stats_exec_sql(
- pinfo,
- "PROCEDURE TABLE_STATS_SAVE_UPDATE () IS\n"
- "BEGIN\n"
- "UPDATE \"" TABLE_STATS_NAME "\" SET\n"
- "last_update = :last_update,\n"
- "n_rows = :n_rows,\n"
- "clustered_index_size = :clustered_index_size,\n"
- "sum_of_other_index_sizes = "
- " :sum_of_other_index_sizes\n"
- "WHERE\n"
- "database_name = :database_name AND\n"
- "table_name = :table_name;\n"
- "END;");
- }
-
if (ret != DB_SUCCESS) {
char buf[MAX_FULL_NAME_LEN];
ut_print_timestamp(stderr);
@@ -2304,6 +2260,10 @@ dict_stats_save(
index != NULL;
index = dict_table_get_next_index(index)) {
+ if (only_for_index != NULL && index->id != *only_for_index) {
+ continue;
+ }
+
if (dict_stats_should_ignore_index(index)) {
continue;
}
@@ -2860,7 +2820,7 @@ dict_stats_update_for_index(
dict_table_stats_lock(index->table, RW_X_LATCH);
dict_stats_analyze_index(index);
dict_table_stats_unlock(index->table, RW_X_LATCH);
- dict_stats_save(index->table);
+ dict_stats_save(index->table, &index->id);
DBUG_VOID_RETURN;
}
/* else */
@@ -2955,7 +2915,7 @@ dict_stats_update(
return(err);
}
- err = dict_stats_save(table);
+ err = dict_stats_save(table, NULL);
return(err);
}
@@ -2988,7 +2948,7 @@ dict_stats_update(
if (dict_stats_persistent_storage_check(false)) {
- return(dict_stats_save(table));
+ return(dict_stats_save(table, NULL));
}
return(DB_STATS_DO_NOT_EXIST);
@@ -3834,7 +3794,7 @@ test_dict_stats_save()
index2_stat_n_sample_sizes[2] = TEST_IDX2_N_DIFF3_SAMPLE_SIZE;
index2_stat_n_sample_sizes[3] = TEST_IDX2_N_DIFF4_SAMPLE_SIZE;
- ret = dict_stats_save(&table);
+ ret = dict_stats_save(&table, NULL);
ut_a(ret == DB_SUCCESS);