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

From: Otto Weichselbaum <Otto(dot)Weichselbaum(at)sew(dot)at>
To: pgsql-bugs(at)postgresql(dot)org
Subject: JDBC-Interface - Behaviour on Update, Insert or Delete returning ResultSets - Inconsistency to Console & ODBC
Date: 2007-08-18 00:03:46
Message-ID: 46C63762.6000308@sew.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Helvetica, Arial, sans-serif">Dear Ladies and Gentlemen,<br>
<br>
I do not know if this can even be considered a bug, but I would be
pleased, if somebody could make a statement on this:<br>
<br>
environment:<br>
</font>
<ul>
<li>PostgreSQL 8.1 and 8.2</li>
<li>Redhat and WinXP</li>
</ul>
While using views calling functions on INSERT, UPDATE and DELETE via
according rules, I noticed an inconsistent behaviour of the
JDBC-interface of postgres;<br>
 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<br>
BUT<br>
when called via JDBC only an 'UpdateCount' of 0 is returned;<br>
debugging to protocol-level showed, that the postgreSQL-server does not
even differ between a 'simple' UPDATE or one returning tuples;<br>
<br>
a 'simple' UPDATE returning only an 'UpdateCount' produces the
following sequence of commands (at protocol-level):<br>
49 - 50 - 110 - 67 - 90      or in characters      '1' - '2' - 'n' -
'C' - Z'<br>
exactly the same is returned on an UPDATE returning tuples; <br>
of course, as 'n' means that no data is available (according to class
org.postgresql.core.v3.QueryExecutorImpl) no tuple will be available
and the 'UpdateCount' will also be 0;<br>
<br>
... so am I right guessing that there is no way to retrieve the
resulting tuples via JDBC? (- in difference to the console and ODBC)<br>
<br>
For our needs we implemented a java.sql.Driver encapsulating the
sun.jdbc.odbc.JdbcOdbcDriver that returns the expected values as a
workaround, but that causes additional conversions that are not really
necessary;<br>
in my opinion it would be a better solution to leave the decision,
whether to return the tuples, an 'UpdateCount' or even throw an
Exception up to the implementor of the driver and not to ignore the
fact that tuples where produced already on server-side;<br>
<br>
I am looking forward to hearing your point of view!<br>
<br>
With best regards,<br>
<br>
Otto Weichselbaum<br>
<br>
<br>
<div class="moz-signature">-- <br>
<style type="text/css">
<!--
body{
font-family: arial;
font-size: 12px;
}

p.title{
font-size: 14px;
font-variant: small-caps;
font-weight: bold;
font-style: italic;
margin-top: 3px;
margin-bottom: 3px;
}

p.space{
margin-top: 2px;
margin-bottom: 2px;
}
-->
</style>
____________________________<br>
<p class="title">SEW &#8211; Otto Weichselbaum</p>
DI (FH) Otto Weichselbaum<br>
A-4040 LINZ, Heindlstrasse 19/4<br>
eMail: <a href="mailto:Otto(dot)Weichselbaum(at)sew(dot)at">Otto(dot)Weichselbaum(at)sew(dot)at</a><br>
fax: +43 (0) 732 925400<br>
mobile: +43 (0) 664 8251111<br>
</div>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 2.9 KB

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Nitin Saxena 2007-08-18 03:12:28 Re: error while starting database
Previous Message Kris Jurka 2007-08-17 19:03:22 Re: BUG #3544: SQLException from JDBC driver