Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> writes:
> While investigating a CTE-related query, I've noticed that we don't
> really remove all unreachable CTEs.
We expend a grand total of three lines of code on making that happen.
I'm pretty much -1 on adding a great deal more code or complexity
to make it happen recursively; the case simply doesn't arise in
reasonably well written queries.
regards, tom lane