Re: currval bug?? - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: currval bug??
Date
Msg-id Pine.BSO.4.56.0412211345510.2330@leary.csoft.net
Whole thread Raw
In response to currval bug??  (Gabriele Carteni <gabriele.carteni@unile.it>)
Responses Re: currval bug??  (Gabriele Carteni <gabriele.carteni@unile.it>)
List pgsql-jdbc

On Tue, 21 Dec 2004, Gabriele Carteni wrote:

> Hi all,
> i have recently upgraded my development environment:
> FROM postgresql 7.4 TO postgresql 8.0beta5
> FROM jdk1.4 TO jdk1.5
> FROM pg74.215.jdbc3.jar TO pg80b1.308.jdbc3.jar
>
> now, i have a FRUSTRATING bug:
>
> With this query (which works fine with previous pg74jdbc):
>
> *insert into tablename (fieldname) values ('testvalue');select
> currval('tablename_id_seq');*
>
> *org.postgresql.util.PSQLException: No results were returned by the query.*
>
> Obviously the query has to return a result.

The 7.4 driver sends the whole query string together to the backend and
gets a result.  The 8.0 driver splits the query into two and sends them
individually.  This is required to use the V3 extended query protocol.
When it gets the result from the first part it is expecting a result and
isn't getting one.  I'm not sure if this should be an error or not, in
general mashing queries together isn't a great idea.  Perhaps you should
be using Statement.execute() and then iterating through any/all results
returned?

Kris Jurka

pgsql-jdbc by date:

Previous
From: Gabriele Carteni
Date:
Subject: currval bug??
Next
From: Gabriele Carteni
Date:
Subject: Re: currval bug??