Skip Menu |

This queue is for tickets about the DBD-Pg CPAN distribution.

Report information
The Basics
Id: 92724
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: greg [...] turnstep.com
Requestors: justin [...] internetionals.nl
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 3.1.0



Subject: CTE support in 'is_dml'
Date: Tue, 04 Feb 2014 13:22:48 +0100
To: bug-DBD-Pg [...] rt.cpan.org
From: Justin Ossevoort <justin [...] internetionals.nl>
Hello, I was looking at the way prepared statements were being used in DBD::Pg. In the documentation it is mentioned that prepared statements are only used for queries beginning with one of: SELECT, INSERT, UPDATE or DELETE. This is matched (as documented) in the 'is_dml' function. Since Postgresql 8.1 there is also support for CTEs (http://www.postgresql.org/docs/8.4/static/queries-with.html). Initially only SELECT queries were supported, but since 9.1 there is also support for Data-Modifying Statements (http://www.postgresql.org/docs/9.1/static/queries-with.html#QUERIES-WITH-MODIFYING). But still constrained to DML statements. CTEs are commonly used to break up complex queries or the pre-calculate common values. Recursive CTEs are commonly used to perform complex queries that would otherwise be difficult using normal queries (like Tree and Graph logic). The 'WITH' keyword should probably be added to the 'is_dml' check so their (often complex plans) can be properly prepared (and cached). Regards, justin....
Thanks, I added WITH and VALUES, as of a1b4b2e39583482de23689c7a6411df483e06bfc