MCPcopy Create free account
hub / github.com/MariaDB/server / ha_commit_trans

Function ha_commit_trans

sql/handler.cc:1757–2159  ·  view source on GitHub ↗

@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. */

Source from the content-addressed store, hash-verified

1755 TODO: This should be fixed in later ( >= 5.1) releases.
1756*/
1757int ha_commit_trans(THD *thd, bool all)
1758{
1759 int error= 0, cookie;
1760 /*
1761 'all' means that this is either an explicit commit issued by
1762 user, or an implicit commit issued by a DDL.
1763 */
1764 THD_TRANS *trans= all ? &thd->transaction->all : &thd->transaction->stmt;
1765 /*
1766 "real" is a nick name for a transaction for which a commit will
1767 make persistent changes. E.g. a 'stmt' transaction inside an 'all'
1768 transaction is not 'real': even though it's possible to commit it,
1769 the changes are not durable as they might be rolled back if the
1770 enclosing 'all' transaction is rolled back.
1771 */
1772 bool is_real_trans= ((all || thd->transaction->all.ha_list == 0) &&
1773 !(thd->variables.option_bits & OPTION_GTID_BEGIN));
1774 Ha_trx_info *ha_info= trans->ha_list;
1775 bool need_prepare_ordered, need_commit_ordered;
1776 my_xid xid;
1777#ifdef WITH_WSREP
1778 const bool run_wsrep_hooks= wsrep_run_commit_hook(thd, all);
1779#endif /* WITH_WSREP */
1780 DBUG_ENTER("ha_commit_trans");
1781 DBUG_PRINT("info",("thd: %p option_bits: %lu all: %d",
1782 thd, (ulong) thd->variables.option_bits, all));
1783
1784 /* Just a random warning to test warnings pushed during autocommit. */
1785 DBUG_EXECUTE_IF("warn_during_ha_commit_trans",
1786 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
1787 ER_WARNING_NOT_COMPLETE_ROLLBACK,
1788 ER_THD(thd, ER_WARNING_NOT_COMPLETE_ROLLBACK)););
1789
1790 DBUG_PRINT("info",
1791 ("all: %d thd->in_sub_stmt: %d ha_info: %p is_real_trans: %d",
1792 all, thd->in_sub_stmt, ha_info, is_real_trans));
1793 /*
1794 We must not commit the normal transaction if a statement
1795 transaction is pending. Otherwise statement transaction
1796 flags will not get propagated to its normal transaction's
1797 counterpart.
1798 */
1799 DBUG_ASSERT(thd->transaction->stmt.ha_list == NULL ||
1800 trans == &thd->transaction->stmt);
1801
1802 DBUG_ASSERT(!thd->in_sub_stmt);
1803
1804 if (thd->in_sub_stmt)
1805 {
1806 /*
1807 Since we don't support nested statement transactions in 5.0,
1808 we can't commit or rollback stmt transactions while we are inside
1809 stored functions or triggers. So we simply do nothing now.
1810 TODO: This should be fixed in later ( >= 5.1) releases.
1811 */
1812 if (!all)
1813 DBUG_RETURN(0);
1814 /*

Callers 13

truncate_state_tableMethod · 0.85
record_gtidMethod · 0.85
gtid_delete_pendingMethod · 0.85
ha_enable_transactionFunction · 0.85
trans_beginFunction · 0.85
trans_commitFunction · 0.85
trans_commit_implicitFunction · 0.85
trans_commit_stmtFunction · 0.85
trans_xa_commitFunction · 0.85
find_gtid_pos_tables_cbFunction · 0.85

Calls 15

wsrep_run_commit_hookFunction · 0.85
push_warningFunction · 0.85
my_errorFunction · 0.85
wsrep_is_activeFunction · 0.85
wsrep_commit_emptyFunction · 0.85
ha_rollback_transFunction · 0.85
trans_rollback_stmtFunction · 0.85
commit_one_phase_2Function · 0.85
wsrep_have_no2pc_rw_haFunction · 0.85
my_messageFunction · 0.85
wsrep_before_commitFunction · 0.85

Tested by

no test coverage detected