Andrei Lepikhov <a.lepik...@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