pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Postgres 7.0 JDBC - update count for DELETE is always 1
7+ messages / 4 participants
[nested] [flat]

* Postgres 7.0 JDBC - update count for DELETE is always 1
@ 2000-06-05 00:38  Stephen Crawley <crawley@dstc.edu.au>
  0 siblings, 1 reply; 7+ messages in thread

From: Stephen Crawley @ 2000-06-05 00:38 UTC (permalink / raw)
  To: pgsql-interfaces


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

  




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1
@ 2000-06-05 17:46  Gregory Krasnow OpenSourceCRM <gak@opensourcecrm.org>
  0 siblings, 1 reply; 7+ messages in thread

From: Gregory Krasnow OpenSourceCRM @ 2000-06-05 17:46 UTC (permalink / raw)
  To: Joseph Shraibman <jks@selectacast.net>; Stephen Crawley <crawley@dstc.edu.au>; +Cc: pgsql-interfaces

This is a little off-topic, but I have been unable to get in through
anonymous cvs.  
I have tried:
 cvs -d :pserver:anoncvs@hub.org:/usr/local/cvsroot login

with postgresql as the password

- Greg

-----Original Message-----
From: Joseph Shraibman [mailto:jks@selectacast.net]
Sent: Monday, June 05, 2000 10:48 AM
To: Stephen Crawley
Cc: pgsql-interfaces@postgresql.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
> 
>



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Postgres 7.0 JDBC - update count for DELETE is always 1
@ 2000-06-05 17:47  Joseph Shraibman <jks@selectacast.net>
  parent: Stephen Crawley <crawley@dstc.edu.au>
  0 siblings, 0 replies; 7+ messages in thread

From: Joseph Shraibman @ 2000-06-05 17:47 UTC (permalink / raw)
  To: Stephen Crawley <crawley@dstc.edu.au>; +Cc: pgsql-interfaces

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
> 
>



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Postgres 7.0 JDBC - update count for DELETE is always 1
@ 2000-06-05 18:04  Joseph Shraibman <jks@selectacast.net>
  parent: Gregory Krasnow OpenSourceCRM <gak@opensourcecrm.org>
  0 siblings, 0 replies; 7+ messages in thread

From: Joseph Shraibman @ 2000-06-05 18:04 UTC (permalink / raw)
  To: Gregory Krasnow OpenSourceCRM <gak@opensourcecrm.org>; +Cc: Stephen Crawley <crawley@dstc.edu.au>; pgsql-interfaces

Gregory Krasnow OpenSourceCRM wrote:
> 
> This is a little off-topic, but I have been unable to get in through
> anonymous cvs.
> I have tried:
>  cvs -d :pserver:anoncvs@hub.org:/usr/local/cvsroot login
> 
> with postgresql as the password
> 
> - Greg
> 
I don't know much about cvs, but the file below works for me with the
command 'cvsup pgsql.cvsup' 

#file: pgsql.cvsup
# CVSup distribution file for the PostgreSQL ORDBMS project
# Modified by lockhart@alumni.caltech.edu 1997-08-28
# - Point to my local snapshot source tree
#
# Defaults that apply to all the collections
*default host=postgresql.org
*default compress
*default release=cvs
*default delete use-rel-suffix
*default tag=.
#*default tag=REL6_5_3
#*default date=2000.02.20.00.00.00

# base directory points to where CVSup will store its 'bookmarks'
file(s)
# will create subdirectory sup/
#*default base=/opt/postgres # /usr/local/pgsql
*default base=/usr/src/cvs
#*default base=/var/lib/pgsql
# prefix directory points to where CVSup will store the actual
distribution(s)
#*default prefix=/opt/postgres/cvs # /usr/local/pgsql
*default prefix=/usr/src/cvs
#*default prefix=/var/lib/pgsql

# complete distribution, including all below
pgsql

# individual distributions vs 'the whole thing'
# pgsql-doc
# pgsql-perl5
# pgsql-src
# end file



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1
@ 2000-06-06 08:55  Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Peter Mount @ 2000-06-06 08:55 UTC (permalink / raw)
  To: 'Joseph Shraibman' <jks@selectacast.net>; Stephen Crawley <crawley@dstc.edu.au>; +Cc: pgsql-interfaces

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@selectacast.net]
> Sent:	Monday, June 05, 2000 6:48 PM
> To:	Stephen Crawley
> Cc:	pgsql-interfaces@postgresql.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
> > 
> >



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1
@ 2000-06-06 08:55  Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Peter Mount @ 2000-06-06 08:55 UTC (permalink / raw)
  To: 'Gregory Krasnow OpenSourceCRM' <gak@opensourcecrm.org>; Joseph Shraibman <jks@selectacast.net>; Stephen Crawley <crawley@dstc.edu.au>; +Cc: pgsql-interfaces

It's now :pserver:anoncvs@hub.org:/home/projects/pgsql/cvsroot

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

> -----Original Message-----
> From:	Gregory Krasnow OpenSourceCRM [SMTP:gak@opensourcecrm.org]
> Sent:	Monday, June 05, 2000 6:46 PM
> To:	Joseph Shraibman; Stephen Crawley
> Cc:	pgsql-interfaces@postgresql.org
> Subject:	RE: [INTERFACES] Postgres 7.0 JDBC - update count for DELETE
> is a lways 1
> 
> This is a little off-topic, but I have been unable to get in through
> anonymous cvs.  
> I have tried:
>  cvs -d :pserver:anoncvs@hub.org:/usr/local/cvsroot login
> 
> with postgresql as the password
> 
> - Greg
> 
> -----Original Message-----
> From: Joseph Shraibman [mailto:jks@selectacast.net]
> Sent: Monday, June 05, 2000 10:48 AM
> To: Stephen Crawley
> Cc: pgsql-interfaces@postgresql.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
> > 
> >



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1
@ 2000-06-06 11:06  Peter Mount <petermount@it.maidstone.gov.uk>
  0 siblings, 0 replies; 7+ messages in thread

From: Peter Mount @ 2000-06-06 11:06 UTC (permalink / raw)
  To: Peter Mount <petermount@it.maidstone.gov.uk>; 'Joseph Shraibman' <jks@selectacast.net>; Stephen Crawley <crawley@dstc.edu.au>; +Cc: 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@it.maidstone.gov.uk]
> Sent:	Tuesday, June 06, 2000 9:55 AM
> To:	'Joseph Shraibman'; Stephen Crawley
> Cc:	pgsql-interfaces@postgresql.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@selectacast.net]
> > Sent:	Monday, June 05, 2000 6:48 PM
> > To:	Stephen Crawley
> > Cc:	pgsql-interfaces@postgresql.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
> > > 
> > >



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2000-06-06 11:06 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-06-05 00:38 Postgres 7.0 JDBC - update count for DELETE is always 1 Stephen Crawley <crawley@dstc.edu.au>
2000-06-05 17:47 ` Joseph Shraibman <jks@selectacast.net>
2000-06-05 17:46 RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1 Gregory Krasnow OpenSourceCRM <gak@opensourcecrm.org>
2000-06-05 18:04 ` Joseph Shraibman <jks@selectacast.net>
2000-06-06 08:55 RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1 Peter Mount <petermount@it.maidstone.gov.uk>
2000-06-06 08:55 RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1 Peter Mount <petermount@it.maidstone.gov.uk>
2000-06-06 11:06 RE: Postgres 7.0 JDBC - update count for DELETE is a lways 1 Peter Mount <petermount@it.maidstone.gov.uk>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox