xref: /PHP-8.4/ext/pdo_sqlite/tests/gh13998.phpt (revision 2a1aa8ca)
1--TEST--
2Fix GH-13998: Manage refcount of agg_context->val correctly
3--EXTENSIONS--
4pdo_sqlite
5--FILE--
6<?php
7$step = function () {
8    throw new Exception();
9};
10$finalize = function () {
11};
12
13$db = new PDO('sqlite::memory:');
14$db->query('CREATE TABLE test (a int, b int)');
15$stmt = $db->query('INSERT INTO test VALUES (1, 1), (2, 2), (3, 3)');
16$db->sqliteCreateAggregate('S', $step, $finalize, 1);
17
18try {
19    $db->query('SELECT S(a) FROM test');
20} catch (Exception $e) {
21    echo 'done!';
22}
23?>
24--EXPECT--
25done!
26