I wrote: > Andrew Gierth <and...@tao11.riddles.org.uk> writes: >> So what I think we need to do here is to forbid inlining if (a) the >> refcount is greater than 1 and (b) the CTE in question contains, >> recursively anywhere inside its rtable or the rtables of any of its >> nested CTEs, a "self_reference" RTE.
> That's kind of "ugh" too: it sounds expensive, and doing it in a way > that doesn't produce false positives would be even more complicated. After further investigation, I concluded that that wasn't that awful, so done that way. I'm still not entirely convinced about the behavior for nested WITHs with different materialization specifications, but that seems like a separate topic. regards, tom lane