X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 43AC95287F for ; Thu, 21 Jul 2005 21:54:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88824-05 for ; Fri, 22 Jul 2005 00:54:32 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 078E652803 for ; Thu, 21 Jul 2005 21:54:30 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j6M0sJ0E024344; Thu, 21 Jul 2005 20:54:19 -0400 (EDT) To: Oliver Jowett Cc: Kris Jurka , Christian Cryder , pgsql-jdbc@postgresql.org Subject: Re: Timestamp Conversion Woes Redux In-reply-to: <42E03BB8.7090101@opencloud.com> References: <90876a9e05071810503606d431@mail.gmail.com> <16335.1121714809@sss.pgh.pa.us> <10C90079-DD0A-43D7-9389-7486803F0AB1@fastcrypt.com> <42DC37AC.5030704@opencloud.com> <42DCF0C9.4030501@opencloud.com> <23396.1121781259@sss.pgh.pa.us> <392278AB-987F-40CF-B59D-DDF53B9A4ACF@fastcrypt.com> <90876a9e050719093261c52c64@mail.gmail.com> <42DDF238.8090601@opencloud.com> <42DEDB5A.9000803@opencloud.com> <26535.1121903232@sss.pgh.pa.us> <42DEEA63.6090507@opencloud.com> <26982.1121906793@sss.pgh.pa.us> <42E03BB8.7090101@opencloud.com> Comments: In-reply-to Oliver Jowett message dated "Fri, 22 Jul 2005 12:20:08 +1200" Date: Thu, 21 Jul 2005 20:54:19 -0400 Message-ID: <24343.1121993659@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/230 X-Sequence-Number: 13378 Oliver Jowett writes: > i.e. currently the core of the problem is this behaviour: > template1=# select '2005-01-01 15:00:00 +1000'::timestamptz::timestamp; > timestamp > --------------------- > 2005-01-01 18:00:00 > (1 row) Well, the current interpretation is that timestamptz -> timestamp produces a timestamp representing what the timestamptz equates to in your current TimeZone. I do not foresee changing that behavior when/if we add explicit TZ info to timestamptz --- it would break just about every existing app that uses this conversion. In any case, this wouldn't solve Christian's complaint, because the root of his problem is that the value ever goes through timestamptz at all. That is necessarily going to "munge" values that don't correspond to legal local times in whatever zone you are using. The more I think about this, the more I think that the correct solution must include having the driver set TimeZone = UTC (and complain if the app tries to change it). Then you can specify parameter types as either timestamp or timestamptz, it doesn't really matter, because conversions between them on the server side will be no-ops. When you convert a Java Timestamp to send to the server, you always convert it using a UTC Calendar object. I'm not sure if the setTimestamp variants with a Calendar are special in this regime; arguably you should ignore the supplied Calendar, on the principle that you know what the Timestamp is supposed to mean. regards, tom lane