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

Re: JDBC-Interface - Behaviour on Update, Insert or Delete returning ResultSets - Inconsistency to Console & ODBC

From: Kris Jurka <books(at)ejurka(dot)com>
To: Otto Weichselbaum <Otto(dot)Weichselbaum(at)sew(dot)at>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: JDBC-Interface - Behaviour on Update, Insert or Delete returning ResultSets - Inconsistency to Console & ODBC
Date: 2007-08-18 17:29:34
Message-ID: Pine.BSO.4.64.0708181323220.28001@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-bugs

On Sat, 18 Aug 2007, Otto Weichselbaum wrote:

> While using views calling functions on INSERT, UPDATE and DELETE via
> according rules, I noticed an inconsistent behaviour of the
> JDBC-interface of postgres;
>  an INSERT-, UPDATE- or DELETE-statement producing tuples as return-value
> (in our case through rules calling functions but although via the
> 'RETURNING'-clause of a single INSERT- or UPDATE-statement) is returning
> the expected number of tuples when called via the console (even through
> pgAdmin) or via ODBC
> BUT
> when called via JDBC only an 'UpdateCount' of 0 is returned;
> debugging to protocol-level showed, that the postgreSQL-server does not
> even differ between a 'simple' UPDATE or one returning tuples;

I believe this differing results you are seeing is based upon whether the 
query is executed using the simple or extended query protocol.  The JDBC 
driver always uses extended query protocol when speaking to a V3 protocol 
capable server.  Another workaround you can use is adding 
?protocolVersion=2 to your URL to make it use the V2 protocol and simple 
query execution.

It works with the simple query protocol because you send the server a 
query and then loop retrieving any number of results that are returned. 
The extended query protocol is designed around single query gives a 
single result, so it isn't really prepared to handle the update count 
and results at the same time.

Kris Jurka

In response to

pgsql-bugs by date

Next:From: Alejandro Sengès GonzálezDate: 2007-08-19 00:02:50
Subject: POSTGRES - DATA RECOVERY
Previous:From: Douglas ToltzmanDate: 2007-08-18 17:01:43
Subject: Re: error while starting database

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