xref: /PHP-8.0/ext/pgsql/tests/80_bug32223.phpt (revision f8d79582)
1--TEST--
2Bug #32223 (weird behaviour of pg_last_notice)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6
7_skip_lc_messages();
8
9@pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
10$res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
11begin
12        RAISE NOTICE ''11111'';
13        return ''f'';
14end;
15' LANGUAGE plpgsql;");
16if (!$res) die('skip PLPGSQL not available');
17?>
18--INI--
19pgsql.ignore_notice=0
20--FILE--
21<?php
22
23require_once('config.inc');
24require_once('lcmess.inc');
25
26$dbh = @pg_connect($conn_str);
27if (!$dbh) {
28    die ("Could not connect to the server");
29}
30
31_set_lc_messages();
32
33$res = pg_query($dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
34begin
35        RAISE NOTICE ''11111'';
36        return ''f'';
37end;
38' LANGUAGE plpgsql;");
39
40$res = pg_query($dbh, 'SET client_min_messages TO NOTICE;');
41var_dump($res);
42$res = pg_query($dbh, 'SELECT test_notice()');
43var_dump($res);
44$row = pg_fetch_row($res, 0);
45var_dump($row);
46pg_free_result($res);
47if ($row[0] == 'f')
48{
49    var_dump(pg_last_notice($dbh));
50}
51
52pg_close($dbh);
53
54?>
55--EXPECTF--
56resource(%d) of type (pgsql result)
57resource(%d) of type (pgsql result)
58array(1) {
59  [0]=>
60  string(1) "f"
61}
62string(14) "NOTICE:  11111"
63