PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #4112

pgsql simpleQuery: FETCH queries should return DB_result

Details

Submitted2005-04-11 01:53 UTC
Frommogul-peardb at gelatinous dot com
Assigneddanielc
StatusClosed
PackageDB
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2005-04-11 01:53 UTC] mogul-peardb at gelatinous dot com

Description:
------------
Using DB 1.7.4.

Function simpleQuery() in the pgsql driver does a preg_match() against the query executed to determine if it's one that should return data. FETCH is not one of the query types that it recognizes as returning data, and it should be.

Reproduce code:
---------------
Code to reproduce:
$db->query('BEGIN');
$db->query('DECLARE cursor0 CURSOR FOR SELECT * FROM foo');
$result = $db->query('FETCH FORWARD 50 FROM cursor0');

The line as it stands in pgsql.php is:
} elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|SHOW)\s/si', $query)) {

It should be:
} elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|FETCH|SHOW)\s/si', $query)) {

Without this fix, any FETCH queries done against a cursor fail, and cursors are not usable through PEAR DB.

Expected result:
----------------
$result should be a DB_result

Actual result:
--------------
$result is DB_OK

[2005-06-03 07:56 UTC] smith at backendmedia dot com

Daniel, looks like this bug is a quick fix.

[2005-11-12 15:38 UTC] sibaz at sibaz dot com

This is still broken in 1.7.6
pgsql.php:344: } elseif (preg_match('/^\s*\(*\s*(SELECT|EXPLAIN|SHOW)\s/si', $query)) {
should be
} elseif (preg_match('/^\s*\(*\s*(SELECT|FETCH|EXPLAIN|SHOW)\s/si', $query)) {