On Fri, 24 Jan 2003, Tom Lane wrote:
> "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" <surrano@mailbox.hu> writes:
> > CONCLUSION: I think both the optimizer, both the side effects would be
> > happier if all of COALESCE's expressions were only calculated once.
>
> Yup, and NULLIF too. Want to submit a patch? Look for CaseExpr in the
> sources, copy/paste/modify.
>
I have been looking at this and the NULLIF case seems complicatd.
Essentially for NULLIF(left,right) I want to ExecEvalExpr(left,...)
and construct a Const node with the result. Then makeSimpleA_Expr for
const left = right. Evaluate that and if not true return the already
evaluated left side otherwise NULL.
This seems to merge all phases from parse to execution into the execution
phase. How can I evaluate an expression and then construct a new
expression with that result in a clean manner?
Kris Jurka