Bug #76548 [NEW]: pg_fetch_result did not fetch the next row
| From: | sukei13 at gmail dot com | Date: | Fri, 29 Jun 2018 14:41:31 +0000 |
| Subject: | Bug #76548 [NEW]: pg_fetch_result did not fetch the next row | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216036@lists.php.net to get a copy of this message | ||
From: sukei13 at gmail dot com
Operating system:
PHP version: Irrelevant
Package: PostgreSQL related
Bug Type: Bug
Bug description:pg_fetch_result did not fetch the next row
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 bug report at https://bugs.php.net/bug.php?id=76548&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76548&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76548&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76548&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76548&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76548&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76548&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76548&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76548&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76548&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76548&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76548&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76548&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76548&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76548&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76548&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76548&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76548&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76548&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76548&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76548&r=mysqlcfg