File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -2490,6 +2490,28 @@ public function testStartTransactionCommand() {
24902490 $ this ->assertCount ( 0 , $ this ->engine ->get_query_results () );
24912491 }
24922492
2493+ public function testRepeatedTransactionCommands (): void {
2494+ $ this ->assertQuery ( 'CREATE TABLE t (id INT) ' );
2495+
2496+ // 1st BEGIN starts a transaction.
2497+ $ this ->assertQuery ( 'BEGIN ' );
2498+ $ this ->assertQuery ( 'INSERT INTO t (id) VALUES (1); ' );
2499+
2500+ // 2nd BEGIN commits the previous transaction and starts a new one.
2501+ $ this ->assertQuery ( 'BEGIN ' );
2502+ $ this ->assertQuery ( 'INSERT INTO t (id) VALUES (2); ' );
2503+
2504+ // ROLLBACK rolls back the 2nd transaction.
2505+ $ this ->assertQuery ( 'ROLLBACK ' );
2506+ $ results = $ this ->assertQuery ( 'SELECT * FROM t; ' );
2507+ $ this ->assertEquals ( array ( (object ) array ( 'id ' => '1 ' ) ), $ results );
2508+
2509+ // Repeated ROLLBACK should do nothing.
2510+ $ this ->assertQuery ( 'ROLLBACK ' );
2511+ $ results = $ this ->assertQuery ( 'SELECT * FROM t; ' );
2512+ $ this ->assertEquals ( array ( (object ) array ( 'id ' => '1 ' ) ), $ results );
2513+ }
2514+
24932515 public function testCount () {
24942516 $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('first'); " );
24952517 $ this ->assertQuery ( "INSERT INTO _options (option_name) VALUES ('second'); " );
You can’t perform that action at this time.
0 commit comments