[libpostgresql-jdbc-java] 03/10: When manipulating large objects we must handle the oid as a Java long rather than an int so it works when the oid counter exceeds Integer.MAX_VALUE. This doesn't remove the existing int API to avoid breaking code, but instead adds a parallel API that uses long.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:20:00 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_1_409
in repository libpostgresql-jdbc-java.

commit ce6f457f622f7fe467f061965fb2ba0ed2ed9020
Author: Kris Jurka <books at ejurka.com>
Date:   Mon Feb 19 06:05:02 2007 +0000

    When manipulating large objects we must handle the oid as a Java long
    rather than an int so it works when the oid counter exceeds
    Integer.MAX_VALUE.  This doesn't remove the existing int API to avoid
    breaking code, but instead adds a parallel API that uses long.
---
 doc/pgjdbc.xml                                     |  8 +-
 org/postgresql/fastpath/Fastpath.java              | 35 +++++++-
 org/postgresql/jdbc2/AbstractJdbc2Blob.java        |  4 +-
 org/postgresql/jdbc2/AbstractJdbc2BlobClob.java    |  4 +-
 org/postgresql/jdbc2/AbstractJdbc2Clob.java        |  4 +-
 org/postgresql/jdbc2/AbstractJdbc2ResultSet.java   |  6 +-
 org/postgresql/jdbc2/AbstractJdbc2Statement.java   | 22 +++---
 org/postgresql/jdbc2/Jdbc2Blob.java                |  4 +-
 org/postgresql/jdbc2/Jdbc2Clob.java                |  4 +-
 org/postgresql/jdbc2/Jdbc2ResultSet.java           |  6 +-
 org/postgresql/jdbc3/AbstractJdbc3Blob.java        |  4 +-
 org/postgresql/jdbc3/AbstractJdbc3Clob.java        |  4 +-
 org/postgresql/jdbc3/Jdbc3Blob.java                |  4 +-
 org/postgresql/jdbc3/Jdbc3Clob.java                |  4 +-
 org/postgresql/jdbc3/Jdbc3ResultSet.java           |  6 +-
 org/postgresql/jdbc3g/Jdbc3gBlob.java              |  4 +-
 org/postgresql/jdbc3g/Jdbc3gClob.java              |  4 +-
 org/postgresql/jdbc3g/Jdbc3gResultSet.java         |  6 +-
 org/postgresql/largeobject/LargeObject.java        | 17 +++-
 org/postgresql/largeobject/LargeObjectManager.java | 92 ++++++++++++++++++++--
 org/postgresql/test/jdbc2/BlobTest.java            |  8 +-
 21 files changed, 187 insertions(+), 63 deletions(-)

diff --git a/doc/pgjdbc.xml b/doc/pgjdbc.xml
index 8c35312..8c7d7f5 100644
--- a/doc/pgjdbc.xml
+++ b/doc/pgjdbc.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0"?>
 <!--
   Copyright (c) 2004-2005, PostgreSQL Global Development Group
-  $PostgreSQL: pgjdbc/doc/pgjdbc.xml,v 1.25.2.1 2006/05/22 19:40:07 jurka Exp $
+  $PostgreSQL: pgjdbc/doc/pgjdbc.xml,v 1.25.2.2 2006/09/26 05:18:11 jurka Exp $
 -->
 
 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
@@ -1373,7 +1373,7 @@ conn.setAutoCommit(false);
 LargeObjectManager lobj = ((org.postgresql.PGConnection)conn).getLargeObjectAPI();
 
 // Create a new large object
-int oid = lobj.create(LargeObjectManager.READ | LargeObjectManager.WRITE);
+long oid = lobj.createLO(LargeObjectManager.READ | LargeObjectManager.WRITE);
 
 // Open the large object for writing
 LargeObject obj = lobj.open(oid, LargeObjectManager.WRITE);
