Skip to content

Commit 6e380fa

Browse files
committed
COPY TO STDOUT doesn't throw UnsupportedOperationException
TODO: put into separate loop?
1 parent 327f599 commit 6e380fa

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgDecoder.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ private void decodeMessage(ChannelHandlerContext ctx, byte id, ByteBuf in) {
176176
decodeNotificationResponse(ctx, in);
177177
break;
178178
}
179+
// TODO: check if these handlers need to be at this level of loop
180+
// TODO: check if COPY needs a separate loop
181+
case PgProtocolConstants.MESSAGE_TYPE_COPY_OUT_RESPONSE: {
182+
decodeCopyOutResponse(ctx, in);
183+
break;
184+
}
185+
case PgProtocolConstants.MESSAGE_TYPE_COPY_DATA: {
186+
decodeCopyData(ctx, in);
187+
break;
188+
}
189+
case PgProtocolConstants.MESSAGE_TYPE_COPY_COMPLETION: {
190+
decodeCopyCompletion(ctx, in);
191+
break;
192+
}
179193
default: {
180194
throw new UnsupportedOperationException();
181195
}
@@ -455,4 +469,10 @@ private void decodeBackendKeyData(ByteBuf in) {
455469
private void decodeNotificationResponse(ChannelHandlerContext ctx, ByteBuf in) {
456470
ctx.fireChannelRead(new Notification(in.readInt(), Util.readCStringUTF8(in), Util.readCStringUTF8(in)));
457471
}
472+
473+
private void decodeCopyOutResponse(ChannelHandlerContext ctx, ByteBuf in) {}
474+
475+
private void decodeCopyData(ChannelHandlerContext ctx, ByteBuf in) {}
476+
477+
private void decodeCopyCompletion(ChannelHandlerContext ctx, ByteBuf in) {}
458478
}

vertx-pg-client/src/main/java/io/vertx/pgclient/impl/codec/PgProtocolConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ public class PgProtocolConstants {
7171
public static final byte MESSAGE_TYPE_FUNCTION_RESULT = 'V';
7272
public static final byte MESSAGE_TYPE_SSL_YES = 'S';
7373
public static final byte MESSAGE_TYPE_SSL_NO = 'N';
74+
75+
// COPY-related
76+
public static final byte MESSAGE_TYPE_COPY_OUT_RESPONSE = 'H';
77+
public static final byte MESSAGE_TYPE_COPY_DATA = 'd';
78+
public static final byte MESSAGE_TYPE_COPY_COMPLETION = 'c';
7479
}

vertx-pg-client/src/test/java/io/vertx/pgclient/PgConnectionCopyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public void testSimpleQuery(TestContext ctx) {
5454
Async async = ctx.async();
5555
connector.accept(ctx.asyncAssertSuccess(conn -> {
5656
conn
57-
.query("SELECT 1")
57+
.query("COPY world TO STDOUT (FORMAT csv)")
5858
.execute()
5959
.onComplete(ctx.asyncAssertSuccess(result1 -> {
60-
ctx.assertEquals(1, result1.size());
60+
ctx.assertEquals(0, result1.size());
6161
async.complete();
6262
}));
6363
}));

0 commit comments

Comments
 (0)