@@ -7,8 +7,6 @@ var ConnectionParameters = require(__dirname + '/connection-parameters');
77var Query = require ( __dirname + '/query' ) ;
88var defaults = require ( __dirname + '/defaults' ) ;
99var Connection = require ( __dirname + '/connection' ) ;
10- var CopyFromStream = require ( __dirname + '/copystream' ) . CopyFromStream ;
11- var CopyToStream = require ( __dirname + '/copystream' ) . CopyToStream ;
1210
1311var Client = function ( config ) {
1412 EventEmitter . call ( this ) ;
@@ -130,17 +128,6 @@ Client.prototype.connect = function(callback) {
130128 self . activeQuery . handleCopyInResponse ( self . connection ) ;
131129 } ) ;
132130
133- con . on ( 'copyOutResponse' , function ( msg ) {
134- if ( self . activeQuery . stream === undefined ) {
135- self . activeQuery . _canceledDueToError = new Error ( 'No destination stream defined' ) ;
136- //canceling query requires creation of new connection
137- //look for postgres frontend/backend protocol
138- //TODO - this needs to die/be refactored
139- ( new self . constructor ( { port : self . port , host : self . host } ) )
140- . cancel ( self , self . activeQuery ) ;
141- }
142- } ) ;
143-
144131 con . on ( 'copyData' , function ( msg ) {
145132 self . activeQuery . handleCopyData ( msg , self . connection ) ;
146133 } ) ;
@@ -185,13 +172,13 @@ Client.prototype.connect = function(callback) {
185172 con . once ( 'end' , function ( ) {
186173 if ( callback ) {
187174 // haven't received a connection message yet !
188- var err = new Error ( 'Connection was ended during query ' ) ;
175+ var err = new Error ( 'Connection terminated ' ) ;
189176 callback ( err ) ;
190177 callback = null ;
191178 return ;
192179 }
193180 if ( self . activeQuery ) {
194- var disconnectError = new Error ( 'Connection was ended during query ' ) ;
181+ var disconnectError = new Error ( 'Connection terminated ' ) ;
195182 self . activeQuery . handleError ( disconnectError , con ) ;
196183 self . activeQuery = null ;
197184 }
@@ -209,9 +196,8 @@ Client.prototype.getStartupConf = function() {
209196 var params = this . connectionParameters ;
210197
211198 var data = {
212- user : params . user ,
213- database : params . database
214- // client_encoding : "'".concat(params.client_encoding).concat("'")
199+ user : params . user ,
200+ database : params . database
215201 } ;
216202
217203 var appName = params . application_name || params . fallback_application_name ;
@@ -301,30 +287,12 @@ Client.prototype._pulseQueryQueue = function() {
301287 }
302288} ;
303289
304- Client . prototype . _copy = function ( text , stream ) {
305- var config = { } ;
306- config . text = text ;
307- config . stream = stream ;
308- config . callback = function ( error ) {
309- if ( error ) {
310- config . stream . error ( error ) ;
311- } else {
312- config . stream . close ( ) ;
313- }
314- } ;
315- var query = new Query ( config ) ;
316- this . queryQueue . push ( query ) ;
317- this . _pulseQueryQueue ( ) ;
318- return config . stream ;
319-
320- } ;
321-
322290Client . prototype . copyFrom = function ( text ) {
323- return this . _copy ( text , new CopyFromStream ( ) ) ;
291+ throw new Error ( "For PostgreSQL COPY TO/COPY FROM support npm install pg-copy-streams" ) ;
324292} ;
325293
326294Client . prototype . copyTo = function ( text ) {
327- return this . _copy ( text , new CopyToStream ( ) ) ;
295+ throw new Error ( "For PostgreSQL COPY TO/COPY FROM support npm install pg-copy-streams" ) ;
328296} ;
329297
330298Client . prototype . query = function ( config , values , callback ) {
0 commit comments