@@ -7,8 +7,6 @@ var ConnectionParameters = require(__dirname + '/connection-parameters');
7
7
var Query = require ( __dirname + '/query' ) ;
8
8
var defaults = require ( __dirname + '/defaults' ) ;
9
9
var Connection = require ( __dirname + '/connection' ) ;
10
- var CopyFromStream = require ( __dirname + '/copystream' ) . CopyFromStream ;
11
- var CopyToStream = require ( __dirname + '/copystream' ) . CopyToStream ;
12
10
13
11
var Client = function ( config ) {
14
12
EventEmitter . call ( this ) ;
@@ -130,17 +128,6 @@ Client.prototype.connect = function(callback) {
130
128
self . activeQuery . handleCopyInResponse ( self . connection ) ;
131
129
} ) ;
132
130
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
-
144
131
con . on ( 'copyData' , function ( msg ) {
145
132
self . activeQuery . handleCopyData ( msg , self . connection ) ;
146
133
} ) ;
@@ -185,13 +172,13 @@ Client.prototype.connect = function(callback) {
185
172
con . once ( 'end' , function ( ) {
186
173
if ( callback ) {
187
174
// haven't received a connection message yet !
188
- var err = new Error ( 'Connection was ended during query ' ) ;
175
+ var err = new Error ( 'Connection terminated ' ) ;
189
176
callback ( err ) ;
190
177
callback = null ;
191
178
return ;
192
179
}
193
180
if ( self . activeQuery ) {
194
- var disconnectError = new Error ( 'Connection was ended during query ' ) ;
181
+ var disconnectError = new Error ( 'Connection terminated ' ) ;
195
182
self . activeQuery . handleError ( disconnectError , con ) ;
196
183
self . activeQuery = null ;
197
184
}
@@ -209,9 +196,8 @@ Client.prototype.getStartupConf = function() {
209
196
var params = this . connectionParameters ;
210
197
211
198
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
215
201
} ;
216
202
217
203
var appName = params . application_name || params . fallback_application_name ;
@@ -301,30 +287,12 @@ Client.prototype._pulseQueryQueue = function() {
301
287
}
302
288
} ;
303
289
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
-
322
290
Client . 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" ) ;
324
292
} ;
325
293
326
294
Client . 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" ) ;
328
296
} ;
329
297
330
298
Client . prototype . query = function ( config , values , callback ) {
0 commit comments