Re: ResultSet with more than 5 rows causes error

From: Kris Jurka <books(at)ejurka(dot)com>
To: Ludovico Bianchini <metlud(at)yahoo(dot)it>
Cc: pgsql-jdbc(at)postgresql(dot)org, pg(at)fastcrypt(dot)com
Subject: Re: ResultSet with more than 5 rows causes error
Date: 2007-10-01 07:11:12
Message-ID: Pine.BSO.4.64.0710010309130.30230@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Thu, 27 Sep 2007, Ludovico Bianchini wrote:

> Sorry, the error does not seem to be in the ResultSet but instead in the
> Callable Statement, method execute().
>
> java.lang.NullPointerException
> at
> org.postgresql.core.v3.SimpleParameterList.getV3Length(SimpleParameterList.java:228)
> at
> org.postgresql.core.v3.QueryExecutorImpl.sendBind(QueryExecutorImpl.java:807)
> at

I've managed to reproduce this problem with the attached test case.
At fault are the ill conceived side effects in
org.postgresql.core.v3.SimpleParameterList#getTypeOID. An accessor
like getTypeOID shouldn't be responsible for setting a value for the
out parameter. getTypeOID is called from QueryExecutorImpl's
sendParse method, which obviously isn't called when we reuse a server
side prepared statement and don't need to reparse. This leaves an
uninitialized value in the paramValues array which we die on later.

How can overriding things in getTypeOID be wise without doing the
same overriding in getTypeOIDs? In any case that all seems like the
wrong approach. It would be ideal to be able to handle all of this in
registerOutParameter, but that is tricky for INOUT parameters which
can come from two places in either order. What about putting all the
oid/value hacking into checkAllParametersSet which we can be sure will
be called?

It won't get called for describe only executions, which doing a
little testing doesn't seem to work for CallableStatements in the
first place. Maybe for clarity a separate method should be added to
SimpleParameterList to do the OUT parameter mashing.

Dave, your thoughts?

Kris Jurka

Attachment Content-Type Size
FuncNPE.java text/plain 739 bytes
FuncDesc.java text/plain 694 bytes

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-10-01 07:12:44 Re: rs.getBigDecimal returning Null on field that is not null
Previous Message Oliver Jowett 2007-09-30 20:50:54 Re: Prepared Statements vs. pgbouncer