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(
/* Set the MySQL flag to mark that there is an active transaction */
if (trx->active_trans == 0) {
innobase_register_trx_and_stmt(hton, current_thd);
innobase_register_trx_and_stmt(hton, thd);
trx->active_trans = 1;
}
......@@ -8121,14 +8121,14 @@ ha_innobase::add_index(
ulint num_of_idx;
ulint num_created;
ibool dict_locked = FALSE;
ibool new_primary;
ulint new_primary;
ibool new_unique = FALSE;
ulint error;
DBUG_ENTER("ha_innobase::add_index");
ut_a(table && key_info && num_of_keys);
update_thd(current_thd);
update_thd(ha_thd());
heap = mem_heap_create_noninline(1024);
......@@ -8179,9 +8179,9 @@ ha_innobase::add_index(
to drop all original secondary indexes from the table. These
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(
heap, '1', innodb_table->name);
......@@ -8256,7 +8256,7 @@ ha_innobase::add_index(
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.*/
if (error == DB_SUCCESS && new_primary) {
......@@ -8313,8 +8313,7 @@ ha_innobase::add_index(
if (indexed_table != innodb_table) {
row_merge_drop_table(trx, indexed_table);
}
mem_heap_free_noninline(heap);
DBUG_RETURN(convert_error_code_to_mysql(error, user_thd));
goto func_exit;
}
/* If a new primary key was defined for the table and
......@@ -8373,9 +8372,10 @@ ha_innobase::add_index(
}
func_exit:
/* There might be work for utility threads.*/
mem_heap_free_noninline(heap);
innobase_commit_low(trx);
/* There might be work for utility threads.*/
srv_active_wake_master_thread();
DBUG_RETURN(convert_error_code_to_mysql(error, user_thd));
......
......@@ -1471,7 +1471,7 @@ row_merge_rename_index(
trx_start_if_not_started(trx);
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, "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