|  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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
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-2019 The PHP Group
All rights reserved.
Last updated: Mon Sep 23 17:01:26 2019 UTC