Re: [HACKERS] NULL as an argument in plpgsql functions - Mailing list pgsql-hackers

From D'Arcy" "J.M." Cain
Subject Re: [HACKERS] NULL as an argument in plpgsql functions
Date
Msg-id m11XhPi-0000e5C@druid.net
Whole thread Raw
In response to Re: [HACKERS] NULL as an argument in plpgsql functions  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
Responses Re: [HACKERS] NULL as an argument in plpgsql functions  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: [HACKERS] NULL as an argument in plpgsql functions  (wieck@debis.com (Jan Wieck))
List pgsql-hackers
Thus spake Thomas Lockhart
> Another side issue; any function called with a null parameter will
> actually not get called at all! Postgres assumes that a function
> called with null must return null, so doesn't bother calling the
> routine...

Did this get changed recently?  AFAIK the routine gets called.  It's just
that the result is ignored and null is then returned.  This bit me in the
ass when I was working on the inet stuff.  If I didn't check for NULL and
return something my function would dump core but if I tried to deal with
the NULL and return something sensible, the function returned NULL anyway.

There was a discussion at the time about fixing this so that the function
never got called as investigation showed that there were existing ones
that would also crash if given null inputs.  Did this ever happen?

-- 
D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves
http://www.druid.net/darcy/                |  and a sheep voting on
+1 416 425 1212     (DoD#0082)    (eNTP)   |  what's for dinner.


pgsql-hackers by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: [HACKERS] NULL as an argument in plpgsql functions
Next
From: Peter Eisentraut
Date:
Subject: Re: [HACKERS] Tricky query, tricky response