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