mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
From: Peter T Mount <patches@maidast.demon.co.uk>
[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!).
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user