-
Notifications
You must be signed in to change notification settings - Fork 206
Expand file tree
/
Copy pathCopyOutCommandCodec.java
More file actions
43 lines (37 loc) · 1.08 KB
/
CopyOutCommandCodec.java
File metadata and controls
43 lines (37 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package io.vertx.pgclient.impl.codec;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.buffer.impl.BufferImpl;
import io.vertx.sqlclient.SqlResult;
import io.vertx.sqlclient.impl.SqlResultImpl;
class CopyOutCommandCodec extends PgCommandCodec<Boolean, CopyOutCommand> {
CopyOutDataDecoder decoder;
CopyOutCommandCodec(CopyOutCommand cmd) {
super(cmd);
decoder = new CopyOutDataDecoder(cmd.collector());
}
@Override
public void handleCommandComplete(int updated) {
this.result = false;
Buffer result;
Throwable failure;
int size;
if (decoder != null) {
failure = decoder.complete();
result = decoder.result();
size = decoder.size();
decoder.reset();
} else {
failure = null;
result = new BufferImpl();
size = 0;
}
cmd.resultHandler().handleResult(updated, size, null, result, failure);
}
@Override
public void handleErrorResponse(ErrorResponse errorResponse) {
failure = errorResponse.toException();
}
void encode(PgEncoder encoder) {
encoder.writeQuery(new Query(cmd.sql()));
}
}