Skip site navigation (1) Skip section navigation (2)

Re: CallableStatement and getUpdateCount

From: Kris Jurka <books(at)ejurka(dot)com>
To: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: Sam Lawrence *EXTERN* <sam(at)fsbtech(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: CallableStatement and getUpdateCount
Date: 2008-04-02 17:07:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

On Wed, 2 Apr 2008, Albe Laurenz wrote:

> If I understood correctly then there *is* a result set in the case mentioned.
> Would it work as desired if the two checks in getUpdateCount were reversed?
>        if (result.getResultSet() != null)
>            return -1;
>        if (isFunction)
>            return 1;

Reading some more, the whole "if (isFunction)" line is bogus.  I was 
thinking that the current situation was that all function calls returned 
an update count of 1, but that's not true.  If you look at the code in 
AbstractJdbc2Statement.executeWithFlags(int) you can see that if someone 
has registered an output parameter (returnTypeSet), then it extracts the 
results out of the underlying ResultSet and discards it (sets it to null). 
So when getUpdateCount is called, the first result == null check is hit so 
we return -1.

So right now the only case we're returning 1 is when we actually do have a 
ResultSet which is exactly the opposite of what we want.  I've applied the 
attached patch to CVS and backpatched to 8.0.

Kris Jurka

Attachment: call-update-count.patch
Description: text/plain (2.8 KB)

In response to


pgsql-jdbc by date

Next:From: Craig RingerDate: 2008-04-02 17:08:51
Subject: Hibernate / other ORM and pg_advisory_lock
Previous:From: Shavonne Marietta WijesingheDate: 2008-04-02 09:40:35
Subject: Re: JSP to PostgreSql

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group