diff options
author | Marc G. Fournier | 1998-02-02 13:17:01 +0000 |
---|---|---|
committer | Marc G. Fournier | 1998-02-02 13:17:01 +0000 |
commit | 4e9dd952966b600951f05ab2913b5b97936d42ba (patch) | |
tree | 9f0fada5717856c244f94f19f9a3829a4c21270e /src/interfaces/jdbc/postgresql/PG_Stream.java | |
parent | 67c92f423aae5bb2500b7dffb0fc2a4267d2e546 (diff) |
From: Peter T Mount <[email protected]>
[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!).
Diffstat (limited to 'src/interfaces/jdbc/postgresql/PG_Stream.java')
-rw-r--r-- | src/interfaces/jdbc/postgresql/PG_Stream.java | 42 |
1 files changed, 41 insertions, 1 deletions
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 @@ -140,6 +142,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 * * @return the character received @@ -187,6 +200,33 @@ public class PG_Stream } /** + * 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 * has gone wrong. @@ -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) |