postgresql/src/backend/rewrite
Tom Lane fc1286d3cb Fix rewriter to cope (more or less) with CTEs in the query being rewritten.
Since the original implementation of CTEs only allowed them in SELECT
queries, the rule rewriter did not expect to find any CTEs in statements
being rewritten by ON INSERT/UPDATE/DELETE rules.  We had dealt with this
to some extent but the code was still several bricks shy of a load, as
illustrated in bug #6051 from Jehan-Guillaume de Rorthais.

In particular, we have to be able to copy CTEs from the original query's
cteList into that of a rule action, in case the rule action references the
CTE (which it pretty much always will).  This also implies we were doing
things in the wrong order in RewriteQuery: we have to recursively rewrite
the CTE queries before expanding the main query, so that we have the
rewritten queries available to copy.

There are unpleasant limitations yet to resolve here, but at least we now
throw understandable FEATURE_NOT_SUPPORTED errors for them instead of just
failing with bizarre implementation-dependent errors.  In particular, we
can't handle propagating the same CTE into multiple post-rewrite queries
(because then the CTE would be evaluated multiple times), and we can't cope
with conflicts between CTE names in the original query and in the rule
actions.
2011-06-07 00:08:31 -04:00
..
Makefile
rewriteDefine.c Clean up most -Wunused-but-set-variable warnings from gcc 4.6 2011-04-11 22:28:45 +03:00
rewriteHandler.c Fix rewriter to cope (more or less) with CTEs in the query being rewritten. 2011-06-07 00:08:31 -04:00
rewriteManip.c Pass collation to makeConst() instead of looking it up internally. 2011-03-25 20:10:42 -04:00
rewriteRemove.c
rewriteSupport.c pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00