[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] com php-src: Fixed bug #76548 =?UTF-8?Q?pg=5Ffetch=5Fresult=20did=20not?= =?UTF-8?Q?=20fet
From:       Anatol Belski <ab () php ! net>
Date:       2018-06-29 16:34:53
Message-ID: php-mail-d4fdd29ce6f41ec343c63ccdb8ec5d3b1727480968 () git ! php ! net
[Download RAW message or body]

Commit:    cb97fd309790330bced04091fac46ea1466283c9
Author:    Anatol Belski <ab@php.net>         Fri, 29 Jun 2018 18:34:53 +0200
Parents:   bf5a802f5a87010cee94df1cda2918f3be8ae96e
Branches:  PHP-7.1 PHP-7.2 master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=cb97fd309790330bced04091fac46ea1466283c9


Log:
Fixed bug #76548 pg_fetch_result did not fetch the next row

Bugs:
https://bugs.php.net/76548

Changed paths:
  M  ext/pgsql/pgsql.c
  A  ext/pgsql/tests/bug76548.phpt


Diff:
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 904b9aa..6da01d4 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -2669,6 +2669,7 @@ PHP_FUNCTION(pg_fetch_result)
 		if (pgsql_row >= PQntuples(pgsql_result)) {
 			RETURN_FALSE;
 		}
+		pg_result->row++;
 	} else {
 		if (row < 0 || row >= PQntuples(pgsql_result)) {
 			php_error_docref(NULL, E_WARNING, "Unable to jump to row " ZEND_LONG_FMT " on \
                PostgreSQL result index " ZEND_LONG_FMT,
diff --git a/ext/pgsql/tests/bug76548.phpt b/ext/pgsql/tests/bug76548.phpt
new file mode 100644
index 0000000..3a0b892
--- /dev/null
+++ b/ext/pgsql/tests/bug76548.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #76548 pg_fetch_result did not fetch the next row
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+include('config.inc');
+
+$conn = pg_connect($conn_str);
+
+$result = pg_query($conn, 'SELECT v FROM (VALUES (1), (2), (3)) AS t(v)');
+
+while ($value = pg_fetch_result($result, 0)) {
+  var_dump($value); // should be 1, 2 then 3.
+}
+
+?>
+==DONE==
+--EXPECTF--
+string(1) "1"
+string(1) "2"
+string(1) "3"
+==DONE==


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic