diff --git a/lib/native/query.js b/lib/native/query.js index 5436f02..55b3262 100644 --- a/lib/native/query.js +++ b/lib/native/query.js @@ -19,6 +19,9 @@ var NativeQuery = function(config, values, callback) { this.text = c.text; this.values = c.values; this.callback = c.callback; + if(process.domain && c.callback) { + this.callback = process.domain.bind(c.callback); + } this.singleRowMode = false; if(!this.callback) { diff --git a/lib/pool.js b/lib/pool.js index e2fe222..67140e6 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -64,23 +64,9 @@ var pools = { pool.acquire(function(err, client) { if(domain) { cb = domain.bind(cb); - domain.add(client); - //native clients do not have a connection object - if(client.connection) { - domain.add(client.connection); - domain.add(client.connection.stream); - } } if(err) return cb(err, null, function() {/*NOOP*/}); cb(null, client, function(err) { - if(domain) { - //native clients do not have a connection object - if(client.connection) { - domain.remove(client.connection.stream); - domain.remove(client.connection); - } - domain.remove(client); - } if(err) { pool.destroy(client); } else { diff --git a/lib/query.js b/lib/query.js index 03843ce..0c6bbc7 100644 --- a/lib/query.js +++ b/lib/query.js @@ -20,6 +20,9 @@ var Query = function(config, values, callback) { //use unique portal name each time this.portal = config.portal || ""; this.callback = config.callback; + if(process.domain && config.callback) { + this.callback = process.domain.bind(config.callback); + } this._fieldNames = []; this._fieldConverters = []; this._result = new Result(config.rowMode);