-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix getColumnMeta() for GH-15287 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0) #16249
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
base: master
Are you sure you want to change the base?
Conversation
d0f9bb4
to
0d3829e
Compare
I noticed this week-end that pgsql_driver.c too was full of PQexec (for internal needs). So 44afde3 exposes … But then I noticed some patterns that could be factorized in |
Sure, you can always explore in your own fork for a while and see how it goes. 8.5 release is in 1 year + :) |
44afde3
to
a10ef19
Compare
@devnexen wrote:
That's a good point! Now as I both rebased and amended, the changes are not that clear in the last diff :-\ |
fce61c9
to
be8ac25
Compare
…lumnMeta() - each call queried the DB to know the name associated with the table's OID: cache the result between two calls - make pdo_pgsql_translate_oid_to_table higher-level, with the last parameter being the handle instead of the raw connection; thus the statement is cleaner, letting the handle do all memory handling on the table oid-to-name translation cache (which by the way is a driver feature more than a statement 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
we unconditionally set it, but conditionally unset it, letting a dangling pointer that was tentatively freed a second time
be8ac25
to
75fd500
Compare
Now that 8.4 is out, it's time to think of 8.5. Although the nature of the PR (fixing an incompatibility between prefetch mode and metadata reading) could have made it a candidate for a 8.4.x, This is a first, working pass on the subject, while I found time to code it: it is a technically self-sustainable fix, although we could go further in what
But as I am not sure of the time I could devote to this ideal solution, |
As stated in the UPGRADING, using the passthrough ("single-row") mode of libpq forbids passing a new query while the current one's results have not been entirely consumed.
… But I didn't notice that ext/pdo_pgsql internally used new queries to fetch metadata.
This PR makes those internal calls return NULL for non-essential metadata, instead of letting libpq abort the user-called query.
It moreover includes a small tweak to table oid-to-name translation, with a 1-slot cache.
This may by chance allow the internal call to return something instead of NULL,
but it will nonetheless avoid 30 server calls to get the table name of 30 columns of the same table.