@@ -1396,7 +1396,7 @@ obj.close();
 // Now insert the row into imageslo
 PreparedStatement ps = conn.prepareStatement("INSERT INTO imageslo VALUES (?, ?)");
 ps.setString(1, file.getName());
-ps.setInt(2, oid);
+ps.setLong(2, oid);
 ps.executeUpdate();
 ps.close();
 fis.close();
@@ -1421,7 +1421,7 @@ ps.setString(1, "myimage.gif");
 ResultSet rs = ps.executeQuery();
 while (rs.next()) {
     // Open the large object for reading
-    int oid = rs.getInt(1);
+    long oid = rs.getLong(1);
     LargeObject obj = lobj.open(oid, LargeObjectManager.READ);
 
     // Read the data
diff --git a/org/postgresql/fastpath/Fastpath.java b/org/postgresql/fastpath/Fastpath.java
index 716a10c..84189a6 100644
--- a/org/postgresql/fastpath/Fastpath.java
+++ b/org/postgresql/fastpath/Fastpath.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/fastpath/Fastpath.java,v 1.31 2005/01/11 08:25:45 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/fastpath/Fastpath.java,v 1.32 2005/01/14 01:20:18 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -31,6 +31,11 @@ import org.postgresql.util.GT;
  */
 public class Fastpath
 {
+    // Java passes oids around as longs, but in the backend
+    // it's an unsigned int, so we use this to make the conversion
+    // of long -> signed int which the backend interprets as unsigned.
+    private final static long NUM_OIDS = 4294967296L; // 2^32
+
     // This maps the functions names to their id's (possible unique just
     // to a connection).
     private final Hashtable func = new Hashtable();
@@ -127,6 +132,20 @@ public class Fastpath
     }
 
     /**
+     * This convenience method assumes that the return value is an oid.
+     * @param name Function name
+     * @param args Function arguments
+     * @exception SQLException if a database-access error occurs or no result
+     */
+    public long getOID(String name, FastpathArg[] args) throws SQLException
+    {
+        long oid = getInteger(name, args);
+        if (oid < 0)
+            oid += NUM_OIDS;
+        return oid;
+    }
+
+    /**
      * This convenience method assumes that the return value is not an Integer
      * @param name Function name
      * @param args Function arguments
@@ -220,5 +239,19 @@ public class Fastpath
 
         return id.intValue();
     }
+
+    /**
+     * Creates a FastpathArg with an oid parameter.
+     * This is here instead of a constructor of FastpathArg
+     * because the constructor can't tell the difference between
+     * an long that's really int8 and a long thats an oid.
+     */
+    public static FastpathArg createOIDArg(long oid)
+    {
+        if (oid > Integer.MAX_VALUE)
+            oid -= NUM_OIDS;
+        return new FastpathArg((int)oid);
+    }
+
 }
 
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Blob.java b/org/postgresql/jdbc2/AbstractJdbc2Blob.java
index a21cab4..ecbba55 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Blob.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Blob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Blob.java,v 1.8 2005/02/15 08:56:25 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Blob.java,v 1.9 2005/03/28 08:52:35 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -18,7 +18,7 @@ public abstract class AbstractJdbc2Blob extends AbstractJdbc2BlobClob
 {
     private LargeObject lo;
 
-    public AbstractJdbc2Blob(PGConnection conn, int oid) throws SQLException
+    public AbstractJdbc2Blob(PGConnection conn, long oid) throws SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java b/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java
index eb3cdb4..6ab0058 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java,v 1.2 2005/05/08 23:18:24 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2BlobClob.java,v 1.3 2005/05/09 03:17:18 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -33,7 +33,7 @@ public class AbstractJdbc2BlobClob
 {
     private LargeObject lo;
 
-    public AbstractJdbc2BlobClob(PGConnection conn, int oid) throws SQLException
+    public AbstractJdbc2BlobClob(PGConnection conn, long oid) throws SQLException
     {
         LargeObjectManager lom = conn.getLargeObjectAPI();
         this.lo = lom.open(oid);
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Clob.java b/org/postgresql/jdbc2/AbstractJdbc2Clob.java
index 2231121..a20a3ec 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Clob.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Clob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Clob.java,v 1.7 2005/01/11 08:25:45 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Clob.java,v 1.8 2005/02/15 08:56:25 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -23,7 +23,7 @@ public class AbstractJdbc2Clob
 {
     private LargeObject lo;
 
-    public AbstractJdbc2Clob(PGConnection conn, int oid) throws SQLException
+    public AbstractJdbc2Clob(PGConnection conn, long oid) throws SQLException
     {
         LargeObjectManager lom = conn.getLargeObjectAPI();
         this.lo = lom.open(oid);
diff --git a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
index 48ebec8..6d85ca5 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.80.2.1 2005/12/04 21:41:21 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java,v 1.80.2.2 2006/08/06 18:11:43 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -2062,7 +2062,7 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg
                 if ( fields[columnIndex - 1].getOID() == 26)
                 {
                     LargeObjectManager lom = connection.getLargeObjectAPI();
-                    LargeObject lob = lom.open(getInt(columnIndex));
+                    LargeObject lob = lom.open(getLong(columnIndex));
                     byte buf[] = lob.read(lob.size());
                     lob.close();
                     return trimBytes(columnIndex, buf);
@@ -2178,7 +2178,7 @@ public abstract class AbstractJdbc2ResultSet implements BaseResultSet, org.postg
             if ( fields[columnIndex - 1].getOID() == 26)
             {
                 LargeObjectManager lom = connection.getLargeObjectAPI();
-                LargeObject lob = lom.open(getInt(columnIndex));
+                LargeObject lob = lom.open(getLong(columnIndex));
                 return lob.getInputStream();
             }
         }
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 0452c65..3409bee 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.84.2.7 2006/11/05 05:44:44 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.84.2.8 2007/01/04 21:59:26 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -1273,11 +1273,11 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
         {
             //Version 7.1 and earlier support done as LargeObjects
             LargeObjectManager lom = connection.getLargeObjectAPI();
-            int oid = lom.create();
+            long oid = lom.createLO();
             LargeObject lob = lom.open(oid);
             lob.write(x);
             lob.close();
-            setInt(parameterIndex, oid);
+            setLong(parameterIndex, oid);
         }
     }
 
@@ -1473,7 +1473,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
             //but the jdbc spec indicates that streams should be
             //available for LONGVARBINARY instead
             LargeObjectManager lom = connection.getLargeObjectAPI();
-            int oid = lom.create();
+            long oid = lom.createLO();
             LargeObject lob = lom.open(oid);
             OutputStream los = lob.getOutputStream();
             try
@@ -1496,7 +1496,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
                 throw new PSQLException(GT.tr("Provided InputStream failed."), PSQLState.UNEXPECTED_ERROR, se);
             }
             // lob is closed by the stream so don't call lob.close()
-            setInt(parameterIndex, oid);
+            setLong(parameterIndex, oid);
         }
     }
 
@@ -2714,7 +2714,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
 
         InputStream l_inStream = x.getBinaryStream();
         LargeObjectManager lom = connection.getLargeObjectAPI();
-        int oid = lom.create();
+        long oid = lom.createLO();
         LargeObject lob = lom.open(oid);
         OutputStream los = lob.getOutputStream();
         byte[] buf = new byte[4096];
@@ -2750,7 +2750,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
             {
             }
         }
