Skip to content

Add experimental DuckDB backend support#442

Draft
adamziel wants to merge 316 commits into
WordPress:trunkfrom
adamziel:add-duckdb-support
Draft

Add experimental DuckDB backend support#442
adamziel wants to merge 316 commits into
WordPress:trunkfrom
adamziel:add-duckdb-support

Conversation

@adamziel

@adamziel adamziel commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

What it does

Adds an experimental optional duckdb backend alongside the existing SQLite path.

The default SQLite runtime stays zero-dependency. DuckDB is only selected when DB_ENGINE=duckdb and the DuckDB PHP client autoloader is supplied through DUCKDB_PHP_AUTOLOAD.

Rationale

DuckDB gives the project a second SQL execution backend for local development, compatibility experiments, and analytical-style database work. It has different runtime requirements from SQLite, so the implementation is explicitly gated behind runtime checks for PHP/FFI/client availability.

This PR keeps unsupported MySQL behavior explicit: unsupported statements fail through WP_DuckDB_Driver_Exception instead of silently pretending to work.

Implementation

Adds the DuckDB driver under packages/mysql-on-sqlite/src/duckdb:

  • connection, prepared statement, result statement, runtime gate, and driver exception wrappers
  • MySQL-to-DuckDB translation for common WordPress DDL, DML, metadata, expression, and wpdb query shapes
  • metadata emulation for MySQL-shaped information_schema, SHOW, DESCRIBE, indexes, constraints, and table status queries
  • WordPress drop-in support via DB_ENGINE=duckdb
  • DuckDB-specific PHPUnit, WordPress PHPUnit, WordPress E2E, smoke, and runtime setup paths
  • CI fast-fail guards and 30-minute PR workflow caps for long DuckDB/WASM paths
  • strict full WordPress PHPUnit coverage for DuckDB, with expected-result allowlists disabled
  • fast paths for high-frequency WordPress PHPUnit transaction/autocommit boilerplate

The DuckDB path remains experimental. The SQLite path remains the default runtime.

Testing instructions

Default suite:

cd packages/mysql-on-sqlite
composer run test

Coding standards:

composer run check-cs

Live DuckDB suite, with a DuckDB PHP autoloader installed separately:

cd packages/mysql-on-sqlite
WP_DUCKDB_TESTS=1 \
WP_DUCKDB_AUTOLOAD=/path/to/duckdb/vendor/autoload.php \
DUCKDB_PHP_AUTOLOAD=/path/to/duckdb/vendor/autoload.php \
php -d ffi.enable=1 ./vendor/bin/phpunit -c ./phpunit.xml.dist --group duckdb

Current status

Current PR head: 21d5965.

Verified locally:

  • composer check-cs -- --no-cache --report-full --report-checkstyle=./phpcs-report.xml
  • WP_DUCKDB_TESTS=1 ... php -d ffi.enable=1 packages/mysql-on-sqlite/vendor/bin/phpunit -c packages/mysql-on-sqlite/phpunit.xml.dist --group duckdb
  • focused DuckDB transaction/found-rows fast-path tests

GitHub status at this update:

  • CS: passing on 21d5965
  • MySQL Proxy Tests: passing on 21d5965
  • Verify release metadata: passing on 21d5965
  • full WordPress/DuckDB CI: queued or running; not yet claimed green

adamziel added 30 commits June 27, 2026 04:53
@adamziel adamziel added the duckdb-setup-fast-fail Run setup-backed DuckDB WordPress smoke and recent fast-fail gates on PR label Jun 30, 2026
@adamziel adamziel marked this pull request as draft July 1, 2026 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duckdb-setup-fast-fail Run setup-backed DuckDB WordPress smoke and recent fast-fail gates on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant