Skip to content

Commit a9983ab

Browse files
author
Barry Lind
committed
Initial attempt to integrate in V3 protocol support. This is still a work in
progress, although all RTs pass using the V3 protocol on a 7.4 database and also pass using the V2 protocol on a 7.3 database. SSL support is known not to work. Modified Files: jdbc/org/postgresql/PGConnection.java jdbc/org/postgresql/errors.properties jdbc/org/postgresql/core/BaseConnection.java jdbc/org/postgresql/core/Encoding.java jdbc/org/postgresql/core/Field.java jdbc/org/postgresql/core/PGStream.java jdbc/org/postgresql/core/QueryExecutor.java jdbc/org/postgresql/core/StartupPacket.java jdbc/org/postgresql/fastpath/Fastpath.java jdbc/org/postgresql/fastpath/FastpathArg.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/test/jdbc2/BlobTest.java jdbc/org/postgresql/test/jdbc2/CallableStmtTest.java jdbc/org/postgresql/test/jdbc2/MiscTest.java jdbc/org/postgresql/test/jdbc3/Jdbc3TestSuite.java
1 parent d998fac commit a9983ab

File tree

14 files changed

+841
-82
lines changed

14 files changed

+841
-82
lines changed

src/interfaces/jdbc/org/postgresql/PGConnection.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@
99
* Copyright (c) 2003, PostgreSQL Global Development Group
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.5 2003/04/14 10:39:51 davec Exp $
12+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.6 2003/05/29 03:21:32 barry Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
1616
package org.postgresql;
1717

1818
import java.sql.*;
19-
import java.util.Properties;
20-
import java.util.Vector;
2119
import org.postgresql.core.Encoding;
2220
import org.postgresql.fastpath.Fastpath;
2321
import org.postgresql.largeobject.LargeObjectManager;

src/interfaces/jdbc/org/postgresql/core/BaseConnection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.2 2003/04/13 04:10:07 barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/BaseConnection.java,v 1.3 2003/05/29 03:21:32 barry Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313
package org.postgresql.core;
1414

1515
import java.sql.DatabaseMetaData;
16-
import java.sql.ResultSet;
1716
import java.sql.Statement;
1817
import java.sql.SQLException;
1918
import org.postgresql.PGConnection;
@@ -32,6 +31,8 @@ public interface BaseConnection extends PGConnection
3231
public Encoding getEncoding() throws SQLException;
3332
public DatabaseMetaData getMetaData() throws SQLException;
3433
public Object getObject(String type, String value) throws SQLException;
34+
public int getPGProtocolVersionMajor();
35+
public int getPGProtocolVersionMinor();
3536
public PGStream getPGStream();
3637
public String getPGType(int oid) throws SQLException;
3738
public int getPGType(String pgTypeName) throws SQLException;

src/interfaces/jdbc/org/postgresql/core/Encoding.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Encoding.java,v 1.10 2003/03/07 18:39:41 barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Encoding.java,v 1.11 2003/05/29 03:21:32 barry Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -140,15 +140,22 @@ public String name()
140140
*/
141141
public byte[] encode(String s) throws SQLException
142142
{
143+
byte[] l_return;
143144
try
144145
{
145146
if (encoding == null)
146147
{
147-
return s.getBytes();
148+
l_return = s.getBytes();
148149
}
149150
else
150151
{
151-
return s.getBytes(encoding);
152+
l_return = s.getBytes(encoding);
153+
}
154+
//Don't return null, return an empty byte[] instead
155+
if (l_return == null) {
156+
return new byte[0];
157+
} else {
158+
return l_return;
152159
}
153160
}
154161
catch (UnsupportedEncodingException e)

src/interfaces/jdbc/org/postgresql/core/Field.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@
66
* Copyright (c) 2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.1 2003/03/07 18:39:41 barry Exp $
9+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Field.java,v 1.2 2003/05/29 03:21:32 barry Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
1313
package org.postgresql.core;
1414

15-
import java.lang.*;
1615
import java.sql.*;
17-
import java.util.*;
1816
import org.postgresql.core.BaseConnection;
19-
import org.postgresql.util.PSQLException;
2017

2118
/*
2219
*/

src/interfaces/jdbc/org/postgresql/core/PGStream.java

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Copyright (c) 2003, PostgreSQL Global Development Group
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.1 2003/03/07 18:39:41 barry Exp $
10+
* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/PGStream.java,v 1.2 2003/05/29 03:21:32 barry Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -84,6 +84,25 @@ public void SendInteger(int val, int siz) throws IOException
8484
Send(buf);
8585
}
8686

87+
/*
88+
* Sends an integer to the back end
89+
*
90+
* @param val the integer to be sent
91+
* @param siz the length of the integer in bytes (size of structure)
92+
* @exception IOException if an I/O error occurs
93+
*/
94+
public void SendIntegerR(int val, int siz) throws IOException
95+
{
96+
byte[] buf = new byte[siz];
97+
98+
for (int i = 0; i < siz; i++)
99+
{
100+
buf[i] = (byte)(val & 0xff);
101+
val >>= 8;
102+
}
103+
Send(buf);
104+
}
105+
87106
/*
88107
* Send an array of bytes to the backend
89108
*
@@ -273,7 +292,39 @@ else if (c == 0)
273292
* an array of strings
274293
* @exception SQLException if a data I/O error occurs
275294
*/
276-
public byte[][] ReceiveTuple(int nf, boolean bin) throws SQLException
295+
public byte[][] ReceiveTupleV3(int nf, boolean bin) throws SQLException
296+
{
297+
//TODO: use l_msgSize
298+
int l_msgSize = ReceiveIntegerR(4);
299+
int i;
300+
int l_nf = ReceiveIntegerR(2);
301+
byte[][] answer = new byte[l_nf][0];
302+
303+
for (i = 0 ; i < l_nf ; ++i)
304+
{
305+
int l_size = ReceiveIntegerR(4);
306+
boolean isNull = l_size == -1;
307+
if (isNull)
308+
answer[i] = null;
309+
else
310+
{
311+
answer[i] = Receive(l_size);
312+
}
313+
}
314+
return answer;
315+
}
316+
317+
/*
318+
* Read a tuple from the back end. A tuple is a two dimensional
319+
* array of bytes
320+
*
321+
* @param nf the number of fields expected
322+
* @param bin true if the tuple is a binary tuple
323+
* @return null if the current response has no more tuples, otherwise
324+
* an array of strings
325+
* @exception SQLException if a data I/O error occurs
326+
*/
327+
public byte[][] ReceiveTupleV2(int nf, boolean bin) throws SQLException
277328
{
278329
int i, bim = (nf + 7) / 8;
279330
byte[] bitmask = Receive(bim);
@@ -313,7 +364,7 @@ public byte[][] ReceiveTuple(int nf, boolean bin) throws SQLException
313364
* @return array of bytes received
314365
* @exception SQLException if a data I/O error occurs
315366
*/
316-
private byte[] Receive(int siz) throws SQLException
367+
public byte[] Receive(int siz) throws SQLException
317368
{
318369
byte[] answer = new byte[siz];
319370
Receive(answer, 0, siz);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy