Re: [GENERAL] Needed function IF(expr, expr, expr)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [GENERAL] Needed function IF(expr, expr, expr)
Date: 2003-09-08 01:14:49
Message-ID: 18180.1062983689@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Greg Stark <gsstark(at)mit(dot)edu> writes:
> Hm. I wonder if there are cases of people using functions like this with
> user-defined volatile functions depending on the function's side effects
> happening the correct number of times. Or do volatile functions not get
> inlined like this?

SQL functions can't have side effects, at least not if they are simple
SELECTs, which is the only kind that gets inlined.

> To do it I think you would need a iseq() function that compared NULLs as being
> equal.

No, just

CASE WHEN (col = checkval) OR (col IS NULL AND checkval IS NULL)
...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rod Taylor 2003-09-08 01:29:01 Re: Needed function IF(expr, expr, expr)
Previous Message Ron Dyck 2003-09-08 01:10:53 How do I unsubscribe

Browse pgsql-hackers by date

  From Date Subject
Next Message Rod Taylor 2003-09-08 01:29:01 Re: Needed function IF(expr, expr, expr)
Previous Message Tom Lane 2003-09-08 00:57:04 Re: Unixware 713 probs