Re: Literal vs parameterized 'timestamp with time zone' value - Mailing list pgsql-jdbc

From Tom Lane
Subject Re: Literal vs parameterized 'timestamp with time zone' value
Date
Msg-id 7656.1182273574@sss.pgh.pa.us
Whole thread Raw
In response to Re: Literal vs parameterized 'timestamp with time zone' value  (Kris Jurka <books@ejurka.com>)
List pgsql-jdbc
Kris Jurka <books@ejurka.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

pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: SSL support for javax.sql.DataSource
Next
From: "Albe Laurenz"
Date:
Subject: Re: SSL support for javax.sql.DataSource