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 D043452AD5 for ; Wed, 20 Jul 2005 21:46:57 -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 06913-06 for ; Thu, 21 Jul 2005 00:46:46 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 8BC8B52892 for ; Wed, 20 Jul 2005 21:46:44 -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 j6L0kXos026983; Wed, 20 Jul 2005 20:46:33 -0400 (EDT) To: Oliver Jowett Cc: Kris Jurka , Christian Cryder , pgsql-jdbc@postgresql.org Subject: Re: Timestamp Conversion Woes Redux In-reply-to: <42DEEA63.6090507@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> Comments: In-reply-to Oliver Jowett message dated "Thu, 21 Jul 2005 12:20:51 +1200" Date: Wed, 20 Jul 2005 20:46:33 -0400 Message-ID: <26982.1121906793@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/213 X-Sequence-Number: 13361 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). > Timestamps are then interpreted by feeding them through a Calendar for > locale- and timezone-specific formatting -- e.g. you can ask a Calendar > for the hour of a particular Timestamp, and it'll give you the > appropriate hour based on the timezone the Calendar is for. Right, this corresponds to the server's idea of rotating the timestamptz value to the client's TimeZone for display. > In other words, a timestamp-without-zone is just a > year-month-day-hour-minute-second tuple, which could correspond to many > instants in time depending on timezone and daylight savings changes? Exactly. This I believe is per SQL spec. > The thing is that there are two distinct variants of setTimestamp(): > (1) setTimestamp(index, timestamp) > (2) setTimestamp(index, timestamp, calendar) > (2) obviously maps to timestamp-with-zone. Hm, that's not obvious to me at all. If the timestamp is supposed to be unconditional absolute time, then the only sensible interpretation of (1) is that you're setting a timestamptz, and (2) would presumably produce a timestamp-without-tz value corresponding to the local time readout of the Calendar. > If we go with 1(a) then we have problems when casting to a > timestamp-without-zone value when the JVM and server timezones do not match. > If we go with 1(b) then we have problems when casting to a > timestamp-with-zone value when the JVM and server timezones do not > match, or when daylight savings means there are two possible instants in > a particular timezone identified by the timestamp-without-zone. No matter what we do, we will have issues if the user uses the wrong variant of setTimestamp for a particular parameter --- the server will add its own rotation by the TimeZone offset while converting timestamp to timestamptz or vice versa. You could possibly avoid that gotcha by setting the server's TimeZone to UTC, but I got the impression you wanted to avoid doing that. regards, tom lane