Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ PHP NEWS
. Fixed a leak when a persistent connection failed a liveness check
with no other live PDO handle. (iliaal)

- PDO_PGSQL:
. Fixed PDO::CURSOR_SCROLL statements failing under lazy fetching
(PDO::ATTR_PREFETCH => 0). (KentarouTakeda)

- Readline:
. Fixed the interactive shell not waiting for the pager process to exit.
(Weilin Du)
Expand Down
4 changes: 4 additions & 0 deletions ext/pdo_pgsql/pgsql_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ static bool pgsql_handle_preparer(pdo_dbh_t *dbh, zend_string *sql, pdo_stmt_t *
: H->default_fetching_laziness
;

if (scrollable) {
S->is_unbuffered = false;
}

ret = pdo_parse_params(stmt, sql, &nsql);

if (ret == -1) {
Expand Down
33 changes: 33 additions & 0 deletions ext/pdo_pgsql/tests/cursor_scroll_lazy_fetch.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
PDO PgSQL a scrollable cursor is unaffected by lazy fetching
--EXTENSIONS--
pdo_pgsql
--SKIPIF--
<?php
require __DIR__ . '/config.inc';
require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
PDOTest::skip();
?>
--FILE--
<?php

require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc';
$pdo = PDOTest::test_factory(__DIR__ . '/common.phpt');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$sql = "SELECT * FROM generate_series(1, 3)";
$scrollable = [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL];

$stmt = $pdo->prepare($sql, $scrollable + [PDO::ATTR_PREFETCH => 0]);
$stmt->execute();
echo 'lazy on the statement: ', implode(',', $stmt->fetchAll(PDO::FETCH_COLUMN)), PHP_EOL;

$pdo->setAttribute(PDO::ATTR_PREFETCH, 0);
$stmt = $pdo->prepare($sql, $scrollable);
$stmt->execute();
echo 'lazy on the connection: ', implode(',', $stmt->fetchAll(PDO::FETCH_COLUMN)), PHP_EOL;

?>
--EXPECT--
lazy on the statement: 1,2,3
lazy on the connection: 1,2,3
Loading