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