forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbug60244.phpt
68 lines (62 loc) · 1.38 KB
/
bug60244.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
--TEST--
Bug #60244 (pg_fetch_* functions do not validate that row param is >0)
--EXTENSIONS--
pgsql
--SKIPIF--
<?php
include("skipif.inc");
?>
--FILE--
<?php
include 'config.inc';
$db = pg_connect($conn_str);
$result = pg_query($db, "select 'a' union select 'b'");
try {
var_dump(pg_fetch_array($result, -1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump(pg_fetch_assoc($result, -1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump(pg_fetch_object($result, -1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
try {
var_dump(pg_fetch_row($result, -1));
} catch (\ValueError $e) {
echo $e->getMessage() . \PHP_EOL;
}
var_dump(pg_fetch_array($result, 0));
var_dump(pg_fetch_assoc($result, 0));
var_dump(pg_fetch_object($result, 0));
var_dump(pg_fetch_row($result, 0));
pg_close($db);
?>
--EXPECTF--
pg_fetch_array(): Argument #2 ($row) must be greater than or equal to 0
pg_fetch_assoc(): Argument #2 ($row) must be greater than or equal to 0
pg_fetch_object(): Argument #2 ($row) must be greater than or equal to 0
pg_fetch_row(): Argument #2 ($row) must be greater than or equal to 0
array(2) {
[0]=>
string(1) "a"
["?column?"]=>
string(1) "a"
}
array(1) {
["?column?"]=>
string(1) "a"
}
object(stdClass)#%d (1) {
["?column?"]=>
string(1) "a"
}
array(1) {
[0]=>
string(1) "a"
}