xref: /PHP-7.3/ext/pgsql/tests/09notice.phpt (revision b8bb4d77)
1--TEST--
2PostgreSQL notice function
3--SKIPIF--
4<?php
5
6include("skipif.inc");
7
8_skip_lc_messages();
9
10?>
11--FILE--
12<?php
13include 'config.inc';
14include 'lcmess.inc';
15
16ini_set('pgsql.log_notice', TRUE);
17ini_set('pgsql.ignore_notice', FALSE);
18
19$db = pg_connect($conn_str);
20
21_set_lc_messages();
22
23$res = pg_query($db, 'SET client_min_messages TO NOTICE;');
24var_dump($res);
25
26// Get empty notice
27var_dump(pg_last_notice($db));
28var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
29
30pg_query($db, "BEGIN;");
31pg_query($db, "BEGIN;");
32pg_query($db, "BEGIN;");
33pg_query($db, "BEGIN;");
34
35// Get notices
36var_dump(pg_last_notice($db));
37var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
38
39// Clear and get notices
40var_dump(pg_last_notice($db, PGSQL_NOTICE_CLEAR));
41var_dump(pg_last_notice($db, PGSQL_NOTICE_LAST));
42var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
43
44// Invalid option
45var_dump(pg_last_notice($db, 99));
46?>
47--EXPECTF--
48resource(%d) of type (pgsql result)
49string(0) ""
50array(0) {
51}
52
53Notice: pg_query(): %s already a transaction in progress in %s on line %d
54
55Notice: pg_query(): %s already a transaction in progress in %s on line %d
56
57Notice: pg_query(): %s already a transaction in progress in %s on line %d
58string(52) "WARNING:  there is already a transaction in progress"
59array(3) {
60  [0]=>
61  string(52) "WARNING:  there is already a transaction in progress"
62  [1]=>
63  string(52) "WARNING:  there is already a transaction in progress"
64  [2]=>
65  string(52) "WARNING:  there is already a transaction in progress"
66}
67bool(true)
68string(0) ""
69array(0) {
70}
71
72Warning: pg_last_notice(): Invalid option specified (99) in %s%e09notice.php on line %d
73bool(false)
74