-        setInt(i, oid);
+        setLong(i, oid);
     }
 
     public void setCharacterStream(int i, java.io.Reader x, int length) throws SQLException
@@ -2806,7 +2806,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
             //but the jdbc spec indicates that streams should be
             //available for LONGVARCHAR instead
             LargeObjectManager lom = connection.getLargeObjectAPI();
-            int oid = lom.create();
+            long oid = lom.createLO();
             LargeObject lob = lom.open(oid);
             OutputStream los = lob.getOutputStream();
             try
@@ -2829,7 +2829,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
                 throw new PSQLException(GT.tr("Unexpected error writing large object to database."), PSQLState.UNEXPECTED_ERROR, se);
             }
             // lob is closed by the stream so don't call lob.close()
-            setInt(i, oid);
+            setLong(i, oid);
         }
     }
 
@@ -2846,7 +2846,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
         InputStream l_inStream = x.getAsciiStream();
         int l_length = (int) x.length();
         LargeObjectManager lom = connection.getLargeObjectAPI();
-        int oid = lom.create();
+        long oid = lom.createLO();
         LargeObject lob = lom.open(oid);
         OutputStream los = lob.getOutputStream();
         try
@@ -2869,7 +2869,7 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
             throw new PSQLException(GT.tr("Unexpected error writing large object to database."), PSQLState.UNEXPECTED_ERROR, se);
         }
         // lob is closed by the stream so don't call lob.close()
