|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76548 pg_fetch_result did not fetch the next row
Submitted: 2018-06-29 14:41 UTC Modified: -
From: sukei13 at gmail dot com Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: sukei13 at gmail dot com
New email:
PHP Version: OS:


 [2018-06-29 14:41 UTC] sukei13 at gmail dot com
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.

Test script:

$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, ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-29 16:36 UTC]
Automatic comment on behalf of ab
Log: Fixed bug #76548 pg_fetch_result did not fetch the next row
 [2018-06-29 16:36 UTC]
-Status: Open +Status: Closed
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 11 18:01:33 2020 UTC