diff options
author | Barry Lind <barry@xythos.com> | 2001-11-25 23:26:59 +0000 |
---|---|---|
committer | Barry Lind <barry@xythos.com> | 2001-11-25 23:26:59 +0000 |
commit | 4bc8c8dd95367a1dd0e9af3f1805bb85018ec307 (patch) | |
tree | cb1ae41232cde0100e91e4c74e382f0db1de497a /src/interfaces/jdbc/org/postgresql/Statement.java | |
parent | 23b5ca91aa92abf518fe1e86eb2b7b478414192b (diff) | |
download | postgresql-4bc8c8dd95367a1dd0e9af3f1805bb85018ec307.tar.gz |
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
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/Statement.java')
-rw-r--r-- | src/interfaces/jdbc/org/postgresql/Statement.java | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/Statement.java b/src/interfaces/jdbc/org/postgresql/Statement.java index 95fd62d9f8..932b93aec8 100644 --- a/src/interfaces/jdbc/org/postgresql/Statement.java +++ b/src/interfaces/jdbc/org/postgresql/Statement.java @@ -8,19 +8,6 @@ import org.postgresql.util.PSQLException; * org.postgresql.jdbc1.Statement and org.postgresql.jdbc2.Statement that are * unique to PostgreSQL's JDBC driver. * - * <p>They are defined so that client code can cast to org.postgresql.Statement - * without having to predetermine the jdbc driver type. - * - * <p>ie: Before this class existed, you had to use: - * - * <p>((org.postgresql.jdbc2.Statement)stat).getInsertedOID(); - * - * <p>now you use: - * - * <p>((org.postgresql.Statement)stat).getInsertedOID(); - * - * <p>As you can see, this is independent of JDBC1.2, JDBC2.0 or the upcoming - * JDBC3. */ public abstract class Statement @@ -196,16 +183,27 @@ public abstract class Statement } /* - * New in 7.1: Returns the Last inserted oid. This should be used, rather - * than the old method using getResultSet, which for executeUpdate returns - * null. - * @return OID of last insert + * Returns the Last inserted/updated oid. Deprecated in 7.2 because + * range of OID values is greater than a java signed int. + * @deprecated Replaced by getLastOID in 7.2 */ public int getInsertedOID() throws SQLException { if (result == null) return 0; - return ((org.postgresql.ResultSet) result).getInsertedOID(); + return (int)((org.postgresql.ResultSet) result).getLastOID(); + } + + /* + * Returns the Last inserted/updated oid. + * @return OID of last insert + * @since 7.2 + */ + public long getLastOID() throws SQLException + { + if (result == null) + return 0; + return ((org.postgresql.ResultSet) result).getLastOID(); } /* |