Skip to content
Permalink
Browse files

Merge 4cba56b into 0600990

  • Loading branch information...
davecramer committed Aug 7, 2019
2 parents 0600990 + 4cba56b commit f3947539d0b27353a1584e620881a7fa7921a59b
@@ -1023,7 +1023,6 @@ public synchronized void writeToCopy(CopyOperationImpl op, byte[] data, int off,
pgStream.sendInteger4(siz + 4);
pgStream.send(data, off, siz);

processCopyResults(op, false); // collect any pending notifications without blocking
} catch (IOException ioe) {
throw new PSQLException(GT.tr("Database connection failed when writing to copy"),
PSQLState.CONNECTION_FAILURE, ioe);
@@ -1038,7 +1037,6 @@ public synchronized void flushCopy(CopyOperationImpl op) throws SQLException {

try {
pgStream.flush();
processCopyResults(op, false); // collect any pending notifications without blocking
} catch (IOException ioe) {
throw new PSQLException(GT.tr("Database connection failed when writing to copy"),
PSQLState.CONNECTION_FAILURE, ioe);
@@ -1195,6 +1193,9 @@ CopyOperationImpl processCopyResults(CopyOperationImpl op, boolean block)
LOGGER.log(Level.FINEST, " <=BE CopyData");

len = pgStream.receiveInteger4() - 4;

assert len > 0 : "Copy Data length must be greater than 4";

byte[] buf = pgStream.receive(len);
if (op == null) {
error = new PSQLException(GT.tr("Got CopyData without an active copy operation"),
@@ -2370,6 +2371,9 @@ protected void processResults(ResultHandler handler, int flags) throws IOExcepti
*/
private void skipMessage() throws IOException {
int len = pgStream.receiveInteger4();

assert len >= 4 : "Length from skip message must be at least 4 ";

// skip len-4 (length includes the 4 bytes for message length itself
pgStream.skip(len - 4);
}
@@ -2440,7 +2444,9 @@ public void handleCommandStatus(String status, int updateCount, long insertOID)
}

private void receiveAsyncNotify() throws IOException {
pgStream.receiveInteger4(); // MESSAGE SIZE
int len = pgStream.receiveInteger4(); // MESSAGE SIZE
assert len > 4 : "Length for AsyncNotify must be at least 4";

int pid = pgStream.receiveInteger4();
String msg = pgStream.receiveString();
String param = pgStream.receiveString();
@@ -2458,6 +2464,8 @@ private SQLException receiveErrorResponse() throws IOException {
// check at the bottom to see if we need to throw an exception

int elen = pgStream.receiveInteger4();
assert elen > 4 : "Error response length must be greater than 4";

EncodingPredictor.DecodeResult totalMessage = pgStream.receiveErrorString(elen - 4);
ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage);

@@ -2476,6 +2484,8 @@ private SQLException receiveErrorResponse() throws IOException {

private SQLWarning receiveNoticeResponse() throws IOException {
int nlen = pgStream.receiveInteger4();
assert nlen > 4 : "Notice Response length must be greater than 4";

ServerErrorMessage warnMsg = new ServerErrorMessage(pgStream.receiveString(nlen - 4));

if (LOGGER.isLoggable(Level.FINEST)) {
@@ -117,12 +117,13 @@ public boolean isClosed() {
private ByteBuffer readInternal(boolean block) throws SQLException {
boolean updateStatusRequired = false;
while (copyDual.isActive()) {

ByteBuffer buffer = receiveNextData(block);

if (updateStatusRequired || isTimeUpdate()) {
timeUpdateStatus();
}

ByteBuffer buffer = receiveNextData(block);

if (buffer == null) {
return null;
}

0 comments on commit f394753

Please sign in to comment.
You can’t perform that action at this time.