-        setInt(i, oid);
+        setLong(i, oid);
     }
 
     public void setNull(int i, int t, String s) throws SQLException
diff --git a/org/postgresql/jdbc2/Jdbc2Blob.java b/org/postgresql/jdbc2/Jdbc2Blob.java
index b1abe0f..9742443 100644
--- a/org/postgresql/jdbc2/Jdbc2Blob.java
+++ b/org/postgresql/jdbc2/Jdbc2Blob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2Blob.java,v 1.3 2004/11/09 08:49:03 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2Blob.java,v 1.4 2005/01/11 08:25:46 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -13,7 +13,7 @@ package org.postgresql.jdbc2;
 public class Jdbc2Blob extends AbstractJdbc2Blob implements java.sql.Blob
 {
 
-    public Jdbc2Blob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
+    public Jdbc2Blob(org.postgresql.PGConnection conn, long oid) throws java.sql.SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc2/Jdbc2Clob.java b/org/postgresql/jdbc2/Jdbc2Clob.java
index 1572ba0..e46f002 100644
--- a/org/postgresql/jdbc2/Jdbc2Clob.java
+++ b/org/postgresql/jdbc2/Jdbc2Clob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2Clob.java,v 1.3 2004/11/09 08:49:10 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2Clob.java,v 1.4 2005/01/11 08:25:46 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -13,7 +13,7 @@ package org.postgresql.jdbc2;
 public class Jdbc2Clob extends AbstractJdbc2Clob implements java.sql.Clob
 {
 
-    public Jdbc2Clob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
+    public Jdbc2Clob(org.postgresql.PGConnection conn, long oid) throws java.sql.SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc2/Jdbc2ResultSet.java b/org/postgresql/jdbc2/Jdbc2ResultSet.java
index b42a054..5911a49 100644
--- a/org/postgresql/jdbc2/Jdbc2ResultSet.java
+++ b/org/postgresql/jdbc2/Jdbc2ResultSet.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java,v 1.15 2004/12/17 21:24:29 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java,v 1.16 2005/01/11 08:25:46 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -41,7 +41,7 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
         if (wasNullFlag)
             return null;
 
-        return new org.postgresql.jdbc2.Jdbc2Clob(connection, getInt(i));
+        return new org.postgresql.jdbc2.Jdbc2Clob(connection, getLong(i));
     }
 
     public java.sql.Blob getBlob(int i) throws SQLException
@@ -51,7 +51,7 @@ public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
         if (wasNullFlag)
             return null;
 
-        return new org.postgresql.jdbc2.Jdbc2Blob(connection, getInt(i));
+        return new org.postgresql.jdbc2.Jdbc2Blob(connection, getLong(i));
     }
 
     public java.sql.Array createArray(int i) throws SQLException
