@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. */
| 1755 | TODO: This should be fixed in later ( >= 5.1) releases. |
| 1756 | */ |
| 1757 | int 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 | /* |
no test coverage detected