On Sat, Oct 12, 2024 at 4:59 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> This means that it will work so long as all of the Vars needed by the
> EC member expression are available from the plan node's input, which
> they surely are if they are referenced in the existing tlist. That
> is, even if we wanted to compute "t2.i + 2" it'd be fine.
>
> (This would fall down perhaps if there are volatile functions in
> the sort expression, but I believe we already reject using volatile
> expressions for merge append, so it's not a problem.)
>
> So I conclude that Andrei's patch will fix it, although I don't like
> the way that that requires (potentially) multiple re-executions of
> pull_var_clause. I think we should refactor the code to avoid that,
> which actually ends up being less code, as in the attached draft.
+1. I think it's conceptually correct that if 'Var_A + 2' is
computable in a plan node's targetlist, then 'Var_A + 1' must be also
computable in the same targetlist.
Thanks
Richard