1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

This patch fixes a bug introduced in the jdbc bytea support patch.

That patch broke the ability to read data from binary cursors.
--Barry Lind
 Modified Files:
 	pgsql/src/interfaces/jdbc/org/postgresql/Connection.java
 	pgsql/src/interfaces/jdbc/org/postgresql/ResultSet.java
 	pgsql/src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java
 	pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Connection.java
 	pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
 	pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Connection.java
 	pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java
 	pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/UpdateableResultSet.java
This commit is contained in:
Barry Lind
2001-10-09 20:47:35 +00:00
parent ffb8f73890
commit 839b9bc011
8 changed files with 446 additions and 437 deletions

View File

@ -17,7 +17,7 @@ import org.postgresql.largeobject.*;
import org.postgresql.util.*;
/**
* $Id: Connection.java,v 1.12 2001/09/10 15:07:05 momjian Exp $
* $Id: Connection.java,v 1.13 2001/10/09 20:47:35 barry Exp $
*
* A Connection represents a session with a specific database. Within the
* context of a Connection, SQL statements are executed and results are
@ -204,16 +204,16 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
* This overides the method in org.postgresql.Connection and returns a
* ResultSet.
*/
public java.sql.ResultSet getResultSet(org.postgresql.Connection conn, java.sql.Statement stat,Field[] fields, Vector tuples, String status, int updateCount, int insertOID) throws SQLException
public 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
{
// In 7.1 we now test concurrency to see which class to return. If we are not working with a
// Statement then default to a normal ResultSet object.
if(stat!=null) {
if(stat.getResultSetConcurrency()==java.sql.ResultSet.CONCUR_UPDATABLE)
return new org.postgresql.jdbc2.UpdateableResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID);
return new org.postgresql.jdbc2.UpdateableResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID,binaryCursor);
}
return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID);
return new org.postgresql.jdbc2.ResultSet((org.postgresql.jdbc2.Connection)conn,fields,tuples,status,updateCount,insertOID,binaryCursor);
}
// *****************
@ -296,9 +296,9 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
"date",
"time",
"abstime","timestamp",
"_bool", "_char", "_int2", "_int4", "_text",
"_oid", "_varchar", "_int8", "_float4", "_float8",
"_abstime", "_date", "_time", "_timestamp", "_numeric",
"_bool", "_char", "_int2", "_int4", "_text",
"_oid", "_varchar", "_int8", "_float4", "_float8",
"_abstime", "_date", "_time", "_timestamp", "_numeric",
"_bytea"
};
@ -324,8 +324,8 @@ public class Connection extends org.postgresql.Connection implements java.sql.Co
Types.DATE,
Types.TIME,
Types.TIMESTAMP,Types.TIMESTAMP,
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY, Types.ARRAY,
Types.ARRAY
};

View File

@ -74,9 +74,9 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
* @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)
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID, boolean binaryCursor)
{
super(conn,fields,tuples,status,updateCount,insertOID);
super(conn,fields,tuples,status,updateCount,insertOID,binaryCursor);
}
/**
@ -90,10 +90,10 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
* @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)
{
super(conn,fields,tuples,status,updateCount,0);
}
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
{
super(conn,fields,tuples,status,updateCount,0,false);
}
/**
* A ResultSet is initially positioned before its first row,
@ -313,6 +313,9 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
if (columnIndex < 1 || columnIndex > fields.length)
throw new PSQLException("postgresql.res.colrange");
//If the data is already binary then just return it
if (binaryCursor) return this_row[columnIndex - 1];
if (connection.haveMinimumCompatibleVersion("7.2")) {
//Version 7.2 supports the bytea datatype for byte arrays
return PGbytea.toBytes(getString(columnIndex));

View File

@ -40,9 +40,9 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
* @param updateCount the number of rows affected by the operation
* @param cursor the positioned update/delete cursor name
*/
public UpdateableResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID)
public UpdateableResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount,int insertOID, boolean binaryCursor)
{
super(conn,fields,tuples,status,updateCount,insertOID);
super(conn,fields,tuples,status,updateCount,insertOID,binaryCursor);
}
/**
@ -56,10 +56,10 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
* @param updateCount the number of rows affected by the operation
* @param cursor the positioned update/delete cursor name
*/
public UpdateableResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
{
super(conn,fields,tuples,status,updateCount,0);
}
// public UpdateableResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
// {
// super(conn,fields,tuples,status,updateCount,0,false);
//}
public void cancelRowUpdates() throws SQLException
{
@ -77,7 +77,7 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
{
// New in 7.1 - The updateable ResultSet class will now return
// CONCUR_UPDATEABLE.
return CONCUR_UPDATABLE;
return CONCUR_UPDATABLE;
}
public void insertRow() throws SQLException
@ -120,26 +120,26 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
}
public void updateAsciiStream(int columnIndex,
java.io.InputStream x,
int length
) throws SQLException
java.io.InputStream x,
int length
) throws SQLException
{
// only sub-classes implement CONCUR_UPDATEABLE
throw org.postgresql.Driver.notImplemented();
}
public void updateBigDecimal(int columnIndex,
java.math.BigDecimal x
) throws SQLException
java.math.BigDecimal x
) throws SQLException
{
// only sub-classes implement CONCUR_UPDATEABLE
throw org.postgresql.Driver.notImplemented();
}
public void updateBinaryStream(int columnIndex,
java.io.InputStream x,
int length
) throws SQLException
java.io.InputStream x,
int length
) throws SQLException
{
// only sub-classes implement CONCUR_UPDATEABLE
throw org.postgresql.Driver.notImplemented();
@ -164,9 +164,9 @@ public class UpdateableResultSet extends org.postgresql.jdbc2.ResultSet
}
public void updateCharacterStream(int columnIndex,
java.io.Reader x,
int length
) throws SQLException
java.io.Reader x,
int length
) throws SQLException
{
// only sub-classes implement CONCUR_UPDATEABLE
throw org.postgresql.Driver.notImplemented();