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

From Andrei Lepikhov
Subject Re: The const expression evaluation routine should always return a copy
Date
Msg-id 95d6a074-e985-49c3-9796-3f759081f8ca@postgrespro.ru
Whole thread Raw
In response to Re: The const expression evaluation routine should always return a copy  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 28/2/2024 04:19, Tom Lane wrote:
> 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.
Thanks for the explanation. I was just such a developer of extensions 
who had looked into the internals of the eval_const_expressions, found a 
call for a '_mutator' function, and made such a mistake :).
I agree that freeing the return node value doesn't provide a sensible 
benefit because the underlying bushy tree was copied during mutation. 
What's more, it makes even less sense with the selectivity context 
coming shortly (I hope).

-- 
regards,
Andrei Lepikhov
Postgres Professional




pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Synchronizing slots from primary to standby
Next
From: Dilip Kumar
Date:
Subject: Re: SLRU optimization - configurable buffer pool and partitioning the SLRU lock