Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0 #301

Merged
merged 6 commits into from
Apr 4, 2013
Merged

V1.0 #301

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 1 addition & 35 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ var Connection = require(__dirname + '/connection');
var CopyFromStream = require(__dirname + '/copystream').CopyFromStream;
var CopyToStream = require(__dirname + '/copystream').CopyToStream;

var deprecate = require('deprecate');

var Client = function(config) {
EventEmitter.call(this);

Expand Down Expand Up @@ -205,13 +203,7 @@ Client.prototype._pulseQueryQueue = function() {
this.activeQuery.submit(this.connection);
} else if(this.hasExecuted) {
this.activeQuery = null;
//TODO remove pauseDrain for v1.0
if(this._drainPaused > 0) {
this._drainPaused++;
}
else {
this.emit('drain');
}
this.emit('drain');
}
}
};
Expand Down Expand Up @@ -255,32 +247,6 @@ Client.prototype.query = function(config, values, callback) {
return query;
};

//prevents client from otherwise emitting 'drain' event until 'resumeDrain' is
//called
Client.prototype.pauseDrain = function() {
deprecate('Client.prototype.pauseDrain is deprecated and will be removed it v1.0.0 (very soon)',
'please see the following for more details:',
'https://github.com/brianc/node-postgres/wiki/pg',
'https://github.com/brianc/node-postgres/issues/227',
'https://github.com/brianc/node-postgres/pull/274',
'feel free to get in touch via github if you have questions');
this._drainPaused = 1;
};

//resume raising 'drain' event
Client.prototype.resumeDrain = function() {
deprecate('Client.prototype.resumeDrain is deprecated and will be removed it v1.0.0 (very soon)',
'please see the following for more details:',
'https://github.com/brianc/node-postgres/wiki/pg',
'https://github.com/brianc/node-postgres/issues/227',
'https://github.com/brianc/node-postgres/pull/274',
'feel free to get in touch via github if you have questions');
if(this._drainPaused > 1) {
this.emit('drain');
}
this._drainPaused = 0;
};

Client.prototype.end = function() {
this.connection.end();
};
Expand Down
2 changes: 1 addition & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var EventEmitter = require('events').EventEmitter;
var util = require('util');

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

