1
0
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:
Barry Lind
2001-11-25 23:26:59 +00:00
parent 23b5ca91aa
commit 4bc8c8dd95
14 changed files with 79 additions and 45 deletions

View File

@ -11,7 +11,7 @@ import org.postgresql.util.*;
import org.postgresql.core.*;
/*
* $Id: Connection.java,v 1.38 2001/11/19 23:19:20 momjian Exp $
* $Id: Connection.java,v 1.39 2001/11/25 23:26:56 barry Exp $
*
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
* JDBC2 versions of the Connection class.
@ -594,14 +594,26 @@ public abstract class Connection
return null;
}
/*
* This stores an object into the database. This method was
* deprecated in 7.2 bacause an OID can be larger than the java signed
* int returned by this method.
* @deprecated Replaced by storeObject() in 7.2
*/
public int putObject(Object o) throws SQLException
{
return (int) storeObject(o);
}
/*
* This stores an object into the database.
* @param o Object to store
* @return OID of the new rectord
* @exception SQLException if value is not correct for this type
* @see org.postgresql.util.Serialize
* @since 7.2
*/
public int putObject(Object o) throws SQLException
public long storeObject(Object o) throws SQLException
{
try
{
@ -615,13 +627,13 @@ public abstract class Connection
{
Serialize ser = new Serialize(this, type);
objectTypes.put(type, ser);
return ser.store(o);
return ser.storeObject(o);
}
// If it's an object, it should be an instance of our Serialize class
// If so, then call it's fetch method.
if (x instanceof Serialize)
return ((Serialize)x).store(o);
return ((Serialize)x).storeObject(o);
// Thow an exception because the type is unknown
throw new PSQLException("postgresql.con.strobj");
@ -697,7 +709,7 @@ public abstract class Connection
* This returns a resultset. It must be overridden, so that the correct
* version (from jdbc1 or jdbc2) are returned.
*/
public abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, int insertOID, boolean binaryCursor) throws SQLException;
public abstract java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
/*
* In some cases, it is desirable to immediately release a Connection's