From: | pgsql-bugs(at)postgresql(dot)org |
---|---|
To: | pgsql-bugs(at)postgresql(dot)org |
Subject: | prepareStatement.executeUpdate(deleteQuery) returns 1 even when no data deleted. |
Date: | 2000-08-29 18:02:06 |
Message-ID: | 200008291802.e7TI26h98836@hub.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Samuel Minne (sminne(at)allis(dot)fr) reports a bug with a severity of 2
The lower the number the more severe it is.
Short Description
prepareStatement.executeUpdate(deleteQuery) returns 1 even when no data deleted.
Long Description
With a delete query, prepareStatement.executeUpdate() should return the number of deleted rows.
It returns 1 even when no data were deleted by the query.
The prepareStatement.getUpdateCount() returns -1 before the call to executeUpdate(), and 1 after.
This problem was found by my regression test program, which insert its own data on tables. The same program works with mysql and mm jdbc driver.
I think the problem come from the jdbc driver.
Sample Code
public synchronized boolean removeLink(Element doc,Integer tagId)
throws SQLException, ElementNotSupportedException {
boolean linkRemoved=true;
if ( doc.getType() != Element.DOCUMENT) throw new ElementNotSupportedException();
Document myDocument= (Document)doc;
// Suppression du lien existant
StringBuffer query=new StringBuffer();
query.append("delete from lien_sequence");
query.append(" where doc_id=?" );
query.append(" and tag_id=?" );
//System.out.println("Docid "+myDocument.id + ": Tag "+tagId.intValue());
Connection con= myConnectionPoolManager.requestConnection(myUpdateConnectionPool);
PreparedStatement myPreparedStatement= con.prepareStatement(query.toString());
myPreparedStatement.setInt(1,myDocument.id);
myPreparedStatement.setObject(2,tagId); // Gre la valeur NULL de l'Integer
//System.out.println("Query "+query.toString());
if (myPreparedStatement.executeUpdate() != 1) linkRemoved= false;
//System.out.println("updatecount=" +myPreparedStatement.getUpdateCount());
//System.out.println("updatecount=" +myPreparedStatement.executeUpdate());
//System.out.println("updatecount=" +myPreparedStatement.getUpdateCount());
//System.exit(-1);
myConnectionPoolManager.closeStatement(myPreparedStatement);
myConnectionPoolManager.returnConnection(myUpdateConnectionPool,con);
//System.out.println("Docid "+myDocument.id + ": Tag "+tagId.intValue());
//System.out.println("Result "+linkRemoved);
return linkRemoved;
}
No file was uploaded with this report
From | Date | Subject | |
---|---|---|---|
Next Message | pgsql-bugs | 2000-08-29 19:06:51 | initdb -t trashes the entire database system |
Previous Message | Steve Wolfe | 2000-08-29 16:47:51 | Re: [BUGS] Re: cannot vacuum a database ! |