Commit cebdfa6
authored
Improve compatibility with legacy SQLite versions (#302)
## SQLite Version Compatibility Fixes
This PR adds support for older SQLite versions by addressing various
compatibility issues. It also updates the CI workflow to **test against
multiple SQLite versions**.
**Compatibility fixes:**
1. **UPSERT / ON CONFLICT clause (SQLite < 3.35.0)** — The generic `ON
CONFLICT DO UPDATE` clause without an explicit column list is only
supported from SQLite 3.35.0. For older versions, we now catch the
constraint violation error, parse the conflicting column names from the
error message, and re-execute with an explicit column list.
2. **STRICT tables (SQLite < 3.37.0)** — The `STRICT` keyword for table
creation is only supported from SQLite 3.37.0. It is now conditionally
omitted on older versions.
3. **VALUES list `columnN` naming (SQLite < 3.33.0)** — Automatic column
naming for VALUES lists (`column1`, `column2`, etc.) is only supported
from SQLite 3.33.0. For older versions, we now emulate this by
prepending a dummy `SELECT NULL AS column1, ... WHERE FALSE UNION ALL
...` header.
4. **`UPDATE ... FROM` syntax (SQLite < 3.33.0)** — The `UPDATE ...
FROM` syntax is only supported from SQLite 3.33.0. We now avoid using it
internally in the information schema builder.
5. **`IIF()` function (all versions)** — The `IIF()` function was added
in SQLite 3.32.0. We now use `CASE WHEN ... THEN ... ELSE ... END`
instead for broader compatibility.
6. **`SUBSTRING()` function (all versions)** — The `SUBSTRING()`
function is not supported in older SQLite versions. We now translate it
to `SUBSTR()`.
7. **`sqlite_schema` table (SQLite < 3.33.0)** — The `sqlite_schema`
table alias was added in SQLite 3.33.0. We now use the older
`sqlite_master` name for compatibility.
8. **SQLite version detection** — Changed from using a `SELECT
SQLITE_VERSION()` query to using the `PDO::ATTR_SERVER_VERSION`
attribute for retrieving the SQLite version, which avoids extra queries
by using SQLite C API directly.
9. **CI workflow** — Added support for testing against multiple SQLite
versions.1 parent 216e3a5 commit cebdfa6
File tree
13 files changed
+476
-135
lines changed- .github/workflows
- tests
- wp-includes/sqlite-ast
13 files changed
+476
-135
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
34 | 55 | | |
35 | 56 | | |
36 | 57 | | |
37 | 58 | | |
38 | 59 | | |
39 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
40 | 75 | | |
41 | 76 | | |
42 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
21 | 41 | | |
22 | 42 | | |
23 | 43 | | |
24 | 44 | | |
| 45 | + | |
25 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
254 | 260 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
264 | 279 | | |
265 | 280 | | |
266 | 281 | | |
267 | 282 | | |
268 | | - | |
| 283 | + | |
269 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
270 | 310 | | |
271 | | - | |
272 | 311 | | |
273 | 312 | | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
| 313 | + | |
| 314 | + | |
278 | 315 | | |
279 | 316 | | |
280 | 317 | | |
281 | 318 | | |
282 | 319 | | |
283 | 320 | | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | 321 | | |
291 | 322 | | |
292 | 323 | | |
293 | 324 | | |
294 | | - | |
| 325 | + | |
295 | 326 | | |
296 | | - | |
297 | | - | |
298 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
299 | 331 | | |
300 | 332 | | |
301 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6768 | 6768 | | |
6769 | 6769 | | |
6770 | 6770 | | |
| 6771 | + | |
| 6772 | + | |
| 6773 | + | |
| 6774 | + | |
| 6775 | + | |
| 6776 | + | |
| 6777 | + | |
| 6778 | + | |
6771 | 6779 | | |
6772 | 6780 | | |
6773 | 6781 | | |
| |||
6841 | 6849 | | |
6842 | 6850 | | |
6843 | 6851 | | |
| 6852 | + | |
| 6853 | + | |
| 6854 | + | |
| 6855 | + | |
| 6856 | + | |
| 6857 | + | |
| 6858 | + | |
| 6859 | + | |
6844 | 6860 | | |
6845 | 6861 | | |
6846 | 6862 | | |
| |||
6915 | 6931 | | |
6916 | 6932 | | |
6917 | 6933 | | |
| 6934 | + | |
| 6935 | + | |
| 6936 | + | |
| 6937 | + | |
| 6938 | + | |
| 6939 | + | |
| 6940 | + | |
| 6941 | + | |
6918 | 6942 | | |
6919 | 6943 | | |
6920 | 6944 | | |
| |||
10118 | 10142 | | |
10119 | 10143 | | |
10120 | 10144 | | |
10121 | | - | |
10122 | | - | |
10123 | | - | |
10124 | | - | |
| 10145 | + | |
| 10146 | + | |
| 10147 | + | |
| 10148 | + | |
| 10149 | + | |
| 10150 | + | |
| 10151 | + | |
| 10152 | + | |
| 10153 | + | |
| 10154 | + | |
| 10155 | + | |
10125 | 10156 | | |
10126 | 10157 | | |
10127 | 10158 | | |
| |||
10146 | 10177 | | |
10147 | 10178 | | |
10148 | 10179 | | |
10149 | | - | |
10150 | | - | |
| 10180 | + | |
| 10181 | + | |
| 10182 | + | |
| 10183 | + | |
| 10184 | + | |
| 10185 | + | |
| 10186 | + | |
10151 | 10187 | | |
10152 | 10188 | | |
10153 | 10189 | | |
| |||
10613 | 10649 | | |
10614 | 10650 | | |
10615 | 10651 | | |
10616 | | - | |
10617 | | - | |
10618 | | - | |
10619 | | - | |
| 10652 | + | |
| 10653 | + | |
| 10654 | + | |
| 10655 | + | |
| 10656 | + | |
| 10657 | + | |
| 10658 | + | |
| 10659 | + | |
| 10660 | + | |
| 10661 | + | |
| 10662 | + | |
10620 | 10663 | | |
10621 | 10664 | | |
10622 | 10665 | | |
| |||
10652 | 10695 | | |
10653 | 10696 | | |
10654 | 10697 | | |
10655 | | - | |
10656 | | - | |
| 10698 | + | |
| 10699 | + | |
| 10700 | + | |
| 10701 | + | |
| 10702 | + | |
| 10703 | + | |
| 10704 | + | |
10657 | 10705 | | |
10658 | 10706 | | |
10659 | 10707 | | |
| |||
11231 | 11279 | | |
11232 | 11280 | | |
11233 | 11281 | | |
| 11282 | + | |
| 11283 | + | |
| 11284 | + | |
| 11285 | + | |
| 11286 | + | |
| 11287 | + | |
| 11288 | + | |
| 11289 | + | |
| 11290 | + | |
| 11291 | + | |
| 11292 | + | |
| 11293 | + | |
| 11294 | + | |
| 11295 | + | |
11234 | 11296 | | |
0 commit comments