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

From Thomas Lockhart
Subject Re: [SQL] nulls and datetime
Date
Msg-id 383026E7.11E9B7A1@alumni.caltech.edu
Whole thread Raw
In response to Re: [SQL] nulls and datetime  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [SQL] nulls and datetime
List pgsql-sql
> > I have a table with datetime fields, some of which are null. I'm
> > trying to extract the date and time components with the date() and
> > time() functions but the null values break these functions.
> regression=>  SELECT t1, date(d1) from test1;
> ERROR:  Unable to convert null datetime to date
> This is undesirable, I agree.  It seems to me that those routines should
> just return NULL given NULL input, rather than going out of their way to
> break applications.  Thomas, can you defend this behavior?

No, other than this is the first time I've ever seen that code execute
;)

In previous versions, single-argument functions with NULL input were
short-circuited in fmgr (??) and never actually were called. I put in
this code just as a guard.

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.
                     - Thomas

-- 
Thomas Lockhart                lockhart@alumni.caltech.edu
South Pasadena, California


pgsql-sql by date:

Previous
From: "D'Arcy" "J.M." Cain
Date:
Subject: Re: [SQL] how can tell if a column is a primary key?
Next
From: Tom Lane
Date:
Subject: Re: [SQL] how can tell if a column is a primary key?