Skip to content

Stdlib: ext/sqlite3 — SQLite3 class connect/exec/query (ext/sqlite3 parity) #3434

Description

@PurHur

Category

stdlib

Problem

Embedded SQLite via SQLite3 class (not only PDO) is common in tooling, tests, and desktop PHP apps. This repo has no ext/sqlite3 moduleclass_exists('SQLite3') is false and new SQLite3(':memory:') fatals.

PDO sqlite is tracked separately (#3367). This issue is the procedural/OOP SQLite3 API from ext/sqlite3.

php-src reference

Repro (failure today)

test/repro/maintainer_sqlite3_memory.php:

<?php
var_export(class_exists('SQLite3'));
echo "\n";
$db = new SQLite3(':memory:');
$db->exec('CREATE TABLE t (v TEXT)');
$db->exec("INSERT INTO t VALUES ('ok')");
echo $db->querySingle('SELECT v FROM t'), "\n";
$db->close();
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_sqlite3_memory.php
php bin/vm.php test/repro/maintainer_sqlite3_memory.php 2>&1 | head -3
'
Runtime Output
Zend PHP + ext/sqlite3 true then ok
bin/vm.php false / Class "SQLite3" not found

Scope (v1 subset — this repo)

Area Path
Module ext/sqlite3/Module.php, BuiltinClasses.php
VM class SQLite3 with __construct($filename), exec(), querySingle(), close()
Constants SQLITE3_ASSOC, SQLITE3_NUM, SQLITE3_BOTH, SQLITE3_OK, SQLITE3_ERROR
Native link libsqlite3 via AOT runtime / FFI (mirror #3367 PDO sqlite linking)
Tests test/compliance/cases/stdlib/sqlite3_memory.phpt
Matrix script/capability-matrix.php

Phase 2: SQLite3Stmt, SQLite3Result, createFunction, loadExtension (likely disabled), openBlob.

PHP-in-PHP: SQL execution wrappers in ext/sqlite3/*.php; C only for sqlite3_* FFI trampolines.

Done when

  • Repro prints true then ok on VM
  • class_exists('SQLite3') true after module init
  • Invalid SQL → exec() returns false; lastErrorMsg() non-empty (Zend subset)
  • ./script/ci-fast.sh --filter sqlite3_memory green
  • AOT link documents libsqlite3 dependency (same as PDO sqlite if shared)

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && vendor/bin/phpunit --filter sqlite3_memory'

Links

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions