Commit 04ca407d authored by Will DeVries's avatar Will DeVries Committed by Sergei Petrunia

Fix more transaction assertions and issues.

parent e3bd28ff
......@@ -148,7 +148,7 @@ int clustrix_connection::connect()
int clustrix_connection::begin_command(uchar command)
{
assert(has_transaction);
assert(command == CLUSTRIX_TRANSACTION_CMD || has_transaction);
command_length = 0;
int error_code = 0;
if ((error_code = add_command_operand_uchar(command)))
......@@ -192,7 +192,6 @@ int clustrix_connection::read_query_response()
return error_code;
}
auto_commit_closed();
return 0;
}
......@@ -205,8 +204,10 @@ int clustrix_connection::send_transaction_cmd()
int error_code;
if ((error_code = begin_command(CLUSTRIX_TRANSACTION_CMD)))
DBUG_RETURN(error_code);
if ((error_code = send_command()))
DBUG_RETURN(error_code);
if ((error_code = read_query_response()))
DBUG_RETURN(mysql_errno(&clustrix_net));
......@@ -346,6 +347,7 @@ int clustrix_connection::write_row(ulonglong clustrix_table_oid,
if ((error_code = read_query_response()))
return error_code;
auto_commit_closed();
*last_insert_id = clustrix_net.insert_id;
return error_code;
}
......@@ -381,6 +383,7 @@ int clustrix_connection::key_update(ulonglong clustrix_table_oid,
if ((error_code = read_query_response()))
return error_code;
auto_commit_closed();
return error_code;
}
......@@ -406,6 +409,7 @@ int clustrix_connection::key_delete(ulonglong clustrix_table_oid,
if ((error_code = read_query_response()))
return error_code;
auto_commit_closed();
return error_code;
}
......@@ -719,9 +723,11 @@ int clustrix_connection::update_query(String &stmt, LEX_CSTRING &dbname,
if ((error_code = send_command()))
return error_code;
if ((error_code = read_query_response()))
return error_code;
auto_commit_closed();
*affected_rows = clustrix_net.affected_rows;
return 0;
......@@ -837,6 +843,7 @@ int clustrix_connection::scan_end(clustrix_connection_cursor *scan)
if ((error_code = read_query_response()))
return error_code;
auto_commit_closed();
return 0;
}
......
......@@ -409,8 +409,6 @@ int ha_clustrixdb::write_row(const uchar *buf)
if (!trx)
return error_code;
assert(trx->has_open_transaction());
/* Convert the row format to binlog (packed) format */
uchar *packed_new_row = (uchar*) my_alloca(estimate_row_size(table));
size_t packed_size = pack_row(table, table->write_set, packed_new_row, buf);
......@@ -442,8 +440,6 @@ int ha_clustrixdb::update_row(const uchar *old_data, const uchar *new_data)
if (!trx)
DBUG_RETURN(error_code);
assert(trx->has_open_transaction());
size_t row_size = estimate_row_size(table);
size_t packed_key_len;
uchar *packed_key = (uchar*) my_alloca(row_size);
......@@ -502,8 +498,6 @@ int ha_clustrixdb::delete_row(const uchar *buf)
if (!trx)
return error_code;
assert(trx->has_open_transaction());
// The estimate should consider only key fields widths.
size_t packed_key_len;
uchar *packed_key = (uchar*) my_alloca(estimate_row_size(table));
......@@ -1037,7 +1031,7 @@ static int clustrixdb_commit(handlerton *hton, THD *thd, bool all)
clustrix_connection* trx = (clustrix_connection *) thd_get_ha_data(thd, hton);
assert(trx);
bool send_cmd;
bool send_cmd = FALSE;
if (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
if (trx->has_open_transaction())
send_cmd = trx->commit_transaction();
......@@ -1057,7 +1051,7 @@ static int clustrixdb_rollback(handlerton *hton, THD *thd, bool all)
clustrix_connection* trx = (clustrix_connection *) thd_get_ha_data(thd, hton);
assert(trx);
bool send_cmd;
bool send_cmd = FALSE;
if (all || !thd_test_options(thd, OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
if (trx->has_open_transaction())
send_cmd = trx->rollback_transaction();
......
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