mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
This patch fixes a bug reported by Graham Leggett (minfrin@sharp.fm).
The bug was that any insert or update would fail if the returned oid was larger than a signed int. Since OIDs are unsigned int's it was a bug that the code used a java signed int to deal with the values. The bug would result in the error message: "Unable to fathom update count". While fixing the bug, it became apparent that other code made a similar assumption about OIDs being signed ints. Therefore some methods that returned or took OIDs are arguements also needed to be changed. Since we are so close to the 7.2 release I have added new methods that return longs and deprecated the old methods returning ints. Therefore all old code should still work without requiring a code change to cast from long to int. Also note that the methods below are PostgreSQL specific extensions to the JDBC api are are not part of the spec from Sun, thus it is unlikely that they are used much or at all. The deprecated methods are: ResultSet.getInsertedOID() Statement.getInsertedOID() Serialize.store() Connection.putObject() and are replaced by: ResultSet.getLastOID() Statement.getLastOID() Serialize.storeObject() Connection.storeObject() All the deprecated methods returned int, while their replacements return long This patch also fixes two comments in MD5Digest that the author Jeremy Wohl submitted. --Barry
This commit is contained in:
@ -20,7 +20,7 @@ public abstract class ResultSet
|
||||
protected String status; // Status of the result
|
||||
protected boolean binaryCursor = false; // is the data binary or Strings
|
||||
protected int updateCount; // How many rows did we get back?
|
||||
protected int insertOID; // The oid of an inserted row
|
||||
protected long insertOID; // The oid of an inserted row
|
||||
protected int current_row; // Our pointer to where we are at
|
||||
protected byte[][] this_row; // the current row result
|
||||
protected Connection connection; // the connection which we returned from
|
||||
@ -42,7 +42,7 @@ public abstract class ResultSet
|
||||
* @param updateCount the number of rows affected by the operation
|
||||
* @param cursor the positioned update/delete cursor name
|
||||
*/
|
||||
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, int insertOID, boolean binaryCursor)
|
||||
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
|
||||
{
|
||||
this.connection = conn;
|
||||
this.fields = fields;
|
||||
@ -170,9 +170,21 @@ public abstract class ResultSet
|
||||
}
|
||||
|
||||
/*
|
||||
* returns the OID of the last inserted row
|
||||
* returns the OID of the last inserted row. Deprecated in 7.2 because
|
||||
* range for OID values is greater than java signed int.
|
||||
* @deprecated Replaced by getLastOID() in 7.2
|
||||
*/
|
||||
public int getInsertedOID()
|
||||
{
|
||||
return (int) getLastOID();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* returns the OID of the last inserted row
|
||||
* @since 7.2
|
||||
*/
|
||||
public long getLastOID()
|
||||
{
|
||||
return insertOID;
|
||||
}
|
||||
|
Reference in New Issue
Block a user