On 13 May 2017 at 08:39, Bruce Momjian <bruce@momjian.us> wrote:
> To summarize, it seems we have two options if we want to add fence
> control to CTEs:
>
> 1. add INLINE to disable the CTE fence
> 2. add MATERIALIZE to enable the CTE fence
I think #1 is out of the question.
What would we do in cases like:
WITH INLINE cte AS (SELECT random() a)
SELECT * FROM cte UNION SELECT * FROM cte;
I assume we won't want to inline when the CTE query contains a
volatile function, and we certainly won't in cases like:
WITH INLINE cte AS (DELETE FROM a RETURNING *)
INSERT INTO b SELECT * from cte WHERE cte.value > 5;
We'd be certain to receive complaints from disgruntled users about
"Why is this not inlined when I specified INLINE?"
#2 does not suffer from that.
-- David Rowley http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training & Services