Skip to content

Commit

Permalink
Remove some fields from dict_table_t
Browse files Browse the repository at this point in the history
dict_table_t::thd: Remove. This was only used by btr_root_block_get()
for reporting decryption failures, and it was only assigned by
ha_innobase::open(), and never cleared. This could mean that if a
connection is closed, the pointer would become stale, and the server
could crash while trying to report the error. It could also mean
that an error is being reported to the wrong client. It is better
to use current_thd in this case, even though it could mean that if
the code is invoked from an InnoDB background operation, there would
be no connection to which to send the error message.

Remove dict_table_t::crypt_data and dict_table_t::page_0_read.
These fields were never read.

fil_open_single_table_tablespace(): Remove the parameter "table".
  • Loading branch information
dr-m committed Jun 15, 2017
1 parent 88b9618 commit 58f87a4
Show file tree
Hide file tree
Showing 16 changed files with 14 additions and 82 deletions.
3 changes: 2 additions & 1 deletion storage/innobase/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,8 @@ btr_root_block_get(
if (index && index->table) {
index->table->file_unreadable = true;

ib_push_warning(index->table->thd, DB_DECRYPTION_FAILED,
ib_push_warning(
static_cast<THD*>(NULL), DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/dict/dict0load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ dict_check_tablespaces_and_store_max_id(
dberr_t err = fil_open_single_table_tablespace(
read_page_0, srv_read_only_mode ? false : true,
space_id, dict_tf_to_fsp_flags(flags),
name, filepath, NULL);
name, filepath);

if (err != DB_SUCCESS) {
ib_logf(IB_LOG_LEVEL_ERROR,
Expand Down Expand Up @@ -2415,7 +2415,7 @@ dict_load_table(
err = fil_open_single_table_tablespace(
true, false, table->space,
dict_tf_to_fsp_flags(table->flags),
name, filepath, table);
name, filepath);

if (err != DB_SUCCESS) {
/* We failed to find a sensible
Expand Down
18 changes: 1 addition & 17 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4036,8 +4036,7 @@ fil_open_single_table_tablespace(
ulint flags, /*!< in: expected FSP_SPACE_FLAGS */
const char* tablename, /*!< in: table name in the
databasename/tablename format */
const char* path_in, /*!< in: tablespace filepath */
dict_table_t* table) /*!< in: table */
const char* path_in) /*!< in: table */
{
dberr_t err = DB_SUCCESS;
bool dict_filepath_same_as_default = false;
Expand Down Expand Up @@ -4147,11 +4146,6 @@ fil_open_single_table_tablespace(
#endif /* UNIV_LOG_ARCHIVE */
NULL, &def.crypt_data);

if (table) {
table->crypt_data = def.crypt_data;
table->page_0_read = true;
}

def.valid = !def.check_msg && def.id == id
&& fsp_flags_match(flags, def.flags);

Expand All @@ -4174,11 +4168,6 @@ fil_open_single_table_tablespace(
#endif /* UNIV_LOG_ARCHIVE */
NULL, &remote.crypt_data);

if (table) {
table->crypt_data = remote.crypt_data;
table->page_0_read = true;
}

/* Validate this single-table-tablespace with SYS_TABLES. */
remote.valid = !remote.check_msg && remote.id == id
&& fsp_flags_match(flags, remote.flags);
Expand All @@ -4203,11 +4192,6 @@ fil_open_single_table_tablespace(
#endif /* UNIV_LOG_ARCHIVE */
NULL, &dict.crypt_data);

if (table) {
table->crypt_data = dict.crypt_data;
table->page_0_read = true;
}

/* Validate this single-table-tablespace with SYS_TABLES. */
dict.valid = !dict.check_msg && dict.id == id
&& fsp_flags_match(flags, dict.flags);
Expand Down
2 changes: 0 additions & 2 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5860,8 +5860,6 @@ ha_innobase::open(

innobase_copy_frm_flags_from_table_share(ib_table, table->s);

ib_table->thd = (void*)thd;

/* No point to init any statistics if tablespace is still encrypted. */
if (ib_table->is_readable()) {
dict_stats_init(ib_table);
Expand Down
4 changes: 0 additions & 4 deletions storage/innobase/include/dict0mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,6 @@ struct dict_table_t{
table_id_t id; /*!< id of the table */
mem_heap_t* heap; /*!< memory heap */
char* name; /*!< table name */
void* thd; /*!< thd */
bool page_0_read; /*!< true if page 0 has
been already read */
fil_space_crypt_t *crypt_data; /*!< crypt data if present */
const char* dir_path_of_temp_table;/*!< NULL or the directory path
where a TEMPORARY table that was explicitly
created by a user should be placed if
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1045,8 +1045,7 @@ fil_open_single_table_tablespace(
ulint flags, /*!< in: expected FSP_SPACE_FLAGS */
const char* tablename, /*!< in: table name in the
databasename/tablename format */
const char* filepath, /*!< in: tablespace filepath */
dict_table_t* table) /*!< in: table */
const char* filepath) /*!< in: tablespace filepath */
__attribute__((nonnull(5), warn_unused_result));

#endif /* !UNIV_HOTBACKUP */
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/row/row0import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3617,7 +3617,7 @@ row_import_for_mysql(
err = fil_open_single_table_tablespace(
true, true, table->space,
dict_tf_to_fsp_flags(table->flags),
table->name, filepath, table);
table->name, filepath);

DBUG_EXECUTE_IF("ib_import_open_tablespace_failure",
err = DB_TABLESPACE_NOT_FOUND;);
Expand Down
12 changes: 0 additions & 12 deletions storage/innobase/row/row0mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4242,18 +4242,6 @@ row_drop_table_for_mysql(
rw_lock_x_unlock(dict_index_get_lock(index));
}

/* If table has not yet have crypt_data, try to read it to
make freeing the table easier. */
if (!table->crypt_data) {

if (fil_space_t* space = fil_space_acquire_silent(table->space)) {
/* We use crypt data in dict_table_t in ha_innodb.cc
to push warnings to user thread. */
table->crypt_data = space->crypt_data;
fil_space_release(space);
}
}

/* We use the private SQL parser of Innobase to generate the
query graphs needed in deleting the dictionary data from system
tables in Innobase. Deleting a row from SYS_INDEXES table also
Expand Down
3 changes: 2 additions & 1 deletion storage/xtradb/btr/btr0btr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ btr_root_block_get(
if (index && index->table) {
index->table->file_unreadable = true;

ib_push_warning(index->table->thd, DB_DECRYPTION_FAILED,
ib_push_warning(
static_cast<THD*>(NULL), DB_DECRYPTION_FAILED,
"Table %s in tablespace %lu is encrypted but encryption service or"
" used key_id is not available. "
" Can't continue reading table.",
Expand Down
4 changes: 2 additions & 2 deletions storage/xtradb/dict/dict0load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ dict_check_tablespaces_and_store_max_id(
dberr_t err = fil_open_single_table_tablespace(
read_page_0, srv_read_only_mode ? false : true,
space_id, dict_tf_to_fsp_flags(flags),
name, filepath, NULL);
name, filepath);

if (err != DB_SUCCESS) {
ib_logf(IB_LOG_LEVEL_ERROR,
Expand Down Expand Up @@ -2437,7 +2437,7 @@ dict_load_table(
err = fil_open_single_table_tablespace(
true, false, table->space,
dict_tf_to_fsp_flags(table->flags),
name, filepath, table);
name, filepath);

if (err != DB_SUCCESS) {
/* We failed to find a sensible
Expand Down
18 changes: 1 addition & 17 deletions storage/xtradb/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4229,8 +4229,7 @@ fil_open_single_table_tablespace(
ulint flags, /*!< in: expected FSP_SPACE_FLAGS */
const char* tablename, /*!< in: table name in the
databasename/tablename format */
const char* path_in, /*!< in: tablespace filepath */
dict_table_t* table) /*!< in: table */
const char* path_in) /*!< in: table */
{
dberr_t err = DB_SUCCESS;
bool dict_filepath_same_as_default = false;
Expand Down Expand Up @@ -4339,11 +4338,6 @@ fil_open_single_table_tablespace(
def.file, false, &def.flags, &def.id,
NULL, &def.crypt_data);

if (table) {
table->crypt_data = def.crypt_data;
table->page_0_read = true;
}

def.valid = !def.check_msg && def.id == id
&& fsp_flags_match(flags, def.flags);

Expand All @@ -4363,11 +4357,6 @@ fil_open_single_table_tablespace(
remote.file, false, &remote.flags, &remote.id,
NULL, &remote.crypt_data);

if (table) {
table->crypt_data = remote.crypt_data;
table->page_0_read = true;
}

/* Validate this single-table-tablespace with SYS_TABLES. */
remote.valid = !remote.check_msg && remote.id == id
&& fsp_flags_match(flags, remote.flags);
Expand All @@ -4389,11 +4378,6 @@ fil_open_single_table_tablespace(
dict.file, false, &dict.flags, &dict.id,
NULL, &dict.crypt_data);

if (table) {
table->crypt_data = dict.crypt_data;
table->page_0_read = true;
}

/* Validate this single-table-tablespace with SYS_TABLES. */
dict.valid = !dict.check_msg && dict.id == id
&& fsp_flags_match(flags, dict.flags);
Expand Down
2 changes: 0 additions & 2 deletions storage/xtradb/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6429,8 +6429,6 @@ ha_innobase::open(

innobase_copy_frm_flags_from_table_share(ib_table, table->s);

ib_table->thd = (void*)thd;

/* No point to init any statistics if tablespace is still encrypted. */
if (ib_table->is_readable()) {
dict_stats_init(ib_table);
Expand Down
4 changes: 0 additions & 4 deletions storage/xtradb/include/dict0mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -1048,10 +1048,6 @@ struct dict_table_t{
table_id_t id; /*!< id of the table */
mem_heap_t* heap; /*!< memory heap */
char* name; /*!< table name */
void* thd; /*!< thd */
bool page_0_read; /*!< true if page 0 has
been already read */
fil_space_crypt_t *crypt_data; /*!< crypt data if present */
const char* dir_path_of_temp_table;/*!< NULL or the directory path
where a TEMPORARY table that was explicitly
created by a user should be placed if
Expand Down
3 changes: 1 addition & 2 deletions storage/xtradb/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -1043,8 +1043,7 @@ fil_open_single_table_tablespace(
ulint flags, /*!< in: expected FSP_SPACE_FLAGS */
const char* tablename, /*!< in: table name in the
databasename/tablename format */
const char* filepath, /*!< in: tablespace filepath */
dict_table_t* table) /*!< in: table */
const char* filepath) /*!< in: tablespace filepath */
__attribute__((nonnull(5), warn_unused_result));

#endif /* !UNIV_HOTBACKUP */
Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/row/row0import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3618,7 +3618,7 @@ row_import_for_mysql(
err = fil_open_single_table_tablespace(
true, true, table->space,
dict_tf_to_fsp_flags(table->flags),
table->name, filepath, table);
table->name, filepath);

DBUG_EXECUTE_IF("ib_import_open_tablespace_failure",
err = DB_TABLESPACE_NOT_FOUND;);
Expand Down
12 changes: 0 additions & 12 deletions storage/xtradb/row/row0mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4272,18 +4272,6 @@ row_drop_table_for_mysql(
rw_lock_x_unlock(dict_index_get_lock(index));
}

/* If table has not yet have crypt_data, try to read it to
make freeing the table easier. */
if (!table->crypt_data) {

if (fil_space_t* space = fil_space_acquire_silent(table->space)) {
/* We use crypt data in dict_table_t in ha_innodb.cc
to push warnings to user thread. */
table->crypt_data = space->crypt_data;
fil_space_release(space);
}
}

/* We use the private SQL parser of Innobase to generate the
query graphs needed in deleting the dictionary data from system
tables in Innobase. Deleting a row from SYS_INDEXES table also
Expand Down

0 comments on commit 58f87a4

Please sign in to comment.