From fe1ef6e2e024ad9d66b3905477e1053ffd08503d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Jake=C5=A1?= Date: Tue, 7 Jul 2026 13:11:42 +0200 Subject: [PATCH] Enable SQLite column metadata Build Unix SQLite with SQLITE_ENABLE_COLUMN_METADATA so the metadata APIs are available on macOS and Linux. Remove the pdo_sqlite configure override that forced PHP to treat sqlite3_column_table_name() as unavailable, and add sanity checks for both SQLite compile options and PDO column metadata. --- src/SPC/builder/extension/pdo_sqlite.php | 23 ----------------------- src/SPC/builder/unix/library/sqlite.php | 7 ++++++- src/globals/ext-tests/pdo_sqlite.php | 16 ++++++++++++++++ src/globals/ext-tests/sqlite3.php | 10 ++++++++++ 4 files changed, 32 insertions(+), 24 deletions(-) delete mode 100644 src/SPC/builder/extension/pdo_sqlite.php create mode 100644 src/globals/ext-tests/pdo_sqlite.php create mode 100644 src/globals/ext-tests/sqlite3.php diff --git a/src/SPC/builder/extension/pdo_sqlite.php b/src/SPC/builder/extension/pdo_sqlite.php deleted file mode 100644 index 4d6f296c..00000000 --- a/src/SPC/builder/extension/pdo_sqlite.php +++ /dev/null @@ -1,23 +0,0 @@ -configure()->make(); + UnixAutoconfExecutor::create($this) + ->appendEnv([ + 'CFLAGS' => '-DSQLITE_ENABLE_COLUMN_METADATA=1', + ]) + ->configure() + ->make(); $this->patchPkgconfPrefix(['sqlite3.pc']); } } diff --git a/src/globals/ext-tests/pdo_sqlite.php b/src/globals/ext-tests/pdo_sqlite.php new file mode 100644 index 00000000..9e5e7f14 --- /dev/null +++ b/src/globals/ext-tests/pdo_sqlite.php @@ -0,0 +1,16 @@ +exec('CREATE TABLE spc_column_metadata_test (id INTEGER)'); + +$stmt = $pdo->query('SELECT id FROM spc_column_metadata_test'); +if ($stmt === false) { + throw new RuntimeException('Failed to query SQLite metadata test table.'); +} + +$metadata = $stmt->getColumnMeta(0); +if (($metadata['table'] ?? null) !== 'spc_column_metadata_test') { + throw new RuntimeException('PDO SQLite column metadata does not include the origin table.'); +} diff --git a/src/globals/ext-tests/sqlite3.php b/src/globals/ext-tests/sqlite3.php new file mode 100644 index 00000000..c3221e35 --- /dev/null +++ b/src/globals/ext-tests/sqlite3.php @@ -0,0 +1,10 @@ +querySingle("SELECT sqlite_compileoption_used('ENABLE_COLUMN_METADATA')"); + +if ((int) $enabled !== 1) { + throw new RuntimeException('SQLite was not built with SQLITE_ENABLE_COLUMN_METADATA.'); +}