Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D66859FBE9A for ; Tue, 19 Jun 2007 14:19:44 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 54725-02-2 for ; Tue, 19 Jun 2007 14:19:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 9AE049FBEB1 for ; Tue, 19 Jun 2007 14:19:40 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l5JHJY2t007657; Tue, 19 Jun 2007 13:19:34 -0400 (EDT) To: Kris Jurka cc: Christopher Hunt , pgsql-jdbc@postgresql.org Subject: Re: Literal vs parameterized 'timestamp with time zone' value In-reply-to: References: <094DD6D8-B500-479F-B730-0BFCC256A5DE@internode.on.net> Comments: In-reply-to Kris Jurka message dated "Tue, 19 Jun 2007 12:47:12 -0400" Date: Tue, 19 Jun 2007 13:19:34 -0400 Message-ID: <7656.1182273574@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/65 X-Sequence-Number: 17127 Kris Jurka 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