Commit dfa24e55 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-7974 XA trnasactions.

XID_STATE::registered_for_binlog is replaced with rw_trans flag
in ha_prepare().
parent 22e70afb
...@@ -113,6 +113,10 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"", ...@@ -113,6 +113,10 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
static TYPELIB known_extensions= {0,"known_exts", NULL, NULL}; static TYPELIB known_extensions= {0,"known_exts", NULL, NULL};
uint known_extensions_id= 0; uint known_extensions_id= 0;
static
uint
ha_check_and_coalesce_trx_read_only(THD *thd, Ha_trx_info *ha_list,
bool all);
static int commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans, static int commit_one_phase_2(THD *thd, bool all, THD_TRANS *trans,
bool is_real_trans); bool is_real_trans);
...@@ -1247,7 +1251,6 @@ int ha_prepare(THD *thd) ...@@ -1247,7 +1251,6 @@ int ha_prepare(THD *thd)
Ha_trx_info *ha_info= trans->ha_list; Ha_trx_info *ha_info= trans->ha_list;
DBUG_ENTER("ha_prepare"); DBUG_ENTER("ha_prepare");
thd->transaction.xid_state.registered_for_binlog= false;
if (ha_info) if (ha_info)
{ {
for (; ha_info; ha_info= ha_info->next()) for (; ha_info; ha_info= ha_info->next())
...@@ -1272,8 +1275,12 @@ int ha_prepare(THD *thd) ...@@ -1272,8 +1275,12 @@ int ha_prepare(THD *thd)
} }
} }
if (thd->transaction.xid_state.registered_for_binlog && uint rw_ha_count=
unlikely(tc_log->log_xa_prepare(thd, all))) ha_check_and_coalesce_trx_read_only(thd,trans->ha_list, all);
bool rw_trans=
(rw_ha_count > (thd->is_current_stmt_binlog_disabled()?0U:1U));
if (rw_trans && tc_log->log_xa_prepare(thd, all))
{ {
ha_rollback_trans(thd, all); ha_rollback_trans(thd, all);
error=1; error=1;
......
...@@ -1958,12 +1958,11 @@ binlog_truncate_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr, bool all) ...@@ -1958,12 +1958,11 @@ binlog_truncate_trx_cache(THD *thd, binlog_cache_mngr *cache_mngr, bool all)
static int binlog_prepare(handlerton *hton, THD *thd, bool all) static int binlog_prepare(handlerton *hton, THD *thd, bool all)
{ {
/* /*
Mark the XA for binlogging. do nothing.
Transactions with no binlog handler registered like readonly ones, just pretend we can do 2pc, so that MySQL won't
should not go to the binlog. switch to 1pc.
Real work is done in MYSQL_BIN_LOG::log_xa_prepare() real work is done in MYSQL_BIN_LOG::log_xa_prepare()
*/ */
thd->transaction.xid_state.registered_for_binlog= true;
return 0; return 0;
} }
......
...@@ -1296,7 +1296,6 @@ typedef struct st_xid_state { ...@@ -1296,7 +1296,6 @@ typedef struct st_xid_state {
That can cause inconsistencies (shoud be fixed?). That can cause inconsistencies (shoud be fixed?).
*/ */
bool is_binlogged; bool is_binlogged;
bool registered_for_binlog;
/** /**
Check that XA transaction has an uncommitted work. Report an error Check that XA transaction has an uncommitted work. Report an error
......
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