diff --git a/org/postgresql/jdbc3/AbstractJdbc3Blob.java b/org/postgresql/jdbc3/AbstractJdbc3Blob.java
index 04cb070..629bafa 100644
--- a/org/postgresql/jdbc3/AbstractJdbc3Blob.java
+++ b/org/postgresql/jdbc3/AbstractJdbc3Blob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java,v 1.7 2005/03/28 08:52:35 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Blob.java,v 1.8 2005/05/08 23:18:24 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -17,7 +17,7 @@ import org.postgresql.largeobject.LargeObject;
 public abstract class AbstractJdbc3Blob extends org.postgresql.jdbc2.AbstractJdbc2Blob
 {
 
-    public AbstractJdbc3Blob(org.postgresql.PGConnection conn, int oid) throws SQLException
+    public AbstractJdbc3Blob(org.postgresql.PGConnection conn, long oid) throws SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc3/AbstractJdbc3Clob.java b/org/postgresql/jdbc3/AbstractJdbc3Clob.java
index bf13b88..429fc19 100644
--- a/org/postgresql/jdbc3/AbstractJdbc3Clob.java
+++ b/org/postgresql/jdbc3/AbstractJdbc3Clob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java,v 1.5 2005/01/11 08:25:46 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/AbstractJdbc3Clob.java,v 1.6 2005/02/15 08:56:26 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -15,7 +15,7 @@ import java.sql.*;
 public abstract class AbstractJdbc3Clob extends org.postgresql.jdbc2.AbstractJdbc2Clob
 {
 
-    public AbstractJdbc3Clob(org.postgresql.PGConnection conn, int oid) throws SQLException
+    public AbstractJdbc3Clob(org.postgresql.PGConnection conn, long oid) throws SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc3/Jdbc3Blob.java b/org/postgresql/jdbc3/Jdbc3Blob.java
index c26a5a8..37f761e 100644
--- a/org/postgresql/jdbc3/Jdbc3Blob.java
+++ b/org/postgresql/jdbc3/Jdbc3Blob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3Blob.java,v 1.3 2004/11/09 08:50:11 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3Blob.java,v 1.4 2005/01/11 08:25:46 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -15,7 +15,7 @@ import java.sql.*;
 public class Jdbc3Blob extends org.postgresql.jdbc3.AbstractJdbc3Blob implements java.sql.Blob
 {
 
-    public Jdbc3Blob(org.postgresql.PGConnection conn, int oid) throws SQLException
+    public Jdbc3Blob(org.postgresql.PGConnection conn, long oid) throws SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc3/Jdbc3Clob.java b/org/postgresql/jdbc3/Jdbc3Clob.java
index de82abf..005f4a9 100644
--- a/org/postgresql/jdbc3/Jdbc3Clob.java
+++ b/org/postgresql/jdbc3/Jdbc3Clob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3Clob.java,v 1.3 2004/11/09 08:50:21 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3Clob.java,v 1.4 2005/01/11 08:25:46 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -13,7 +13,7 @@ package org.postgresql.jdbc3;
 public class Jdbc3Clob extends org.postgresql.jdbc3.AbstractJdbc3Clob implements java.sql.Clob
 {
 
-    public Jdbc3Clob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
+    public Jdbc3Clob(org.postgresql.PGConnection conn, long oid) throws java.sql.SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc3/Jdbc3ResultSet.java b/org/postgresql/jdbc3/Jdbc3ResultSet.java
index 72eaea3..f1db9c7 100644
--- a/org/postgresql/jdbc3/Jdbc3ResultSet.java
+++ b/org/postgresql/jdbc3/Jdbc3ResultSet.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java,v 1.12 2004/12/17 21:24:30 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java,v 1.13 2005/01/11 08:25:47 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -41,7 +41,7 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
         if (wasNullFlag)
             return null;
 
-        return new Jdbc3Clob(connection, getInt(i));
+        return new Jdbc3Clob(connection, getLong(i));
     }
 
     public java.sql.Blob getBlob(int i) throws SQLException
@@ -51,7 +51,7 @@ public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
         if (wasNullFlag)
             return null;
 
-        return new Jdbc3Blob(connection, getInt(i));
+        return new Jdbc3Blob(connection, getLong(i));
     }
 
     public Array createArray(int i) throws SQLException
diff --git a/org/postgresql/jdbc3g/Jdbc3gBlob.java b/org/postgresql/jdbc3g/Jdbc3gBlob.java
index bc73e32..1ff7dfb 100644
--- a/org/postgresql/jdbc3g/Jdbc3gBlob.java
+++ b/org/postgresql/jdbc3g/Jdbc3gBlob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gBlob.java,v 1.3 2004/11/09 08:51:22 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gBlob.java,v 1.4 2005/01/11 08:25:47 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -15,7 +15,7 @@ import java.sql.*;
 public class Jdbc3gBlob extends org.postgresql.jdbc3.AbstractJdbc3Blob implements java.sql.Blob
 {
 
-    public Jdbc3gBlob(org.postgresql.PGConnection conn, int oid) throws SQLException
+    public Jdbc3gBlob(org.postgresql.PGConnection conn, long oid) throws SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc3g/Jdbc3gClob.java b/org/postgresql/jdbc3g/Jdbc3gClob.java
index c71bbd8..8ab1ba2 100644
--- a/org/postgresql/jdbc3g/Jdbc3gClob.java
+++ b/org/postgresql/jdbc3g/Jdbc3gClob.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gClob.java,v 1.3 2004/11/09 08:51:22 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gClob.java,v 1.4 2005/01/11 08:25:47 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -13,7 +13,7 @@ package org.postgresql.jdbc3g;
 public class Jdbc3gClob extends org.postgresql.jdbc3.AbstractJdbc3Clob implements java.sql.Clob
 {
 
-    public Jdbc3gClob(org.postgresql.PGConnection conn, int oid) throws java.sql.SQLException
+    public Jdbc3gClob(org.postgresql.PGConnection conn, long oid) throws java.sql.SQLException
     {
         super(conn, oid);
     }
diff --git a/org/postgresql/jdbc3g/Jdbc3gResultSet.java b/org/postgresql/jdbc3g/Jdbc3gResultSet.java
index 5d8c41d..9e116bb 100644
--- a/org/postgresql/jdbc3g/Jdbc3gResultSet.java
+++ b/org/postgresql/jdbc3g/Jdbc3gResultSet.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gResultSet.java,v 1.4 2004/12/17 21:24:30 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc3g/Jdbc3gResultSet.java,v 1.5 2005/01/11 08:25:47 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -41,7 +41,7 @@ public class Jdbc3gResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
         if (wasNullFlag)
             return null;
 
-        return new Jdbc3gClob(connection, getInt(i));
+        return new Jdbc3gClob(connection, getLong(i));
     }
 
     public java.sql.Blob getBlob(int i) throws SQLException
@@ -51,7 +51,7 @@ public class Jdbc3gResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet
         if (wasNullFlag)
             return null;
 
-        return new Jdbc3gBlob(connection, getInt(i));
+        return new Jdbc3gBlob(connection, getLong(i));
     }
 
     public Array createArray(int i) throws SQLException
diff --git a/org/postgresql/largeobject/LargeObject.java b/org/postgresql/largeobject/LargeObject.java
index 50561b9..2ede2be 100644
--- a/org/postgresql/largeobject/LargeObject.java
+++ b/org/postgresql/largeobject/LargeObject.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/largeobject/LargeObject.java,v 1.16 2005/01/11 08:25:47 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/largeobject/LargeObject.java,v 1.17 2005/01/14 01:20:22 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -61,7 +61,7 @@ public class LargeObject
     public static final int SEEK_END = 2;
 
     private Fastpath fp; // Fastpath API to use
-    private int oid; // OID of this object
+    private long oid; // OID of this object
     private int fd; // the descriptor of the open large object
 
     private BlobOutputStream os;  // The current output stream
@@ -80,13 +80,13 @@ public class LargeObject
      * @exception SQLException if a database-access error occurs.
      * @see org.postgresql.largeobject.LargeObjectManager
      */
-    protected LargeObject(Fastpath fp, int oid, int mode) throws SQLException
+    protected LargeObject(Fastpath fp, long oid, int mode) throws SQLException
     {
         this.fp = fp;
         this.oid = oid;
 
         FastpathArg args[] = new FastpathArg[2];
-        args[0] = new FastpathArg(oid);
+        args[0] = Fastpath.createOIDArg(oid);
         args[1] = new FastpathArg(mode);
         this.fd = fp.getInteger("lo_open", args);
     }
@@ -104,9 +104,18 @@ public class LargeObject
 
     /**
      * @return the OID of this LargeObject
+     * @deprecated As of 8.3, replaced by {@link #getLongOID()}
      */
     public int getOID()
     {
+        return (int)oid;
+    }
+
+    /**
+     * @return the OID of this LargeObject
+     */
+    public long getLongOID()
+    {
         return oid;
     }
 
diff --git a/org/postgresql/largeobject/LargeObjectManager.java b/org/postgresql/largeobject/LargeObjectManager.java
index 4fa5a9e..ea1db89 100644
--- a/org/postgresql/largeobject/LargeObjectManager.java
+++ b/org/postgresql/largeobject/LargeObjectManager.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/largeobject/LargeObjectManager.java,v 1.18 2005/01/11 08:25:47 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/largeobject/LargeObjectManager.java,v 1.19 2005/01/14 01:20:22 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -152,9 +152,23 @@ public class LargeObjectManager
      * @param oid of large object
      * @return LargeObject instance providing access to the object
      * @exception SQLException on error
+     * @deprecated As of 8.3, replaced by {@link #open(long)}
      */
     public LargeObject open(int oid) throws SQLException
     {
+        return open((long)oid);
+    }
+
+    /**
+     * This opens an existing large object, based on its OID. This method
+     * assumes that READ and WRITE access is required (the default).
+     *
+     * @param oid of large object
+     * @return LargeObject instance providing access to the object
+     * @exception SQLException on error
+     */
+    public LargeObject open(long oid) throws SQLException
+    {
         return open(oid, READWRITE);
     }
 
@@ -165,9 +179,23 @@ public class LargeObjectManager
      * @param mode mode of open
      * @return LargeObject instance providing access to the object
      * @exception SQLException on error
+     * @deprecated As of 8.3, replaced by {@link #open(long, int)}
      */
     public LargeObject open(int oid, int mode) throws SQLException
     {
+        return open((long)oid, mode);
+    }
+
+    /**
+     * This opens an existing large object, based on its OID
+     *
+     * @param oid of large object
+     * @param mode mode of open
+     * @return LargeObject instance providing access to the object
+     * @exception SQLException on error
+     */
+    public LargeObject open(long oid, int mode) throws SQLException
+    {
         if (conn.getAutoCommit())
             throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."),
                                     PSQLState.NO_ACTIVE_SQL_TRANSACTION);
@@ -181,6 +209,7 @@ public class LargeObjectManager
      *
      * @return oid of new object
      * @exception SQLException on error
+     * @deprecated As of 8.3, replaced by {@link #createLO()}
      */
     public int create() throws SQLException
     {
@@ -188,20 +217,46 @@ public class LargeObjectManager
     }
 
     /**
+     * This creates a large object, returning its OID.
+     *
+     * <p>It defaults to READWRITE for the new object's attributes.
+     *
+     * @return oid of new object
+     */
+    public long createLO() throws SQLException
+    {
+        return createLO(READWRITE);
+    }
+
+    /**
      * This creates a large object, returning its OID
      *
      * @param mode a bitmask describing different attributes of the new object
      * @return oid of new object
      * @exception SQLException on error
      */
-    public int create(int mode) throws SQLException
+    public long createLO(int mode) throws SQLException
     {
         if (conn.getAutoCommit())
             throw new PSQLException(GT.tr("Large Objects may not be used in auto-commit mode."),
                                     PSQLState.NO_ACTIVE_SQL_TRANSACTION);
         FastpathArg args[] = new FastpathArg[1];
         args[0] = new FastpathArg(mode);
-        return fp.getInteger("lo_creat", args);
+        return fp.getOID("lo_creat", args);
+    }
+
+    /**
+     * This creates a large object, returning its OID
+     *
+     * @param mode a bitmask describing different attributes of the new object
+     * @return oid of new object
+     * @exception SQLException on error
+     * @deprecated As of 8.3, replaced by {@link #createLO(int)}
+     */
+    public int create(int mode) throws SQLException
+    {
+        long oid = createLO(mode);
+        return (int)oid;
     }
 
     /**
@@ -210,10 +265,10 @@ public class LargeObjectManager
      * @param oid describing object to delete
      * @exception SQLException on error
      */
-    public void delete(int oid) throws SQLException
+    public void delete(long oid) throws SQLException
     {
         FastpathArg args[] = new FastpathArg[1];
-        args[0] = new FastpathArg(oid);
+        args[0] = Fastpath.createOIDArg(oid);
         fp.fastpath("lo_unlink", false, args);
     }
 
@@ -225,10 +280,37 @@ public class LargeObjectManager
      *
      * @param oid describing object to delete
      * @exception SQLException on error
+     * @deprecated As of 8.3, replaced by {@link #unlink(long)}
      */
     public void unlink(int oid) throws SQLException
     {
+        delete((long)oid);
+    }
+
+    /**
+     * This deletes a large object.
+     *
+     * <p>It is identical to the delete method, and is supplied as the C API uses
+     * unlink.
+     *
+     * @param oid describing object to delete
+     * @exception SQLException on error
+     */
+    public void unlink(long oid) throws SQLException
+    {
         delete(oid);
     }
 
+    /**
+     * This deletes a large object.
+     *
+     * @param oid describing object to delete
+     * @exception SQLException on error
+     * @deprecated As of 8.3, replaced by {@link #delete(long)}
+     */
+    public void delete(int oid) throws SQLException
+    {
+        delete((long)oid);
+    }
+
 }
diff --git a/org/postgresql/test/jdbc2/BlobTest.java b/org/postgresql/test/jdbc2/BlobTest.java
index ed005f4..99f0682 100644
--- a/org/postgresql/test/jdbc2/BlobTest.java
+++ b/org/postgresql/test/jdbc2/BlobTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/BlobTest.java,v 1.17 2005/09/29 20:49:23 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/BlobTest.java,v 1.18 2005/10/03 17:27:33 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -158,13 +158,13 @@ public class BlobTest extends TestCase
      * because it always works, and we can use it as a base to test the new
      * methods.
      */
-    private int uploadFile(String file, int method) throws Exception
+    private long uploadFile(String file, int method) throws Exception
     {
         LargeObjectManager lom = ((org.postgresql.PGConnection)con).getLargeObjectAPI();
 
         FileInputStream fis = new FileInputStream(file);
 
-        int oid = lom.create(LargeObjectManager.READWRITE);
+        long oid = lom.createLO(LargeObjectManager.READWRITE);
         LargeObject blob = lom.open(oid);
 
         int s, t;
@@ -227,7 +227,7 @@ public class BlobTest extends TestCase
         while (rs.next())
         {
             String file = rs.getString(1);
-            int oid = rs.getInt(2);
+            long oid = rs.getLong(2);
 
             FileInputStream fis = new FileInputStream(file);
             LargeObject blob = lom.open(oid);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list