Skip to content

Commit 766b428

Browse files
committed
merge branch v1.0
2 parents 173f3f3 + 1d65417 commit 766b428

27 files changed

+123
-696
lines changed

lib/client.js

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ var Connection = require(__dirname + '/connection');
1010
var CopyFromStream = require(__dirname + '/copystream').CopyFromStream;
1111
var CopyToStream = require(__dirname + '/copystream').CopyToStream;
1212

13-
var deprecate = require('deprecate');
14-
1513
var Client = function(config) {
1614
EventEmitter.call(this);
1715

@@ -214,13 +212,7 @@ Client.prototype._pulseQueryQueue = function() {
214212
this.activeQuery.submit(this.connection);
215213
} else if(this.hasExecuted) {
216214
this.activeQuery = null;
217-
//TODO remove pauseDrain for v1.0
218-
if(this._drainPaused > 0) {
219-
this._drainPaused++;
220-
}
221-
else {
222-
this.emit('drain');
223-
}
215+
this.emit('drain');
224216
}
225217
}
226218
};
@@ -264,32 +256,6 @@ Client.prototype.query = function(config, values, callback) {
264256
return query;
265257
};
266258

267-
//prevents client from otherwise emitting 'drain' event until 'resumeDrain' is
268-
//called
269-
Client.prototype.pauseDrain = function() {
270-
deprecate('Client.prototype.pauseDrain is deprecated and will be removed it v1.0.0 (very soon)',
271-
'please see the following for more details:',
272-
'https://github.com/brianc/node-postgres/wiki/pg',
273-
'https://github.com/brianc/node-postgres/issues/227',
274-
'https://github.com/brianc/node-postgres/pull/274',
275-
'feel free to get in touch via github if you have questions');
276-
this._drainPaused = 1;
277-
};
278-
279-
//resume raising 'drain' event
280-
Client.prototype.resumeDrain = function() {
281-
deprecate('Client.prototype.resumeDrain is deprecated and will be removed it v1.0.0 (very soon)',
282-
'please see the following for more details:',
283-
'https://github.com/brianc/node-postgres/wiki/pg',
284-
'https://github.com/brianc/node-postgres/issues/227',
285-
'https://github.com/brianc/node-postgres/pull/274',
286-
'feel free to get in touch via github if you have questions');
287-
if(this._drainPaused > 1) {
288-
this.emit('drain');
289-
}
290-
this._drainPaused = 0;
291-
};
292-
293259
Client.prototype.end = function() {
294260
this.connection.end();
295261
};

lib/connection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ var EventEmitter = require('events').EventEmitter;
44
var util = require('util');
55

66
var utils = require(__dirname + '/utils');
7-
var Writer = require(__dirname + '/writer');
7+
var Writer = require('buffer-writer');
88

