From 2fc22de21a7649e473ad17c77536452c1e805912 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 16 Jan 2013 12:40:59 +0100 Subject: [PATCH] Send backend a CopyFail when no stream is defined to copy from --- lib/connection.js | 5 +++++ lib/query.js | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/connection.js b/lib/connection.js index 49722c2d..ccc5571b 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -267,6 +267,11 @@ p.sendCopyFromChunk = function (chunk) { p.endCopyFrom = function () { this.stream.write(this.writer.add(emptyBuffer).flush(0x63)); } +p.sendCopyFail = function (msg) { + //this.stream.write(this.writer.add(emptyBuffer).flush(0x66)); + this.writer.addCString(msg); + this._send(0x66); +} //parsing methods p.setBuffer = function(buffer) { if(this.lastBuffer) { //we have unfinished biznaz diff --git a/lib/query.js b/lib/query.js index 2f80411d..5f22a66b 100644 --- a/lib/query.js +++ b/lib/query.js @@ -171,11 +171,7 @@ p.prepare = function(connection) { }; p.streamData = function (connection) { if ( this.stream ) this.stream.startStreamingToConnection(connection); - else { - connection.endCopyFrom(); // send an EOF to connection - // TODO: signal the problem somehow - //this.handleError(new Error('No source stream defined')); - } + else connection.sendCopyFail('No source stream defined'); }; p.handleCopyFromChunk = function (chunk) { if ( this.stream ) this.stream.handleChunk(chunk);