From: Oliver Jowett <oliver@opencloud.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: tgl@sss.pgh.pa.us
Cc: emergency.shower@gmail.com
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Timestamp weirdness
Date: Tue, 26 Jul 2005 11:08:08 +1200
Message-ID: <42E570D8.3010901@opencloud.com> (raw)
In-Reply-To: <s2e4c364.081@gwmta.wicourts.gov>
References: <s2e4c364.081@gwmta.wicourts.gov>
Kevin Grittner wrote:
> If (hypothetically) timestampz is a protocol data element which does
> include time zone,
timestamptz is TIMESTAMP WITH TIME ZONE; it does include a timezone. The
server uses that timezone to determine the instant the timestamptz
represents when it parses the value.
> we might get to acceptable behavior if the JDBC
> driver always converted the timestamp representation to the time zone
> specified by the Calendar object and passed that time zone along.
This only works if the target type really is timestamptz.
If the target type is actually timestamp (TIMESTAMP WITHOUT TIME ZONE),
the server converts the instant identified by the timestamptz value
using the server's TimeZone setting to get a local date/time, and stores
that. This produces the wrong value if the timezone supplied by the
client isn't the same as the server TimeZone.
The JDBC driver doesn't know ahead of time whether the target type is
timestamp or timestamptz.
What I've suggested elsewhere is to invoke the server behaviour that
usually operates on untyped strings (by passing the "unknown" oid,
rather than either timestamp or timestamptz) when supplying type
information for parameters. The string -> timestamp conversion
*completely ignores* the supplied timezone, just using the specified
date/time directly, so we get the behaviour we want when the desired
type is really a timestamp. There are some disadvantages to this -- the
server doesn't necessarily always get it right, and it'd mask errors
such as using setTimestamp() on a text field -- but it seems the least
worst option.
-O
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: oliver@opencloud.com, Kevin.Grittner@wicourts.gov, tgl@sss.pgh.pa.us, emergency.shower@gmail.com
Subject: Re: Timestamp weirdness
In-Reply-To: <42E570D8.3010901@opencloud.com>
References: <s2e4c364.081@gwmta.wicourts.gov> <42E570D8.3010901@opencloud.com>
* 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