Re: CallableStatement and getUpdateCount - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: CallableStatement and getUpdateCount
Date
Msg-id Pine.BSO.4.64.0804021158280.21649@leary.csoft.net
Whole thread Raw
In response to Re: CallableStatement and getUpdateCount  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Responses Re: CallableStatement and getUpdateCount  (Sam Lawrence <sam@fsbtech.com>)
Re: CallableStatement and getUpdateCount  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
List 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

pgsql-jdbc by date:

Previous
From: "Shavonne Marietta Wijesinghe"
Date:
Subject: Re: JSP to PostgreSql
Next
From: Craig Ringer
Date:
Subject: Hibernate / other ORM and pg_advisory_lock