xref: /PHP-7.3/ext/sqlite3/tests/bug68760.phpt (revision b746e698)
1--TEST--
2Bug #68760 (Callback throws exception behaviour. Segfault in 5.6)
3--SKIPIF--
4<?php
5if (!extension_loaded('sqlite3')) die('skip');
6?>
7--FILE--
8<?php
9function oopsFunction($a, $b) {
10	echo "callback".PHP_EOL;
11	throw new \Exception("oops");
12}
13
14$db = new SQLite3(":memory:");
15$db->exec("CREATE TABLE test (col1 string)");
16$db->exec("INSERT INTO test VALUES ('a1')");
17$db->exec("INSERT INTO test VALUES ('a10')");
18$db->exec("INSERT INTO test VALUES ('a2')");
19
20try {
21    $db->createCollation('NATURAL_CMP', 'oopsFunction');
22    $naturalSort = $db->query("SELECT col1 FROM test ORDER BY col1 COLLATE NATURAL_CMP");
23    while ($row = $naturalSort->fetchArray()) {
24        echo $row['col1'], "\n";
25    }
26    $db->close();
27}
28catch(\Exception $e) {
29    echo "Exception: ".$e->getMessage();
30}
31?>
32--EXPECT--
33callback
34Exception: oops
35