From 4e9dd952966b600951f05ab2913b5b97936d42ba Mon Sep 17 00:00:00 2001 From: "Marc G. Fournier" Date: Mon, 2 Feb 1998 13:17:01 +0000 Subject: From: Peter T Mount [This is a repost - it supercedes the previous one. It fixes the patch so it doesn't bread aix port, plus there's a file missing out of the original post because difforig doesn't pick up new files. It's now attached. peter] This patch brings the JDBC driver up to the current protocol spec. Basically, the backend now tells the driver what authentication scheme to use. The patch also fixes a performance problem with large objects. In the buffer manager, each fastpath call was sending multiple Notifications to the backend (sometimes more data in the form of notifications were being sent than blob data!). --- src/interfaces/jdbc/postgresql/PG_Stream.java | 42 ++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'src/interfaces/jdbc/postgresql/PG_Stream.java') diff --git a/src/interfaces/jdbc/postgresql/PG_Stream.java b/src/interfaces/jdbc/postgresql/PG_Stream.java index 8c5f5215614..f786b507d1b 100644 --- a/src/interfaces/jdbc/postgresql/PG_Stream.java +++ b/src/interfaces/jdbc/postgresql/PG_Stream.java @@ -76,6 +76,8 @@ public class PG_Stream * This is required when the backend uses the routines in the * src/backend/libpq/pqcomprim.c module. * + * As time goes by, this should become obsolete. + * * @param val the integer to be sent * @param siz the length of the integer in bytes (size of structure) * @exception IOException if an I/O error occurs @@ -139,6 +141,17 @@ public class PG_Stream } } + /** + * Sends a packet, prefixed with the packet's length + * @param buf buffer to send + * @exception SQLException if an I/O Error returns + */ + public void SendPacket(byte[] buf) throws IOException + { + SendInteger(buf.length+4,4); + Send(buf); + } + /** * Receives a single character from the backend * @@ -186,6 +199,33 @@ public class PG_Stream return n; } + /** + * Receives an integer from the backend + * + * @param siz length of the integer in bytes + * @return the integer received from the backend + * @exception SQLException if an I/O error occurs + */ + public int ReceiveIntegerR(int siz) throws SQLException + { + int n = 0; + + try + { + for (int i = 0 ; i < siz ; i++) + { + int b = pg_input.read(); + + if (b < 0) + throw new IOException("EOF"); + n = b | (n << 8); + } + } catch (IOException e) { + throw new SQLException("Error reading from backend: " + e.toString()); + } + return n; + } + /** * Receives a null-terminated string from the backend. Maximum of * maxsiz bytes - if we don't see a null, then we assume something @@ -253,7 +293,7 @@ public class PG_Stream answer[i] = null; else { - int len = ReceiveInteger(4); + int len = ReceiveIntegerR(4); if (!bin) len -= 4; if (len < 0) -- cgit v1.2.3