? --help ? build ? build.properties ? copydiff ? item.dump ? jars ? jdbc.copy.submit ? jdbc.copy.threadcopy ? patch ? temp ? org/postgresql/Driver.java ? org/postgresql/PGConnection.class ? org/postgresql/PGNotification.class ? org/postgresql/PG_Stream.class ? org/postgresql/copy ? org/postgresql/core/Encoding.class ? org/postgresql/fastpath/Fastpath.class ? org/postgresql/fastpath/FastpathArg.class ? org/postgresql/largeobject/BlobOutputStream.class ? org/postgresql/largeobject/LargeObject.class ? org/postgresql/largeobject/LargeObjectManager.class ? org/postgresql/test/CopyTest.java ? org/postgresql/test/TestUtil.class ? org/postgresql/test/jdbc2/ANTTest.class ? org/postgresql/test/jdbc2/BatchExecuteTest.class ? org/postgresql/test/jdbc2/BlobTest.class ? org/postgresql/test/jdbc2/CallableStmtTest.class ? org/postgresql/test/jdbc2/ConnectionTest.class ? org/postgresql/test/jdbc2/CopyTest.java ? org/postgresql/test/jdbc2/DatabaseMetaDataPropertiesTest.class ? org/postgresql/test/jdbc2/DatabaseMetaDataTest.class ? org/postgresql/test/jdbc2/DateTest.class ? org/postgresql/test/jdbc2/DriverTest.class ? org/postgresql/test/jdbc2/EncodingTest.class ? org/postgresql/test/jdbc2/JBuilderTest.class ? org/postgresql/test/jdbc2/Jdbc2TestSuite.class ? org/postgresql/test/jdbc2/MiscTest.class ? org/postgresql/test/jdbc2/ResultSetTest.class ? org/postgresql/test/jdbc2/SerializeObject.class ? org/postgresql/test/jdbc2/SerializeTest.class ? org/postgresql/test/jdbc2/ServerPreparedStmtTest.class ? org/postgresql/test/jdbc2/TimeTest.class ? org/postgresql/test/jdbc2/TimestampTest.class ? org/postgresql/test/jdbc2/UpdateableResultTest.class ? org/postgresql/util/Serialize.class Index: org/postgresql/PGConnection.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/PGConnection.java,v retrieving revision 1.3 diff -c -r1.3 PGConnection.java *** org/postgresql/PGConnection.java 2002/09/06 21:23:05 1.3 --- org/postgresql/PGConnection.java 2003/02/26 17:31:33 *************** *** 6,11 **** --- 6,12 ---- import org.postgresql.core.Encoding; import org.postgresql.fastpath.Fastpath; import org.postgresql.largeobject.LargeObjectManager; + import org.postgresql.copy.CopyManager; /* $Header: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/PGConnection.java,v 1.3 2002/09/06 21:23:05 momjian Exp $ * This interface defines PostgreSQL extentions to the java.sql.Connection interface. *************** *** 41,46 **** --- 42,52 ---- */ public int getPGType(String typeName) throws SQLException; + /** + * This returns the bulk data "copy" API for the current connection + */ + public CopyManager getCopyAPI() throws SQLException; + /* * This returns the LargeObject API for the current connection. */ *************** *** 75,81 **** * Returns null if there have been no notifications. */ public PGNotification[] getNotifications(); ! } --- 81,87 ---- * Returns null if there have been no notifications. */ public PGNotification[] getNotifications(); ! } Index: org/postgresql/PG_Stream.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/PG_Stream.java,v retrieving revision 1.17 diff -c -r1.17 PG_Stream.java *** org/postgresql/PG_Stream.java 2002/08/20 04:26:02 1.17 --- org/postgresql/PG_Stream.java 2003/02/26 17:31:33 *************** *** 21,27 **** public class PG_Stream { private Socket connection; ! private InputStream pg_input; private BufferedOutputStream pg_output; private byte[] byte_buf = new byte[8*1024]; --- 21,27 ---- public class PG_Stream { private Socket connection; ! private PushbackInputStream pg_input; private BufferedOutputStream pg_output; private byte[] byte_buf = new byte[8*1024]; *************** *** 42,49 **** connection.setTcpNoDelay(true); // Buffer sizes submitted by Sverre H Huseby ! pg_input = new BufferedInputStream(connection.getInputStream(), 8192); pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192); } /* --- 42,63 ---- connection.setTcpNoDelay(true); // Buffer sizes submitted by Sverre H Huseby ! BufferedInputStream pg_input_buffered = new BufferedInputStream(connection.getInputStream(), 8192); ! // using a Pushback greatly simplifies the COPY code ! pg_input = new PushbackInputStream(pg_input_buffered, 3); pg_output = new BufferedOutputStream(connection.getOutputStream(), 8192); + } + + /* + * Places a byte at the front of the input so that it is the next byte to be read. This is used to decipher the end of a COPY, which consists of three bytes. + * + * @param b the byte to push back into the InputStream + * @exception IOException if an I/O error occurs + * @see java.io.PushbackInputStream + */ + public void unread(int b) throws IOException + { + pg_input.unread(b); } /* Index: org/postgresql/errors.properties =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/errors.properties,v retrieving revision 1.17 diff -c -r1.17 errors.properties *** org/postgresql/errors.properties 2003/02/12 06:13:04 1.17 --- org/postgresql/errors.properties 2003/02/26 17:31:34 *************** *** 26,31 **** --- 26,34 ---- postgresql.con.tuple:Tuple received before MetaData. postgresql.con.type:Unknown Response Type {0} postgresql.con.user:The user property is missing. It is mandatory. + postgresql.copy.protocolerror:Error response {0} + postgresql.copy.protocolsurprise:Expected {0} but received {1} + postgresql.copy.ioerror:IOException {0} postgresql.fp.error:FastPath call returned {0} postgresql.fp.expint:Fastpath call {0} - No result was returned and we expected an integer. postgresql.fp.protocol:FastPath protocol error: {0} Index: org/postgresql/jdbc1/AbstractJdbc1Connection.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java,v retrieving revision 1.15 diff -c -r1.15 AbstractJdbc1Connection.java *** org/postgresql/jdbc1/AbstractJdbc1Connection.java 2003/02/05 11:12:39 1.15 --- org/postgresql/jdbc1/AbstractJdbc1Connection.java 2003/02/26 17:31:36 *************** *** 7,16 **** --- 7,18 ---- import java.util.*; import org.postgresql.Driver; import org.postgresql.PGNotification; + import org.postgresql.PGConnection; import org.postgresql.PG_Stream; import org.postgresql.core.*; import org.postgresql.fastpath.Fastpath; import org.postgresql.largeobject.LargeObjectManager; + import org.postgresql.copy.CopyManager; import org.postgresql.util.*; *************** *** 515,520 **** --- 517,532 ---- public Encoding getEncoding() throws SQLException { return encoding; + } + + // This holds a reference to the "copy" API if already open + private CopyManager copyManager = null; + + public CopyManager getCopyAPI() throws SQLException + { + if (copyManager == null) + copyManager = new CopyManager((PGConnection)this, pg_stream); + return copyManager; } /* Index: org/postgresql/test/jdbc2/Jdbc2TestSuite.java =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/interfaces/jdbc/org/postgresql/test/jdbc2/Jdbc2TestSuite.java,v retrieving revision 1.4 diff -c -r1.4 Jdbc2TestSuite.java *** org/postgresql/test/jdbc2/Jdbc2TestSuite.java 2002/10/01 00:39:02 1.4 --- org/postgresql/test/jdbc2/Jdbc2TestSuite.java 2003/02/26 17:31:37 *************** *** 68,73 **** --- 68,76 ---- suite.addTestSuite(CallableStmtTest.class ); + // COPY Protocol Test + suite.addTestSuite(CopyTest.class); + // That's all folks return suite; }