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 240F052B94 for ; Thu, 21 Jul 2005 21:20:13 -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 37289-09 for ; Fri, 22 Jul 2005 00:20:10 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 0825752B91 for ; Thu, 21 Jul 2005 21:20:09 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DvlGr-00050K-5L; Fri, 22 Jul 2005 12:20:09 +1200 Message-ID: <42E03BB8.7090101@opencloud.com> Date: Fri, 22 Jul 2005 12:20:08 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Kris Jurka , Christian Cryder , pgsql-jdbc@postgresql.org Subject: Re: Timestamp Conversion Woes Redux 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> In-Reply-To: <26982.1121906793@sss.pgh.pa.us> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/229 X-Sequence-Number: 13377 Tom Lane wrote: > Oliver Jowett writes: > >>That's correct. A Timestamp is essentially a wrapper around >>milliseconds-since-epoch. > > > OK --- that is also our interpretation of TIMESTAMP WITH TIME ZONE > (at the moment anyway --- there's some agitation for putting an > explicit zone identifier in too, because it looks like the SQL spec > requires that). After some thought, an explicit zone identifier would solve the java-side problems if it also meant that the timestamptz to timestamp cast was done using that timezone. 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) This is not the most obvious result until you realize that timestamptz loses timezone info: template1=# select '2005-01-01 15:00:00 +1000'::timestamptz; timestamptz ------------------------ 2005-01-01 18:00:00+13 (1 row) I'd like to see the first case above produce 15:00:00, which seems doable if timestamptz is storing a timezone offset as well as a milliseconds-per-epoch. If we had that behaviour, then we just always pass down a timestamptz parameter with an appropriate timezone, and any implicit cast to timestamp "just works". This is similar in effect to using UNKNOWN in some ways since with UNKNOWN, if it really is a timestamp that is needed, the timestamp parser works on the input directly and throws away the timezone rather than doing the timezone juggling that timestamptz -> timestamp does: template1=# select '2005-01-01 15:00:00 +1000'::timestamp; timestamp --------------------- 2005-01-01 15:00:00 (1 row) -O