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 659CD3CC3F4 for ; Sat, 18 Dec 2004 05:14:29 +0000 (GMT) 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 23397-01 for ; Sat, 18 Dec 2004 05:14:24 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 2EC583CC1E8 for ; Sat, 18 Dec 2004 05:14:18 +0000 (GMT) Received: (qmail 1317 invoked by uid 1112); 18 Dec 2004 05:15:54 -0000 Date: Sat, 18 Dec 2004 00:15:54 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Antje.Stejskal@ppi.de Cc: pgsql-jdbc@postgresql.org Subject: Re: Bug in JDBC-Driver? In-Reply-To: Message-ID: References: <6D48B8403D926449BDE8440EC7EEC46D021F2026@max.ppinet.de> MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-2116700532-1103346954=:15005" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.014 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200412/138 X-Sequence-Number: 11804 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. --0-2116700532-1103346954=:15005 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 30 Nov 2004, Kris Jurka wrote: > Yes, this looks like a driver bug, but I don't see an easy way to get > around it. The problem arises from the fact that you are using a > timestamp without time zone and the 8.0 driver using the V3 protocol types > all java.sql.Timestamp objects as timestamp with time zone. The solution to this requires that the data sent to the server is already in the server's timezone, so that when it converts to the server's timezone nothing happens. There are two ways to make this happen, for the driver to be aware of the server's timezone and modify the data to match before sending, or to force the server's timezone to be that of the client. The first approach is hard because it is difficult to ascertain the server's timezone (pre 8.0). In 7.4 SHOW timezone; usually gives "unknown". You could try doing things like SELECT now() - now() AT TIME ZONE 'UTC'; but that only gives you the offset on the current date, not an arbitrary date. The second approach forces the server timezone to be the JVM's via the pseudo sql/java: SET TIMEZONE = java.util.TimeZone.getDefault().getID(); This is a little more intrusive on the server side, but it should not be visible using standard JDBC calls for date and time information. The attached patch implements this and I plan to apply it unless someone has a better idea or a reason it won't work. Kris Jurka --0-2116700532-1103346954=:15005 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="zones.patch" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="zones.patch" SW5kZXg6IG9yZy9wb3N0Z3Jlc3FsL2NvcmUvdjMvQ29ubmVjdGlvbkZhY3Rv cnlJbXBsLmphdmENCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0NClJDUyBmaWxl OiAvdXNyL2xvY2FsL2N2c3Jvb3QvcGdqZGJjL3BnamRiYy9vcmcvcG9zdGdy ZXNxbC9jb3JlL3YzL0Nvbm5lY3Rpb25GYWN0b3J5SW1wbC5qYXZhLHYNCnJl dHJpZXZpbmcgcmV2aXNpb24gMS44DQpkaWZmIC1jIC1yMS44IENvbm5lY3Rp b25GYWN0b3J5SW1wbC5qYXZhDQoqKiogb3JnL3Bvc3RncmVzcWwvY29yZS92 My9Db25uZWN0aW9uRmFjdG9yeUltcGwuamF2YQkxMSBEZWMgMjAwNCAwMzoz MTo1MiAtMDAwMAkxLjgNCi0tLSBvcmcvcG9zdGdyZXNxbC9jb3JlL3YzL0Nv bm5lY3Rpb25GYWN0b3J5SW1wbC5qYXZhCTE4IERlYyAyMDA0IDA0OjQ3OjEx IC0wMDAwDQoqKioqKioqKioqKioqKioNCioqKiA4MCw5MSAqKioqDQogICAg ICAgICAgICAgIGlmICh0cnlTU0wpDQogICAgICAgICAgICAgICAgICBuZXdT dHJlYW0gPSBlbmFibGVTU0wobmV3U3RyZWFtLCByZXF1aXJlU1NMLCBpbmZv KTsNCiAgDQogICAgICAgICAgICAgIC8vIENvbnN0cnVjdCBhbmQgc2VuZCBh IHN0YXJ0dXAgcGFja2V0Lg0KICAgICAgICAgICAgICBTdHJpbmdbXVtdIHBh cmFtcyA9IHsNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgeyAidXNlciIsIHVzZXIgfSwNCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgeyAiZGF0YWJhc2UiLCBkYXRhYmFzZSB9LA0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB7ICJjbGllbnRf ZW5jb2RpbmciLCAiVU5JQ09ERSIgfSwNCiEgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgeyAiRGF0ZVN0eWxlIiwgIklTTyIgfQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07DQogIA0KICAgICAg ICAgICAgICBzZW5kU3RhcnR1cFBhY2tldChuZXdTdHJlYW0sIHBhcmFtcyk7 DQotLS0gODAsOTQgLS0tLQ0KICAgICAgICAgICAgICBpZiAodHJ5U1NMKQ0K ICAgICAgICAgICAgICAgICAgbmV3U3RyZWFtID0gZW5hYmxlU1NMKG5ld1N0 cmVhbSwgcmVxdWlyZVNTTCwgaW5mbyk7DQogIA0KKyAgICAgICAgICAgICBT dHJpbmcgem9uZSA9IGphdmEudXRpbC5UaW1lWm9uZS5nZXREZWZhdWx0KCku Z2V0SUQoKTsNCisgIA0KICAgICAgICAgICAgICAvLyBDb25zdHJ1Y3QgYW5k IHNlbmQgYSBzdGFydHVwIHBhY2tldC4NCiAgICAgICAgICAgICAgU3RyaW5n W11bXSBwYXJhbXMgPSB7DQogICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICAgIHsgInVzZXIiLCB1c2VyIH0sDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgIHsgImRhdGFiYXNlIiwgZGF0YWJhc2Ug fSwNCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgeyAi Y2xpZW50X2VuY29kaW5nIiwgIlVOSUNPREUiIH0sDQohICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICAgIHsgIkRhdGVTdHlsZSIsICJJU08i IH0sDQohICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHsg IlRpbWVab25lIiwgem9uZX0NCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgICB9Ow0KICANCiAgICAgICAgICAgICAgc2VuZFN0YXJ0dXBQYWNr ZXQobmV3U3RyZWFtLCBwYXJhbXMpOw0K --0-2116700532-1103346954=:15005--