xref: /PHP-5.6/ext/pgsql/tests/bug60244.phpt (revision 32c4c239)
1--TEST--
2Bug #60244 (pg_fetch_* functions do not validate that row param is >0)
3--SKIPIF--
4<?php
5include("skipif.inc");
6?>
7--FILE--
8<?php
9
10include 'config.inc';
11
12$db = pg_connect($conn_str);
13$result = pg_query("select 'a' union select 'b'");
14
15var_dump(pg_fetch_array($result, -1));
16var_dump(pg_fetch_assoc($result, -1));
17var_dump(pg_fetch_object($result, -1));
18var_dump(pg_fetch_row($result, -1));
19
20var_dump(pg_fetch_array($result, 0));
21var_dump(pg_fetch_assoc($result, 0));
22var_dump(pg_fetch_object($result, 0));
23var_dump(pg_fetch_row($result, 0));
24
25pg_close($db);
26
27?>
28--EXPECTF--
29Warning: pg_fetch_array(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
30bool(false)
31
32Warning: pg_fetch_assoc(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
33bool(false)
34
35Warning: pg_fetch_object(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
36bool(false)
37
38Warning: pg_fetch_row(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
39bool(false)
40array(2) {
41  [0]=>
42  string(1) "a"
43  ["?column?"]=>
44  string(1) "a"
45}
46array(1) {
47  ["?column?"]=>
48  string(1) "a"
49}
50object(stdClass)#1 (1) {
51  ["?column?"]=>
52  string(1) "a"
53}
54array(1) {
55  [0]=>
56  string(1) "a"
57}
58