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 15try { 16 var_dump(pg_fetch_array($result, -1)); 17} catch (\ValueError $e) { 18 echo $e->getMessage() . \PHP_EOL; 19} 20try { 21 var_dump(pg_fetch_assoc($result, -1)); 22} catch (\ValueError $e) { 23 echo $e->getMessage() . \PHP_EOL; 24} 25try { 26 var_dump(pg_fetch_object($result, -1)); 27} catch (\ValueError $e) { 28 echo $e->getMessage() . \PHP_EOL; 29} 30try { 31 var_dump(pg_fetch_row($result, -1)); 32} catch (\ValueError $e) { 33 echo $e->getMessage() . \PHP_EOL; 34} 35 36var_dump(pg_fetch_array($result, 0)); 37var_dump(pg_fetch_assoc($result, 0)); 38var_dump(pg_fetch_object($result, 0)); 39var_dump(pg_fetch_row($result, 0)); 40 41pg_close($db); 42 43?> 44--EXPECT-- 45pg_fetch_array(): Argument #2 ($row) must be greater than or equal to 0 46pg_fetch_assoc(): Argument #2 ($row) must be greater than or equal to 0 47pg_fetch_object(): Argument #2 ($row) must be greater than or equal to 0 48pg_fetch_row(): Argument #2 ($row) must be greater than or equal to 0 49array(2) { 50 [0]=> 51 string(1) "a" 52 ["?column?"]=> 53 string(1) "a" 54} 55array(1) { 56 ["?column?"]=> 57 string(1) "a" 58} 59object(stdClass)#1 (1) { 60 ["?column?"]=> 61 string(1) "a" 62} 63array(1) { 64 [0]=> 65 string(1) "a" 66} 67