Re: Literal vs parameterized 'timestamp with time zone' value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Christopher Hunt <huntc(at)internode(dot)on(dot)net>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Literal vs parameterized 'timestamp with time zone' value
Date: 2007-06-19 17:19:34
Message-ID: 7656.1182273574@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Kris Jurka <books(at)ejurka(dot)com> writes:
> In the second example a string comparison is being done instead of a
> timestamp comparison. Consider this psql example:

> jurka=# select now() < 'a'::text;
> ?column?
> ----------
> t
> (1 row)

BTW, as of 8.3 this particular foot-gun will go away:

regression=# select now() < 'a'::text;
ERROR: operator does not exist: timestamp with time zone < text
LINE 1: select now() < 'a'::text;
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

You'll still be able to force a textual comparison if you really want
one:

regression=# select now()::text < 'a'::text;
?column?
----------
t
(1 row)

but it won't happen silently.

regards, tom lane

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Albe Laurenz 2007-06-20 12:01:11 Re: SSL support for javax.sql.DataSource
Previous Message Kris Jurka 2007-06-19 16:52:18 Re: SSL support for javax.sql.DataSource