pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
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: Fri, 22 Jul 2005 12:20:08 +1200
Message-ID: <42E03BB8.7090101@opencloud.com> (raw)
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>

Tom Lane wrote:
> 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).

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



view thread (92+ messages)  latest in thread

Message-ID: <42E03BB8.7090101@opencloud.com>
Permalink:  ../42E03BB8.7090101@opencloud.com/
Also on:    postgresql.org/message-id/42E03BB8.7090101@opencloud.com

 · 

reply

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, tgl@sss.pgh.pa.us, books@ejurka.com, c.s.cryder@gmail.com
  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> <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> <42E03BB8.7090101@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