xref: /PHP-5.5/ext/sqlite3/tests/bug68760.phpt (revision 8f9cb39c)
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";
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--EXPECTF--
33callback
34Warning: SQLite3::query(): An error occurred while invoking the compare callback in %a%ebug68760.php on line %i
35Exception: oops
36
37