pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Unable to convert null timestamp to date. Bug?
2+ messages / 2 participants
[nested] [flat]

* Unable to convert null timestamp to date. Bug?
@ 2000-12-07 23:08  Edmar Wiggers <edmar@brasmap.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Edmar Wiggers @ 2000-12-07 23:08 UTC (permalink / raw)
  To: pgsql-sql; pgsql-bugs@postgresql.org


Strange, this works:
  select * from users where last_visit > now() + 7; 
  -- last_visit is nullable, of type timestamp

But this doesn't
  select * from users where last_visit + 7 > now();
  ERROR:  Unable to convert null timestamp to date
  -- yes, there are users where last_visit IS NULL

BTW, this works too:
  select null+1; -- obviously returns NULL

System is FreeBSD 4.1, PgSQL 7.0.2

Anyone got a clue?

Yours sincerely,

Edmar Wiggers
BRASMAP Information Systems
+55 48 9960 2752



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: [SQL] Unable to convert null timestamp to date. Bug?
@ 2000-12-08 01:01  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Edmar Wiggers <edmar@brasmap.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2000-12-08 01:01 UTC (permalink / raw)
  To: Edmar Wiggers <edmar@brasmap.com>; +Cc: pgsql-sql; pgsql-bugs@postgresql.org

"Edmar Wiggers" <edmar@brasmap.com> writes:
>   select * from users where last_visit + 7 > now();
>   ERROR:  Unable to convert null timestamp to date

Yeah, someone who hadn't quite grokked the concept of NULL seems to have
written a lot of the date.c code :-(.

This is fixed for 7.1.  If it's really bothering you in 7.0.*, see
src/backend/utils/adt/date.c, and change code like

    if (!PointerIsValid(timestamp))
        elog(ERROR, "Unable to convert null timestamp to date");

to

    if (!PointerIsValid(timestamp))
	return NULL;

in several places.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2000-12-08 01:01 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-12-07 23:08 Unable to convert null timestamp to date. Bug? Edmar Wiggers <edmar@brasmap.com>
2000-12-08 01:01 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox