xref: /PHP-8.2/ext/sqlite3/tests/bug72668.phpt (revision 7f2f0c00)
1--TEST--
2Bug #72668 (Spurious warning when exception is thrown in user defined function)
3--EXTENSIONS--
4sqlite3
5--FILE--
6<?php
7function my_udf_md5($string) {
8    throw new \Exception("test exception\n");
9}
10
11$db = new SQLite3(':memory:');
12$db->createFunction('my_udf_md5', 'my_udf_md5');
13
14try {
15    $result = $db->query('SELECT my_udf_md5("test")');
16    var_dump($result);
17}
18catch(\Exception $e) {
19    echo "Exception: ".$e->getMessage();
20}
21try {
22    $result = $db->querySingle('SELECT my_udf_md5("test")');
23    var_dump($result);
24}
25catch(\Exception $e) {
26    echo "Exception: ".$e->getMessage();
27}
28$statement = $db->prepare('SELECT my_udf_md5("test")');
29try {
30    $result = $statement->execute();
31    var_dump($result);
32}
33catch(\Exception $e) {
34    echo "Exception: ".$e->getMessage();
35}
36?>
37--EXPECT--
38Exception: test exception
39Exception: test exception
40Exception: test exception
41