Re: The const expression evaluation routine should always return a copy - Mailing list pgsql-hackers

From Tom Lane
Subject Re: The const expression evaluation routine should always return a copy
Date
Msg-id 2157387.1709068790@sss.pgh.pa.us
Whole thread Raw
In response to The const expression evaluation routine should always return a copy  (Andrei Lepikhov <a.lepikhov@postgrespro.ru>)
Responses Re: The const expression evaluation routine should always return a copy
List pgsql-hackers
Andrei Lepikhov <a.lepikhov@postgrespro.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



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Remove --with-CC autoconf option
Next
From: Thomas Munro
Date:
Subject: Re: Relation bulk write facility