Re: Second RewriteQuery complains about first RewriteQuery in edge case
Dean Rasheed <dean.a.rasheed@gmail.com>
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bernice Southey <bernice.southey@gmail.com>,
Kirill Reshke <reshkekirill@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-29T12:42:56Z
Lists: pgsql-hackers
On Thu, 27 Nov 2025 at 21:40, Tom Lane <tgl@sss.pgh.pa.us> wrote: > > Yeah, this looks pretty good. Two nitpicky suggestions: > > * Perhaps using foreach_current_index() would be better than > adding the separate loop variable "i" in RewriteQuery. Ah, good point. I'd forgotten about that macro. > * I think it would be wise to add a comment about this in > rewriteRuleAction too, perhaps along the lines of > > - /* OK, it's safe to combine the CTE lists */ > + /* > + * OK, it's safe to combine the CTE lists. Beware that RewriteQuery > + * knows we concatenate the lists in this order. > + */ > sub_action->cteList = list_concat(sub_action->cteList, > copyObject(parsetree->cteList)); Agreed. Done that way. Thanks for reviewing. Regards, Dean