Re: [SQL] nulls and datetime

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gary MacMinn <G(dot)MacMinn(at)nca(dot)gov(dot)au>, pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] nulls and datetime
Date: 1999-11-15 15:29:43
Message-ID: 383026E7.11E9B7A1@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)alumni(dot)caltech(dot)edu
South Pasadena, California

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 1999-11-15 15:41:45 Re: [SQL] nulls and datetime
Previous Message Tom Lane 1999-11-15 15:24:16 Re: [SQL] how can tell if a column is a primary key?