Commit d398e717 authored by marko's avatar marko

branches/zip: Fix a few bugs in fast index creation. No more crashes

occur in mysql-test-run, but mysql-test-run reports some warnings for
some tests and incorrect results for innodb-index.test.

innobase_start_trx_and_assign_read_view(): Use thd instead of current_thd.

ha_innobase::add_index(): Use ha_thd() instead of current_thd.
Commit the transaction at the end.

row_merge_rename_index(): Really change the name of the index.  This was
broken in r1430.
parent e621c1e2
...@@ -1812,7 +1812,7 @@ innobase_start_trx_and_assign_read_view( ...@@ -1812,7 +1812,7 @@ innobase_start_trx_and_assign_read_view(
/* Set the MySQL flag to mark that there is an active transaction */ /* Set the MySQL flag to mark that there is an active transaction */
if (trx->active_trans == 0) { if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(hton, current_thd); innobase_register_trx_and_stmt(hton, thd);
trx->active_trans = 1; trx->active_trans = 1;
} }
...@@ -8121,14 +8121,14 @@ ha_innobase::add_index( ...@@ -8121,14 +8121,14 @@ ha_innobase::add_index(
ulint num_of_idx; ulint num_of_idx;
ulint num_created; ulint num_created;
ibool dict_locked = FALSE; ibool dict_locked = FALSE;
ibool new_primary; ulint new_primary;
ibool new_unique = FALSE; ibool new_unique = FALSE;
ulint error; ulint error;
DBUG_ENTER("ha_innobase::add_index"); DBUG_ENTER("ha_innobase::add_index");
ut_a(table && key_info && num_of_keys); ut_a(table && key_info && num_of_keys);
update_thd(current_thd); update_thd(ha_thd());
heap = mem_heap_create_noninline(1024); heap = mem_heap_create_noninline(1024);
...@@ -8179,9 +8179,9 @@ err_exit: ...@@ -8179,9 +8179,9 @@ err_exit:
to drop all original secondary indexes from the table. These to drop all original secondary indexes from the table. These
indexes will be rebuilt below. */ indexes will be rebuilt below. */
new_primary = 0 != (DICT_CLUSTERED & index_defs[0].ind_type); new_primary = DICT_CLUSTERED & index_defs[0].ind_type;
if (new_primary) { if (UNIV_UNLIKELY(new_primary)) {
char* new_table_name = innobase_create_temporary_tablename( char* new_table_name = innobase_create_temporary_tablename(
heap, '1', innodb_table->name); heap, '1', innodb_table->name);
...@@ -8256,7 +8256,7 @@ err_exit: ...@@ -8256,7 +8256,7 @@ err_exit:
error = row_lock_table_for_merge(trx, innodb_table, LOCK_X); error = row_lock_table_for_merge(trx, innodb_table, LOCK_X);
} }
/* Set an exclusive table lock for the new table if a primary /* Acquire an exclusive table lock on the new table if a primary
key is to be built.*/ key is to be built.*/
if (error == DB_SUCCESS && new_primary) { if (error == DB_SUCCESS && new_primary) {
...@@ -8313,8 +8313,7 @@ error_handling: ...@@ -8313,8 +8313,7 @@ error_handling:
if (indexed_table != innodb_table) { if (indexed_table != innodb_table) {
row_merge_drop_table(trx, indexed_table); row_merge_drop_table(trx, indexed_table);
} }
mem_heap_free_noninline(heap); goto func_exit;
DBUG_RETURN(convert_error_code_to_mysql(error, user_thd));
} }
/* If a new primary key was defined for the table and /* If a new primary key was defined for the table and
...@@ -8373,9 +8372,10 @@ error_handling: ...@@ -8373,9 +8372,10 @@ error_handling:
} }
func_exit: func_exit:
/* There might be work for utility threads.*/
mem_heap_free_noninline(heap); mem_heap_free_noninline(heap);
innobase_commit_low(trx);
/* There might be work for utility threads.*/
srv_active_wake_master_thread(); srv_active_wake_master_thread();
DBUG_RETURN(convert_error_code_to_mysql(error, user_thd)); DBUG_RETURN(convert_error_code_to_mysql(error, user_thd));
......
...@@ -1471,7 +1471,7 @@ row_merge_rename_index( ...@@ -1471,7 +1471,7 @@ row_merge_rename_index(
trx_start_if_not_started(trx); trx_start_if_not_started(trx);
trx->op_info = "renaming index"; trx->op_info = "renaming index";
pars_info_add_str_literal(info, "name", index->name); pars_info_add_str_literal(info, "name", index->name + 1);
pars_info_add_dulint_literal(info, "indexid", index->id); pars_info_add_dulint_literal(info, "indexid", index->id);
pars_info_add_dulint_literal(info, "tableid", table->id); pars_info_add_dulint_literal(info, "tableid", table->id);
......
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