99
var Connection = function(config) {
1010
EventEmitter.call(this);

lib/defaults.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,3 @@ module.exports = {
3333
//pool log function / boolean
3434
poolLog: false
3535
};
36-
37-
var deprecate = require('deprecate');
38-
//getter/setter to disable deprecation warnings
39-
module.exports.__defineGetter__("hideDeprecationWarnings", function() {
40-
return deprecate.silent;
41-
});
42-
module.exports.__defineSetter__("hideDeprecationWarnings", function(val) {
43-
deprecate.silence = val;
44-
});

lib/deprecate.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

lib/pool.js

Lines changed: 7 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ var EventEmitter = require('events').EventEmitter;
33
var defaults = require(__dirname + '/defaults');
44
var genericPool = require('generic-pool');
55

6-
var deprecate = require('deprecate');
7-
86
var pools = {
97
//dictionary of all key:pool pairs
108
all: {},
@@ -54,64 +52,17 @@ var pools = {
5452
pool.connect = function(cb) {
5553
pool.acquire(function(err, client) {
5654
if(err) return cb(err, null, function() {/*NOOP*/});
57-
//support both 2 (old) and 3 arguments
58-
(cb.length > 2 ? newConnect : oldConnect)(pool, client, cb);
55+
cb(null, client, function(err) {
56+
if(err) {
57+
pool.destroy(client);
58+
} else {
59+
pool.release(client);
60+
}
61+
});
5962
});
6063
};
6164
return pool;
6265
}
6366
};
6467

65-
//the old connect method of the pool
66-
//would automatically subscribe to the 'drain'
67-
//event and automatically return the client to
68-
//the pool once 'drain' fired once. This caused
69-
//a bunch of problems, but for backwards compatibility
70-
//we're leaving it in
71-
var alarmDuration = 5000;
72-
var errorMessage = [
73-
'A client has been checked out from the pool for longer than ' + alarmDuration + ' ms.',
74-
'You might have a leak!',
75-
'You should use the following new way to check out clients','pg.connect(function(err, client, done)) {',
76-
' //do something',
77-
' done(); //call done() to signal you are finished with the client',
78-
'}'
79-
].join(require('os').EOL);
80-
81-
var oldConnect = function(pool, client, cb) {
82-
deprecate('pg.connect(function(err, client) { ...}) is deprecated and will be removed it v1.0.0 (very soon)',
83-
'instead, use pg.connect(function(err, client, done) { ... })',
84-
'automatic releasing of clients back to the pool was a mistake and will be removed',
85-
'please see the following for more details:',
86-
'https://github.com/brianc/node-postgres/wiki/pg',
87-
'https://github.com/brianc/node-postgres/issues/227',
88-
'https://github.com/brianc/node-postgres/pull/274',
89-
'feel free to get in touch via github if you have questions');
90-
var tid = setTimeout(function() {
91-
console.error(errorMessage);
92-
}, alarmDuration);
93-
var onError = function() {
94-
clearTimeout(tid);
95-
client.removeListener('drain', release);
96-
};
97-
var release = function() {
98-
clearTimeout(tid);
99-
pool.release(client);
100-
client.removeListener('error', onError);
101-
};
102-
client.once('drain', release);
103-
client.once('error', onError);
104-
cb(null, client);
105-
};
106-
107-
var newConnect = function(pool, client, cb) {
108-
cb(null, client, function(err) {
109-
if(err) {
110-
pool.destroy(client);
111-
} else {
112-
pool.release(client);
113-
}
114-
});
115-
};
116-
11768
module.exports = pools;

lib/types/binaryParsers.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var deprecate = require('deprecate');
2-
31
var parseBits = function(data, bits, offset, invert, callback) {
42
offset = offset || 0;
53
invert = invert || false;
@@ -47,12 +45,6 @@ var parseBits = function(data, bits, offset, invert, callback) {
4745
};
4846

4947
var parseFloatFromBits = function(data, precisionBits, exponentBits) {
50-
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
51-
'JavaScript has a hard time with floats and there is precision loss which can cause',
52-
'unexpected, hard to trace, potentially bad bugs in your program',
53-
'for more information see the following:',
54-
'https://github.com/brianc/node-postgres/pull/271',
55-
'in node-postgres v1.0.0 all floats & decimals will be returned as strings');
5648
var bias = Math.pow(2, exponentBits - 1) - 1;
5749
var sign = parseBits(data, 1);
5850
var exponent = parseBits(data, exponentBits, 1);

lib/types/textParsers.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
var deprecate = require('deprecate');
2-
31
var arrayParser = require(__dirname + "/arrayParser.js");
42

53
//parses PostgreSQL server formatted date strings into javascript date objects
@@ -78,18 +76,8 @@ var parseIntegerArray = function(val) {
7876
};
7977

8078
var parseFloatArray = function(val) {
81-
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
82-
'JavaScript has a hard time with floats and there is precision loss which can cause',
83-
'unexpected, hard to trace, potentially bad bugs in your program',
84-
'for more information see the following:',
85-
'https://github.com/brianc/node-postgres/pull/271',
86-
'in node-postgres v1.0.0 all floats & decimals will be returned as strings',
87-
'feel free to get in touch via a github issue if you have any questions');
8879
if(!val) { return null; }
89-
var p = arrayParser.create(val, function(entry){
90-
if(entry !== null) {
91-
entry = parseFloat(entry, 10);
92-
}
80+
var p = arrayParser.create(val, function(entry) {
9381
return entry;
9482
});
9583

@@ -171,27 +159,11 @@ var parseInteger = function(val) {
171159
return parseInt(val, 10);
172160
};
173161

174-
var parseFloatAndWarn = function(val) {
175-
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
176-
'JavaScript has a hard time with floats and there is precision loss which can cause',
177-
'unexpected, hard to trace, potentially bad bugs in your program',
178-
'for more information see the following:',
179-
'https://github.com/brianc/node-postgres/pull/271',
180-
'in node-postgres v1.0.0 all floats & decimals will be returned as strings');
181-
return parseFloat(val);
182-
};
183-
184162
var init = function(register) {
185163
register(20, parseInteger);
186164
register(21, parseInteger);
187165
register(23, parseInteger);
188166
register(26, parseInteger);
189-
//TODO remove for v1.0
190-
register(1700, parseFloatAndWarn);
191-
//TODO remove for v1.0
192-
register(700, parseFloatAndWarn);
193-
//TODO remove for v1.0
194-
register(701, parseFloatAndWarn);
195167
register(16, parseBool);
196168
register(1082, parseDate); // date
197169
register(1114, parseDate); // timestamp without timezone

lib/writer.js

Lines changed: 0 additions & 128 deletions
This file was deleted.

0 commit comments

Comments
 (0)