|  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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
40 - 26 = ?
Subscribe to this entry?

 [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: Sat Oct 19 12:01:27 2019 UTC