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: Pine.BSO.4.64.0804021158280.21649@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
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 Content-Type Size
call-update-count.patch text/plain 2.8 KB

In response to

Responses

Browse pgsql-jdbc by date

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