pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kris Jurka <books@ejurka.com>
Cc: Christopher Hunt <huntc@internode.on.net>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Literal vs parameterized 'timestamp with time zone' value
Date: Tue, 19 Jun 2007 13:19:34 -0400
Message-ID: <7656.1182273574@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSO.4.64.0706191240200.15310@leary.csoft.net>
References: <094DD6D8-B500-479F-B730-0BFCC256A5DE@internode.on.net>
	<Pine.BSO.4.64.0706191240200.15310@leary.csoft.net>

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



view thread (9+ messages)

Message-ID: <7656.1182273574@sss.pgh.pa.us>
Permalink:  ../7656.1182273574@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/7656.1182273574@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: tgl@sss.pgh.pa.us, books@ejurka.com, huntc@internode.on.net
  Subject: Re: Literal vs parameterized 'timestamp with time zone' value
  In-Reply-To: <7656.1182273574@sss.pgh.pa.us>
  References: <094DD6D8-B500-479F-B730-0BFCC256A5DE@internode.on.net> <Pine.BSO.4.64.0706191240200.15310@leary.csoft.net> <7656.1182273574@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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