Re: 7.2.1: coalesce double-calls function?

From: Kris Jurka <books(at)ejurka(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: SZŰCS Gábor <surrano(at)mailbox(dot)hu>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: 7.2.1: coalesce double-calls function?
Date: 2003-02-04 17:41:25
Message-ID: Pine.LNX.4.33.0302041219130.27245-100000@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 24 Jan 2003, Tom Lane wrote:

> "=?iso-8859-2?B?U1rbQ1MgR+Fib3I=?=" <surrano(at)mailbox(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Johnson, Shaunn 2003-02-04 18:02:59 looking for system tables via ODBC
Previous Message Tom Lane 2003-02-04 17:24:49 Re: Tuning Question sort_mem vs pgsql_tmp