PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB » Bug #606

pgsql tableInfo has a bug that free's the result set

Details

Submitted2004-01-21 20:48 UTC
Fromtyardley at dmisi dot com
Assigneddanielc
StatusBogus
PackageDB
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2004-01-21 20:48 UTC] tyardley at dmisi dot com

Description:
------------
When a result set is used instead of a table name, the result set is
free'd even when it is not supposed to be. This problem seems to
only exist in the DB/pgsql.php code.

offending code:

// free the result only if we were called on a table
if (is_string($result) && is_resource($id)) {
@pg_freeresult($id);
}

should be changed to:
// free the result only if we were called on a table
if (is_string($result)) {
@pg_freeresult($id);
}

This goes back as far as I can remember.. and existed all the way
back to 1.2 I believe.

Tim Yardley

Reproduce code:
---------------
None needed. Just look at the source for the function.

if you must duplicate it do a query and then...
$result->tableInfo();
$result->free();

the free will fail.

Expected result:
----------------
the free should suceed and free the result (not having the function
do it itself).

Actual result:
--------------
the free obviously fails since tableInfo() free's it when it isn't
supposed to.