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

Bug #2586 queries starting with multiple open parentheses are not supported
Submitted: 2004-10-22 12:31 UTC
From: quipo Assigned: danielc
Status: Closed Package: DB
PHP Version: 4.3.9 OS: irrelevant
Roadmaps: (Not assigned)    

 [2004-10-22 12:31 UTC] quipo
Description: ------------ a query like this one: ((SELECT * FROM table ...)) will fail because the regexp in simpleQuery() does not allow queries starting with multiple open parentheses. Reproduce code: --------------- I'm using the pgsql driver right now, but other drivers may be affected as well, I haven't checked. the fix is easy: /pear/DB/pgsql.php from CVS, LINE 197: } elseif (preg_match('/^\s*\(?\s*(SELECT(?!\s+INTO)|EXPLAIN|SHOW)\s/si', $query)) { replace with } elseif (preg_match('/^\s*\(*\s*(SELECT(?!\s+INTO)|EXPLAIN|SHOW)\s/si', $query)) { (notice the star instead of the question mark after the open parenthesis) Expected result: ---------------- DB_Result object Actual result: -------------- DB_OK is returned


 [2004-10-25 13:13 UTC] danielc
Putting entire queries in parentheses is strange and unnecessary. We won't support it.
 [2004-10-25 13:40 UTC] quipo
Sorry to insist, but those parentheses are absolutely necessary. I have to deal with multiple UNIONs and subqueries, so I don't think that having a query starting with two parentheses is all that strange. Of course the one-select example I gave is pointless, but I don't see any reason why PEAR::DB should limit the number of parentheses to one, when the dbms don't. I don't think this is a weird feature request, just a simple, plain bug in the regexp. The one-char fix I proposed does not have any side effect, AFAICS.
 [2004-10-25 14:16 UTC] danielc
Fine. I'll reopen the bug and deal with it later.
 [2004-12-10 06:27 UTC] danielc
Fixed in CVS.