1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 00:18:23 +02:00

PHP bug 67130: nextRowset should work with unfetched rows

This commit is contained in:
Peter LeBrun
2016-07-01 15:44:06 -04:00
committed by Adam Baratz
parent b29ad29b91
commit dfd6baee0c
2 changed files with 59 additions and 2 deletions
+23 -2
View File
@@ -119,7 +119,7 @@ static int pdo_dblib_stmt_dtor(pdo_stmt_t *stmt)
return 1;
}
static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt)
static int pdo_dblib_stmt_next_rowset_no_cancel(pdo_stmt_t *stmt)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;
@@ -142,6 +142,27 @@ static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt)
return 1;
}
static int pdo_dblib_stmt_next_rowset(pdo_stmt_t *stmt)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
pdo_dblib_db_handle *H = S->H;
RETCODE ret = SUCCESS;
/* Ideally use dbcanquery here, but there is a bug in FreeTDS's implementation of dbcanquery
* It has been resolved but is currently only available in nightly builds
*/
while (NO_MORE_ROWS != ret) {
ret = dbnextrow(H->link);
if (FAIL == ret) {
pdo_raise_impl_error(stmt->dbh, stmt, "HY000", "PDO_DBLIB: dbnextrow() returned FAIL");
return 0;
}
}
return pdo_dblib_stmt_next_rowset_no_cancel(stmt);
}
static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt)
{
pdo_dblib_stmt *S = (pdo_dblib_stmt*)stmt->driver_data;
@@ -160,7 +181,7 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt)
return 0;
}
ret = pdo_dblib_stmt_next_rowset(stmt);
ret = pdo_dblib_stmt_next_rowset_no_cancel(stmt);
stmt->row_count = DBCOUNT(H->link);
stmt->column_count = dbnumcols(H->link);
+36
View File
@@ -0,0 +1,36 @@
--TEST--
PDO_DBLIB: \PDOStatement::nextRowset() should succeed when all rows in current rowset haven't been fetched
--SKIPIF--
<?php
if (!extension_loaded('pdo_dblib')) die('skip not loaded');
require dirname(__FILE__) . '/config.inc';
?>
--FILE--
<?php
require dirname(__FILE__) . '/config.inc';
$stmt = $db->query('SELECT 1; SELECT 2; SELECT 3;');
var_dump($stmt->fetch());
var_dump($stmt->fetch());
var_dump($stmt->nextRowset());
var_dump($stmt->nextRowset());
var_dump($stmt->fetch());
var_dump($stmt->nextRowset());
?>
--EXPECT--
array(2) {
["computed"]=>
int(1)
[0]=>
int(1)
}
bool(false)
bool(true)
bool(true)
array(2) {
["computed"]=>
int(3)
[0]=>
int(3)
}
bool(false)