Re: The const expression evaluation routine should always return a copy

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: The const expression evaluation routine should always return a copy
Date: 2024-02-27 21:19:50
Message-ID: 2157387.1709068790@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru> writes:
> IMO, the routine eval_const_expressions_mutator contains some stale code:

I'd like to push back against the idea that eval_const_expressions
is expected to return a freshly-copied tree. Its API specification
contains no such claim. It's true that it appears to do that
everywhere but here, but I think that's an implementation detail
that callers had better not depend on. It's not hard to imagine
someone trying to improve its performance by avoiding unnecessary
copying.

Also, your proposed patch introduces a great deal of schizophrenia,
because SubPlan has substructure. What's the point of making a copy
of the SubPlan node itself, if the testexpr and args aren't copied?
But we shouldn't modify those, because as the comment states, it's
a bit late to be doing so.

I agree that the comment claiming we can't get here is outdated,
but I'm unexcited about changing the code's behavior.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2024-02-27 22:30:00 Re: Relation bulk write facility
Previous Message Daniel Gustafsson 2024-02-27 21:09:24 Re: Remove --with-CC autoconf option