- objectTypes.put(defaultObjectTypes[i][0],defaultObjectTypes[i][1]);
+
for(int i=0;i
+ objectTypes.put(defaultObjectTypes[i][0],defaultObjectTypes[i][1]);
}
// These are required by other common classes
* 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
* @exception SQLException if a database access error occurs
*/
public void close() throws SQLException {
- if (pg_stream != null) {
- try {
- pg_stream.SendChar('X');
- pg_stream.flush();
- pg_stream.close();
- } catch (IOException e) {}
- pg_stream = null;
- }
+ if (pg_stream != null) {
+ try {
+ pg_stream.SendChar('X');
+ pg_stream.flush();
+ pg_stream.close();
+ } catch (IOException e) {}
+ pg_stream = null;
+ }
}
/**
* @exception SQLException if a database access error occurs
*/
public String nativeSQL(String sql) throws SQLException {
- return sql;
+ return sql;
}
/**
* @exception SQLException if a database access error occurs
*/
public SQLWarning getWarnings() throws SQLException {
- return firstWarning;
+ return firstWarning;
}
/**
* @exception SQLException if a database access error occurs
*/
public void clearWarnings() throws SQLException {
- firstWarning = null;
+ firstWarning = null;
}
* @exception SQLException if a database access error occurs
*/
public void setReadOnly(boolean readOnly) throws SQLException {
- this.readOnly = readOnly;
+ this.readOnly = readOnly;
}
/**
* @exception SQLException if a database access error occurs
*/
public boolean isReadOnly() throws SQLException {
- return readOnly;
+ return readOnly;
}
/**
* @exception SQLException if a database access error occurs
*/
public void setAutoCommit(boolean autoCommit) throws SQLException {
- if (this.autoCommit == autoCommit)
- return;
- if (autoCommit)
- ExecSQL("end");
- else {
+ if (this.autoCommit == autoCommit)
+ return;
+ if (autoCommit)
+ ExecSQL("end");
+ else {
if (haveMinimumServerVersion("7.1")){
ExecSQL("begin;"+getIsolationLevelSQL());
}else{
- ExecSQL("begin");
- ExecSQL(getIsolationLevelSQL());
+ ExecSQL("begin");
+ ExecSQL(getIsolationLevelSQL());
}
- }
- this.autoCommit = autoCommit;
+ }
+ this.autoCommit = autoCommit;
}
/**
* @see setAutoCommit
*/
public boolean getAutoCommit() throws SQLException {
- return this.autoCommit;
+ return this.autoCommit;
}
/**
* @see setAutoCommit
*/
public void commit() throws SQLException {
- if (autoCommit)
- return;
- if (haveMinimumServerVersion("7.1")){
- ExecSQL("commit;begin;"+getIsolationLevelSQL());
- }else{
- ExecSQL("commit");
- ExecSQL("begin");
- ExecSQL(getIsolationLevelSQL());
+ if (autoCommit)
+ return;
+ if (haveMinimumServerVersion("7.1")){
+ ExecSQL("commit;begin;"+getIsolationLevelSQL());
+ }else{
+ ExecSQL("commit");
+ ExecSQL("begin");
+ ExecSQL(getIsolationLevelSQL());
}
}
* @see commit
*/
public void rollback() throws SQLException {
- if (autoCommit)
- return;
- if (haveMinimumServerVersion("7.1")){
- ExecSQL("rollback; begin;"+getIsolationLevelSQL());
- }else{
- ExecSQL("rollback");
- ExecSQL("begin");
- ExecSQL(getIsolationLevelSQL());
- }
+ if (autoCommit)
+ return;
+ if (haveMinimumServerVersion("7.1")){
+ ExecSQL("rollback; begin;"+getIsolationLevelSQL());
+ }else{
+ ExecSQL("rollback");
+ ExecSQL("begin");
+ ExecSQL(getIsolationLevelSQL());
+ }
}
/**
* @exception SQLException if a database access error occurs
*/
public int getTransactionIsolation() throws SQLException {
- clearWarnings();
- ExecSQL("show xactisolevel");
-
- SQLWarning warning = getWarnings();
- if (warning != null) {
- String message = warning.getMessage();
- clearWarnings();
- if (message.indexOf("READ COMMITTED") != -1)
- return java.sql.Connection.TRANSACTION_READ_COMMITTED;
- else if (message.indexOf("READ UNCOMMITTED") != -1)
- return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
- else if (message.indexOf("REPEATABLE READ") != -1)
- return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
- else if (message.indexOf("SERIALIZABLE") != -1)
- return java.sql.Connection.TRANSACTION_SERIALIZABLE;
- }
- return java.sql.Connection.TRANSACTION_READ_COMMITTED;
+ clearWarnings();
+ ExecSQL("show xactisolevel");
+
+ SQLWarning warning = getWarnings();
+ if (warning != null) {
+ String message = warning.getMessage();
+ clearWarnings();
+ if (message.indexOf("READ COMMITTED") != -1)
+ return java.sql.Connection.TRANSACTION_READ_COMMITTED;
+ else if (message.indexOf("READ UNCOMMITTED") != -1)
+ return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
+ else if (message.indexOf("REPEATABLE READ") != -1)
+ return java.sql.Connection.TRANSACTION_REPEATABLE_READ;
+ else if (message.indexOf("SERIALIZABLE") != -1)
+ return java.sql.Connection.TRANSACTION_SERIALIZABLE;
+ }
+ return java.sql.Connection.TRANSACTION_READ_COMMITTED;
}
/**
* You can call this method to try to change the transaction
* isolation level using one of the TRANSACTION_* values.
- *
+ *
* Note: setTransactionIsolation cannot be called while
* in the middle of a transaction
*
* @see java.sql.DatabaseMetaData#supportsTransactionIsolationLevel
*/
public void setTransactionIsolation(int level) throws SQLException {
- //In 7.1 and later versions of the server it is possible using
+ //In 7.1 and later versions of the server it is possible using
//the "set session" command to set this once for all future txns
- //however in 7.0 and prior versions it is necessary to set it in
+ //however in 7.0 and prior versions it is necessary to set it in
//each transaction, thus adding complexity below.
//When we decide to drop support for servers older than 7.1
//this can be simplified
isolationLevel = level;
String isolationLevelSQL;
- if (!haveMinimumServerVersion("7.1")) {
- isolationLevelSQL = getIsolationLevelSQL();
- } else {
- isolationLevelSQL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ";
- switch(isolationLevel) {
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
- isolationLevelSQL += "READ COMMITTED";
- break;
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
- isolationLevelSQL += "SERIALIZABLE";
- break;
- default:
- throw new PSQLException("postgresql.con.isolevel",
- new Integer(isolationLevel));
- }
- }
- ExecSQL(isolationLevelSQL);
+ if (!haveMinimumServerVersion("7.1")) {
+ isolationLevelSQL = getIsolationLevelSQL();
+ } else {
+ isolationLevelSQL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ";
+ switch(isolationLevel) {
+ case java.sql.Connection.TRANSACTION_READ_COMMITTED:
+ isolationLevelSQL += "READ COMMITTED";
+ break;
+ case java.sql.Connection.TRANSACTION_SERIALIZABLE:
+ isolationLevelSQL += "SERIALIZABLE";
+ break;
+ default:
+ throw new PSQLException("postgresql.con.isolevel",
+ new Integer(isolationLevel));
+ }
+ }
+ ExecSQL(isolationLevelSQL);
}
/**
* servers are dropped
*/
protected String getIsolationLevelSQL() throws SQLException {
- //7.1 and higher servers have a default specified so
- //no additional SQL is required to set the isolation level
- if (haveMinimumServerVersion("7.1")) {
+ //7.1 and higher servers have a default specified so
+ //no additional SQL is required to set the isolation level
+ if (haveMinimumServerVersion("7.1")) {
return "";
}
- StringBuffer sb = new StringBuffer("SET TRANSACTION ISOLATION LEVEL");
+ StringBuffer sb = new StringBuffer("SET TRANSACTION ISOLATION LEVEL");
- switch(isolationLevel) {
- case java.sql.Connection.TRANSACTION_READ_COMMITTED:
- sb.append(" READ COMMITTED");
+ switch(isolationLevel) {
+ case java.sql.Connection.TRANSACTION_READ_COMMITTED:
+ sb.append(" READ COMMITTED");
break;
- case java.sql.Connection.TRANSACTION_SERIALIZABLE:
- sb.append(" SERIALIZABLE");
+ case java.sql.Connection.TRANSACTION_SERIALIZABLE:
+ sb.append(" SERIALIZABLE");
break;
- default:
- throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel));
- }
+ default:
+ throw new PSQLException("postgresql.con.isolevel",new Integer(isolationLevel));
+ }
return sb.toString();
}
*/
public String getCatalog() throws SQLException
{
- return PG_DATABASE;
+ return PG_DATABASE;
}
/**
*/
public void finalize() throws Throwable
{
- close();
+ close();
}
private static String extractVersionNumber(String fullVersionString)
* Get server version number
*/
public String getDBVersionNumber() {
- return dbVersionNumber;
+ return dbVersionNumber;
}
public boolean haveMinimumServerVersion(String ver) throws SQLException
}
}
-
+
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
* @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;
this.insertOID = insertOID;
this.this_row = null;
this.current_row = -1;
+ this.binaryCursor = binaryCursor;
}
* @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)
- {
- this(conn,fields,tuples,status,updateCount,0);
- }
+ public ResultSet(Connection conn, Field[] fields, Vector tuples, String status, int updateCount)
+ {
+ this(conn,fields,tuples,status,updateCount,0,false);
+ }
/**
* We at times need to know if the resultSet we are working
*/
public int getInsertedOID()
{
- return insertOID;
+ return insertOID;
}
/**
*
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 {
private final org.postgresql.Connection connection;
public QueryExecutor(String sql,
- java.sql.Statement statement,
- PG_Stream pg_stream,
- org.postgresql.Connection connection)
- throws SQLException
+ java.sql.Statement statement,
+ PG_Stream pg_stream,
+ org.postgresql.Connection connection)
+ throws SQLException
{
- this.sql = sql;
- this.statement = statement;
- this.pg_stream = pg_stream;
- this.connection = connection;
-
- if (statement != null)
- maxRows = statement.getMaxRows();
- else
- maxRows = 0;
+ this.sql = sql;
+ this.statement = statement;
+ this.pg_stream = pg_stream;
+ this.connection = connection;
+
+ if (statement != null)
+ maxRows = statement.getMaxRows();
+ else
+ maxRows = 0;
}
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;
*/
public java.sql.ResultSet execute() throws SQLException {
- int fqp = 0;
- boolean hfr = false;
-
- synchronized(pg_stream) {
-
- sendQuery(sql);
-
- while (!hfr || fqp > 0) {
- int c = pg_stream.ReceiveChar();
-
- switch (c)
- {
- case 'A': // Asynchronous Notify
- int pid = pg_stream.ReceiveInteger(4);
- String msg = pg_stream.ReceiveString(connection.getEncoding());
- break;
- case 'B': // Binary Data Transfer
- receiveTuple(true);
- break;
- case 'C': // Command Status
- receiveCommandStatus();
-
- if (fields != null)
- hfr = true;
- else {
- sendQuery(" ");
- fqp++;
- }
- break;
- case 'D': // Text Data Transfer
- receiveTuple(false);
- break;
- case 'E': // Error Message
- throw new SQLException(pg_stream.ReceiveString(connection.getEncoding()));
- case 'I': // Empty Query
- int t = pg_stream.ReceiveChar();
- if (t != 0)
- throw new PSQLException("postgresql.con.garbled");
-
- if (fqp > 0)
- fqp--;
- if (fqp == 0)
- hfr = true;
- break;
- case 'N': // Error Notification
- connection.addWarning(pg_stream.ReceiveString(connection.getEncoding()));
- break;
- case 'P': // Portal Name
- String pname = pg_stream.ReceiveString(connection.getEncoding());
- break;
- case 'T': // MetaData Field Description
- receiveFields();
- break;
- case 'Z': // backend ready for query, ignore for now :-)
- break;
- default:
- throw new PSQLException("postgresql.con.type",
- new Character((char) c));
- }
- }
-
- return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid);
- }
+ int fqp = 0;
+ boolean hfr = false;
+
+ synchronized(pg_stream) {
+
+ sendQuery(sql);
+
+ while (!hfr || fqp > 0) {
+ int c = pg_stream.ReceiveChar();
+
+ switch (c)
+ {
+ case 'A': // Asynchronous Notify
+ int pid = pg_stream.ReceiveInteger(4);
+ String msg = pg_stream.ReceiveString(connection.getEncoding());
+ break;
+ case 'B': // Binary Data Transfer
+ receiveTuple(true);
+ break;
+ case 'C': // Command Status
+ receiveCommandStatus();
+
+ if (fields != null)
+ hfr = true;
+ else {
+ sendQuery(" ");
+ fqp++;
+ }
+ break;
+ case 'D': // Text Data Transfer
+ receiveTuple(false);
+ break;
+ case 'E': // Error Message
+ throw new SQLException(pg_stream.ReceiveString(connection.getEncoding()));
+ case 'I': // Empty Query
+ int t = pg_stream.ReceiveChar();
+ if (t != 0)
+ throw new PSQLException("postgresql.con.garbled");
+
+ if (fqp > 0)
+ fqp--;
+ if (fqp == 0)
+ hfr = true;
+ break;
+ case 'N': // Error Notification
+ connection.addWarning(pg_stream.ReceiveString(connection.getEncoding()));
+ break;
+ case 'P': // Portal Name
+ String pname = pg_stream.ReceiveString(connection.getEncoding());
+ break;
+ case 'T': // MetaData Field Description
+ receiveFields();
+ break;
+ case 'Z': // backend ready for query, ignore for now :-)
+ break;
+ default:
+ throw new PSQLException("postgresql.con.type",
+ new Character((char) c));
+ }
+ }
+ return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid, binaryCursor);
+ }
}
/**
* Send a query to the backend.
*/
private void sendQuery(String query) throws SQLException {
- try {
- pg_stream.SendChar('Q');
- pg_stream.Send(connection.getEncoding().encode(query));
- pg_stream.SendChar(0);
- pg_stream.flush();
-
- } catch (IOException e) {
- throw new PSQLException("postgresql.con.ioerror", e);
- }
+ try {
+ pg_stream.SendChar('Q');
+ pg_stream.Send(connection.getEncoding().encode(query));
+ pg_stream.SendChar(0);
+ pg_stream.flush();
+
+ } catch (IOException e) {
+ throw new PSQLException("postgresql.con.ioerror", e);
+ }
}
/**
* @param isBinary set if the tuple should be treated as binary data
*/
private void receiveTuple(boolean isBinary) throws SQLException {
- if (fields == null)
- throw new PSQLException("postgresql.con.tuple");
- Object tuple = pg_stream.ReceiveTuple(fields.length, isBinary);
- if (maxRows == 0 || tuples.size() < maxRows)
- tuples.addElement(tuple);
+ 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);
}
/**
*/
private void receiveCommandStatus() throws SQLException {
- status = pg_stream.ReceiveString(connection.getEncoding());
-
- try {
- // Now handle the update count correctly.
- if (status.startsWith("INSERT") || status.startsWith("UPDATE") || status.startsWith("DELETE") || status.startsWith("MOVE")) {
- update_count = Integer.parseInt(status.substring(1 + status.lastIndexOf(' ')));
- }
- if (status.startsWith("INSERT")) {
- insert_oid = Integer.parseInt(status.substring(1 + status.indexOf(' '),
- status.lastIndexOf(' ')));
- }
- } catch (NumberFormatException nfe) {
- throw new PSQLException("postgresql.con.fathom", status);
- }
+ status = pg_stream.ReceiveString(connection.getEncoding());
+
+ try {
+ // Now handle the update count correctly.
+ if (status.startsWith("INSERT") || status.startsWith("UPDATE") || status.startsWith("DELETE") || status.startsWith("MOVE")) {
+ update_count = Integer.parseInt(status.substring(1 + status.lastIndexOf(' ')));
+ }
+ if (status.startsWith("INSERT")) {
+ insert_oid = Integer.parseInt(status.substring(1 + status.indexOf(' '),
+ status.lastIndexOf(' ')));
+ }
+ } catch (NumberFormatException nfe) {
+ throw new PSQLException("postgresql.con.fathom", status);
+ }
}
/**
* Receive the field descriptions from the back end.
*/
private void receiveFields() throws SQLException {
- if (fields != null)
- throw new PSQLException("postgresql.con.multres");
-
- int size = pg_stream.ReceiveIntegerR(2);
- fields = new Field[size];
-
- for (int i = 0; i < fields.length; i++) {
- String typeName = pg_stream.ReceiveString(connection.getEncoding());
- int typeOid = pg_stream.ReceiveIntegerR(4);
- int typeLength = pg_stream.ReceiveIntegerR(2);
- int typeModifier = pg_stream.ReceiveIntegerR(4);
- fields[i] = new Field(connection, typeName, typeOid, typeLength, typeModifier);
- }
+ if (fields != null)
+ throw new PSQLException("postgresql.con.multres");
+
+ int size = pg_stream.ReceiveIntegerR(2);
+ fields = new Field[size];
+
+ for (int i = 0; i < fields.length; i++) {
+ String typeName = pg_stream.ReceiveString(connection.getEncoding());
+ int typeOid = pg_stream.ReceiveIntegerR(4);
+ int typeLength = pg_stream.ReceiveIntegerR(2);
+ int typeModifier = pg_stream.ReceiveIntegerR(4);
+ fields[i] = new Field(connection, typeName, typeOid, typeLength, typeModifier);
+ }
}
}
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
* 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);
}
* @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);
}
/**
* @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,
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));
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
* 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);
}
// *****************
"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"
};
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
};
* @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);
}
/**
* @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,
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));
* @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);
}
/**
* @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
{
{
// New in 7.1 - The updateable ResultSet class will now return
// CONCUR_UPDATEABLE.
- return CONCUR_UPDATABLE;
+ return CONCUR_UPDATABLE;
}
public void insertRow() throws SQLException
}
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();
}
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();