xref: /PHP-7.1/ext/pgsql/tests/80_bug32223b.phpt (revision 7af945e2)
1--TEST--
2Bug #32223 (weird behaviour of pg_last_notice using define)
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
26define('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
43function tester() {
44        $res = pg_query(dbh, 'SELECT test_notice()');
45        $row = pg_fetch_row($res, 0);
46        var_dump($row);
47        pg_free_result($res);
48        if ($row[0] == 'f')
49        {
50                var_dump(pg_last_notice(dbh));
51        }
52}
53tester();
54
55pg_close(dbh);
56
57?>
58===DONE===
59--EXPECTF--
60resource(%d) of type (pgsql result)
61array(1) {
62  [0]=>
63  string(1) "f"
64}
65string(14) "NOTICE:  11111"
66===DONE===
67