Skip to content

Commit 2fc22de

Browse files
author
Sandro Santilli
committed
Send backend a CopyFail when no stream is defined to copy from
1 parent a39e0d7 commit 2fc22de

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/connection.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,11 @@ p.sendCopyFromChunk = function (chunk) {
267267
p.endCopyFrom = function () {
268268
this.stream.write(this.writer.add(emptyBuffer).flush(0x63));
269269
}
270+
p.sendCopyFail = function (msg) {
271+
//this.stream.write(this.writer.add(emptyBuffer).flush(0x66));
272+
this.writer.addCString(msg);
273+
this._send(0x66);
274+
}
270275
//parsing methods
271276
p.setBuffer = function(buffer) {
272277
if(this.lastBuffer) { //we have unfinished biznaz

lib/query.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ p.prepare = function(connection) {
171171
};
172172
p.streamData = function (connection) {
173173
if ( this.stream ) this.stream.startStreamingToConnection(connection);
174-
else {
175-
connection.endCopyFrom(); // send an EOF to connection
176-
// TODO: signal the problem somehow
177-
//this.handleError(new Error('No source stream defined'));
178-
}
174+
else connection.sendCopyFail('No source stream defined');
179175
};
180176
p.handleCopyFromChunk = function (chunk) {
181177
if ( this.stream ) this.stream.handleChunk(chunk);

0 commit comments

Comments
 (0)