Bug #76548 [Opn->Csd]: pg_fetch_result did not fetch the next row
| From: | ab@php.net | Date: | Fri, 29 Jun 2018 16:36:50 +0000 |
| Subject: | Bug #76548 [Opn->Csd]: pg_fetch_result did not fetch the next row | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-216038@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76548&edit=1
ID: 76548
Updated by: ab@php.net
Reported by: sukei13 at gmail dot com
Summary: pg_fetch_result did not fetch the next row
-Status: Open
+Status: Closed
Type: Bug
Package: PostgreSQL related
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=cb97fd309790330bced04091fac46ea1466283c9
Log: Fixed bug #76548 pg_fetch_result did not fetch the next row
Previous Comments:
------------------------------------------------------------------------
[2018-06-29 14:41:28] sukei13 at gmail dot com
Description:
------------
pg_fetch_result used in its short form: pg_fetch_result(resource $result, mixed $field). should
fetch the next row each time it's called according to the documentation and the behavior of the
other pg_fetch_* behavior.
in php-src, the pg_result->row internal counter is never incremented. This result in fetching the
same row endlessly.
https://github.com/php/php-src/blob/php5_5_0/ext/pgsql/pgsql.c#L1182:L1188
Test script:
---------------
<?php
$connection = pg_connect('...');
$result = pg_query($connection, 'SELECT v FROM (VALUES (1), (2), (3)) AS t(v)'):
// cause an infinite loop since the pg_fetch_result func fetch the first value endlessly.
while ($value = pg_fetch_result($result, 0)) {
var_dump($value); // should be 1, 2 then 3.
}
Expected result:
----------------
1, 2, 3
Actual result:
--------------
1, 1, 1, 1, 1, ...
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76548&edit=1