Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #17136 PostgreSQL Recursive SQL (or simply WITH Query) doesn't work properly
Submitted: 2010-02-19 11:56 UTC
From: sakai Assigned: aharvey
Status: Closed Package: DB (version 1.7.13)
PHP Version: 5.1.6 OS: CentOS release 5.4
Roadmaps: 1.7.14RC2    
Subscription  


 [2010-02-19 11:56 UTC] sakai (Kiyoshi Ssakai)
Description: ------------ Simply, DB/pgsql.php is not expecting WITH queries. I suppose it's on Line 356 of DB/pgsql.php. Test script: --------------- //postgres=> SELECT * FROM tree ; // id | parent //----+-------- // 1 | // 2 | 1 // 3 | 1 // 4 | 2 //(4 rows) $ret = $db->getAll( 'WITH RECURSIVE r AS (SELECT * FROM tree WHERE id = 1 UNION ALL SELECT tree.* FROM tree, r WHERE tree.parent = r.id)' . ' SELECT * FROM r ORDER BY id' ); var_dump($ret); Expected result: ---------------- array(4) { [0]=> array(2) { ["id"]=> string(1) "1" ["parent"]=> NULL } [1]=> array(2) { ["id"]=> string(1) "2" ["parent"]=> string(1) "1" } [2]=> array(2) { ["id"]=> string(1) "3" ["parent"]=> string(1) "1" } [3]=> array(2) { ["id"]=> string(1) "4" ["parent"]=> string(1) "2" } } Actual result: -------------- int(1)

Comments

 [2010-02-19 14:40 UTC] sakai (Kiyoshi Sakai)
Actually, I do NOT know if WITH sub-queries can be followed by main queries other than SELECTs... If UPDATE or things like that can be the main query, Fixing this problem might not be simple as adding 'WITH' to Line 356 of DB/pgsql.php. Thanks anyway for handling this.
 [2010-12-24 12:11 UTC] aharvey (Adam Harvey)
-Status: Open +Status: Closed -Assigned To: +Assigned To: aharvey -Roadmap Versions: +Roadmap Versions: 1.7.14RC2
This bug has been fixed in SVN. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.