[php-src] PR #23892: Fix getColumnMeta() for GH-15287 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0)
| From: | outtersg | Date: | Thu, 24 Sep 2026 17:04:45 +0000 |
| Subject: | [php-src] PR #23892: Fix getColumnMeta() for GH-15287 Pdo\Pgsql::setAttribute(PDO::ATTR_PREFETCH, 0) | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38785@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23892
Author: outtersg
As stated in the UPGRADING, using the passthrough ("single-row") mode of libpq (introduced
in https://github.com/php/php-src/issues/15287)
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
(example use case: a call to getColumnMeta() while fetch()ing row by row will interleave the
getColumnMeta()-triggered internal query to the database, with the results fetching for the
user-called query).
This PR:
* **prevents
getColumnMeta() from interfering with an unbuffered user query**\
by returning an empty value for every metadata that would emit an internal query, thus breaking
libpq inner workings
* caches the table name so that **30 calls to getColumnMeta() won't call the
database 30 times**
This is a second take to #16249; compared to it:
* **+** The [UAF](https://github.com/php/php-src/pull/16249#discussion_r4095582864) is fixed
* **+** The [egg-and-chicken
problem](https://github.com/php/php-src/pull/16249#issuecomment-3349120535) at shutdown time may
hopefully be fixed\
thanks to a rebasing on the latest master which includes fixes from #23065 (and maybe #17567 too?)
* **-** I'm giving up on generalizing the PR to every internal query, focusing on
getColumnMeta() only:\
This can be done on a call-by-call basis, as did in fact @KentarouTakeda for COPY in
the aforementioned PR
Of course I'd feel more comfortable if there was a way to run the full CI chain _before_
merging: any hint from GH rgulars?