summaryrefslogtreecommitdiff
path: root/sql/sql_class.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2018-01-15 13:50:28 +0400
committerAlexander Barkov <bar@mariadb.org>2018-01-15 13:50:28 +0400
commit88a9b23396531f0f0f63c1f989af69772216d442 (patch)
tree1ba43a3216ab692907124fa3f8c740362a4ff6b5 /sql/sql_class.h
parent5fe1d7d07611855963ea62ca39461289d8f8d25e (diff)
downloadmariadb-git-88a9b23396531f0f0f63c1f989af69772216d442.tar.gz
MDEV-14609 XA Transction unable to ROLLBACK TO SAVEPOINT
The function trans_rollback_to_savepoint(), unlike trans_savepoint(), did not allow xa_state=XA_ACTIVE, so an attempt to do ROLLBCK TO SAVEPOINT inside an XA transaction incorrectly returned an error "...command cannot be executed ... in the ACTIVE state...". Partially merging a MySQL patch: 7fb5c47390311d9b1b5367f97cb8fedd4102dd05 This is WL#7193 (Decouple THD and st_transactions)... The currently merged part includes these changes: - Introducing st_xid_state::check_has_uncommitted_xa() - Reusing it in both trans_rollback_to_savepoint() and trans_savepoint(), so now both allow XA_ACTIVE.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r--sql/sql_class.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h
index f4be996c9a9..e8f50f13ebc 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -991,6 +991,30 @@ typedef struct st_xid_state {
bool in_thd;
/* Error reported by the Resource Manager (RM) to the Transaction Manager. */
uint rm_error;
+
+ /**
+ Check that XA transaction has an uncommitted work. Report an error
+ to the user in case when there is an uncommitted work for XA transaction.
+
+ @return result of check
+ @retval false XA transaction is NOT in state IDLE, PREPARED
+ or ROLLBACK_ONLY.
+ @retval true XA transaction is in state IDLE or PREPARED
+ or ROLLBACK_ONLY.
+ */
+
+ bool check_has_uncommitted_xa() const
+ {
+ if (xa_state == XA_IDLE ||
+ xa_state == XA_PREPARED ||
+ xa_state == XA_ROLLBACK_ONLY)
+ {
+ my_error(ER_XAER_RMFAIL, MYF(0), xa_state_names[xa_state]);
+ return true;
+ }
+ return false;
+ }
+
} XID_STATE;
extern mysql_mutex_t LOCK_xid_cache;