mirror of
https://github.com/MariaDB/server.git
synced 2026-05-14 19:07:15 +02:00
Move XID_state::xa_state handing inside xa.cc
Let xid_cache_insert()/xid_cache_delete() handle xa_state. Let session tracker use is_explicit_XA() rather than xa_state != XA_NOTR. Fixed open_tables() to refuse data access in XA_ROLLBACK_ONLY state. Removed dead code from THD::cleanup(). It was supposed to be a reminder, but it got messed up over time. spider_internal_start_trx() is called either with XA_NOTR or XA_ACTIVE, which is guarded by server callers. Thus is_explicit_XA() is acceptable replacement for XA_ACTIVE check (which was likely wrong anyway). Setting xa_state to XA_PREPARED in spider_internal_xa_prepare() isn't meaningful, as this value is never accessed later. It can't be accessed by current thread and it can't be recovered either. It can only be accessed by spider internally, which never happens. Make spider_xa_lock()/spider_xa_unlock() static. Part of MDEV-7974 - backport fix for mysql bug#12161 (XA and binlog)
This commit is contained in:
parent
f189f34ed4
commit
a168cfb396
9 changed files with 56 additions and 80 deletions
28
sql/xa.h
28
sql/xa.h
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
|
||||
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED, XA_ROLLBACK_ONLY};
|
||||
extern const char *xa_state_names[];
|
||||
class XID_cache_element;
|
||||
|
||||
struct XID_STATE {
|
||||
|
|
@ -27,36 +26,15 @@ struct XID_STATE {
|
|||
enum xa_states xa_state; // used by external XA only
|
||||
XID_cache_element *xid_cache_element;
|
||||
|
||||
/**
|
||||
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;
|
||||
}
|
||||
|
||||
bool check_has_uncommitted_xa() const;
|
||||
bool is_explicit_XA() const { return xid_cache_element != 0; }
|
||||
void set_error(uint error);
|
||||
void er_xaer_rmfail() const;
|
||||
};
|
||||
|
||||
void xid_cache_init(void);
|
||||
void xid_cache_free(void);
|
||||
bool xid_cache_insert(XID *xid, enum xa_states xa_state);
|
||||
bool xid_cache_insert(XID *xid);
|
||||
bool xid_cache_insert(THD *thd, XID_STATE *xid_state);
|
||||
void xid_cache_delete(THD *thd, XID_STATE *xid_state);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue