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

From: wieck(at)debis(dot)com (Jan Wieck)
To: pgsql-hackers(at)postgreSQL(dot)org
Cc: lockhart(at)alumni(dot)caltech(dot)edu
Subject: Re: [HACKERS] NULL as an argument in plpgsql functions
Date: 1999-10-04 11:16:01
Message-ID: m11Y665-0003kLC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 1999-10-04 14:03:34 Database names with spaces
Previous Message The Hermit Hacker 1999-10-03 19:57:30 Re: [HACKERS] RI status report #2