Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4D06F6509DB for ; Fri, 11 Jul 2008 04:46:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 03024-01 for ; Fri, 11 Jul 2008 04:45:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from rs44.luxsci.com (rs44.luxsci.com [64.49.254.134]) by postgresql.org (Postfix) with ESMTP id 08B876507D4 for ; Fri, 11 Jul 2008 04:45:20 -0300 (ADT) Received: from rs48.luxsci.com (rs48.luxsci.com [65.61.166.92]) by rs44.luxsci.com (8.13.1/8.13.7) with ESMTP id m6B7jF9V006899 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 11 Jul 2008 02:45:15 -0500 Received: from rs48.luxsci.com (localhost [127.0.0.1]) by rs48.luxsci.com (8.13.1/8.13.7) with ESMTP id m6B7jCPn028910; Fri, 11 Jul 2008 02:45:13 -0500 Received: (from root@localhost) by rs48.luxsci.com (8.13.1/8.13.7/Submit) id m6B7j29N028652; Fri, 11 Jul 2008 07:45:02 GMT Received: (from pchaubey@vertex.co.in) by Lux Scientiae SMTP Processor; Fri, 11 Jul 2008 07:45:01 +0000 Received: from [192.168.3.6] (narad.vertex.co.in [203.124.128.106] (may be forged)) (user=pchaubey@vertex.co.in mech=PLAIN bits=2) by rs48.luxsci.com (8.13.1/8.13.7) with ESMTP id m6B7iuaN028390 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 11 Jul 2008 02:44:59 -0500 Message-ID: <48770F69.8020104@vertex.co.in> Date: Fri, 11 Jul 2008 13:14:41 +0530 From: Pushker Chaubey User-Agent: Thunderbird 1.5.0.14 (Windows/20071210) MIME-Version: 1.0 To: Ken Johanson CC: pgsql-jdbc@postgresql.org Subject: Re: Timestamp without Timezone and differing client / server tzs References: <4873154E.6020808@kensystem.com> <4873201F.1000700@opencloud.com> <487439D8.2050508@kensystem.com> <48743B53.4000002@opencloud.com> <48743F0C.6020504@kensystem.com> <4874419A.6030705@opencloud.com> <48744BE0.1010304@kensystem.com> <48746759.5080507@vertex.co.in> <4876E645.4080503@kensystem.com> In-Reply-To: <4876E645.4080503@kensystem.com> Content-Type: multipart/alternative; boundary="--__--PART--213053.282341055--__--" Content-Transfer-Encoding: binary X-Comment: Lux Scientiae SMTP Processor Message ID - 1215762302-3062006.60274938 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200807/32 X-Sequence-Number: 18817 ----__--PART--213053.282341055--__-- Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Ken Johanson wrote: > Pushker Chaubey wrote: >> >> Ken Johanson wrote: >>> The servers and their schema (use-of ts w/o tz are not under my=20 >>> control; adding with-timezone would likely break apps that transmit=20 >>> date values with offset already normalized). >> Just wondering, other apps using same database must also be facing=20 >> the same problem as you are if they operate across various timezones. >> Since all the applications are sharing the same timestamp(without TZ)=20 >> column they all should follow the same protocol to update and read=20 >> values for this shared timestamp(without TZ) column. >> >> We had a similar situation where the schema (having a timestamp=20 >> without timezone column ) was not under our control and we had=20 >> clients across various timezone who accessed the database. >> If one client with timezone TZ1 updated the value, the other client=20 >> with timezone TZ2 did not read the correct value. >> To get around that we agreed on a reference timezone (GMT) so that=20 >> stored timestamp value would be as per GMT timezone. > > I (and the other clients in their real timezones) are using a very=20 > similar config/protocol. The server is set to UTC and everyone agrees=20 > to convert the textual/iso8601 representation to it UTC value going=20 > out, and parse as UTC coming back. Just pass TZ to SimpleDateformat as=20 > one mean of accomplishing this. It's very easy conceptually. Well,=20 > only for query and their literal values constructed as in the=20 > StringBuffer way etc. > > The kicker happens when using PreparedStatements or an overlying API=20 > that relies on them. We have no control (as I understand so far) over=20 > how the PG driver does conversion. > > So I have to write a layer over some middleware that converts the=20 > values before passing down to PS (may not be possible though). The=20 > inelegant part is the server-specific config being stored not in the=20 > URL but elsewhere... I could get creative and piggyback my own param=20 > in the URL if I can access it. > > So much to ponder. For now there's the political-correctness joy (not)=20 > of having to inform customer that right now anyway, PG cant do what=20 > they're doing with database and driver X. > > Thanks for your thoughts Pushker, > > Ken > > > > Hi, Not sure but this may be of some help. Or you might have already tried=20 this....when you say "The server is set to UTC and everyone agrees to convert the=20 textual/iso8601 representation to it UTC value going out, and parse as=20 UTC coming back......." ||to_timestamp|(|text|, |text|) |||to_char|(|timestamp|, |text|) ||>> insert |||into T values( to_timestamp|(|'<>'|,=20 'format'||)) || >> select |||to_char|(|timestamp|, ||'format'||) |||from T |||client queries always deal in terms UTC datetime 'strings'. The=20 conversion between string to timestamp and vice-versa happens on the=20 server side independent of client's driver/ timezone. |And, these datetime strings can easily be generated and parsed back as=20 you mentioned (SimpleDateFormat) regards, Pushker Chaubey || =0D The information contained in this electronic message and any attachments to= this message are intended for the exclusive use of the addressee(s) and ma= y contain proprietary, confidential or privileged information. If you are n= ot the intended recipient, you should not disseminate, distribute or copy t= his e-mail. Please notify the sender immediately and destroy the original m= essage all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient shoul= d check this email and any attachments for the presence of viruses. The com= pany accepts no liability for any damage caused by any virus transmitted by= this email. Please do not print this email unless it is absolutely necessary.= ----__--PART--213053.282341055--__-- Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Ken Johanson wrote:
Pushker Chaubey wrote:

