Commit dd450ebc authored by Will DeVries's avatar Will DeVries Committed by Sergei Petrunia

Prevent row based commands from being called with auto-commit.

This patch also fixes a bug in scan_end() and removes an unneeded call
to set_overwrite_status().
parent 0b01f9ef
...@@ -332,6 +332,10 @@ int clustrix_connection::write_row(ulonglong clustrix_table_oid, ...@@ -332,6 +332,10 @@ int clustrix_connection::write_row(ulonglong clustrix_table_oid,
int error_code; int error_code;
command_length = 0; command_length = 0;
// row based commands should not be called with auto commit.
if (commit_flag_next & CLUSTRIX_TRANS_COMMIT_ON_FINISH)
return HA_ERR_INTERNAL_ERROR;
if ((error_code = begin_command(CLUSTRIX_WRITE_ROW))) if ((error_code = begin_command(CLUSTRIX_WRITE_ROW)))
return error_code; return error_code;
...@@ -347,7 +351,6 @@ int clustrix_connection::write_row(ulonglong clustrix_table_oid, ...@@ -347,7 +351,6 @@ int clustrix_connection::write_row(ulonglong clustrix_table_oid,
if ((error_code = read_query_response())) if ((error_code = read_query_response()))
return error_code; return error_code;
auto_commit_closed();
*last_insert_id = clustrix_net.insert_id; *last_insert_id = clustrix_net.insert_id;
return error_code; return error_code;
} }
...@@ -361,6 +364,10 @@ int clustrix_connection::key_update(ulonglong clustrix_table_oid, ...@@ -361,6 +364,10 @@ int clustrix_connection::key_update(ulonglong clustrix_table_oid,
int error_code; int error_code;
command_length = 0; command_length = 0;
// row based commands should not be called with auto commit.
if (commit_flag_next & CLUSTRIX_TRANS_COMMIT_ON_FINISH)
return HA_ERR_INTERNAL_ERROR;
if ((error_code = begin_command(CLUSTRIX_KEY_UPDATE))) if ((error_code = begin_command(CLUSTRIX_KEY_UPDATE)))
return error_code; return error_code;
...@@ -383,9 +390,7 @@ int clustrix_connection::key_update(ulonglong clustrix_table_oid, ...@@ -383,9 +390,7 @@ int clustrix_connection::key_update(ulonglong clustrix_table_oid,
if ((error_code = read_query_response())) if ((error_code = read_query_response()))
return error_code; return error_code;
auto_commit_closed();
return error_code; return error_code;
} }
int clustrix_connection::key_delete(ulonglong clustrix_table_oid, int clustrix_connection::key_delete(ulonglong clustrix_table_oid,
...@@ -394,6 +399,10 @@ int clustrix_connection::key_delete(ulonglong clustrix_table_oid, ...@@ -394,6 +399,10 @@ int clustrix_connection::key_delete(ulonglong clustrix_table_oid,
int error_code; int error_code;
command_length = 0; command_length = 0;
// row based commands should not be called with auto commit.
if (commit_flag_next & CLUSTRIX_TRANS_COMMIT_ON_FINISH)
return HA_ERR_INTERNAL_ERROR;
if ((error_code = begin_command(CLUSTRIX_KEY_DELETE))) if ((error_code = begin_command(CLUSTRIX_KEY_DELETE)))
return error_code; return error_code;
...@@ -409,7 +418,6 @@ int clustrix_connection::key_delete(ulonglong clustrix_table_oid, ...@@ -409,7 +418,6 @@ int clustrix_connection::key_delete(ulonglong clustrix_table_oid,
if ((error_code = read_query_response())) if ((error_code = read_query_response()))
return error_code; return error_code;
auto_commit_closed();
return error_code; return error_code;
} }
...@@ -421,6 +429,10 @@ int clustrix_connection::key_read(ulonglong clustrix_table_oid, uint index, ...@@ -421,6 +429,10 @@ int clustrix_connection::key_read(ulonglong clustrix_table_oid, uint index,
int error_code; int error_code;
command_length = 0; command_length = 0;
// row based commands should not be called with auto commit.
if (commit_flag_next & CLUSTRIX_TRANS_COMMIT_ON_FINISH)
return HA_ERR_INTERNAL_ERROR;
if ((error_code = begin_command(CLUSTRIX_KEY_READ))) if ((error_code = begin_command(CLUSTRIX_KEY_READ)))
return error_code; return error_code;
...@@ -443,7 +455,6 @@ int clustrix_connection::key_read(ulonglong clustrix_table_oid, uint index, ...@@ -443,7 +455,6 @@ int clustrix_connection::key_read(ulonglong clustrix_table_oid, uint index,
if (packet_length == packet_error) if (packet_length == packet_error)
return mysql_errno(&clustrix_net); return mysql_errno(&clustrix_net);
auto_commit_closed();
uchar *data = clustrix_net.net.read_pos; uchar *data = clustrix_net.net.read_pos;
*rowdata_length = safe_net_field_length_ll(&data, packet_length); *rowdata_length = safe_net_field_length_ll(&data, packet_length);
*rowdata = (uchar *)my_malloc(*rowdata_length, MYF(MY_WME)); *rowdata = (uchar *)my_malloc(*rowdata_length, MYF(MY_WME));
...@@ -616,6 +627,10 @@ int clustrix_connection::scan_table(ulonglong clustrix_table_oid, uint index, ...@@ -616,6 +627,10 @@ int clustrix_connection::scan_table(ulonglong clustrix_table_oid, uint index,
int error_code; int error_code;
command_length = 0; command_length = 0;
// row based commands should not be called with auto commit.
if (commit_flag_next & CLUSTRIX_TRANS_COMMIT_ON_FINISH)
return HA_ERR_INTERNAL_ERROR;
if ((error_code = begin_command(CLUSTRIX_SCAN_TABLE))) if ((error_code = begin_command(CLUSTRIX_SCAN_TABLE)))
return error_code; return error_code;
...@@ -638,11 +653,8 @@ int clustrix_connection::scan_table(ulonglong clustrix_table_oid, uint index, ...@@ -638,11 +653,8 @@ int clustrix_connection::scan_table(ulonglong clustrix_table_oid, uint index,
return error_code; return error_code;
bool stmt_completed = FALSE; bool stmt_completed = FALSE;
error_code = allocate_clustrix_connection_cursor(&clustrix_net, row_req, return allocate_clustrix_connection_cursor(&clustrix_net, row_req,
&stmt_completed, scan); &stmt_completed, scan);
if (stmt_completed)
auto_commit_closed();
return error_code;
} }
/** /**
...@@ -752,6 +764,10 @@ int clustrix_connection::scan_from_key(ulonglong clustrix_table_oid, uint index, ...@@ -752,6 +764,10 @@ int clustrix_connection::scan_from_key(ulonglong clustrix_table_oid, uint index,
int error_code; int error_code;
command_length = 0; command_length = 0;
// row based commands should not be called with auto commit.
if (commit_flag_next & CLUSTRIX_TRANS_COMMIT_ON_FINISH)
return HA_ERR_INTERNAL_ERROR;
if ((error_code = begin_command(CLUSTRIX_SCAN_FROM_KEY))) if ((error_code = begin_command(CLUSTRIX_SCAN_FROM_KEY)))
return error_code; return error_code;
...@@ -780,11 +796,8 @@ int clustrix_connection::scan_from_key(ulonglong clustrix_table_oid, uint index, ...@@ -780,11 +796,8 @@ int clustrix_connection::scan_from_key(ulonglong clustrix_table_oid, uint index,
return error_code; return error_code;
bool stmt_completed = FALSE; bool stmt_completed = FALSE;
error_code = allocate_clustrix_connection_cursor(&clustrix_net, row_req, return allocate_clustrix_connection_cursor(&clustrix_net, row_req,
&stmt_completed, scan); &stmt_completed, scan);
if (stmt_completed)
auto_commit_closed();
return error_code;
} }
int clustrix_connection::scan_next(clustrix_connection_cursor *scan, int clustrix_connection::scan_next(clustrix_connection_cursor *scan,
...@@ -846,11 +859,9 @@ int clustrix_connection::scan_end(clustrix_connection_cursor *scan) ...@@ -846,11 +859,9 @@ int clustrix_connection::scan_end(clustrix_connection_cursor *scan)
if ((error_code = send_command())) if ((error_code = send_command()))
return error_code; return error_code;
if ((error_code = read_query_response())) error_code = read_query_response();
return error_code;
auto_commit_closed(); auto_commit_closed();
return 0; return error_code;
} }
int clustrix_connection::populate_table_list(LEX_CSTRING *db, int clustrix_connection::populate_table_list(LEX_CSTRING *db,
......
...@@ -478,8 +478,6 @@ int ha_clustrixdb::write_row(const uchar *buf) ...@@ -478,8 +478,6 @@ int ha_clustrixdb::write_row(const uchar *buf)
trx->auto_commit_next(); trx->auto_commit_next();
error_code= trx->update_query(update_stmt, table->s->db, &update_rows); error_code= trx->update_query(update_stmt, table->s->db, &update_rows);
thd->get_stmt_da()->set_overwrite_status(true);
if (trx->check_upsert(CLUSTRIX_BULK_UPSERT)) if (trx->check_upsert(CLUSTRIX_BULK_UPSERT))
trx->set_upsert(CLUSTRIX_UPSERT_SENT); trx->set_upsert(CLUSTRIX_UPSERT_SENT);
else else
......
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