xref: /PHP-5.4/ext/pgsql/tests/80_bug32223b.phpt (revision cf39c3d6)
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
40function tester() {
41        $res = pg_query(dbh, 'SELECT test_notice()');
42        $row = pg_fetch_row($res, 0);
43		var_dump($row);
44        pg_free_result($res);
45        if ($row[0] == 'f')
46        {
47                var_dump(pg_last_notice(dbh));
48        }
49}
50tester();
51
52pg_close(dbh);
53
54?>
55===DONE===
56--EXPECTF--
57array(1) {
58  [0]=>
59  string(1) "f"
60}
61string(14) "NOTICE:  11111"
62===DONE===
63