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 34D33529A7 for ; Wed, 20 Jul 2005 08:58:09 -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 53626-03 for ; Wed, 20 Jul 2005 11:58:00 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id A8E815286A for ; Wed, 20 Jul 2005 08:57:58 -0300 (ADT) Received: (qmail 24755 invoked from network); 20 Jul 2005 11:58:02 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 20 Jul 2005 11:58:02 -0000 In-Reply-To: <6E6559F0-401F-47E8-A756-245C5B0813A7@fastcrypt.com> References: <90876a9e05071810503606d431@mail.gmail.com> <16335.1121714809@sss.pgh.pa.us> <10C90079-DD0A-43D7-9389-7486803F0AB1@fastcrypt.com> <42DC37AC.5030704@opencloud.com> <42DCF0C9.4030501@opencloud.com> <23396.1121781259@sss.pgh.pa.us> <392278AB-987F-40CF-B59D-DDF53B9A4ACF@fastcrypt.com> <90876a9e050719093261c52c64@mail.gmail.com> <42DDABAE.7050009@opencloud.com> <15EA293E-6D5D-4FD2-B498-6546113822C1@fastcrypt.com> <42DDB0B0.1020006@opencloud.com> <468CE7D4-3BFC-48D8-BC94-3AA73950EBED@fastcrypt.com> <42DDBE3B.5040801@opencloud.com> <6E6559F0-401F-47E8-A756-245C5B0813A7@fastcrypt.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Oliver Jowett , Christian Cryder Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Timestamp Conversion Woes Redux Date: Wed, 20 Jul 2005 07:58:00 -0400 To: List X-Mailer: Apple Mail (2.733) 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: 200507/169 X-Sequence-Number: 13317 Thinking some more.... It would appear that the setTimestamp is intended to do one or the other, but not both. either you have timezone information or you don't. I think this effectively revokes your license to interpret the spec as you suggested below. Further the JDBCCTS doesn't take have any facility for both scenarios, you can choose the timestamp type that you want it to pass with (assuming you have a choice). Dave On 20-Jul-05, at 5:55 AM, Dave Cramer wrote: > > On 19-Jul-05, at 11:00 PM, Oliver Jowett wrote: > > >> Dave Cramer wrote: >> >> >> >>> Well, we're in a vague area of the spec here. There are two >>> TIMESTAMP >>> types defined by the sql spec, >>> >>> >> >> right. >> >> >> >>> and only one setTimestamp. >>> >>> >> >> The SQL spec doesn't define setTimestamp at all. The JDBC spec >> defines >> *two* setTimestamp methods. >> > This was implied... > >> >> >> >>> There is no indication by the spec >>> that this behaviour is the "right" behaviour. >>> >>> >> >> The javadoc for the with-Calendar variant is quite clear: >> >> >> >>>> Sets the designated parameter to the given java.sql.Timestamp >>>> value, >>>> using the given Calendar object. The driver uses the Calendar >>>> object to >>>> construct an SQL TIMESTAMP value, which the driver then sends to >>>> the >>>> database. With a Calendar object, the driver can calculate the >>>> timestamp >>>> taking into account a custom timezone. If no Calendar object is >>>> specified, the driver uses the default timezone, which is that >>>> of the >>>> virtual machine running the application. >>>> >>>> >> >> I think it's pretty clear that this variant must map to timestamptz. >> > > Well to add more confusion here is the excerpt from Sun's JDBC API > Tutorial > > pg 1024 ( slightly condensed ) > > > The number of milliseconds in a Timestamp object always takes into > account a time zone ... > > In order to calculate the milliseconds the driver takes into > account the time zone, information the DBMS may or may not store. > If no Calendar object is supplied the driver will use the default > Calendar whose time zone is that of the JVM that is > running the application. If the DBMS does provide timezone > information the driver will simply use that and IGNORE (my caps) a > Calendar object that may have been passed to it. > > > > >> >> The javadoc for the no-Calendar variant is more vague: >> >> >> >>>> Sets the designated parameter to the given java.sql.Timestamp >>>> value. The >>>> driver converts this to an SQL TIMESTAMP value when it sends it >>>> to the >>>> database. >>>> >>>> >> >> I'm willing to take that as license to map it to timestamp as >> there's no >> mention of timezone at all, no way to supply one, and "SQL TIMESTAMP" >> defaults to WITHOUT TIME ZONE I believe. >> >> If you want to set a TIMESTAMP WITH TIMEZONE using the default >> timezone, >> the JDBC spec seems to want you to call setTimestamp(i, timestamp, >> null) >> (see the first javadoc excerpt above -- "if no calendar object is >> specified"). The current driver also does this for >> setTimestamp(i,timestamp), which is what I'd like to change. >> >> (and also fix setTimestamp(i,timestamp,calendar) to actually preserve >> the timezone info you give it rather than mashing it into the default >> timezone, but that's a separate issue..) >> >> -O >> >> ---------------------------(end of >> broadcast)--------------------------- >> TIP 9: In versions below 8.0, the planner will ignore your desire to >> choose an index scan if your joining column's datatypes do not >> match >> >> >> > > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: explain analyze is your friend > > Dave Cramer davec@postgresintl.com www.postgresintl.com ICQ #14675561 jabber davecramer@jabber.org ph (519 939 0336 )