var Connection = function(config) {
EventEmitter.call(this);
Expand Down
9 changes: 0 additions & 9 deletions lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,3 @@ module.exports = {
//pool log function / boolean
poolLog: false
};

var deprecate = require('deprecate');
//getter/setter to disable deprecation warnings
module.exports.__defineGetter__("hideDeprecationWarnings", function() {
return deprecate.silent;
});
module.exports.__defineSetter__("hideDeprecationWarnings", function(val) {
deprecate.silence = val;
});
25 changes: 0 additions & 25 deletions lib/deprecate.js

This file was deleted.

63 changes: 7 additions & 56 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ var EventEmitter = require('events').EventEmitter;
var defaults = require(__dirname + '/defaults');
var genericPool = require('generic-pool');

var deprecate = require('deprecate');

var pools = {
//dictionary of all key:pool pairs
all: {},
Expand Down Expand Up @@ -54,64 +52,17 @@ var pools = {
pool.connect = function(cb) {
pool.acquire(function(err, client) {
if(err) return cb(err, null, function() {/*NOOP*/});
//support both 2 (old) and 3 arguments
(cb.length > 2 ? newConnect : oldConnect)(pool, client, cb);
cb(null, client, function(err) {
if(err) {
pool.destroy(client);
} else {
pool.release(client);
}
});
});
};
return pool;
}
};

//the old connect method of the pool
//would automatically subscribe to the 'drain'
//event and automatically return the client to
//the pool once 'drain' fired once. This caused
//a bunch of problems, but for backwards compatibility
//we're leaving it in
var alarmDuration = 5000;
var errorMessage = [
'A client has been checked out from the pool for longer than ' + alarmDuration + ' ms.',
'You might have a leak!',
'You should use the following new way to check out clients','pg.connect(function(err, client, done)) {',
' //do something',
' done(); //call done() to signal you are finished with the client',
'}'
].join(require('os').EOL);

var oldConnect = function(pool, client, cb) {
deprecate('pg.connect(function(err, client) { ...}) is deprecated and will be removed it v1.0.0 (very soon)',
'instead, use pg.connect(function(err, client, done) { ... })',
'automatic releasing of clients back to the pool was a mistake and will be removed',
'please see the following for more details:',
'https://github.com/brianc/node-postgres/wiki/pg',
'https://github.com/brianc/node-postgres/issues/227',
'https://github.com/brianc/node-postgres/pull/274',
'feel free to get in touch via github if you have questions');
var tid = setTimeout(function() {
console.error(errorMessage);
}, alarmDuration);
var onError = function() {
clearTimeout(tid);
client.removeListener('drain', release);
};
var release = function() {
clearTimeout(tid);
pool.release(client);
client.removeListener('error', onError);
};
client.once('drain', release);
client.once('error', onError);
cb(null, client);
};

var newConnect = function(pool, client, cb) {
cb(null, client, function(err) {
if(err) {
pool.destroy(client);
} else {
pool.release(client);
}
});
};

module.exports = pools;
8 changes: 0 additions & 8 deletions lib/types/binaryParsers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var deprecate = require('deprecate');

var parseBits = function(data, bits, offset, invert, callback) {
offset = offset || 0;
invert = invert || false;
Expand Down Expand Up @@ -47,12 +45,6 @@ var parseBits = function(data, bits, offset, invert, callback) {
};

var parseFloatFromBits = function(data, precisionBits, exponentBits) {
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
'JavaScript has a hard time with floats and there is precision loss which can cause',
'unexpected, hard to trace, potentially bad bugs in your program',
'for more information see the following:',
'https://github.com/brianc/node-postgres/pull/271',
'in node-postgres v1.0.0 all floats & decimals will be returned as strings');
var bias = Math.pow(2, exponentBits - 1) - 1;
var sign = parseBits(data, 1);
var exponent = parseBits(data, exponentBits, 1);
Expand Down
32 changes: 1 addition & 31 deletions lib/types/textParsers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var deprecate = require('deprecate');

var arrayParser = require(__dirname + "/arrayParser.js");

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

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

Expand Down Expand Up @@ -171,36 +159,18 @@ var parseInteger = function(val) {
return parseInt(val, 10);
};

var parseFloatAndWarn = function(val) {
deprecate('parsing and returning floats from PostgreSQL server is deprecated',
'JavaScript has a hard time with floats and there is precision loss which can cause',
'unexpected, hard to trace, potentially bad bugs in your program',
'for more information see the following:',
'https://github.com/brianc/node-postgres/pull/271',
'in node-postgres v1.0.0 all floats & decimals will be returned as strings');
return parseFloat(val);
};

var init = function(register) {
register(20, parseInteger);
register(21, parseInteger);
register(23, parseInteger);
register(26, parseInteger);
//TODO remove for v1.0
register(1700, parseFloatAndWarn);
//TODO remove for v1.0
register(700, parseFloatAndWarn);
//TODO remove for v1.0
register(701, parseFloatAndWarn);
register(16, parseBool);
register(1082, parseDate); // date
register(1114, parseDate); // timestamp without timezone
register(1184, parseDate); // timestamp
register(1005, parseIntegerArray); // _int2
register(1007, parseIntegerArray); // _int4
register(1016, parseIntegerArray); // _int8
register(1021, parseFloatArray); // _float4
register(1022, parseFloatArray); // _float8
register(1231, parseIntegerArray); // _numeric
register(1014, parseStringArray); //char
register(1015, parseStringArray); //varchar
Expand Down
128 changes: 0 additions & 128 deletions lib/writer.js

This file was deleted.

Loading