Skip to content

Commit 96c7ba0

Browse files
committed
Extend churn probe with UDF registration
PDO churn alone (raw open/close 0..500 times) didn't reproduce either failing-test bug. Each driver setUp also registers ~44 UDFs via sqliteCreateFunction. Add UDF registration to each churn iteration to mirror the driver, in case stale FUNC_SLOTS state across sqlite3_create_function_v2 calls is the trigger.
1 parent 286a045 commit 96c7ba0

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/phpunit-tests-turso.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,13 +1023,33 @@ jobs:
10231023
// If the bug reproduces past some N, we have a minimal repro
10241024
// and can bisect what specifically accumulates.
10251025
function setup_and_run(int $churn_count): array {
1026+
// Mimic the driver's setUp: register a bunch of UDFs and run
1027+
// common PRAGMAs, like WP_PDO_MySQL_On_SQLite::__construct does.
1028+
$udf_names = [
1029+
'throw','month','monthnum','year','day','hour','minute','second','week',
1030+
'weekday','dayofweek','dayofmonth','unix_timestamp','now','md5','curdate',
1031+
'rand','from_unixtime','localtime','localtimestamp','isnull','if','regexp',
1032+
'field','log','least','greatest','get_lock','release_lock','ucase','lcase',
1033+
'concat','date_add','date_sub','dayname','monthname','quarter','last_day',
1034+
'time_to_sec','timestampdiff','date_format','find_in_set','char_length','format',
1035+
];
10261036
for ($i = 0; $i < $churn_count; $i++) {
1027-
$p = new PDO('sqlite::memory:');
1037+
$pdo_class = PHP_VERSION_ID >= 80400 ? PDO\SQLite::class : PDO::class;
1038+
$p = new $pdo_class('sqlite::memory:');
10281039
$p->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
1040+
$p->setAttribute(PDO::ATTR_TIMEOUT, 30);
1041+
$p->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
1042+
$p->query('PRAGMA foreign_keys = ON');
1043+
foreach ($udf_names as $name) {
1044+
if ($p instanceof PDO\SQLite) {
1045+
$p->createFunction($name, function (...$a) { return ''; });
1046+
} else {
1047+
$p->sqliteCreateFunction($name, function (...$a) { return ''; });
1048+
}
1049+
}
10291050
$p->exec('CREATE TABLE t (id INT, v TEXT)');
10301051
$p->exec("INSERT INTO t VALUES (1, 'a'), (2, 'b'), (3, 'c')");
10311052
$p->query('SELECT * FROM t');
1032-
// CREATE TEMP TABLE on each — exercises temp pager
10331053
$p->exec('CREATE TEMPORARY TABLE t2 (id INT)');
10341054
$p->exec("INSERT INTO t2 VALUES (1)");
10351055
unset($p);

0 commit comments

Comments
 (0)