-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix / implement GH-15287: add a lazy fetch to Pdo\PgSql #15750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This branch is currently uncomplete as I am struggling to make it work on $stmt = $pdo->query(…); as opposed to $stmt = $pdo->prepare(…);
$stmt->execute(); which works. This seems to be related by the fact that This is understandable in the traditional fetch mode (a prepared statement might be reused later, while a singly-executed one is of no interest anymore once the result has been received), Anyone pointing me to the (maybe obvious :-\) difference between execute (in pdo_stmt.c) and query (in pdo_dbh.c), or anywhere else in PDO, would be of a great and appreciated help. |
Nice attempt ! I had a quick glance, I ll have a better look in few days. Fetch with query not working indeed but also I get a crash because of an empty error message. |
a994067
to
6f270c4
Compare
@devnexen wrote:
But I don't reproduce it here: did you get it with the provided |
It is definitively just the symptom.
Your new test but I build with asan. |
Multiple reasons required a reorganize of the process, as diagnosed thanks to the failing test's code structure: $stmt = $pdo->query(…); $stmt->fetchAll();
$stmt = $pdo->query(…); $stmt->fetchAll(); Internally, after having called the second But:
|
Looking good overall, I ve tested your branch for a while. That will be for after 8.4 tough. few nitpicks so far. |
@devnexen wrote:
That's fine. In fact somewhere on StackOverflow I already wrote that "hopefully on PHP 8.5 this will be possible". |
b011c0e
to
d8a6cd4
Compare
Looking nice ! I ll give another round of tests in few days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good implementation-wise.
set S->result to NULL after having freed it (not crucial now, as it is immediately recycled)
fetch part of the lazy fetch mode for Pdo\Pgsql Starts fixing php#15287
use Pdo::setAttribute(PDO::ATTR_PREFETCH, 0)
memory & non-regression test mention in the NEWS file
reindent (the previous commits tried to get the minimal diff by _not_ reindenting preserved code that got if(){}'ed)
Thanks ! |
Make Pdo\PgSql accept Pdo::setAttribute(PDO::ATTR_PREFETCH, 0) to enter libpq's single row mode. This avoids storing the whole result set in memory before being able to call the first fetch(). close phpGH-15750
Make Pdo\PgSql accept Pdo::setAttribute(PDO::ATTR_PREFETCH, 0) to enter libpq's single row mode. This avoids storing the whole result set in memory before being able to call the first fetch(). close phpGH-15750
doing an (internal) query to fetch metadata from the server broke the currently-running query
doing an (internal) query to fetch metadata from the server broke the currently-running query; additionnally, fix the condition to interrupt the previous request (we shall test if *it* was lazy, not if the *new* one will)
…l queries not only the statements, but the driver, love to make internal queries. We make sure no unfinished query still runs when having to pass an internal one.
doing an (internal) query to fetch metadata from the server broke the currently-running query; additionnally, fix the condition to interrupt the previous request (we shall test if *it* was lazy, not if the *new* one will)
…l queries not only the statements, but the driver, love to make internal queries. We make sure no unfinished query still runs when having to pass an internal one. by the way factorize the loops that consumed the preceding query's results
doing an (internal) query to fetch metadata from the server broke the currently-running query; additionnally, fix the condition to interrupt the previous request (we shall test if *it* was lazy, not if the *new* one will)
…l queries not only the statements, but the driver, love to make internal queries. We make sure no unfinished query still runs when having to pass an internal one. by the way factorize the loops that consumed the preceding query's results
doing an (internal) query to fetch metadata from the server broke the currently-running query; additionnally, fix the condition to interrupt the previous request (we shall test if *it* was lazy, not if the *new* one will)
…l queries not only the statements, but the driver, love to make internal queries. We make sure no unfinished query still runs when having to pass an internal one. by the way factorize the loops that consumed the preceding query's results
doing an (internal) query to fetch metadata from the server broke the currently-running query; additionnally, fix the condition to interrupt the previous request (we shall test if *it* was lazy, not if the *new* one will)
…l queries not only the statements, but the driver, love to make internal queries. We make sure no unfinished query still runs when having to pass an internal one. by the way factorize the loops that consumed the preceding query's results
doing an (internal) query to fetch metadata from the server broke the currently-running query; additionnally, fix the condition to interrupt the previous request (we shall test if *it* was lazy, not if the *new* one will)
…l queries not only the statements, but the driver, love to make internal queries. We make sure no unfinished query still runs when having to pass an internal one. by the way factorize the loops that consumed the preceding query's results
Make
Pdo\PgSql
acceptPdo::setAttribute(PDO::ATTR_PREFETCH, 0)
to enter libpq's single row mode.This avoids storing the whole result set in memory before being able to call the first
fetch()
.