pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Jean-Pierre Pelletier <pelletier_32@sympatico.ca>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: setObject on PGInterval throws "Unknown Type null"
Date: Wed, 26 Jan 2005 10:10:38 +1300
Message-ID: <41F6B5CE.3040107@opencloud.com> (raw)
In-Reply-To: <BAYC1-PASMTP0179C8EF006D25C7EB161295860@cez.ice>
References: <BAYC1-PASMTP01298C210325B348452D7995850@cez.ice>
	<41F557C8.6030805@opencloud.com>
	<BAYC1-PASMTP0179C8EF006D25C7EB161295860@cez.ice>

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



view thread (15+ messages)  latest in thread

Message-ID: <41F6B5CE.3040107@opencloud.com>
Permalink:  ../41F6B5CE.3040107@opencloud.com/
Also on:    postgresql.org/message-id/41F6B5CE.3040107@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, pelletier_32@sympatico.ca
  Subject: Re: setObject on PGInterval throws "Unknown Type null"
  In-Reply-To: <41F6B5CE.3040107@opencloud.com>
  References: <BAYC1-PASMTP01298C210325B348452D7995850@cez.ice> <41F557C8.6030805@opencloud.com> <BAYC1-PASMTP0179C8EF006D25C7EB161295860@cez.ice> <41F6B5CE.3040107@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox