Repository navigation
Commit 5ca9ea7
committed
Align savepoint handling with MySQL semantics
In MySQL, savepoints exist only within a transaction. With autocommit
enabled, each statement forms its own implicit transaction, so a SAVEPOINT
statement succeeds but the savepoint is discarded as soon as the statement
completes. It does not start a transaction.
In SQLite, a bare SAVEPOINT opens a transaction. Tracking that transaction
makes the following write succeed, but it runs without a write lock, an
unrelated statement error rolls it back, and it is lost entirely when the
connection closes without a RELEASE. MySQL commits it.
Skip the SQLite statement when no transaction is active instead, and report
the MySQL error 1305 when a savepoint is referenced outside of a transaction.
This makes the savepoint transaction stack unnecessary, so it is removed.
MySQL and SQLite also disagree on what a savepoint name refers to. When a
name is reused, MySQL deletes the original savepoint, while SQLite keeps it
on the stack, shadowed by the new one. Track the savepoint names of the
active transaction and resolve every ROLLBACK TO and RELEASE against them,
so that a name MySQL considers deleted reports error 1305 instead of reaching
the shadowed SQLite savepoint.
The savepoint tests are updated accordingly: those that relied on a bare
SAVEPOINT opening a transaction now open one with START TRANSACTION.
Fixes WordPress#4951 parent 48c457e commit 5ca9ea7
5 files changed
Lines changed: 195 additions & 87 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
- tests/phpunit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
712 | 712 | | |
713 | 713 | | |
714 | 714 | | |
715 | | - | |
| 715 | + | |
716 | 716 | | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
723 | 720 | | |
724 | 721 | | |
725 | 722 | | |
726 | | - | |
| 723 | + | |
727 | 724 | | |
728 | 725 | | |
729 | 726 | | |
| |||
2106 | 2103 | | |
2107 | 2104 | | |
2108 | 2105 | | |
2109 | | - | |
2110 | | - | |
| 2106 | + | |
| 2107 | + | |
2111 | 2108 | | |
2112 | 2109 | | |
2113 | 2110 | | |
| |||
2119 | 2116 | | |
2120 | 2117 | | |
2121 | 2118 | | |
2122 | | - | |
2123 | | - | |
| 2119 | + | |
| 2120 | + | |
2124 | 2121 | | |
2125 | 2122 | | |
2126 | 2123 | | |
| |||
2132 | 2129 | | |
2133 | 2130 | | |
2134 | 2131 | | |
2135 | | - | |
2136 | | - | |
| 2132 | + | |
| 2133 | + | |
2137 | 2134 | | |
2138 | 2135 | | |
2139 | 2136 | | |
| |||
2172 | 2169 | | |
2173 | 2170 | | |
2174 | 2171 | | |
2175 | | - | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
2179 | 2176 | | |
| 2177 | + | |
| 2178 | + | |
2180 | 2179 | | |
2181 | 2180 | | |
2182 | 2181 | | |
2183 | 2182 | | |
2184 | 2183 | | |
2185 | 2184 | | |
2186 | | - | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
2187 | 2190 | | |
2188 | | - | |
2189 | | - | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
2190 | 2201 | | |
2191 | | - | |
| 2202 | + | |
2192 | 2203 | | |
2193 | 2204 | | |
2194 | 2205 | | |
2195 | 2206 | | |
2196 | 2207 | | |
2197 | | - | |
2198 | | - | |
2199 | | - | |
2200 | | - | |
2201 | | - | |
2202 | | - | |
2203 | | - | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
2204 | 2212 | | |
| 2213 | + | |
| 2214 | + | |
2205 | 2215 | | |
2206 | 2216 | | |
2207 | 2217 | | |
| |||
2272 | 2282 | | |
2273 | 2283 | | |
2274 | 2284 | | |
2275 | | - | |
2276 | | - | |
2277 | | - | |
2278 | | - | |
2279 | | - | |
2280 | | - | |
2281 | | - | |
2282 | | - | |
2283 | | - | |
2284 | | - | |
2285 | | - | |
2286 | | - | |
2287 | | - | |
2288 | | - | |
2289 | | - | |
2290 | 2285 | | |
2291 | 2286 | | |
2292 | 2287 | | |
| |||
7867 | 7862 | | |
7868 | 7863 | | |
7869 | 7864 | | |
| 7865 | + | |
| 7866 | + | |
| 7867 | + | |
| 7868 | + | |
| 7869 | + | |
| 7870 | + | |
| 7871 | + | |
| 7872 | + | |
| 7873 | + | |
| 7874 | + | |
| 7875 | + | |
| 7876 | + | |
| 7877 | + | |
| 7878 | + | |
| 7879 | + | |
| 7880 | + | |
| 7881 | + | |
| 7882 | + | |
| 7883 | + | |
7870 | 7884 | | |
7871 | 7885 | | |
7872 | 7886 | | |
| |||
| 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 | 926 | | |
957 | 927 | | |
958 | 928 | | |
| |||
972 | 942 | | |
973 | 943 | | |
974 | 944 | | |
| 945 | + | |
975 | 946 | | |
976 | 947 | | |
977 | 948 | | |
978 | 949 | | |
979 | 950 | | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
980 | 954 | | |
981 | 955 | | |
982 | 956 | | |
| |||
985 | 959 | | |
986 | 960 | | |
987 | 961 | | |
| 962 | + | |
988 | 963 | | |
989 | 964 | | |
990 | 965 | | |
| |||
997 | 972 | | |
998 | 973 | | |
999 | 974 | | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
1000 | 978 | | |
1001 | 979 | | |
1002 | 980 | | |
1003 | 981 | | |
1004 | | - | |
| 982 | + | |
1005 | 983 | | |
1006 | 984 | | |
1007 | 985 | | |
| 986 | + | |
1008 | 987 | | |
1009 | 988 | | |
1010 | 989 | | |
1011 | 990 | | |
1012 | | - | |
1013 | | - | |
1014 | 991 | | |
1015 | | - | |
| 992 | + | |
| 993 | + | |
1016 | 994 | | |
1017 | 995 | | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
| 996 | + | |
1021 | 997 | | |
1022 | 998 | | |
1023 | 999 | | |
1024 | 1000 | | |
1025 | 1001 | | |
1026 | 1002 | | |
1027 | 1003 | | |
| 1004 | + | |
1028 | 1005 | | |
1029 | 1006 | | |
1030 | 1007 | | |
1031 | 1008 | | |
1032 | 1009 | | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1033 | 1013 | | |
1034 | 1014 | | |
1035 | 1015 | | |
1036 | 1016 | | |
1037 | | - | |
| 1017 | + | |
1038 | 1018 | | |
1039 | 1019 | | |
1040 | 1020 | | |
| |||
0 commit comments