Re: [SQL] nulls and datetime

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: [SQL] nulls and datetime
Дата
Msg-id 383026E7.11E9B7A1@alumni.caltech.edu
обсуждение исходный текст
Ответ на Re: [SQL] nulls and datetime  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [SQL] nulls and datetime
Список 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 по дате отправления:

Предыдущее
От: "D'Arcy" "J.M." Cain
Дата:
Сообщение: Re: [SQL] how can tell if a column is a primary key?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] how can tell if a column is a primary key?