From: Tom Lane <tgl@sss.pgh.pa.us>
To: Oliver Jowett <oliver@opencloud.com>
Cc: Kris Jurka <books@ejurka.com>
Cc: Christian Cryder <c.s.cryder@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Timestamp Conversion Woes Redux
Date: Wed, 20 Jul 2005 20:46:33 -0400
Message-ID: <26982.1121906793@sss.pgh.pa.us> (raw)
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>
<C36F2D5F-093E-489C-8D6F-A67B746EA6C8@fastcrypt.com>
<42DCF0C9.4030501@opencloud.com>
<23396.1121781259@sss.pgh.pa.us>
<392278AB-987F-40CF-B59D-DDF53B9A4ACF@fastcrypt.com>
<Pine.BSO.4.56.0507191100110.68@leary.csoft.net>
<90876a9e050719093261c52c64@mail.gmail.com>
<Pine.BSO.4.56.0507200109220.31980@leary.csoft.net>
<42DDF238.8090601@opencloud.com>
<Pine.BSO.4.56.0507201125190.5339@leary.csoft.net>
<42DEDB5A.9000803@opencloud.com>
<26535.1121903232@sss.pgh.pa.us>
<42DEEA63.6090507@opencloud.com>
Oliver Jowett <oliver@opencloud.com> 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
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, oliver@opencloud.com, books@ejurka.com, c.s.cryder@gmail.com
Subject: Re: Timestamp Conversion Woes Redux
In-Reply-To: <26982.1121906793@sss.pgh.pa.us>
References: <90876a9e05071810503606d431@mail.gmail.com> <16335.1121714809@sss.pgh.pa.us> <10C90079-DD0A-43D7-9389-7486803F0AB1@fastcrypt.com> <42DC37AC.5030704@opencloud.com> <C36F2D5F-093E-489C-8D6F-A67B746EA6C8@fastcrypt.com> <42DCF0C9.4030501@opencloud.com> <23396.1121781259@sss.pgh.pa.us> <392278AB-987F-40CF-B59D-DDF53B9A4ACF@fastcrypt.com> <Pine.BSO.4.56.0507191100110.68@leary.csoft.net> <90876a9e050719093261c52c64@mail.gmail.com> <Pine.BSO.4.56.0507200109220.31980@leary.csoft.net> <42DDF238.8090601@opencloud.com> <Pine.BSO.4.56.0507201125190.5339@leary.csoft.net> <42DEDB5A.9000803@opencloud.com> <26535.1121903232@sss.pgh.pa.us> <42DEEA63.6090507@opencloud.com> <26982.1121906793@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