Re: [HACKERS] NULL as an argument in plpgsql functions

Поиск
Список
Период
Сортировка
От wieck@debis.com (Jan Wieck)
Тема Re: [HACKERS] NULL as an argument in plpgsql functions
Дата
Msg-id m11Y665-0003kLC@orion.SAPserv.Hamburg.dsh.de
обсуждение исходный текст
Ответ на Re: [HACKERS] NULL as an argument in plpgsql functions  ("D'Arcy" "J.M." Cain <darcy@druid.net>)
Список pgsql-hackers
D'Arcy J.M. Cain wrote:

> 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?

    It  wasn't  changed.  But  the  isNull bool pointer (in-/out-
    param) is only handed down as the second call argument  if  a
    function  is called via fmgr_c() and has exactly one argument
    as defined in pg_proc.

    Handling NULL on a per argument/return value base is  one  of
    the long standing TODO's.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #

В списке pgsql-hackers по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [HACKERS] RI status report #2
Следующее
От: Tom Lane
Дата:
Сообщение: Status of 'now' column defaults