Repository navigation
Commit 4cfe406
Align savepoint handling with MySQL semantics (#496)
## What?
Align SQL savepoint handling with MySQL semantics.
A standalone `SAVEPOINT` in the default autocommit mode no longer opens
an SQLite transaction. It is discarded immediately, so following writes
use the normal `BEGIN IMMEDIATE` wrapper and commit independently.
Inside explicit transactions, track active savepoint names to emulate
MySQL behavior for nested savepoints, reused and case-insensitive names,
`ROLLBACK TO`, `RELEASE`, and missing-savepoint error 1305.
Missing-savepoint errors leave the surrounding transaction active.
Add regression coverage across the MySQL-on-SQLite, concurrency, PDO
API, and WordPress integration test suites.
## Why?
SQLite treats a standalone `SAVEPOINT` as opening a transaction, but
MySQL does not. Passing it through to SQLite created a hidden
transaction on PHP versions before 8.4. Subsequent writes then either
attempted a nested `BEGIN IMMEDIATE` or bypassed the normal
write-locking path, depending on how the transaction state was tracked.
The original Data Machine reproduction relied on SQLite-only behavior:
issuing a bare `SAVEPOINT`, performing a write, and committing with
`RELEASE SAVEPOINT`. Real MySQL and MariaDB discard the standalone
savepoint, so the later release reports error 1305. That downstream
issue is tracked in Extra-Chill/data-machine#3436.
> [!NOTE]
> Consumers that relied on a bare `SAVEPOINT` opening a transaction on
SQLite must open an explicit transaction instead, matching MySQL
behavior.
Fixes #495
---------
Co-authored-by: Jan Jakeš <jan@jakes.pro>1 parent abf0dac commit 4cfe406
5 files changed
Lines changed: 380 additions & 10 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
- tests/phpunit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
711 | 711 | | |
712 | 712 | | |
713 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
714 | 725 | | |
715 | 726 | | |
716 | 727 | | |
| |||
1182 | 1193 | | |
1183 | 1194 | | |
1184 | 1195 | | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
1190 | 1206 | | |
1191 | 1207 | | |
1192 | 1208 | | |
| |||
2092 | 2108 | | |
2093 | 2109 | | |
2094 | 2110 | | |
2095 | | - | |
| 2111 | + | |
| 2112 | + | |
2096 | 2113 | | |
2097 | 2114 | | |
2098 | 2115 | | |
| |||
2104 | 2121 | | |
2105 | 2122 | | |
2106 | 2123 | | |
2107 | | - | |
| 2124 | + | |
| 2125 | + | |
2108 | 2126 | | |
2109 | 2127 | | |
2110 | 2128 | | |
| |||
2116 | 2134 | | |
2117 | 2135 | | |
2118 | 2136 | | |
2119 | | - | |
| 2137 | + | |
| 2138 | + | |
2120 | 2139 | | |
2121 | 2140 | | |
2122 | 2141 | | |
| |||
2146 | 2165 | | |
2147 | 2166 | | |
2148 | 2167 | | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
2149 | 2171 | | |
2150 | 2172 | | |
2151 | 2173 | | |
2152 | 2174 | | |
2153 | 2175 | | |
2154 | 2176 | | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
2155 | 2182 | | |
| 2183 | + | |
2156 | 2184 | | |
2157 | 2185 | | |
2158 | 2186 | | |
2159 | 2187 | | |
2160 | 2188 | | |
2161 | 2189 | | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
2162 | 2195 | | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
2163 | 2208 | | |
2164 | 2209 | | |
2165 | 2210 | | |
2166 | 2211 | | |
2167 | 2212 | | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
2168 | 2218 | | |
| 2219 | + | |
2169 | 2220 | | |
2170 | 2221 | | |
2171 | 2222 | | |
| |||
7816 | 7867 | | |
7817 | 7868 | | |
7818 | 7869 | | |
| 7870 | + | |
| 7871 | + | |
| 7872 | + | |
| 7873 | + | |
| 7874 | + | |
| 7875 | + | |
| 7876 | + | |
| 7877 | + | |
| 7878 | + | |
| 7879 | + | |
| 7880 | + | |
| 7881 | + | |
| 7882 | + | |
| 7883 | + | |
| 7884 | + | |
| 7885 | + | |
| 7886 | + | |
| 7887 | + | |
| 7888 | + | |
7819 | 7889 | | |
7820 | 7890 | | |
7821 | 7891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
75 | 88 | | |
76 | 89 | | |
77 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
923 | 923 | | |
924 | 924 | | |
925 | 925 | | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
926 | 1038 | | |
927 | 1039 | | |
928 | 1040 | | |
| |||
0 commit comments