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 E3D833A5764 for ; Tue, 25 Jan 2005 21:10:55 +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 20474-04 for ; Tue, 25 Jan 2005 21:10:52 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 288F63A5809 for ; Tue, 25 Jan 2005 21:10:52 +0000 (GMT) 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 (Exim 3.35 #1 (Debian)) id 1CtXxX-0002gV-00; Wed, 26 Jan 2005 10:10:47 +1300 Message-ID: <41F6B5CE.3040107@opencloud.com> Date: Wed, 26 Jan 2005 10:10:38 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jean-Pierre Pelletier Cc: pgsql-jdbc@postgresql.org Subject: Re: setObject on PGInterval throws "Unknown Type null" References: <41F557C8.6030805@opencloud.com> In-Reply-To: X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/247 X-Sequence-Number: 12127 Jean-Pierre Pelletier wrote: > With JDBC Build 309, there are now TWO DIFFERENT JAVA MAPPING OF AN SQL > NULL INTERVAL Yes. No need to shout :) > myPGInterval = (PGInterval) myResultSet.getObject(i) > sets myPGInterval to null > > myPreparedStatement.setObject(i,myPGInterval) > needs myPGInterval to be set to new PGInterval() instead of null [...] > It would be more consistent to output a SQL null interval with > myPreparedStatement.setObject(i, myPGInterval, SomeSpecializedType) > or even with > myPreparedStatement.setNull(i, SomeSpecializedType) I considered using a new Types value, but there are a couple of problems: - how do you allocate Types values that don't collide with future specifications? - the type registration interface would incompatibly change Also, I don't see how that on its own fixes generic "table copy" code -- you still need to know you're dealing with an interval on that particular column so you can pass the right Types value to setObject. Perhaps it works this out via metadata. We could change the table/resultset metadata to return the modified Types values, but that's starting to be an invasive change that affects more than just users of extension types. Another approach would be to continue to use Types.OTHER, but return the equivalent of "new PGInterval()" from getObject() when a NULL resultset value is seen. But that leads to other problems: code that retrieves a value via getObject() has to be aware that a non-null object might actually mean a null column. I'm not sure that either cure is better than the disease. -O