Repository navigation
Commit 6b22c0e
Quote SQLite identifiers in LOCK TABLES, SHOW TABLES, and compound primary key indexes (#599)
### Summary
Fixes #598.
This PR ensures generated SQLite identifiers are consistently quoted via
`$this->quote_sqlite_identifier()` in three query paths inside
`WP_MySQL_On_SQLite`:
1. **`LOCK TABLES` (`execute_transaction_or_locking_statement()`)**:
Quote `$table_name` in `SELECT 1 FROM %s LIMIT 0` so persistent and
`TEMPORARY` tables whose names contain spaces, keywords, or special
characters can be locked without falsely raising `1146 Table '...'
doesn't exist`.
2. **`SHOW [FULL] TABLES` (`execute_show_tables_statement()`)**: Quote
the `Tables_in_<database>` column alias via
`$this->quote_sqlite_identifier( 'Tables_in_' . $database )` so database
identifiers containing escaped backticks do not break the generated
SQLite `SELECT` query.
3. **Compound `PRIMARY KEY` with `AUTO_INCREMENT`
(`get_sqlite_create_table_statement()`)**: Quote `self::RESERVED_PREFIX
. $sqlite_index_name` in `CREATE UNIQUE INDEX %s ON %s (%s)` (matching
regular index generation right below it) so `CREATE TABLE` and `ALTER
TABLE` table rebuilds succeed on quoted table names.
### Testing
Added unit tests in
`packages/mysql-on-sqlite/tests/WP_MySQL_On_SQLite_Tests.php`:
- `testShowTablesWithQuotedDatabaseIdentifier`
- `testCompoundPrimaryKeyWithAutoincrementAndQuotedIdentifiers`
- `testLockTablesWithQuotedIdentifiers`
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved handling of quoted database and table names when listing
tables, locking tables, and using compound primary keys with
auto-increment columns.
* Improved table-lock behavior for names containing dots and for tables
that do not exist.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Jan Jakeš <jan@jakes.pro>1 parent 2716348 commit 6b22c0e
2 files changed
Lines changed: 109 additions & 7 deletions
File tree
- packages/mysql-on-sqlite
- src/sqlite
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2301 | 2301 | | |
2302 | 2302 | | |
2303 | 2303 | | |
2304 | | - | |
| 2304 | + | |
| 2305 | + | |
| 2306 | + | |
| 2307 | + | |
2305 | 2308 | | |
2306 | 2309 | | |
2307 | 2310 | | |
| |||
3722 | 3725 | | |
3723 | 3726 | | |
3724 | 3727 | | |
3725 | | - | |
| 3728 | + | |
3726 | 3729 | | |
3727 | 3730 | | |
3728 | 3731 | | |
3729 | | - | |
| 3732 | + | |
| 3733 | + | |
3730 | 3734 | | |
3731 | 3735 | | |
3732 | | - | |
3733 | | - | |
| 3736 | + | |
| 3737 | + | |
3734 | 3738 | | |
3735 | 3739 | | |
3736 | 3740 | | |
3737 | | - | |
| 3741 | + | |
3738 | 3742 | | |
3739 | 3743 | | |
3740 | 3744 | | |
| |||
7451 | 7455 | | |
7452 | 7456 | | |
7453 | 7457 | | |
7454 | | - | |
| 7458 | + | |
7455 | 7459 | | |
7456 | 7460 | | |
7457 | 7461 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1402 | 1402 | | |
1403 | 1403 | | |
1404 | 1404 | | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
1405 | 1443 | | |
1406 | 1444 | | |
1407 | 1445 | | |
| |||
8161 | 8199 | | |
8162 | 8200 | | |
8163 | 8201 | | |
| 8202 | + | |
| 8203 | + | |
| 8204 | + | |
| 8205 | + | |
| 8206 | + | |
| 8207 | + | |
| 8208 | + | |
| 8209 | + | |
| 8210 | + | |
| 8211 | + | |
| 8212 | + | |
| 8213 | + | |
| 8214 | + | |
| 8215 | + | |
| 8216 | + | |
| 8217 | + | |
| 8218 | + | |
| 8219 | + | |
| 8220 | + | |
| 8221 | + | |
| 8222 | + | |
| 8223 | + | |
| 8224 | + | |
| 8225 | + | |
| 8226 | + | |
| 8227 | + | |
| 8228 | + | |
| 8229 | + | |
| 8230 | + | |
| 8231 | + | |
| 8232 | + | |
| 8233 | + | |
| 8234 | + | |
| 8235 | + | |
| 8236 | + | |
| 8237 | + | |
| 8238 | + | |
| 8239 | + | |
8164 | 8240 | | |
8165 | 8241 | | |
8166 | 8242 | | |
| |||
10546 | 10622 | | |
10547 | 10623 | | |
10548 | 10624 | | |
| 10625 | + | |
| 10626 | + | |
| 10627 | + | |
| 10628 | + | |
| 10629 | + | |
| 10630 | + | |
| 10631 | + | |
| 10632 | + | |
| 10633 | + | |
| 10634 | + | |
| 10635 | + | |
| 10636 | + | |
| 10637 | + | |
| 10638 | + | |
| 10639 | + | |
| 10640 | + | |
| 10641 | + | |
| 10642 | + | |
| 10643 | + | |
| 10644 | + | |
| 10645 | + | |
| 10646 | + | |
10549 | 10647 | | |
10550 | 10648 | | |
10551 | 10649 | | |
| |||
0 commit comments