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