Commit 6322d300 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

refs #4743 use a single txn for alter table on a partitioned tokudb table

git-svn-id: file:///svn/mysql/tokudb-engine/tokudb-engine@46587 c7de825b-a66e-492c-adef-691d508d4ae1
parent eacf091f
...@@ -606,7 +606,7 @@ static inline bool ...@@ -606,7 +606,7 @@ static inline bool
is_null_field( TABLE* table, Field* field, const uchar* record) { is_null_field( TABLE* table, Field* field, const uchar* record) {
uint null_offset; uint null_offset;
bool ret_val; bool ret_val;
if (!field->null_ptr) { if (!field->real_maybe_null()) {
ret_val = false; ret_val = false;
goto exitpt; goto exitpt;
} }
...@@ -5970,7 +5970,7 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) { ...@@ -5970,7 +5970,7 @@ int ha_tokudb::external_lock(THD * thd, int lock_type) {
added_rows = 0; added_rows = 0;
deleted_rows = 0; deleted_rows = 0;
share->rows_from_locked_table = 0; share->rows_from_locked_table = 0;
if (!--trx->tokudb_lock_count) { if (trx->tokudb_lock_count > 0 && !--trx->tokudb_lock_count) {
if (trx->stmt) { if (trx->stmt) {
/* /*
F_UNLCK is done without a transaction commit / rollback. F_UNLCK is done without a transaction commit / rollback.
......
...@@ -28,8 +28,8 @@ ha_tokudb::print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_i ...@@ -28,8 +28,8 @@ ha_tokudb::print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_i
curr_field->field_name, curr_field->field_name,
curr_field->null_bit, curr_field->null_bit,
null_offset, null_offset,
(curr_field->null_ptr != NULL), curr_field->real_maybe_null(),
(curr_field->null_ptr != NULL) ? table->s->default_values[null_offset] & curr_field->null_bit : 0xffffffff curr_field->real_maybe_null() ? table->s->default_values[null_offset] & curr_field->null_bit : 0xffffffff
); );
} }
printf("******\n"); printf("******\n");
...@@ -42,8 +42,8 @@ ha_tokudb::print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_i ...@@ -42,8 +42,8 @@ ha_tokudb::print_alter_info(TABLE *altered_table, Alter_inplace_info *ha_alter_i
curr_field->field_name, curr_field->field_name,
curr_field->null_bit, curr_field->null_bit,
null_offset, null_offset,
(curr_field->null_ptr != NULL), curr_field->real_maybe_null(),
(curr_field->null_ptr != NULL) ? altered_table->s->default_values[null_offset] & curr_field->null_bit : 0xffffffff curr_field->real_maybe_null() ? altered_table->s->default_values[null_offset] & curr_field->null_bit : 0xffffffff
); );
} }
printf("******\n"); printf("******\n");
...@@ -229,10 +229,7 @@ ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info ...@@ -229,10 +229,7 @@ ha_tokudb::prepare_inplace_alter_table(TABLE *altered_table, Alter_inplace_info
tokudb_alter_ctx *ctx = new tokudb_alter_ctx; tokudb_alter_ctx *ctx = new tokudb_alter_ctx;
assert(ctx); assert(ctx);
ha_alter_info->handler_ctx = ctx; ha_alter_info->handler_ctx = ctx;
ctx->alter_txn = transaction;
int r = db_env->txn_begin(db_env, 0, &ctx->alter_txn, 0);
if (r != 0)
result = true; // fail
DBUG_RETURN(result); DBUG_RETURN(result);
} }
...@@ -515,14 +512,25 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info * ...@@ -515,14 +512,25 @@ ha_tokudb::commit_inplace_alter_table(TABLE *altered_table, Alter_inplace_info *
} }
} }
if (commit) { THD *thd = ha_thd();
// commit the alter transaction NOW tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
commit_txn(ctx->alter_txn, 0); assert(trx->stmt == ctx->alter_txn);
ctx->alter_txn = NULL;
} else { if (!commit) {
// abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work. // abort the alter transaction NOW so that any alters are rolled back. this allows the following restores to work.
abort_txn(ctx->alter_txn); THD *thd = ha_thd();
ctx->alter_txn = NULL; tokudb_trx_data *trx = (tokudb_trx_data *) thd_data_get(thd, tokudb_hton->slot);
assert(ctx->alter_txn == trx->stmt);
trx->should_abort = true;
assert(trx->tokudb_lock_count > 0);
if (!--trx->tokudb_lock_count) {
abort_txn(ctx->alter_txn);
ctx->alter_txn = NULL;
trx->stmt = NULL;
trx->sub_sp_level = NULL;
trx->should_abort = false;
}
transaction = NULL;
if (ctx->add_index_changed) { if (ctx->add_index_changed) {
restore_add_index(table, ha_alter_info->index_add_count, ctx->incremented_num_DBs, ctx->modified_DBs); restore_add_index(table, ha_alter_info->index_add_count, ctx->incremented_num_DBs, ctx->modified_DBs);
......
...@@ -171,10 +171,13 @@ static inline const uchar* unpack_toku_field_blob( ...@@ -171,10 +171,13 @@ static inline const uchar* unpack_toku_field_blob(
} }
static inline uint get_null_offset(TABLE* table, Field* field) { static inline uint get_null_offset(TABLE* table, Field* field) {
#if MYSQL_VERSION_ID >= 50606
return field->null_offset(table->record[0]);
#else
return (uint) ((uchar*) field->null_ptr - (uchar*) table->record[0]); return (uint) ((uchar*) field->null_ptr - (uchar*) table->record[0]);
#endif
} }
typedef enum { typedef enum {
toku_type_int = 0, toku_type_int = 0,
toku_type_double, toku_type_double,
......
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