postgresql-jdbc.git / summary / log / commit / refs

commit    8aaf7bb5a7fbec5796fbc811c995f06502276d5c
Author:   Kris Jurka <books@ejurka.com>
Date:     Sun Dec 02 06:48:43 2007 +0000

    When dealing with OIDs larger than 2^31 we can't retrieve these as
    Java ints.  Using long throughout the driver would be a pain, one
    reason is that you can't use a switch on a long variable.  PG supports
    representing OIDs as signed ints (select '3000000000'::oid::int4),
    so retrieve the values as longs, but then cast to int to get the
    signed representation.
    
    As suggested by Tom Lane + Quinton Dolan


org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java | 14 +++++++------- org/postgresql/jdbc2/TypeInfoCache.java | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java index ee5df7be..38976fe5 100644 --- a/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java +++ b/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java @@ -3,7 +3,7 @@ * Copyright (c) 2004-2005, PostgreSQL Global Development Group * * IDENTIFICATION -* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.39 2007/09/10 08:36:43 jurka Exp $ +* $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2DatabaseMetaData.java,v 1.41 2007/12/01 08:28:58 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -1760,9 +1760,9 @@ public abstract class AbstractJdbc2DatabaseMetaData { byte schema[] = rs.getBytes("nspname"); byte procedureName[] = rs.getBytes("proname"); - int returnType = rs.getInt("prorettype"); + int returnType = (int)rs.getLong("prorettype"); String returnTypeType = rs.getString("typtype"); - int returnTypeRelid = rs.getInt("typrelid"); + int returnTypeRelid = (int)rs.getLong("typrelid"); String strArgTypes = rs.getString("proargtypes"); StringTokenizer st = new StringTokenizer(strArgTypes); @@ -1872,7 +1872,7 @@ public abstract class AbstractJdbc2DatabaseMetaData ResultSet columnrs = connection.createStatement().executeQuery(columnsql); while (columnrs.next()) { - int columnTypeOid = columnrs.getInt("atttypid"); + int columnTypeOid = (int)columnrs.getLong("atttypid"); byte[][] tuple = new byte[13][]; tuple[0] = null; tuple[1] = schema; @@ -2333,7 +2333,7 @@ public abstract class AbstractJdbc2DatabaseMetaData while (rs.next()) { byte[][] tuple = new byte[18][]; - int typeOid = rs.getInt("atttypid"); + int typeOid = (int)rs.getLong("atttypid"); int typeMod = rs.getInt("atttypmod"); tuple[0] = null; // Catalog name, not supported @@ -2855,7 +2855,7 @@ public abstract class AbstractJdbc2DatabaseMetaData while (rs.next()) { byte tuple[][] = new byte[8][]; - int typeOid = rs.getInt("atttypid"); + int typeOid = (int)rs.getLong("atttypid"); int typeMod = rs.getInt("atttypmod"); int decimalDigits = TypeInfoCache.getScale(typeOid, typeMod); int columnSize = TypeInfoCache.getPrecision(typeOid, typeMod); @@ -3624,7 +3624,7 @@ public abstract class AbstractJdbc2DatabaseMetaData { byte[][] tuple = new byte[18][]; String typname = rs.getString(1); - int typeOid = rs.getInt(2); + int typeOid = (int)rs.getLong(2); tuple[0] = connection.encodeString(typname); tuple[1] = connection.encodeString(Integer.toString(connection.getSQLType(typname))); diff --git a/org/postgresql/jdbc2/TypeInfoCache.java b/org/postgresql/jdbc2/TypeInfoCache.java index 375f12dd..1140c588 100644 --- a/org/postgresql/jdbc2/TypeInfoCache.java +++ b/org/postgresql/jdbc2/TypeInfoCache.java @@ -3,7 +3,7 @@ * Copyright (c) 2005, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgjdbc/org/postgresql/jdbc2/TypeInfoCache.java,v 1.9 2007/12/01 08:28:58 jurka Exp $ + * $PostgreSQL: pgjdbc/org/postgresql/jdbc2/TypeInfoCache.java,v 1.10 2007/12/01 12:50:44 jurka Exp $ * *------------------------------------------------------------------------- */ @@ -213,7 +213,7 @@ public class TypeInfoCache { oid = new Integer(Oid.UNSPECIFIED); ResultSet rs = _getOidStatement.getResultSet(); if (rs.next()) { - oid = new Integer(rs.getInt(1)); + oid = new Integer((int)rs.getLong(1)); _oidToPgName.put(oid, pgTypeName); } _pgNameToOid.put(pgTypeName, oid); @@ -289,7 +289,7 @@ public class TypeInfoCache { if (!rs.next()) throw new PSQLException(GT.tr("No results were returned by the query."), PSQLState.NO_DATA); - pgType = new Integer(rs.getInt(1)); + pgType = new Integer((int)rs.getLong(1)); _pgArrayToPgType.put(new Integer(oid), pgType); _pgNameToOid.put(rs.getString(2), pgType); _oidToPgName.put(pgType, rs.getString(2)); [parent: d2e372b80d7c]