RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1

From: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>
To: Peter Mount <petermount(at)it(dot)maidstone(dot)gov(dot)uk>, "'Joseph Shraibman'" <jks(at)selectacast(dot)net>, Stephen Crawley <crawley(at)dstc(dot)edu(dot)au>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1
Date: 2000-06-06 11:06:31
Message-ID: 1B3D5E532D18D311861A00600865478CF1AEBC@EXCHANGE1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Well, it's now in there.

I found why it failed to run before. I've been trying to get JBuilder 3.5 to
run the driver, and had an older postgresql.jar file in the jre/lib/ext
directory :-)

Peter

--
Peter Mount
Enterprise Support
Maidstone Borough Council
Any views stated are my own, and not those of Maidstone Borough Council

> -----Original Message-----
> From: Peter Mount [SMTP:petermount(at)it(dot)maidstone(dot)gov(dot)uk]
> Sent: Tuesday, June 06, 2000 9:55 AM
> To: 'Joseph Shraibman'; Stephen Crawley
> Cc: pgsql-interfaces(at)postgresql(dot)org
> Subject: RE: [INTERFACES] Postgres 7.0 JDBC - update count for DELETE
> is a lways 1
>
> I'm getting a little worried about cvs, as I'm seeing more and more of
> these
> "omissions" that I'm certain I'm committing.
>
> It may be my home box that's at fault, but to complicate things, both
> maidast and tyr (the box here at work) were installed from the same media,
> so it's not as simple as the version of cvs I'm running.
>
> Anyhow, I'm looking at this at the moment. However, I can't seem to get it
> to work right now.
>
> Peter
>
> --
> Peter Mount
> Enterprise Support
> Maidstone Borough Council
> Any views stated are my own, and not those of Maidstone Borough Council
>
> > -----Original Message-----
> > From: Joseph Shraibman [SMTP:jks(at)selectacast(dot)net]
> > Sent: Monday, June 05, 2000 6:48 PM
> > To: Stephen Crawley
> > Cc: pgsql-interfaces(at)postgresql(dot)org
> > Subject: Re: [INTERFACES] Postgres 7.0 JDBC - update count for DELETE
> > is always 1
> >
> > This was supposed to be fixed already, but I guess this is just more
> > code that didn't get into the cvs when it should have.
> >
> > Stephen Crawley wrote:
> > >
> > > Hi,
> > >
> > > I'm trying to port a large JDBC application to Postgres 7.0 from
> MySQL,
> > > and I've run into what I believe is a bug in the JDBC driver.
> > >
> > > When my application executes a "DELETE" statement, the ResultSet entry
> > > always says that 1 row has been deleted. Even when nothing has been
> > > deleted. I did a bit of investigation, and I think I've found where
> the
> > > problem is. In the class postgresql.Connection, the method
> > >
> > > public java.sql.ResultSet ExecSQL(String sql) throws SQLException
> > >
> > > contains the following code:
> > >
> > > ...
> > >
> > > int update_count = 1;
> > >
> > > ...
> > >
> > > case 'C': // Command Status
> > > recv_status = pg_stream.ReceiveString(8192);
> > >
> > > // Now handle the update count correctly.
> > > if(recv_status.startsWith("INSERT") ||
> > recv_status.startsWith("UPDATE")) {
> > > try {
> > > update_count =
> > >
> > Integer.parseInt(recv_status.substring(1+recv_status.lastIndexOf('
> > > ')));
> > > } catch(NumberFormatException nfe) {
> > > throw new PSQLException("postgresql.con.fathom",recv_status);
> > > }
> > > }
> > >
> > > ...
> > >
> > > It looks like the code picks out the update count when the query was
> > > described (by the backend) as an INSERT or UPDATE. But it does not
> > > do this for a DELETE.
> > >
> > > I looked at the source of the backend (src/backend/tcop/dest.c, etc)
> and
> > > it does seem to return an update count for the CMD_DELETE command. If
> > > I've got this right, adding
> > >
> > > ... || recv_status.startsWith("DELETE") ...
> > >
> > > to the if statement should fix the problem.
> > >
> > > -- Steve
> > >
> > >

Browse pgsql-interfaces by date

  From Date Subject
Next Message Kovacs Zoltan Sandor 2000-06-06 13:43:10 Re: Transactionless ODBC
Previous Message Peter Mount 2000-06-06 08:55:51 RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1