Commit d9e1e326 authored by marko's avatar marko

branches/zip: Port r973 from trunk.

Do not break the latching order in TRUNCATE TABLE.

dict_truncate_index_tree(): Replace parameter rec_t* rec with
btr_pcur_t* pcur.  Reposition pcur before calling btr_create().

sync_thread_add_level(): Remove the relaxation of the assertion added in r968.
parent 8bcc62c6
...@@ -714,8 +714,10 @@ dict_truncate_index_tree( ...@@ -714,8 +714,10 @@ dict_truncate_index_tree(
/* out: new root page number, or /* out: new root page number, or
FIL_NULL on failure */ FIL_NULL on failure */
dict_table_t* table, /* in: the table the index belongs to */ dict_table_t* table, /* in: the table the index belongs to */
rec_t* rec, /* in/out: record in the clustered index of btr_pcur_t* pcur, /* in/out: persistent cursor pointing to
SYS_INDEXES table */ record in the clustered index of
SYS_INDEXES table. The cursor may be
repositioned in this call. */
mtr_t* mtr) /* in: mtr having the latch mtr_t* mtr) /* in: mtr having the latch
on the record page. The mtr may be on the record page. The mtr may be
committed and restarted in this call. */ committed and restarted in this call. */
...@@ -724,6 +726,7 @@ dict_truncate_index_tree( ...@@ -724,6 +726,7 @@ dict_truncate_index_tree(
ulint space; ulint space;
ulint type; ulint type;
dulint index_id; dulint index_id;
rec_t* rec;
const byte* ptr; const byte* ptr;
ulint len; ulint len;
ulint comp; ulint comp;
...@@ -734,6 +737,7 @@ dict_truncate_index_tree( ...@@ -734,6 +737,7 @@ dict_truncate_index_tree(
#endif /* UNIV_SYNC_DEBUG */ #endif /* UNIV_SYNC_DEBUG */
ut_a(!dict_table_is_comp(dict_sys->sys_indexes)); ut_a(!dict_table_is_comp(dict_sys->sys_indexes));
rec = btr_pcur_get_rec(pcur);
ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len); ptr = rec_get_nth_field_old(rec, DICT_SYS_INDEXES_PAGE_NO_FIELD, &len);
ut_ad(len == 4); ut_ad(len == 4);
...@@ -799,10 +803,11 @@ dict_truncate_index_tree( ...@@ -799,10 +803,11 @@ dict_truncate_index_tree(
/* We will need to commit the mini-transaction in order to avoid /* We will need to commit the mini-transaction in order to avoid
deadlocks in the btr_create() call, because otherwise we would deadlocks in the btr_create() call, because otherwise we would
be freeing and allocating pages in the same mini-transaction. */ be freeing and allocating pages in the same mini-transaction. */
btr_pcur_store_position(pcur, mtr);
mtr_commit(mtr); mtr_commit(mtr);
/* mtr_commit() will invalidate rec. */
rec = NULL;
mtr_start(mtr); mtr_start(mtr);
btr_pcur_restore_position(BTR_MODIFY_LEAF, pcur, mtr);
/* Find the index corresponding to this SYS_INDEXES record. */ /* Find the index corresponding to this SYS_INDEXES record. */
for (index = UT_LIST_GET_FIRST(table->indexes); for (index = UT_LIST_GET_FIRST(table->indexes);
......
...@@ -62,8 +62,10 @@ dict_truncate_index_tree( ...@@ -62,8 +62,10 @@ dict_truncate_index_tree(
/* out: new root page number, or /* out: new root page number, or
FIL_NULL on failure */ FIL_NULL on failure */
dict_table_t* table, /* in: the table the index belongs to */ dict_table_t* table, /* in: the table the index belongs to */
rec_t* rec, /* in/out: record in the clustered index of btr_pcur_t* pcur, /* in/out: persistent cursor pointing to
SYS_INDEXES table */ record in the clustered index of
SYS_INDEXES table. The cursor may be
repositioned in this call. */
mtr_t* mtr); /* in: mtr having the latch mtr_t* mtr); /* in: mtr having the latch
on the record page. The mtr may be on the record page. The mtr may be
committed and restarted in this call. */ committed and restarted in this call. */
......
...@@ -2823,12 +2823,10 @@ row_truncate_table_for_mysql( ...@@ -2823,12 +2823,10 @@ row_truncate_table_for_mysql(
goto next_rec; goto next_rec;
} }
btr_pcur_store_position(&pcur, &mtr); /* This call may commit and restart mtr
and reposition pcur. */
root_page_no = dict_truncate_index_tree(table, &pcur, &mtr);
/* This call may commit and restart mtr. */
root_page_no = dict_truncate_index_tree(table, rec, &mtr);
btr_pcur_restore_position(BTR_MODIFY_LEAF, &pcur, &mtr);
rec = btr_pcur_get_rec(&pcur); rec = btr_pcur_get_rec(&pcur);
if (root_page_no != FIL_NULL) { if (root_page_no != FIL_NULL) {
......
...@@ -1126,7 +1126,6 @@ sync_thread_add_level( ...@@ -1126,7 +1126,6 @@ sync_thread_add_level(
break; break;
case SYNC_TREE_NODE: case SYNC_TREE_NODE:
ut_a(sync_thread_levels_contain(array, SYNC_INDEX_TREE) ut_a(sync_thread_levels_contain(array, SYNC_INDEX_TREE)
|| sync_thread_levels_contain(array, SYNC_DICT_OPERATION)
|| sync_thread_levels_g(array, SYNC_TREE_NODE - 1)); || sync_thread_levels_g(array, SYNC_TREE_NODE - 1));
break; break;
case SYNC_TREE_NODE_NEW: case SYNC_TREE_NODE_NEW:
......
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