Received: from localhost (IDENT:root@hectic-2.jpl.nasa.gov [128.149.68.204]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA13138 for ; Mon, 15 Nov 1999 10:22:46 -0500 (EST) (envelope-from lockhart@alumni.caltech.edu) Received: from alumni.caltech.edu (lockhart@localhost [127.0.0.1]) by localhost (8.8.7/8.8.7) with ESMTP id PAA14321; Mon, 15 Nov 1999 15:29:43 GMT Sender: lockhart@hub.org Message-ID: <383026E7.11E9B7A1@alumni.caltech.edu> Date: Mon, 15 Nov 1999 15:29:43 +0000 From: Thomas Lockhart X-Mailer: Mozilla 4.6 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane CC: Gary MacMinn , pgsql-sql@postgreSQL.org Subject: Re: [SQL] nulls and datetime References: <15251.942646251@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > > 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