更新空行不会开启2阶段提交,没有prepare阶段
开始执行begin命令
#endif
case SQLCOM_BEGIN:
if (trans_begin(thd, lex->start_transaction_opt))
goto error;
my_ok(thd);
break;
**
Begin a new transaction.
@note Beginning a transaction implicitly commits any current
transaction and releases existing locks.
@param thd Current thread
@param flags Transaction flags
@retval FALSE Success
@retval TRUE Failure
*/
bool trans_begin(THD *thd, uint flags)
设置回滚标记
thd->get_transaction()->reset_unsafe_rollback_flags(Transaction_ctx::SESSION);
在performance schema中注册了下事务信息,然后就commit了
trans_commit_stmt(thd);
.....
else if (tc_log)
res= tc_log->commit(thd, false);
在这里判断直接返回了
if (!all && !trn_ctx->is_active(trx_scope) &&
cache_mngr->stmt_cache.is_binlog_empty())
DBUG_RETURN(RESULT_SUCCESS);
可见begin也是经历了一轮事务的处理。
执行update命令
/**
@param[in] ignore_global_read_lock Allow commit to complete even if a
global read lock is active. This can be
used to allow changes to internal tables
(e.g. slave status tables).
@retval
0 ok
@retval
1 transaction was rolled back
@retval
2 error during commit, data may be inconsistent
@todo
Since we don't support nested statement transactions in 5.0,
we can't commit or rollback stmt transactions while we are inside
stored functions or triggers. So we simply do nothing now.
TODO: This should be fixed in later ( >= 5.1) releases.
*/
int ha_commit_trans(THD *thd, bool all, bool ignore_global_read_lock)
{
int error= 0;
bool need_clear_owned_gtid= false;
/*
Save transaction owned gtid into table before transaction prepare
if binlog is disabled, or binlog is enabled and log_slave_updates
is disabled with slave SQL thread or slave worker thread.
*/
error= commit_owned_gtids(thd, all, &need_clear_owned_gtid);
/*
'all' means that this is