mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
Merge pull request #242 from CartoDB/master-error-on-missing-stream
Cleanly handle missing stream error on COPY operation. Closes #241
This commit is contained in:
commit
bd04758a84
@ -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
|
||||
|
||||
11
lib/query.js
11
lib/query.js
@ -17,7 +17,7 @@ var Query = function(config, values, callback) {
|
||||
this.types = config.types;
|
||||
this.name = config.name;
|
||||
this.binary = config.binary;
|
||||
this.stream = config.stream;
|
||||
this.stream = config.stream;
|
||||
//use unique portal name each time
|
||||
this.portal = config.portal || ""
|
||||
this.callback = config.callback;
|
||||
@ -170,9 +170,14 @@ p.prepare = function(connection) {
|
||||
this.getRows(connection);
|
||||
};
|
||||
p.streamData = function (connection) {
|
||||
this.stream.startStreamingToConnection(connection);
|
||||
if ( this.stream ) this.stream.startStreamingToConnection(connection);
|
||||
else connection.sendCopyFail('No source stream defined');
|
||||
};
|
||||
p.handleCopyFromChunk = function (chunk) {
|
||||
this.stream.handleChunk(chunk);
|
||||
if ( this.stream ) this.stream.handleChunk(chunk);
|
||||
else {
|
||||
// TODO: signal the problem somehow
|
||||
//this.handleError(new Error('error', 'No destination stream defined'));
|
||||
}
|
||||
}
|
||||
module.exports = Query;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user