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 6038652C34 for ; Mon, 1 Aug 2005 04:02:41 -0300 (ADT) 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 34473-08 for ; Mon, 1 Aug 2005 07:02:38 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 8046B52C1C for ; Mon, 1 Aug 2005 04:02:36 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1DzUJp-0004KJ-Ay for pgsql-jdbc@postgresql.org; Mon, 01 Aug 2005 19:02:37 +1200 Message-ID: <42EDC90C.4040506@opencloud.com> Date: Mon, 01 Aug 2005 19:02:36 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "pgsql-jdbc@postgresql.org" Subject: Timestamp changes committed to HEAD X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.243 tagged_above=0 required=5 tests=AWL, TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200508/1 X-Sequence-Number: 13570 I've committed my Timestamp/Date/Time changes to CVS HEAD; here's the commit message. With these changes {get,set}{Timestamp,Date,Time} should respect Calendars properly and not make any assumptions about server timezone vs. JVM timezone. Assuming this works as people expect (please test!), any thoughts on whether this is suitable to backport to 8.0? It *is* a big set of changes, but the stable driver is pretty broken in this area as it stands. -O Timestamp/Time/Date work per discussion on pgsql-jdbc. Rewrote quite a bit of TimestampUtils so that timezones are correctly handled both when parsing and when stringizing values. TimestampUtils is now an instance attached to the Connection so we can have different behaviour for 7.3 vs. 7.4 (7.3 does not allow timezone specifications in time literals). Added TimezoneTest to test all the various legal conversions when Calendars are involved. Server versions and what they support: 8.0: everything works 7.4: everything works 7.3: setTime()->timetz, setTimestamp()->time fail 7.2: setTime()->timetz, setTimestamp()->time, +1300 timezones fail The problem with setTime() on timetz is that we can't pass the timezone down in <=7.3 in case it's actually a time value that is expected, so the timetz will always end up with the server's TimeZone regardless of the Calendar passed. A similar problem affects setTimestamp() as it must pass a timezone down in case the expected type is timestamptz, which will fail if the expected type is actually time. We can't fix these cases by asking the server for the actual type expected, as that requires protocol v3 which 7.2/7.3 don't support. The +1300 timezone problem is a server bug in 7.2 (possibly fixed in later 7.2 releases, haven't checked); +1300 is a legal timezone but 7.2 doesn't accept it. Oid.UNKNOWN is now used for setTimestamp() and setDate(). It's unfortunately necessary for setDate() to handle setDate(i,date,calendar) when the underlying column is a timestamptz, for much the same reasons as the timestamp/timestamptz issue -- we need to avoid an unwanted rotation by the server's TimeZone setting. Cleaned up some of the tests in TimestampTest so they don't break when the JVM's timezone is different to the server's timezone. Still broken: CallableStatement.get{Date,Time,Timestamp} with Calendar. Fixing this will like require some rearrangement of when OUT parameters are turned into Objects.