Re: Second RewriteQuery complains about first RewriteQuery in edge case

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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-29 12:42:56
Message-ID: CAEZATCWfNB6PjQgm_1U-PymE8FAZvSKbC2LntHa3YbYohMtffg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, 27 Nov 2025 at 21:40, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2025-11-29 12:45:20 Re: Second RewriteQuery complains about first RewriteQuery in edge case
Previous Message Jim Jones 2025-11-29 12:38:32 Re: [PoC] XMLCast (SQL/XML X025)