@@ -986,6 +986,39 @@ public function test_writes_inside_nested_savepoints_preserve_outer_changes(): v
986986 $ this ->assertSame ( '2 ' , $ this ->driver ->query ( 'SELECT value FROM t ' )->fetchColumn () );
987987 }
988988
989+ public function test_duplicate_savepoint_names_track_innermost_scope (): void {
990+ $ this ->driver ->query ( 'CREATE TABLE t (id INT PRIMARY KEY, value INT) ' );
991+ $ this ->driver ->query ( 'INSERT INTO t VALUES (1, 1) ' );
992+
993+ $ this ->driver ->query ( 'SAVEPOINT repeated ' );
994+ $ this ->driver ->query ( 'UPDATE t SET value = 2 WHERE id = 1 ' );
995+ $ this ->driver ->query ( 'SAVEPOINT repeated ' );
996+ $ this ->driver ->query ( 'UPDATE t SET value = 3 WHERE id = 1 ' );
997+ $ this ->driver ->query ( 'ROLLBACK TO SAVEPOINT repeated ' );
998+ $ this ->driver ->query ( 'RELEASE SAVEPOINT repeated ' );
999+
1000+ $ this ->assertTrue ( $ this ->driver ->inTransaction () );
1001+ $ this ->assertSame ( '2 ' , $ this ->driver ->query ( 'SELECT value FROM t ' )->fetchColumn () );
1002+
1003+ $ this ->driver ->query ( 'RELEASE SAVEPOINT repeated ' );
1004+
1005+ $ this ->assertFalse ( $ this ->driver ->inTransaction () );
1006+ $ this ->assertSame ( '2 ' , $ this ->driver ->query ( 'SELECT value FROM t ' )->fetchColumn () );
1007+ }
1008+
1009+ public function test_quoted_savepoint_names_are_case_insensitive (): void {
1010+ $ this ->driver ->query ( 'CREATE TABLE t (id INT PRIMARY KEY, value INT) ' );
1011+ $ this ->driver ->query ( 'INSERT INTO t VALUES (1, 1) ' );
1012+
1013+ $ this ->driver ->query ( 'SAVEPOINT `MixedCase` ' );
1014+ $ this ->driver ->query ( 'UPDATE t SET value = 2 WHERE id = 1 ' );
1015+ $ this ->driver ->query ( 'ROLLBACK TO SAVEPOINT `mixedcase` ' );
1016+ $ this ->driver ->query ( 'RELEASE SAVEPOINT `MIXEDCASE` ' );
1017+
1018+ $ this ->assertFalse ( $ this ->driver ->inTransaction () );
1019+ $ this ->assertSame ( '1 ' , $ this ->driver ->query ( 'SELECT value FROM t ' )->fetchColumn () );
1020+ }
1021+
9891022 public function test_failed_write_cleans_up_savepoint_transaction_state (): void {
9901023 $ this ->driver ->query ( 'CREATE TABLE t (id INT PRIMARY KEY) ' );
9911024 $ this ->driver ->query ( 'INSERT INTO t VALUES (1) ' );
0 commit comments