Commit 02a99cf
authored
Fix "Expression tree is too large" for strings with large number of
In SQLite, it is generally difficult to work with `NULL` bytes in
strings, because SQLite uses C-style string syntax, which means it
considers the first `NULL` byte as the string terminator in some
scenarios.
While it is possible to store and read `NULL` bytes within strings (with
some limitations), there is no way to express the `NULL` byte in a
string literal. It needs to be done in a different way:
1. Concatenation: `str_part1 || CHAR(0) || str_part2 || …`
2. Passing as a parameter to a prepared statement.
3. Using HEX notation and casting to string.
More details: https://sqlite.org/nulinstr.html
At the moment, the SQLite driver uses concatenation (option 1), which
seems to fail for strings that contain many `NULL` bytes:
```
SQLSTATE[HY000]: General error: 1 Expression tree is too large (maximum depth 1000)
```
This PR fixes this by using HEX encoding.NULL bytes (#274)1 parent 581d361 commit 02a99cf
File tree
2 files changed
+28
-11
lines changed- tests
- wp-includes/sqlite-ast
2 files changed
+28
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3882 | 3882 | | |
3883 | 3883 | | |
3884 | 3884 | | |
| 3885 | + | |
| 3886 | + | |
| 3887 | + | |
| 3888 | + | |
| 3889 | + | |
| 3890 | + | |
| 3891 | + | |
| 3892 | + | |
| 3893 | + | |
| 3894 | + | |
| 3895 | + | |
| 3896 | + | |
| 3897 | + | |
| 3898 | + | |
| 3899 | + | |
| 3900 | + | |
3885 | 3901 | | |
3886 | 3902 | | |
3887 | 3903 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3339 | 3339 | | |
3340 | 3340 | | |
3341 | 3341 | | |
3342 | | - | |
| 3342 | + | |
3343 | 3343 | | |
3344 | 3344 | | |
3345 | 3345 | | |
| |||
3349 | 3349 | | |
3350 | 3350 | | |
3351 | 3351 | | |
3352 | | - | |
| 3352 | + | |
3353 | 3353 | | |
3354 | 3354 | | |
3355 | 3355 | | |
| |||
3358 | 3358 | | |
3359 | 3359 | | |
3360 | 3360 | | |
3361 | | - | |
| 3361 | + | |
3362 | 3362 | | |
3363 | 3363 | | |
3364 | 3364 | | |
3365 | 3365 | | |
3366 | 3366 | | |
3367 | 3367 | | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
3368 | 3374 | | |
3369 | 3375 | | |
3370 | 3376 | | |
3371 | | - | |
3372 | | - | |
3373 | | - | |
3374 | | - | |
3375 | | - | |
3376 | | - | |
3377 | | - | |
| 3377 | + | |
| 3378 | + | |
3378 | 3379 | | |
3379 | | - | |
| 3380 | + | |
3380 | 3381 | | |
3381 | 3382 | | |
3382 | 3383 | | |
| |||
0 commit comments