the V3 protocol.
Modified Files:
Tag: REL7_4_STABLE
jdbc/org/postgresql/Driver.java.in
jdbc/org/postgresql/core/BaseResultSet.java
jdbc/org/postgresql/core/BaseStatement.java
jdbc/org/postgresql/core/Field.java
jdbc/org/postgresql/core/PGStream.java
jdbc/org/postgresql/core/QueryExecutor.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
jdbc/org/postgresql/jdbc1/Jdbc1CallableStatement.java
jdbc/org/postgresql/jdbc1/Jdbc1PreparedStatement.java
jdbc/org/postgresql/jdbc1/Jdbc1RefCursorResultSet.java
jdbc/org/postgresql/jdbc1/Jdbc1ResultSet.java
jdbc/org/postgresql/jdbc1/Jdbc1Statement.java
jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/Array.java
jdbc/org/postgresql/jdbc2/Jdbc2CallableStatement.java
jdbc/org/postgresql/jdbc2/Jdbc2PreparedStatement.java
jdbc/org/postgresql/jdbc2/Jdbc2RefCursorResultSet.java
jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java
jdbc/org/postgresql/jdbc2/Jdbc2Statement.java
jdbc/org/postgresql/jdbc3/AbstractJdbc3ResultSet.java
jdbc/org/postgresql/jdbc3/Jdbc3CallableStatement.java
jdbc/org/postgresql/jdbc3/Jdbc3PreparedStatement.java
jdbc/org/postgresql/jdbc3/Jdbc3RefCursorResultSet.java
jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java
jdbc/org/postgresql/jdbc3/Jdbc3Statement.java
jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java
jdbc/org/postgresql/test/jdbc2/OID74Test.java
Added Files:
Tag: REL7_4_STABLE
jdbc/org/postgresql/test/jdbc2/ServerCursorTest.java
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.36.2.3 2004/03/04 03:25:10 jurka Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/Driver.java.in,v 1.36.2.4 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
//The build number should be incremented for every new build
- private static int m_buildNumber = 212;
+ private static int m_buildNumber = 213;
}
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseResultSet.java,v 1.2 2003/03/08 06:06:55 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseResultSet.java,v 1.2.4.1 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
public boolean next() throws SQLException;
public boolean reallyResultSet();
public void reInit (Field[] fields, Vector tuples, String status,
- int updateCount, long insertOID, boolean binaryCursor);
+ int updateCount, long insertOID);
public void setStatement(BaseStatement statement);
}
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.6 2003/10/29 02:39:09 davec Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseStatement.java,v 1.6.2.1 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
public interface BaseStatement extends org.postgresql.PGStatement
{
- public BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
+ public BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException;
public PGRefCursorResultSet createRefCursorResultSet(String cursorName) throws SQLException;
public BaseConnection getPGConnection();
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.2 2003/05/29 03:21:32 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.2.4.1 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
*/
public class Field
{
+ //Constants for the two V3 protocol data formats
+ public static final int TEXT_FORMAT = 0;
+ public static final int BINARY_FORMAT = 1;
+
private int length; // Internal Length of this field
private int oid; // OID of the type
private int mod; // type modifier of this field
private String name; // Name of this field
+ private int format = TEXT_FORMAT; // In the V3 protocol each field has a format
+ // 0 = text, 1 = binary
+ // In the V2 protocol all fields in a
+ // binary cursor are binary and all
+ // others are text
private BaseConnection conn; // Connection Instantation
return length;
}
+ /*
+ * @return the format of this Field's data (text=0, binary=1)
+ */
+ public int getFormat()
+ {
+ return format;
+ }
+
+ /*
+ * @param format the format of this Field's data (text=0, binary=1)
+ */
+ public void setFormat(int format)
+ {
+ this.format = format;
+ }
+
/*
* We also need to get the PG type name as returned by the back end.
*
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.3 2003/09/08 17:30:22 barry Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.3.2.1 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
* array of bytes
*
* @param nf the number of fields expected
- * @param bin true if the tuple is a binary tuple
* @return null if the current response has no more tuples, otherwise
* an array of strings
* @exception SQLException if a data I/O error occurs
*/
- public byte[][] ReceiveTupleV3(int nf, boolean bin) throws SQLException
+ public byte[][] ReceiveTupleV3(int nf) throws SQLException
{
//TODO: use l_msgSize
int l_msgSize = ReceiveIntegerR(4);
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.27.2.1 2004/02/03 05:43:22 jurka Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/QueryExecutor.java,v 1.27.2.2 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
private Field[] fields = null;
private Vector tuples = new Vector();
- private boolean binaryCursor = false;
private String status = null;
private int update_count = 1;
private long insert_oid = 0;
String param = pgStream.ReceiveString(connection.getEncoding());
connection.addNotification(new org.postgresql.core.Notification(msg, pid));
break;
- case 'B': // Binary Data Transfer
- receiveTupleV3(true);
- break;
case 'C': // Command Status
receiveCommandStatusV3();
break;
- case 'D': // Text Data Transfer
- receiveTupleV3(false);
+ case 'D': // Data Transfer
+ receiveTupleV3();
break;
case 'E': // Error Message
//create a new one
if (rs != null)
{
- rs.reInit(fields, tuples, status, update_count, insert_oid, binaryCursor);
+ rs.reInit(fields, tuples, status, update_count, insert_oid);
}
else
{
- rs = statement.createResultSet(fields, tuples, status, update_count, insert_oid, binaryCursor);
+ rs = statement.createResultSet(fields, tuples, status, update_count, insert_oid);
}
return rs;
}
//create a new one
if (rs != null)
{
- rs.reInit(fields, tuples, status, update_count, insert_oid, binaryCursor);
+ rs.reInit(fields, tuples, status, update_count, insert_oid);
}
else
{
- rs = statement.createResultSet(fields, tuples, status, update_count, insert_oid, binaryCursor);
+ rs = statement.createResultSet(fields, tuples, status, update_count, insert_oid);
}
return rs;
}
/*
* Receive a tuple from the backend.
- *
- * @param isBinary set if the tuple should be treated as binary data
*/
- private void receiveTupleV3(boolean isBinary) throws SQLException
+ private void receiveTupleV3() throws SQLException
{
if (fields == null)
throw new PSQLException("postgresql.con.tuple", PSQLState.CONNECTION_FAILURE);
- Object tuple = pgStream.ReceiveTupleV3(fields.length, isBinary);
- if (isBinary)
- binaryCursor = true;
+ Object tuple = pgStream.ReceiveTupleV3(fields.length);
if (maxRows == 0 || tuples.size() < maxRows)
tuples.addElement(tuple);
}
if (fields == null)
throw new PSQLException("postgresql.con.tuple", PSQLState.CONNECTION_FAILURE);
Object tuple = pgStream.ReceiveTupleV2(fields.length, isBinary);
- if (isBinary)
- binaryCursor = true;
+ if (isBinary) {
+ for (int i = 0; i < fields.length; i++) {
+ fields[i].setFormat(Field.BINARY_FORMAT); //Set the field to binary format
+ }
+ }
if (maxRows == 0 || tuples.size() < maxRows)
tuples.addElement(tuple);
}
int formatType = pgStream.ReceiveIntegerR(2);
//TODO: use the extra values coming back
fields[i] = new Field(connection, typeName, typeOid, typeLength, typeModifier);
+ fields[i].setFormat(formatType);
}
}
/*
}
rs.close();
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
v.addElement(tuple);
}
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
}
rs.close();
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
}
rs.close();
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
}
rs.close();
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
private static void sortStringArray(String s[]) {
v.addElement(tuple);
}
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
/* Perhaps we should check that the given
* catalog.schema.table actually exists. -KJ
*/
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
tuples.addElement(tuple);
}
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, tuples, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, tuples, "OK", 1, 0);
}
/*
}
rs.close();
- return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0, false);
+ return (ResultSet) ((BaseStatement)connection.createStatement()).createResultSet(f, v, "OK", 1, 0);
}
/*
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.22.2.2 2004/02/03 05:25:36 jurka Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.22.2.3 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
protected BaseStatement statement;
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 long insertOID; // The oid of an inserted row
protected int current_row; // Our pointer to where we are at
Vector tuples,
String status,
int updateCount,
- long insertOID,
- boolean binaryCursor)
+ long insertOID)
{
this.connection = statement.getPGConnection();
this.statement = statement;
this.insertOID = insertOID;
this.this_row = null;
this.current_row = -1;
- this.binaryCursor = binaryCursor;
this.lastFetchSize = this.fetchSize = (statement == null ? 0 : statement.getFetchSize());
}
//method to reinitialize a result set with more data
public void reInit (Field[] fields, Vector tuples, String status,
- int updateCount, long insertOID, boolean binaryCursor)
+ int updateCount, long insertOID)
{
this.fields = fields;
// on a reinit the size of this indicates how many we pulled
this.insertOID = insertOID;
this.this_row = null;
this.current_row = -1;
- this.binaryCursor = binaryCursor;
}
//
wasNullFlag = (this_row[columnIndex - 1] == null);
if (!wasNullFlag)
{
- if (binaryCursor)
+ if (fields[columnIndex -1].getFormat() == Field.BINARY_FORMAT)
{
//If the data is already binary then just return it
return this_row[columnIndex - 1];
import java.sql.Types;
import java.util.Vector;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.41.2.4 2004/02/24 13:11:44 jurka Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.41.2.5 2004/03/29 17:47:47 barry Exp $
* This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
protected Object callResult;
protected int maxfieldSize = 0;
- public abstract BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException;
+ public abstract BaseResultSet createResultSet(Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException;
public AbstractJdbc1Statement (BaseConnection connection)
{
super(connection, sql);
}
- public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
super(connection, sql);
}
- public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
Jdbc1RefCursorResultSet(BaseStatement statement, String refCursorName)
{
- super(statement, null, null, null, -1, 0L, false);
+ super(statement, null, null, null, -1, 0L);
this.refCursorHandle = refCursorName;
}
import org.postgresql.core.BaseStatement;
import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.6 2003/03/07 18:39:44 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1ResultSet.java,v 1.6.4.1 2004/03/29 17:47:47 barry Exp $
* This class implements the java.sql.ResultSet interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1ResultSet
public class Jdbc1ResultSet extends org.postgresql.jdbc1.AbstractJdbc1ResultSet implements java.sql.ResultSet
{
- public Jdbc1ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public Jdbc1ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID)
{
- super(statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ super(statement, fields, tuples, status, updateCount, insertOID);
}
public java.sql.ResultSetMetaData getMetaData() throws SQLException
import org.postgresql.core.BaseResultSet;
import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.6 2003/05/03 20:40:45 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/Jdbc1Statement.java,v 1.6.4.1 2004/03/29 17:47:47 barry Exp $
* This class implements the java.sql.Statement interface for JDBC1.
* However most of the implementation is really done in
* org.postgresql.jdbc1.AbstractJdbc1Statement
super(c);
}
- public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc1ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
* Copyright (c) 2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.25.2.3 2004/02/03 05:25:37 jurka Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/AbstractJdbc2ResultSet.java,v 1.25.2.4 2004/03/29 17:47:47 barry Exp $
*
*-------------------------------------------------------------------------
*/
private PreparedStatement selectStatement = null;
- public AbstractJdbc2ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public AbstractJdbc2ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID)
{
- super (statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ super (statement, fields, tuples, status, updateCount, insertOID);
}
public java.net.URL getURL(int columnIndex) throws SQLException
throw org.postgresql.Driver.notImplemented();
}
BaseStatement stat = (BaseStatement) conn.createStatement();
- return (ResultSet) stat.createResultSet(fields, rows, "OK", 1, 0, false);
+ return (ResultSet) stat.createResultSet(fields, rows, "OK", 1, 0);
}
public String toString()
super(connection, sql);
}
- public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
super(connection, sql);
}
- public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
Jdbc2RefCursorResultSet(BaseStatement statement, String refCursorName) throws java.sql.SQLException
{
- super(statement, null, null, null, -1, 0L, false);
+ super(statement, null, null, null, -1, 0L);
this.refCursorHandle = refCursorName;
}
import org.postgresql.core.BaseStatement;
import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.8 2003/03/07 18:39:45 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2ResultSet.java,v 1.8.4.1 2004/03/29 17:47:47 barry Exp $
* This class implements the java.sql.ResultSet interface for JDBC2.
* However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2ResultSet or one of it's parents
public class Jdbc2ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet implements java.sql.ResultSet
{
- public Jdbc2ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public Jdbc2ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID)
{
- super(statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ super(statement, fields, tuples, status, updateCount, insertOID);
}
public ResultSetMetaData getMetaData() throws SQLException
import org.postgresql.core.BaseResultSet;
import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.6 2003/05/03 20:40:45 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc2/Attic/Jdbc2Statement.java,v 1.6.4.1 2004/03/29 17:47:47 barry Exp $
* This class implements the java.sql.Statement interface for JDBC2.
* However most of the implementation is really done in
* org.postgresql.jdbc2.AbstractJdbc2Statement or one of it's parents
super(c);
}
- public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc2ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.4 2003/03/07 18:39:45 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/AbstractJdbc3ResultSet.java,v 1.4.4.1 2004/03/29 17:47:47 barry Exp $
* This class defines methods of the jdbc3 specification. This class extends
* org.postgresql.jdbc2.AbstractJdbc2ResultSet which provides the jdbc2
* methods. The real Statement class (for jdbc3) is org.postgresql.jdbc3.Jdbc3ResultSet
public abstract class AbstractJdbc3ResultSet extends org.postgresql.jdbc2.AbstractJdbc2ResultSet
{
- public AbstractJdbc3ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public AbstractJdbc3ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID)
{
- super (statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ super (statement, fields, tuples, status, updateCount, insertOID);
}
/**
super(connection, sql);
}
- public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
super(connection, sql);
}
- public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, java.util.Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc3ResultSet((BaseStatement)this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc3ResultSet((BaseStatement)this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
super((BaseStatement)statement,
(Field[])null,
(Vector)null,
- (String)null, -1, 0L, false);
+ (String)null, -1, 0L);
this.refCursorHandle = refCursorName;
}
import org.postgresql.core.Field;
import org.postgresql.core.BaseStatement;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.5 2003/03/07 18:39:45 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3ResultSet.java,v 1.5.4.1 2004/03/29 17:47:47 barry Exp $
* This class implements the java.sql.ResultSet interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3ResultSet or one of it's parents
public class Jdbc3ResultSet extends org.postgresql.jdbc3.AbstractJdbc3ResultSet implements java.sql.ResultSet
{
- public Jdbc3ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor)
+ public Jdbc3ResultSet(BaseStatement statement, Field[] fields, Vector tuples, String status, int updateCount, long insertOID)
{
- super(statement, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ super(statement, fields, tuples, status, updateCount, insertOID);
}
public java.sql.ResultSetMetaData getMetaData() throws SQLException
import org.postgresql.core.BaseResultSet;
import org.postgresql.core.Field;
-/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.5 2003/05/03 20:40:45 barry Exp $
+/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc3/Attic/Jdbc3Statement.java,v 1.5.4.1 2004/03/29 17:47:47 barry Exp $
* This class implements the java.sql.Statement interface for JDBC3.
* However most of the implementation is really done in
* org.postgresql.jdbc3.AbstractJdbc3Statement or one of it's parents
super(c);
}
- public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID, boolean binaryCursor) throws SQLException
+ public BaseResultSet createResultSet (Field[] fields, Vector tuples, String status, int updateCount, long insertOID) throws SQLException
{
- return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID, binaryCursor);
+ return new Jdbc3ResultSet(this, fields, tuples, status, updateCount, insertOID);
}
public PGRefCursorResultSet createRefCursorResultSet (String cursorName) throws SQLException
suite.addTestSuite(CallableStmtTest.class );
suite.addTestSuite(CursorFetchTest.class);
+ suite.addTestSuite(ServerCursorTest.class);
// That's all folks
return suite;
* User: alexei
* Date: 17-Dec-2003
* Time: 11:01:44
- * @version $Id: OID74Test.java,v 1.2.2.2 2003/12/18 04:10:12 davec Exp $
+ * @version $Id: OID74Test.java,v 1.2.2.3 2004/03/29 17:47:47 barry Exp $
*/
public class OID74Test extends TestCase
{
}
TestUtil.dropTable(c,"temp");
+ c.commit();
TestUtil.closeDB(c);
}
}
--- /dev/null
+package org.postgresql.test.jdbc2;
+
+import java.sql.*;
+
+import junit.framework.TestCase;
+
+import org.postgresql.test.TestUtil;
+
+/*
+ * Tests for using non-zero setFetchSize().
+ */
+public class ServerCursorTest extends TestCase
+{
+ private Connection con;
+
+ public ServerCursorTest(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ con = TestUtil.openDB();
+ TestUtil.createTable(con, "test_fetch", "value integer,data bytea");
+ con.setAutoCommit(false);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ con.rollback();
+ con.setAutoCommit(true);
+ TestUtil.dropTable(con, "test_fetch");
+ TestUtil.closeDB(con);
+ }
+
+ protected void createRows(int count) throws Exception
+ {
+ PreparedStatement stmt = con.prepareStatement("insert into test_fetch(value,data) values(?,?)");
+ for (int i = 0; i < count; ++i) {
+ stmt.setInt(1,i+1);
+ stmt.setBytes(2,DATA_STRING.getBytes("UTF8"));
+ stmt.executeUpdate();
+ }
+ con.commit();
+ }
+
+ //Test regular cursor fetching
+ public void testBasicFetch() throws Exception
+ {
+ createRows(1);
+
+ PreparedStatement stmt = con.prepareStatement("declare test_cursor cursor for select * from test_fetch");
+ stmt.execute();
+
+ stmt = con.prepareStatement("fetch forward from test_cursor");
+ ResultSet rs = stmt.executeQuery();
+ while (rs.next()) {
+ //there should only be one row returned
+ assertEquals("query value error", 1, rs.getInt(1));
+ byte[] dataBytes = rs.getBytes(2);
+ assertEquals("binary data got munged", DATA_STRING, new String(dataBytes,"UTF8"));
+ }
+
+ }
+
+ //Test binary cursor fetching
+ public void testBinaryFetch() throws Exception
+ {
+ createRows(1);
+
+ PreparedStatement stmt = con.prepareStatement("declare test_cursor binary cursor for select * from test_fetch");
+ stmt.execute();
+
+ stmt = con.prepareStatement("fetch forward from test_cursor");
+ ResultSet rs = stmt.executeQuery();
+ while (rs.next()) {
+ //there should only be one row returned
+ byte[] dataBytes = rs.getBytes(2);
+ assertEquals("binary data got munged", DATA_STRING, new String(dataBytes,"UTF8"));
+ }
+
+ }
+
+ //This string contains a variety different data:
+ // three japanese characters representing "japanese" in japanese
+ // the four characters "\000"
+ // a null character
+ // the seven ascii characters "english"
+ private static final String DATA_STRING = "\u65E5\u672C\u8A9E\\000\u0000english";
+
+}