Commit 642e0207 authored by Jimmy Yang's avatar Jimmy Yang

Merge from mysql-5.1-security to mysql-5.5-security.

parents a49bdbc1 ed2e88e6
...@@ -2841,15 +2841,6 @@ row_truncate_table_for_mysql( ...@@ -2841,15 +2841,6 @@ row_truncate_table_for_mysql(
trx->table_id = table->id; trx->table_id = table->id;
/* Lock all index trees for this table, as we will
truncate the table/index and possibly change their metadata.
All DML/DDL are blocked by table level lock, with
a few exceptions such as queries into information schema
about the table, MySQL could try to access index stats
for this kind of query, we need to use index locks to
sync up */
dict_table_x_lock_indexes(table);
if (table->space && !table->dir_path_of_temp_table) { if (table->space && !table->dir_path_of_temp_table) {
/* Discard and create the single-table tablespace. */ /* Discard and create the single-table tablespace. */
ulint space = table->space; ulint space = table->space;
...@@ -2862,6 +2853,11 @@ row_truncate_table_for_mysql( ...@@ -2862,6 +2853,11 @@ row_truncate_table_for_mysql(
dict_hdr_get_new_id(NULL, NULL, &space); dict_hdr_get_new_id(NULL, NULL, &space);
/* Lock all index trees for this table. We must
do so after dict_hdr_get_new_id() to preserve
the latch order */
dict_table_x_lock_indexes(table);
if (space == ULINT_UNDEFINED if (space == ULINT_UNDEFINED
|| fil_create_new_single_table_tablespace( || fil_create_new_single_table_tablespace(
space, table->name, FALSE, flags, space, table->name, FALSE, flags,
...@@ -2895,6 +2891,15 @@ row_truncate_table_for_mysql( ...@@ -2895,6 +2891,15 @@ row_truncate_table_for_mysql(
FIL_IBD_FILE_INITIAL_SIZE, &mtr); FIL_IBD_FILE_INITIAL_SIZE, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
} }
} else {
/* Lock all index trees for this table, as we will
truncate the table/index and possibly change their metadata.
All DML/DDL are blocked by table level lock, with
a few exceptions such as queries into information schema
about the table, MySQL could try to access index stats
for this kind of query, we need to use index locks to
sync up */
dict_table_x_lock_indexes(table);
} }
/* scan SYS_INDEXES for all indexes of the table */ /* scan SYS_INDEXES for all indexes of the table */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment