-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Avoid database query in getColumnMeta for pdo_pgsql connector #1534
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
status = PQresultStatus(res); | ||
if (status == PGRES_TUPLES_OK && 1 == PQntuples(res)) { | ||
add_assoc_string(return_value, "native_type", PQgetvalue(res, 0, 0)); | ||
PQclear(res); |
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.
Shouldn't PQclear go outside the if?
…y leak inside the if
@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); |
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.
Shouldn't it be getColumnMeta($i)?
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! |
Funny that your test failing on my (admitedly bad) first implementation of #16249, |
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)