Re: [GENERAL] Needed function IF(expr, expr, expr) - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [GENERAL] Needed function IF(expr, expr, expr)
Date
Msg-id 18180.1062983689@sss.pgh.pa.us
Whole thread Raw
In response to Re: [GENERAL] Needed function IF(expr, expr, expr)  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Greg Stark <gsstark@mit.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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] Needed function IF(expr, expr, expr)
Next
From: Rod Taylor
Date:
Subject: Re: [GENERAL] Needed function IF(expr, expr, expr)