1437 $this->database->startAtomic( __METHOD__ );
1438 $this->database->endAtomic( __METHOD__ );
1441 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1442 $this->database->cancelAtomic( __METHOD__ );
1445 $this->database->begin( __METHOD__ );
1446 $this->database->startAtomic( __METHOD__ );
1447 $this->database->endAtomic( __METHOD__ );
1448 $this->database->commit( __METHOD__ );
1451 $this->database->begin( __METHOD__ );
1452 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1453 $this->database->endAtomic( __METHOD__ );
1454 $this->database->commit( __METHOD__ );
1456 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; RELEASE SAVEPOINT wikimedia_rdbms_atomic1; COMMIT' );
1458 $this->database->begin( __METHOD__ );
1459 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1460 $this->database->cancelAtomic( __METHOD__ );
1461 $this->database->commit( __METHOD__ );
1463 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; COMMIT' );
1465 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1466 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1467 $this->database->cancelAtomic( __METHOD__ );
1468 $this->database->endAtomic( __METHOD__ );
1470 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; COMMIT' );
1472 $noOpCallack =
function () {
1475 $this->database->doAtomicSection( __METHOD__, $noOpCallack, IDatabase::ATOMIC_CANCELABLE );
1478 $this->database->doAtomicSection( __METHOD__, $noOpCallack );
1481 $this->database->begin( __METHOD__ );
1482 $this->database->doAtomicSection( __METHOD__, $noOpCallack, IDatabase::ATOMIC_CANCELABLE );
1483 $this->database->rollback( __METHOD__ );
1485 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; RELEASE SAVEPOINT wikimedia_rdbms_atomic1; ROLLBACK' );
1490 IDatabase::TRIGGER_COMMIT =>
'tCommit',
1491 IDatabase::TRIGGER_ROLLBACK =>
'tRollback',
1492 IDatabase::TRIGGER_CANCEL =>
'tCancel',
1495 $this->database->query(
"SELECT 0",
$fname );
1497 $callback1 =
function ( $trigger =
'-' )
use (
$fname, $triggerMap ) {
1498 $this->database->query(
"SELECT 1, {$triggerMap[$trigger]} AS t",
$fname );
1500 $callback2 =
function ( $trigger =
'-' )
use (
$fname, $triggerMap ) {
1501 $this->database->query(
"SELECT 2, {$triggerMap[$trigger]} AS t",
$fname );
1503 $callback3 =
function ( $trigger =
'-' )
use (
$fname, $triggerMap ) {
1504 $this->database->query(
"SELECT 3, {$triggerMap[$trigger]} AS t",
$fname );
1507 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1508 $this->database->onTransactionPreCommitOrIdle( $pcCallback, __METHOD__ );
1509 $this->database->cancelAtomic( __METHOD__ );
1512 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1513 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1514 $this->database->cancelAtomic( __METHOD__ );
1517 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1518 $this->database->onTransactionResolution( $callback1, __METHOD__ );
1519 $this->database->cancelAtomic( __METHOD__ );
1520 $this->
assertLastSql(
'BEGIN; ROLLBACK; SELECT 1, tRollback AS t' );
1522 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1523 $this->database->onAtomicSectionCancel( $callback1, __METHOD__ );
1524 $this->database->cancelAtomic( __METHOD__ );
1525 $this->
assertLastSql(
'BEGIN; ROLLBACK; SELECT 1, tRollback AS t' );
1527 $this->database->startAtomic( __METHOD__ .
'_outer' );
1528 $this->database->onTransactionPreCommitOrIdle( $pcCallback, __METHOD__ );
1529 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1530 $this->database->onTransactionPreCommitOrIdle( $pcCallback, __METHOD__ );
1531 $this->database->cancelAtomic( __METHOD__ );
1532 $this->database->onTransactionPreCommitOrIdle( $pcCallback, __METHOD__ );
1533 $this->database->endAtomic( __METHOD__ .
'_outer' );
1536 'SAVEPOINT wikimedia_rdbms_atomic1',
1537 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1543 $this->database->startAtomic( __METHOD__ .
'_outer' );
1544 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1545 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1546 $this->database->onTransactionCommitOrIdle( $callback2, __METHOD__ );
1547 $this->database->cancelAtomic( __METHOD__ );
1548 $this->database->onTransactionCommitOrIdle( $callback3, __METHOD__ );
1549 $this->database->endAtomic( __METHOD__ .
'_outer' );
1552 'SAVEPOINT wikimedia_rdbms_atomic1',
1553 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1555 'SELECT 1, tCommit AS t',
1556 'SELECT 3, tCommit AS t'
1559 $this->database->startAtomic( __METHOD__ .
'_outer' );
1560 $this->database->onTransactionResolution( $callback1, __METHOD__ );
1561 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1562 $this->database->onTransactionResolution( $callback2, __METHOD__ );
1563 $this->database->cancelAtomic( __METHOD__ );
1564 $this->database->onTransactionResolution( $callback3, __METHOD__ );
1565 $this->database->endAtomic( __METHOD__ .
'_outer' );
1568 'SAVEPOINT wikimedia_rdbms_atomic1',
1569 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1571 'SELECT 1, tCommit AS t',
1572 'SELECT 2, tRollback AS t',
1573 'SELECT 3, tCommit AS t'
1576 $this->database->startAtomic( __METHOD__ .
'_outer' );
1577 $this->database->onAtomicSectionCancel( $callback1, __METHOD__ );
1578 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1579 $this->database->onAtomicSectionCancel( $callback2, __METHOD__ );
1580 $this->database->cancelAtomic( __METHOD__ );
1581 $this->database->onAtomicSectionCancel( $callback3, __METHOD__ );
1582 $this->database->endAtomic( __METHOD__ .
'_outer' );
1585 'SAVEPOINT wikimedia_rdbms_atomic1',
1586 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1587 'SELECT 2, tCancel AS t',
1591 $makeCallback =
function ( $id )
use (
$fname, $triggerMap ) {
1592 return function ( $trigger =
'-' )
use ( $id,
$fname, $triggerMap ) {
1593 $this->database->query(
"SELECT $id, {$triggerMap[$trigger]} AS t",
$fname );
1597 $this->database->startAtomic( __METHOD__ .
'_outer' );
1598 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1599 $this->database->onTransactionResolution( $makeCallback( 1 ), __METHOD__ );
1600 $this->database->cancelAtomic( __METHOD__ );
1601 $this->database->endAtomic( __METHOD__ .
'_outer' );
1604 'SAVEPOINT wikimedia_rdbms_atomic1',
1605 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1607 'SELECT 1, tRollback AS t'
1610 $this->database->startAtomic( __METHOD__ .
'_level1', IDatabase::ATOMIC_CANCELABLE );
1611 $this->database->onTransactionResolution( $makeCallback( 1 ), __METHOD__ );
1612 $this->database->startAtomic( __METHOD__ .
'_level2' );
1613 $this->database->startAtomic( __METHOD__ .
'_level3', IDatabase::ATOMIC_CANCELABLE );
1614 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1615 $this->database->onTransactionResolution( $makeCallback( 2 ), __METHOD__ );
1616 $this->database->endAtomic( __METHOD__ );
1617 $this->database->onTransactionResolution( $makeCallback( 3 ), __METHOD__ );
1618 $this->database->cancelAtomic( __METHOD__ .
'_level3' );
1619 $this->database->endAtomic( __METHOD__ .
'_level2' );
1620 $this->database->onTransactionResolution( $makeCallback( 4 ), __METHOD__ );
1621 $this->database->endAtomic( __METHOD__ .
'_level1' );
1624 'SAVEPOINT wikimedia_rdbms_atomic1',
1625 'SAVEPOINT wikimedia_rdbms_atomic2',
1626 'RELEASE SAVEPOINT wikimedia_rdbms_atomic2',
1627 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1628 'COMMIT; SELECT 1, tCommit AS t',
1629 'SELECT 2, tRollback AS t',
1630 'SELECT 3, tRollback AS t',
1631 'SELECT 4, tCommit AS t'
1634 $this->database->startAtomic( __METHOD__ .
'_level1', IDatabase::ATOMIC_CANCELABLE );
1635 $this->database->onAtomicSectionCancel( $makeCallback( 1 ), __METHOD__ );
1636 $this->database->startAtomic( __METHOD__ .
'_level2' );
1637 $this->database->startAtomic( __METHOD__ .
'_level3', IDatabase::ATOMIC_CANCELABLE );
1638 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1639 $this->database->onAtomicSectionCancel( $makeCallback( 2 ), __METHOD__ );
1640 $this->database->endAtomic( __METHOD__ );
1641 $this->database->onAtomicSectionCancel( $makeCallback( 3 ), __METHOD__ );
1642 $this->database->cancelAtomic( __METHOD__ .
'_level3' );
1643 $this->database->endAtomic( __METHOD__ .
'_level2' );
1644 $this->database->onAtomicSectionCancel( $makeCallback( 4 ), __METHOD__ );
1645 $this->database->endAtomic( __METHOD__ .
'_level1' );
1648 'SAVEPOINT wikimedia_rdbms_atomic1',
1649 'SAVEPOINT wikimedia_rdbms_atomic2',
1650 'RELEASE SAVEPOINT wikimedia_rdbms_atomic2',
1651 'ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1',
1652 'SELECT 2, tCancel AS t',
1653 'SELECT 3, tCancel AS t',
1724 $callback1Called =
null;
1725 $callback1 =
function ( $trigger =
'-' )
use (
$fname, &$callback1Called ) {
1726 $callback1Called = $trigger;
1727 $this->database->query(
"SELECT 1",
$fname );
1729 $callback2Called =
null;
1730 $callback2 =
function ( $trigger =
'-' )
use (
$fname, &$callback2Called ) {
1731 $callback2Called = $trigger;
1732 $this->database->query(
"SELECT 2",
$fname );
1734 $callback3Called =
null;
1735 $callback3 =
function ( $trigger =
'-' )
use (
$fname, &$callback3Called ) {
1736 $callback3Called = $trigger;
1737 $this->database->query(
"SELECT 3",
$fname );
1739 $callback4Called = 0;
1740 $callback4 =
function ()
use (
$fname, &$callback4Called ) {
1742 $this->database->query(
"SELECT 4",
$fname );
1744 $callback5Called = 0;
1745 $callback5 =
function ()
use (
$fname, &$callback5Called ) {
1747 $this->database->query(
"SELECT 5",
$fname );
1750 $this->database->startAtomic( __METHOD__ .
'_outer' );
1751 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1752 $this->database->startAtomic( __METHOD__ .
'_inner' );
1753 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1754 $this->database->onTransactionPreCommitOrIdle( $callback2, __METHOD__ );
1755 $this->database->onTransactionResolution( $callback3, __METHOD__ );
1756 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1757 $this->database->endAtomic( __METHOD__ .
'_inner' );
1758 $this->database->cancelAtomic( __METHOD__ );
1759 $this->database->endAtomic( __METHOD__ .
'_outer' );
1760 $this->assertNull( $callback1Called );
1761 $this->assertNull( $callback2Called );
1762 $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called );
1763 $this->assertEquals( 1, $callback4Called );
1765 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 4; COMMIT; SELECT 3' );
1767 $callback1Called =
null;
1768 $callback2Called =
null;
1769 $callback3Called =
null;
1770 $callback4Called = 0;
1771 $this->database->startAtomic( __METHOD__ .
'_outer' );
1772 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1773 $this->database->startAtomic( __METHOD__ .
'_inner', IDatabase::ATOMIC_CANCELABLE );
1774 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1775 $this->database->onTransactionPreCommitOrIdle( $callback2, __METHOD__ );
1776 $this->database->onTransactionResolution( $callback3, __METHOD__ );
1777 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1778 $this->database->endAtomic( __METHOD__ .
'_inner' );
1779 $this->database->cancelAtomic( __METHOD__ );
1780 $this->database->endAtomic( __METHOD__ .
'_outer' );
1781 $this->assertNull( $callback1Called );
1782 $this->assertNull( $callback2Called );
1783 $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called );
1784 $this->assertEquals( 1, $callback4Called );
1786 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; RELEASE SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 4; COMMIT; SELECT 3' );
1788 $callback1Called =
null;
1789 $callback2Called =
null;
1790 $callback3Called =
null;
1791 $callback4Called = 0;
1792 $this->database->startAtomic( __METHOD__ .
'_outer' );
1793 $atomicId = $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1794 $this->database->startAtomic( __METHOD__ .
'_inner' );
1795 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1796 $this->database->onTransactionPreCommitOrIdle( $callback2, __METHOD__ );
1797 $this->database->onTransactionResolution( $callback3, __METHOD__ );
1798 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1799 $this->database->cancelAtomic( __METHOD__, $atomicId );
1800 $this->database->endAtomic( __METHOD__ .
'_outer' );
1801 $this->assertNull( $callback1Called );
1802 $this->assertNull( $callback2Called );
1803 $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called );
1804 $this->assertEquals( 1, $callback4Called );
1806 $callback1Called =
null;
1807 $callback2Called =
null;
1808 $callback3Called =
null;
1809 $callback4Called = 0;
1810 $this->database->startAtomic( __METHOD__ .
'_outer' );
1811 $atomicId = $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1812 $this->database->startAtomic( __METHOD__ .
'_inner' );
1813 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1814 $this->database->onTransactionPreCommitOrIdle( $callback2, __METHOD__ );
1815 $this->database->onTransactionResolution( $callback3, __METHOD__ );
1816 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1818 $this->database->cancelAtomic( __METHOD__ .
'_X', $atomicId );
1822 "Invalid atomic section ended (got {$m}_X but expected {$m}).",
1826 $this->database->cancelAtomic( __METHOD__ );
1827 $this->database->endAtomic( __METHOD__ .
'_outer' );
1828 $this->assertNull( $callback1Called );
1829 $this->assertNull( $callback2Called );
1830 $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called );
1831 $this->assertEquals( 1, $callback4Called );
1833 $callback4Called = 0;
1834 $callback5Called = 0;
1835 $this->database->getLastSqls();
1836 $this->database->startAtomic( __METHOD__ .
'_outer' );
1837 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1838 $this->database->onAtomicSectionCancel( $callback5, __METHOD__ );
1839 $this->database->startAtomic( __METHOD__ .
'_inner', IDatabase::ATOMIC_CANCELABLE );
1840 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1841 $this->database->cancelAtomic( __METHOD__ .
'_inner' );
1842 $this->database->cancelAtomic( __METHOD__ );
1843 $this->database->endAtomic( __METHOD__ .
'_outer' );
1845 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic2; SELECT 4; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 5; COMMIT' );
1846 $this->assertEquals( 1, $callback4Called );
1847 $this->assertEquals( 1, $callback5Called );
1849 $callback4Called = 0;
1850 $callback5Called = 0;
1851 $this->database->startAtomic( __METHOD__ .
'_outer' );
1852 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1853 $this->database->onAtomicSectionCancel( $callback5, __METHOD__ );
1854 $this->database->startAtomic( __METHOD__ .
'_inner', IDatabase::ATOMIC_CANCELABLE );
1855 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1856 $this->database->endAtomic( __METHOD__ .
'_inner' );
1857 $this->database->cancelAtomic( __METHOD__ );
1858 $this->database->endAtomic( __METHOD__ .
'_outer' );
1860 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; RELEASE SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 5; SELECT 4; COMMIT' );
1861 $this->assertEquals( 1, $callback4Called );
1862 $this->assertEquals( 1, $callback5Called );
1864 $callback4Called = 0;
1865 $callback5Called = 0;
1866 $this->database->startAtomic( __METHOD__ .
'_outer' );
1867 $sectionId = $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1868 $this->database->onAtomicSectionCancel( $callback5, __METHOD__ );
1869 $this->database->startAtomic( __METHOD__ .
'_inner', IDatabase::ATOMIC_CANCELABLE );
1870 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1871 $this->database->cancelAtomic( __METHOD__, $sectionId );
1872 $this->database->endAtomic( __METHOD__ .
'_outer' );
1874 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; SAVEPOINT wikimedia_rdbms_atomic2; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; SELECT 5; SELECT 4; COMMIT' );
1875 $this->assertEquals( 1, $callback4Called );
1876 $this->assertEquals( 1, $callback5Called );
1878 $wrapper = TestingAccessWrapper::newFromObject( $this->database );
1879 $callback1Called =
null;
1880 $callback2Called =
null;
1881 $callback3Called =
null;
1882 $callback4Called = 0;
1883 $this->database->startAtomic( __METHOD__ .
'_outer' );
1884 $this->database->startAtomic( __METHOD__, IDatabase::ATOMIC_CANCELABLE );
1885 $this->database->startAtomic( __METHOD__ .
'_inner' );
1886 $this->database->onTransactionCommitOrIdle( $callback1, __METHOD__ );
1887 $this->database->onTransactionPreCommitOrIdle( $callback2, __METHOD__ );
1888 $this->database->onTransactionResolution( $callback3, __METHOD__ );
1889 $this->database->onAtomicSectionCancel( $callback4, __METHOD__ );
1890 $wrapper->trxStatus = Database::STATUS_TRX_ERROR;
1891 $this->database->cancelAtomic( __METHOD__ .
'_inner' );
1892 $this->database->cancelAtomic( __METHOD__ );
1893 $this->database->endAtomic( __METHOD__ .
'_outer' );
1894 $this->assertNull( $callback1Called );
1895 $this->assertNull( $callback2Called );
1896 $this->assertEquals( IDatabase::TRIGGER_ROLLBACK, $callback3Called );
1897 $this->assertEquals( 1, $callback4Called );
2012 $wrapper = TestingAccessWrapper::newFromObject( $this->database );
2014 $this->database->startAtomic( __METHOD__ );
2015 $wrapper->trxStatus = Database::STATUS_TRX_ERROR;
2016 $this->database->rollback( __METHOD__ );
2017 $this->assertEquals( 0, $this->database->trxLevel() );
2018 $this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() );
2021 $this->database->startAtomic( __METHOD__ );
2022 $this->assertEquals( Database::STATUS_TRX_OK, $wrapper->trxStatus() );
2023 $this->database->delete(
'x', [
'field' => 1 ], __METHOD__ );
2024 $this->database->endAtomic( __METHOD__ );
2025 $this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() );
2026 $this->
assertLastSql(
'BEGIN; DELETE FROM x WHERE field = \'1\'; COMMIT' );
2027 $this->assertEquals( 0, $this->database->trxLevel(),
'Use after rollback()' );
2029 $this->database->begin( __METHOD__ );
2030 $this->database->startAtomic( __METHOD__, Database::ATOMIC_CANCELABLE );
2031 $this->database->update(
'y', [
'a' => 1 ], [
'field' => 1 ], __METHOD__ );
2032 $wrapper->trxStatus = Database::STATUS_TRX_ERROR;
2033 $this->database->cancelAtomic( __METHOD__ );
2034 $this->assertEquals( Database::STATUS_TRX_OK, $wrapper->trxStatus() );
2035 $this->database->startAtomic( __METHOD__ );
2036 $this->database->delete(
'y', [
'field' => 1 ], __METHOD__ );
2037 $this->database->endAtomic( __METHOD__ );
2038 $this->database->commit( __METHOD__ );
2040 $this->
assertLastSql(
'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; UPDATE y SET a = \'1\' WHERE field = \'1\'; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; DELETE FROM y WHERE field = \'1\'; COMMIT' );
2041 $this->assertEquals( 0, $this->database->trxLevel(),
'Use after rollback()' );
2044 $this->database->startAtomic( __METHOD__ );
2045 $this->assertEquals( Database::STATUS_TRX_OK, $wrapper->trxStatus() );
2046 $this->database->delete(
'x', [
'field' => 3 ], __METHOD__ );
2047 $this->database->endAtomic( __METHOD__ );
2048 $this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() );
2049 $this->
assertLastSql(
'BEGIN; DELETE FROM x WHERE field = \'3\'; COMMIT' );
2050 $this->assertEquals( 0, $this->database->trxLevel() );