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....