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:
parent
ffb8f73890
commit
839b9bc011
@ -11,7 +11,7 @@ import org.postgresql.util.*;
|
||||
import org.postgresql.core.*;
|
||||
|
||||
/**
|
||||
* $Id: Connection.java,v 1.29 2001/09/10 15:07:05 momjian Exp $
|
||||
* $Id: Connection.java,v 1.30 2001/10/09 20:47:35 barry Exp $
|
||||
*
|
||||
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
|
||||
* JDBC2 versions of the Connection class.
|
||||
@ -639,7 +639,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) throws SQLException;
|
||||
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;
|
||||
|
||||
/**
|
||||
* In some cases, it is desirable to immediately release a Connection's
|
||||
|
@ -18,6 +18,7 @@ public abstract class ResultSet
|
||||
protected Vector rows; // The results
|
||||
protected Field fields[]; // The field descriptions
|
||||
protected String status; // Status of the result
|
||||
protected boolean binaryCursor = false; // is the data binary or Strings
|
||||
protected int updateCount; // How many rows did we get back?
|
||||
protected int insertOID; // The oid of an inserted row
|
||||
protected int current_row; // Our pointer to where we are at
|
||||
@ -41,7 +42,7 @@ public abstract class ResultSet
|
||||
* @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)
|
||||
{
|
||||
this.connection = conn;
|
||||
this.fields = fields;
|
||||
@ -51,6 +52,7 @@ public abstract class ResultSet
|
||||
this.insertOID = insertOID;
|
||||
this.this_row = null;
|
||||
this.current_row = -1;
|
||||
this.binaryCursor = binaryCursor;
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +69,7 @@ public abstract class ResultSet
|
||||
*/
|
||||
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
|
||||
{
|
||||
this(conn,fields,tuples,status,updateCount,0);
|
||||
this(conn,fields,tuples,status,updateCount,0,false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
|
||||
* <p>The lifetime of a QueryExecutor object is from sending the query
|
||||
* until the response has been received from the backend.
|
||||
*
|
||||
* $Id: QueryExecutor.java,v 1.1 2001/09/06 03:58:59 momjian Exp $
|
||||
* $Id: QueryExecutor.java,v 1.2 2001/10/09 20:47:35 barry Exp $
|
||||
*/
|
||||
|
||||
public class QueryExecutor {
|
||||
@ -42,6 +42,7 @@ public class QueryExecutor {
|
||||
|
||||
private Field[] fields = null;
|
||||
private Vector tuples = new Vector();
|
||||
private boolean binaryCursor = false;
|
||||
private String status = null;
|
||||
private int update_count = 1;
|
||||
private int insert_oid = 0;
|
||||
@ -112,8 +113,7 @@ public class QueryExecutor {
|
||||
new Character((char) c));
|
||||
}
|
||||
}
|
||||
|
||||
return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid);
|
||||
return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid, binaryCursor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,6 +141,7 @@ public class QueryExecutor {
|
||||
if (fields == null)
|
||||
throw new PSQLException("postgresql.con.tuple");
|
||||
Object tuple = pg_stream.ReceiveTuple(fields.length, isBinary);
|
||||
if (isBinary) binaryCursor = true;
|
||||
if (maxRows == 0 || tuples.size() < maxRows)
|
||||
tuples.addElement(tuple);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import org.postgresql.largeobject.*;
|
||||
import org.postgresql.util.*;
|
||||
|
||||
/**
|
||||
* $Id: Connection.java,v 1.10 2001/09/10 15:07:05 momjian Exp $
|
||||
* $Id: Connection.java,v 1.11 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
|
||||
@ -131,10 +131,10 @@ 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 jdbc1 stat is ignored.
|
||||
return new org.postgresql.jdbc1.ResultSet((org.postgresql.jdbc1.Connection)conn,fields,tuples,status,updateCount,insertOID);
|
||||
return new org.postgresql.jdbc1.ResultSet((org.postgresql.jdbc1.Connection)conn,fields,tuples,status,updateCount,insertOID,binaryCursor);
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,9 +70,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,7 +88,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
||||
*/
|
||||
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
|
||||
{
|
||||
super(conn,fields,tuples,status,updateCount,0);
|
||||
super(conn,fields,tuples,status,updateCount,0,false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -375,6 +375,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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
// *****************
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -92,7 +92,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
||||
*/
|
||||
public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
|
||||
{
|
||||
super(conn,fields,tuples,status,updateCount,0);
|
||||
super(conn,fields,tuples,status,updateCount,0,false);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -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));
|
||||
|
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user