Skip to content
This repository was archived by the owner on Jun 2, 2025. It is now read-only.

AST-based SQLite driver #1

Merged
merged 125 commits into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
aac00ce
Split, cleanup, and reorganize the SQLite driver prototype
JanJakes Nov 13, 2024
44641e1
Namespace-prefix the WIP SQLite driver for now to avoid naming conflicts
JanJakes Nov 14, 2024
be35587
Copy WP_SQLite_Translator_Tests and run them against the SQLite driver
JanJakes Nov 14, 2024
c8ea855
Copy the core of WP_SQLite_Translator to WP_SQLite_Driver
JanJakes Nov 18, 2024
62943d6
Add a base generic WP_Parser_Token class, add docs
JanJakes Nov 19, 2024
3449b0b
Complete WP_Parser_Node helper methods, add tests
JanJakes Nov 19, 2024
65afd67
Add basic support for SELECT statements, add unit tests
JanJakes Nov 19, 2024
00ec46d
Add basic support for INSERT, UPDATE, REPLACE, DELETE
JanJakes Nov 20, 2024
b8b4500
Add basic support for CREATE TABLE, implement data types
JanJakes Nov 20, 2024
6be220d
Handle system variables
JanJakes Nov 21, 2024
70744b7
Add support for UPDATE with ORDER BY and LIMIT
JanJakes Nov 22, 2024
797c3b7
Handle specifics of the CREATE TABLE statement
JanJakes Nov 26, 2024
647eaae
Add basic ALTER TABLE support
JanJakes Dec 2, 2024
c515605
Fix MySQL syntax errors in tests
JanJakes Dec 2, 2024
1e5c311
Introduce information schema builder & create information schema tables
JanJakes Dec 19, 2024
b617ef9
Record CREATE TABLE table info in information schema
JanJakes Dec 19, 2024
dbd50e6
Record CREATE TABLE column info in information schema
JanJakes Dec 19, 2024
6bdb7aa
Record CREATE TABLE constraint info in information schema
JanJakes Dec 19, 2024
afeeb18
Record CREATE TABLE inline constraint info in information schema
JanJakes Dec 19, 2024
2eaf077
Sync constraint info to columns table when constraints are modified
JanJakes Dec 19, 2024
d03892d
Record ALTER TABLE ADD COLUMN(s) in information schema
JanJakes Dec 19, 2024
93f536e
Record ALTER TABLE ADD CONSTRAINT in information schema
JanJakes Dec 19, 2024
6940a5b
Record ALTER TABLE CHANGE/MODIFY COLUMN in information schema
JanJakes Dec 19, 2024
127efc2
Record ALTER TABLE DROP COLUMN in information schema
JanJakes Dec 19, 2024
71265ed
Record ALTER TABLE DROP INDEX in information schema
JanJakes Dec 20, 2024
71e8d08
Execute CREATE TABLE using information schema
JanJakes Dec 20, 2024
4b4fb8f
Execute ALTER TABLE using information schema
JanJakes Dec 20, 2024
a0a67c0
Implement SHOW CREATE TABLE using information schema
JanJakes Dec 20, 2024
837655c
Implement SHOW INDEX using information schema
JanJakes Dec 20, 2024
f11fb09
Implement SHOW GRANTS
JanJakes Dec 20, 2024
cf6008d
Implement DESCRIBE using information schema
JanJakes Dec 20, 2024
f5a52ca
Ignore index hints
JanJakes Dec 20, 2024
174916a
Add support for LIKE BINARY
JanJakes Jan 10, 2025
335388b
Add support for REGEXP functions
JanJakes Jan 10, 2025
191864c
Merge branch 'develop' into ast-sqlite-driver
adamziel Jan 10, 2025
86a577c
Add support for LEFT function
JanJakes Jan 10, 2025
0b3ba08
Add support for DATE_ADD and DATE_SUB functions
JanJakes Jan 10, 2025
aa9ad47
Add support for DATE_FORMAT()
JanJakes Jan 13, 2025
f1c89ec
Implement SQL_CALC_FOUND_ROWS and FOUND_ROWS()
JanJakes Jan 15, 2025
d356021
Implement FROM DUAL
JanJakes Jan 15, 2025
8432d2a
Implement "CAST(... AS BINARY)"
JanJakes Jan 15, 2025
ab1e94f
Add support for CURRENT_TIMESTAMP() and NOW()
JanJakes Jan 15, 2025
6f2ffb0
Translate datetime literals, fix string literal processing
JanJakes Jan 15, 2025
6933c72
Add support for HAVING without GROUP BY
JanJakes Jan 15, 2025
32c72bf
Implement DROP for multiple and temporary tables
JanJakes Jan 16, 2025
822464a
Implement ON DUPLICATE KEY UPDATE
JanJakes Jan 16, 2025
94fa134
Implement INSERT IGNORE and UPDATE IGNORE
JanJakes Jan 16, 2025
f8af977
Implement DROP TABLE in information schema
JanJakes Jan 16, 2025
28bb50d
Implement SHOW TABLE STATUS
JanJakes Jan 16, 2025
13cd58f
Implement SHOW TABLES
JanJakes Jan 17, 2025
eecc39b
Fix saving and displaying index info
JanJakes Jan 17, 2025
b8fc7d8
Implement ON UPDATE CURRENT_TIMESTAMP
JanJakes Jan 17, 2025
ff8afed
Prefix index names in SQLite to prevent conflicts
JanJakes Jan 17, 2025
b227db5
Add support for multi-table delete statements
JanJakes Jan 21, 2025
9939dc3
Remove no longer relevant TODOs
JanJakes Jan 21, 2025
32a3a94
Remove no longer used data types cache
JanJakes Jan 21, 2025
3dfc043
Remove destructor
JanJakes Jan 21, 2025
7501c36
Remove unused variable
JanJakes Jan 21, 2025
7d87421
Remove unused property
JanJakes Jan 23, 2025
bb49c90
Simplify setting foreign keys pragma
JanJakes Jan 23, 2025
09edeaa
Use AST to detect transactional statements
JanJakes Jan 23, 2025
86f3b7f
Convert IFs to switch statement
JanJakes Jan 23, 2025
49c9794
Remove outdated comment, add TODO
JanJakes Jan 23, 2025
b0a4520
Improve comment
JanJakes Jan 23, 2025
e2453b7
Use get_child_node() calls to make translation unambiguous
JanJakes Jan 23, 2025
d556c09
Add a TODO comment for AST-querying API
JanJakes Jan 23, 2025
9c1feea
Handle foreign key checks in ALTER TABLE
JanJakes Jan 23, 2025
57287db
Improve query method docs and naming
JanJakes Jan 23, 2025
fa903bc
Fix identifier escaping
JanJakes Jan 23, 2025
38d3491
Throw exceptions for unsupported throw statements
JanJakes Jan 23, 2025
76285ea
Unify identifier quoting
JanJakes Jan 23, 2025
3530023
Improve API of user defined functions
JanJakes Jan 23, 2025
677bca4
Add a TODO for SQLite client info
JanJakes Jan 23, 2025
53eb81e
Use a unified prefix for internal objects
JanJakes Jan 23, 2025
fd6c2fa
Fetch column info only for needed columns when adding a constraint
JanJakes Jan 24, 2025
5b95d96
Preserve ROWIDs in ALTER TABLE statements
JanJakes Jan 24, 2025
e14660e
Fix and improve translation tests
JanJakes Jan 24, 2025
3cfaf92
Use correct string literal quotes
JanJakes Jan 24, 2025
b8b0bef
Use table schema value in all information schema queries
JanJakes Jan 24, 2025
d805979
Remove prototype classes
JanJakes Jan 24, 2025
b6d900b
Remove WIP namespacing (the new classes don't conflict with the exist…
JanJakes Jan 24, 2025
232b1c1
Enable usage of PDO in phpcs
JanJakes Jan 24, 2025
c564fc9
Add a feature flag to use the new driver
JanJakes Jan 27, 2025
c7e121f
Use strict SQLite tables to validate data types
JanJakes Jan 28, 2025
7d471e1
Store last insert ID
JanJakes Jan 28, 2025
9297782
Translate CONCAT function to concat pipes
JanJakes Jan 28, 2025
417d37f
Correctly translate REPLACE statements
JanJakes Jan 28, 2025
10dcfc1
Add basic SHOW VARIABLES support
JanJakes Jan 28, 2025
8a08243
Add support for IF NOT EXISTS when creating a table
JanJakes Jan 28, 2025
56dfd83
Improve string literal translation
JanJakes Jan 28, 2025
5db45db
Fix backslash escaping in a test
JanJakes Jan 28, 2025
39b1aba
Fix identifier translation, use backtics due to issues with double qu…
JanJakes Jan 28, 2025
118c57a
Do not execute statements when there are no IDs to delete
JanJakes Jan 28, 2025
b78d0ad
Add basic support for CHAR_LENGTH
JanJakes Jan 28, 2025
3cbb647
Handle null characters in strings
JanJakes Jan 29, 2025
50d0bd2
Fix column default value handling
JanJakes Jan 29, 2025
bbe6470
Display info when the AST driver is used
JanJakes Jan 29, 2025
069f1ef
Add a test for the reason to use backtick identifier escaping
JanJakes Jan 30, 2025
487bf54
Use PDO to load SQLite version, improve docs
JanJakes Feb 3, 2025
c63607e
Remove all remaining usages of SQLite 3
JanJakes Feb 3, 2025
39ac173
Declare PDO and PDO SQLite requirements in composer.json
JanJakes Feb 3, 2025
d2be9d8
Use getters instead of public properties
JanJakes Feb 3, 2025
8b74f33
Fix query dumping script
JanJakes Feb 3, 2025
625ca4a
Simplify SQLite lock wait logic
JanJakes Feb 4, 2025
d19c9aa
Remove legacy hooks
JanJakes Feb 4, 2025
67c1fff
Closely mirror wpdb::query() and wpdb::_do_query()
JanJakes Feb 4, 2025
0f8dc09
Simplify driver state
JanJakes Feb 4, 2025
59c4451
Remove uselsess return values
JanJakes Feb 4, 2025
a83a5f8
Change FIX comments to CHANGED
JanJakes Feb 4, 2025
f7c99c1
Improve parser node method naming
JanJakes Feb 5, 2025
8b27c85
Fix FROM/IN handling for SHOW statements
JanJakes Feb 5, 2025
c27b571
Add tests for UNION and UNION ALL
JanJakes Feb 5, 2025
0f7060f
Configure the SQLite driver using an $options array
JanJakes Feb 5, 2025
e961bf5
Use custom exception class for driver errors
JanJakes Feb 6, 2025
fda096c
Ignore transaction rollback errors when an exception occurs
JanJakes Feb 6, 2025
e4df6b9
Return true for transactional commands
JanJakes Feb 6, 2025
96e0208
Move database directory creation outside of the driver, revamp it
JanJakes Feb 6, 2025
cb4d6a3
Extract debug mode setting to an option
JanJakes Feb 6, 2025
54c27a2
Improve driver docs and property naming
JanJakes Feb 6, 2025
beaa51d
Revamp error handling, extract error notice creation out from the driver
JanJakes Feb 6, 2025
09fbcd9
Improve docs and naming
JanJakes Feb 7, 2025
4d9d432
Check for mimimum SQLite version
JanJakes Feb 7, 2025
078e2ce
Remove the AST driver files from .gitattributes
JanJakes Jan 29, 2025
6947019
Improve constant name
JanJakes Feb 12, 2025
9c0c9b5
Use past tense in @CHANGED comments
JanJakes Feb 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@ phpunit.xml.dist export-ignore
/.github export-ignore
/grammar-tools export-ignore
/tests export-ignore
/wip export-ignore
/wp-includes/mysql export-ignore
/wp-includes/parser export-ignore
/wp-includes/sqlite/class-wp-sqlite-crosscheck-db.php export-ignore
4 changes: 2 additions & 2 deletions activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ function ( $result ) {
* When the plugin gets merged in wp-core, this is not to be ported.
*/
function sqlite_plugin_copy_db_file() {
// Bail early if the SQLite3 class does not exist.
if ( ! class_exists( 'SQLite3' ) ) {
// Bail early if the PDO SQLite extension is not loaded.
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
return;
}

Expand Down
6 changes: 3 additions & 3 deletions admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ function sqlite_plugin_admin_notice() {
return;
}

// If SQLite is not detected, bail early.
if ( ! class_exists( 'SQLite3' ) ) {
// If PDO SQLite is not loaded, bail early.
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
esc_html__( 'The SQLite Integration plugin is active, but the SQLite3 class is missing from your server. Please make sure that SQLite is enabled in your PHP installation.', 'sqlite-database-integration' )
esc_html__( 'The SQLite Integration plugin is active, but the PDO SQLite extension is missing from your server. Please make sure that PDO SQLite is enabled in your PHP installation.', 'sqlite-database-integration' )
);
return;
}
Expand Down
9 changes: 3 additions & 6 deletions admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ function sqlite_integration_admin_screen() {
?>
</p>
<?php else : ?>
<?php if ( ! class_exists( 'SQLite3' ) ) : ?>
<div class="notice notice-error">
<p><?php esc_html_e( 'We detected that the SQLite3 class is missing from your server. Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>
</div>
<?php elseif ( ! extension_loaded( 'pdo_sqlite' ) ) : ?>
<?php if ( ! extension_loaded( 'pdo_sqlite' ) ) : ?>
<div class="notice notice-error">
<p><?php esc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p>
</div>
Expand Down Expand Up @@ -130,7 +126,8 @@ function sqlite_plugin_adminbar_item( $admin_bar ) {
global $wpdb;

if ( defined( 'SQLITE_DB_DROPIN_VERSION' ) && defined( 'DB_ENGINE' ) && 'sqlite' === DB_ENGINE ) {
$title = '<span style="color:#46B450;">' . __( 'Database: SQLite', 'sqlite-database-integration' ) . '</span>';
$suffix = defined( 'WP_SQLITE_AST_DRIVER' ) && WP_SQLITE_AST_DRIVER ? ' (AST)' : '';
$title = '<span style="color:#46B450;">' . __( 'Database: SQLite', 'sqlite-database-integration' ) . $suffix . '</span>';
} elseif ( stripos( $wpdb->db_server_info(), 'maria' ) !== false ) {
$title = '<span style="color:#DC3232;">' . __( 'Database: MariaDB', 'sqlite-database-integration' ) . '</span>';
} else {
Expand Down
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"issues": "https://github.com/wordpress/sqlite-database-integration/issues"
},
"require": {
"php": ">=7.0"
"php": ">=7.0",
"ext-pdo": "*",
"ext-pdo_sqlite": "*"
},
"require-dev": {
"ext-mbstring": "*",
Expand Down
Loading