Re: [SQL] nulls and datetime - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] nulls and datetime
Date
Msg-id 18520.942680505@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] nulls and datetime  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
List pgsql-sql
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
> In previous versions, single-argument functions with NULL input were
> short-circuited in fmgr (??) and never actually were called.

As long as I've been paying attention (which is only since 6.4 or so),
execQual+fmgr will call the function regardless of the NULL status of
the inputs.  But the NULL flag for the output is taken to be the OR of
the input NULL flags --- so you can't return anything but NULL for a
NULL input, yet the function code is run anyway.

(Actually, a single-argument function is passed the isNull pointer as
an undocumented second argument, so it's possible for such a function
to clear isNull and thus return non-NULL for NULL input.  ISNULL and
ISNOTNULL work that way, but I haven't seen anything else that uses it.)

This is an incredibly ugly set of kluges, of course, and I'm hoping
to get it cleaned up for 7.0.  See my past memos to pg-hackers on fmgr
redesign.

> Seems to me that NULL in should produce NULL out, which was the old
> behavior. I'll add this to my ToDo, unless someone else has already
> picked it up.

If you don't fix it sooner, I will change it when I pass through that
code doing the fmgr interface changes...
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: [SQL] how can tell if a column is a primary key?
Next
From: Thomas Lockhart
Date:
Subject: Re: [SQL] nulls and datetime