Ken Johanson wrote:
The servers and their schema (use-of ts w/o tz are not under my control; adding with-timezone would likely break apps that transmit date values with offset already normalized).
Just wondering, other apps using same database must also be facing the same problem as you are if they operate across various timezones.
Since all the applications are sharing the same timestamp(without TZ) column they all should follow the same protocol to update and read values for this shared timestamp(without TZ) column.

We had a similar situation where the schema (having a timestamp without timezone column ) was not under our control and we had clients across various timezone who accessed the database.
If one client with timezone TZ1 updated the value, the other client with timezone TZ2 did not read the correct value.
To get around that we agreed on a reference timezone (GMT) so that stored timestamp value would be as per GMT timezone.

I (and the other clients in their real timezones) are using a very similar config/protocol. The server is set to UTC and everyone agrees to convert the textual/iso8601 representation to it UTC value going out, and parse as UTC coming back. Just pass TZ to SimpleDateformat as one mean of accomplishing this. It's very easy conceptually. Well, only for query and their literal values constructed as in the StringBuffer way etc.

The kicker happens when using PreparedStatements or an overlying API that relies on them. We have no control (as I understand so far) over how the PG driver does conversion.

So I have to write a layer over some middleware that converts the values before passing down to PS (may not be possible though). The inelegant part is the server-specific config being stored not in the URL but elsewhere... I could get creative and piggyback my own param in the URL if I can access it.

So much to ponder. For now there's the political-correctness joy (not) of having to inform customer that right now anyway, PG cant do what they're doing with database and driver X.

Thanks for your thoughts Pushker,

Ken




Hi,

Not sure but this may be of some help. Or you might have already tried this....when you say
"The server is set to UTC and everyone agrees to convert the textual/iso8601 representation to it UTC value going out, and parse as UTC coming back......."

to_timestamp(text, text)
to_char(timestamp, text)

>> insert into T values( to_timestamp('<<UTC datetime string>>', 'format'))

>> select
to_= char(timestamp, 'format') from T

client queries always deal in terms UTC datetime 'strings'. The conversion between string to timestamp and vice-versa happens on the server side independent of client's driver/ timezone.

And, these datetime strings can easily be generated and parsed back as you mentioned (SimpleDateFormat)

regards,
Pushker Chaubey


=0D The information contained in this electronic message and any attachments to= this message are intended for the exclusive use of the addressee(s) and ma= y contain proprietary, confidential or privileged information. If you are n= ot the intended recipient, you should not disseminate, distribute or copy t= his e-mail. Please notify the sender immediately and destroy the original m= essage all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient shoul= d check this email and any attachments for the presence of viruses. The com= pany accepts no liability for any damage caused by any virus transmitted by= this email. Please do not print this email unless it is absolutely necessary.= ----__--PART--213053.282341055--__----