Skip to content

Avoid database query in getColumnMeta for pdo_pgsql connector - #1534

Closed
jbylund wants to merge 6 commits into
php:masterfrom
jbylund:master
Closed

jbylund wants to merge 6 commits into
php:masterfrom
jbylund:master

Conversation

@jbylund

@jbylund jbylund commented Sep 22, 2015

Copy link
Copy Markdown
Contributor

I think there are a handful of bugs related to this issue. Essentially the current behavior is to run a query per column of the result set, even though we usually know the data type in most instances. This avoids the roundtrips for common types, but still does a roundtrip for user types.

Should close: https://bugs.php.net/bug.php?id=62498 (possibly related duplicates)

Comment thread ext/pdo_pgsql/pgsql_statement.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't PQclear go outside the if?

@weltling

weltling commented Dec 9, 2015

Copy link
Copy Markdown
Contributor

@jbylund thanks for the patch, especially with regard to bug #62498 the fix seems useful. Not a complete meta info cache solution, but simple and straight forward enough improvement. A test for this would make sense, could you please add one? Basically a test that could be run with and without your patch, to see it brings same results.

Thanks.

$select = $db->query('SELECT intcol, stringcol, boolcol, datecol FROM bugtest_62498');
$meta = [];
for ($i=0; $i < 4; $i++) {
$meta[] = $select->getColumnMeta(0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be getColumnMeta($i)?

@php-pulls

Copy link
Copy Markdown

Comment on behalf of ab at php.net:

Applied to 7.0 in e10257b, also i've fixed and extended the test in the follow up commit.

Thanks!

@php-pulls php-pulls closed this Apr 5, 2016
@outtersg

outtersg commented Oct 5, 2024

Copy link
Copy Markdown
Contributor

Funny that your test failing on my (admitedly bad) first implementation of #16249,
made me link another inefficiency in getColumnMeta() to yours, 8 years later
(in pdo_pgsql_translate_oid_to_table() use).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants