| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> |
| Cc: | Bernice Southey <bernice(dot)southey(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Second RewriteQuery complains about first RewriteQuery in edge case |
| Date: | 2025-11-27 16:55:21 |
| Message-ID: | 132240.1764262521@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> Yes, I think that would work, but I think a simpler solution would be
> to just have RewriteQuery() track which CTEs it had already rewritten,
> which can be done just by passing around a list of CTE names.
> Something like the attached.
Hmmm ... I don't love this particular implementation, because it
is doubling down on the already-undesirable assumption that the
rule CTEs have no name conflicts with the outer query's CTEs.
Still, unless somebody sets out to remove that restriction,
it won't matter. (It'd be a good idea for the comments here
to point that out though.)
I do think there's another way we could attack it. Similarly
to the way VALUES RTEs are either processed or skipped by
checking the rangetable length, we could pass down the length
of the outer query's cteList, and assume that the last N entries
in a product query's cteList have already been processed.
(Last N not first N because of the order in which the lists are
concatenated at line 596.) Maybe that's too fragile, but the
approach seems to have worked all right for VALUES.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Antonin Houska | 2025-11-27 16:56:25 | Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements |
| Previous Message | Peter Geoghegan | 2025-11-27 16:40:18 | Re: weird ON CONFLICT clauses |