Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mysql

Package Overview
Dependencies
Maintainers
9
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql - npm Package Compare versions

Comparing version 2.7.0 to 2.8.0

10

Changes.md

@@ -7,4 +7,12 @@ # Changes

## v2.6.0 (2015-05-27)
## v2.8.0 (2015-07-13)
* Add `connect` event to `Connection` #1129
* Default `timeout` for `connection.end` to 30 seconds #1057
* Fix a sync callback when sequence enqueue fails #1147
* Provide static require analysis
* Re-use connection from pool after `conn.changeUser` is used #837 #1088
## v2.7.0 (2015-05-27)
* Destroy/end connections removed from the pool on error

@@ -11,0 +19,0 @@ * Delay implied connect until after `.query` argument validation

@@ -225,9 +225,20 @@ var Crypto = require('crypto');

Connection.prototype.end = function end(options, callback) {
var cb = callback;
var opts = options;
if (!callback && typeof options === 'function') {
callback = options;
options = {};
cb = options;
opts = null;
}
// create custom options reference
opts = Object.create(opts || null)
if (opts.timeout === undefined) {
// default timeout of 30 seconds
opts.timeout = 30000;
}
this._implyConnect();
this._protocol.quit(options, bindToCurrentDomain(callback));
this._protocol.quit(opts, bindToCurrentDomain(cb));
};

@@ -386,2 +397,3 @@

this.state = "connected";
this.emit('connect');
};

@@ -388,0 +400,0 @@

38

lib/Pool.js

@@ -77,7 +77,8 @@ var mysql = require('../');

var pool = this;
var changeUser = this._needsChangeUser(connection);
var pool = this;
this._acquiringConnections.push(connection);
connection.ping({timeout: this.config.acquireTimeout}, function onPing(err) {
function onOperationComplete(err) {
spliceConnection(pool._acquiringConnections, connection);

@@ -95,4 +96,17 @@

if (changeUser) {
pool.emit('connection', connection);
}
cb(null, connection);
});
}
if (changeUser) {
// restore user back to pool configuration
connection.config = this.config.newConnectionConfig();
connection.changeUser({timeout: this.config.acquireTimeout}, onOperationComplete);
} else {
// ping connection
connection.ping({timeout: this.config.acquireTimeout}, onOperationComplete);
}
};

@@ -102,2 +116,3 @@

var cb;
var pool = this;

@@ -114,7 +129,3 @@ if (this._acquiringConnections.indexOf(connection) !== -1) {

if (connection._purge) {
// purge connection from pool
this._purgeConnection(connection);
return;
} else if (this._freeConnections.indexOf(connection) !== -1) {
if (this._freeConnections.indexOf(connection) !== -1) {
// connection already in free connection pool

@@ -225,2 +236,13 @@ // this won't catch all double-release cases

Pool.prototype._needsChangeUser = function _needsChangeUser(connection) {
var connConfig = connection.config;
var poolConfig = this.config.connectionConfig;
// check if changeUser values are different
return connConfig.user !== poolConfig.user
|| connConfig.database !== poolConfig.database
|| connConfig.password !== poolConfig.password
|| connConfig.charsetNumber !== poolConfig.charsetNumber;
}
Pool.prototype._purgeConnection = function _purgeConnection(connection, callback) {

@@ -227,0 +249,0 @@ var cb = callback || function () {};

var inherits = require('util').inherits;
var Connection = require('./Connection')
var __changeUser = Connection.prototype.changeUser;

@@ -11,3 +10,2 @@ module.exports = PoolConnection;

this._pool = pool;
this._purge = false

@@ -25,10 +23,5 @@ // When a fatal error occurs the connection's protocol ends, which will cause

PoolConnection.prototype.changeUser = function changeUser(options, callback) {
this._purge = true;
return __changeUser.apply(this, arguments);
};
PoolConnection.prototype.release = function release() {
var pool = this._pool;
var connection = this;

@@ -35,0 +28,0 @@ if (!pool || pool._closed) {

@@ -1,4 +0,20 @@

var Elements = module.exports = require('require-all')({
dirname : __dirname,
filter : /([A-Z].+)\.js$/,
});
exports.ClientAuthenticationPacket = require('./ClientAuthenticationPacket');
exports.ComChangeUserPacket = require('./ComChangeUserPacket');
exports.ComPingPacket = require('./ComPingPacket');
exports.ComQueryPacket = require('./ComQueryPacket');
exports.ComQuitPacket = require('./ComQuitPacket');
exports.ComStatisticsPacket = require('./ComStatisticsPacket');
exports.EmptyPacket = require('./EmptyPacket');
exports.EofPacket = require('./EofPacket');
exports.ErrorPacket = require('./ErrorPacket');
exports.Field = require('./Field');
exports.FieldPacket = require('./FieldPacket');
exports.HandshakeInitializationPacket = require('./HandshakeInitializationPacket');
exports.LocalDataFilePacket = require('./LocalDataFilePacket');
exports.OkPacket = require('./OkPacket');
exports.OldPasswordPacket = require('./OldPasswordPacket');
exports.ResultSetHeaderPacket = require('./ResultSetHeaderPacket');
exports.RowDataPacket = require('./RowDataPacket');
exports.SSLRequestPacket = require('./SSLRequestPacket');
exports.StatisticsPacket = require('./StatisticsPacket');
exports.UseOldPasswordPacket = require('./UseOldPasswordPacket');

@@ -186,3 +186,3 @@ var Parser = require('./Parser');

Protocol.prototype._validateEnqueue = function(sequence) {
Protocol.prototype._validateEnqueue = function _validateEnqueue(sequence) {
var err;

@@ -215,8 +215,11 @@ var prefix = 'Cannot enqueue ' + sequence.constructor.name;

sequence
.on('error', function(err) {
self._delegateError(err, sequence);
})
.end(err);
// add error handler
sequence.on('error', function (err) {
self._delegateError(err, sequence);
});
process.nextTick(function () {
sequence.end(err);
});
return false;

@@ -223,0 +226,0 @@ };

@@ -1,4 +0,7 @@

var Elements = module.exports = require('require-all')({
dirname : __dirname,
filter : /([A-Z].+)\.js$/,
});
exports.ChangeUser = require('./ChangeUser');
exports.Handshake = require('./Handshake');
exports.Ping = require('./Ping');
exports.Query = require('./Query');
exports.Quit = require('./Quit');
exports.Sequence = require('./Sequence');
exports.Statistics = require('./Statistics');
{
"name": "mysql",
"description": "A node.js driver for mysql. It is written in JavaScript, does not require compiling, and is 100% MIT licensed.",
"version": "2.7.0",
"version": "2.8.0",
"license": "MIT",

@@ -16,4 +16,3 @@ "author": "Felix Geisendörfer <felix@debuggable.com> (http://debuggable.com/)",

"bignumber.js": "2.0.7",
"readable-stream": "~1.1.13",
"require-all": "~1.0.0"
"readable-stream": "~1.1.13"
},

@@ -23,3 +22,4 @@ "devDependencies": {

"rimraf": "2.2.8",
"mkdirp": "0.5.0",
"require-all": "~1.1.0",
"mkdirp": "0.5.1",
"urun": "0.0.8",

@@ -26,0 +26,0 @@ "utest": "0.0.8"

@@ -83,3 +83,4 @@ # mysql

user : 'me',
password : 'secret'
password : 'secret',
database : 'my_db'
});

@@ -128,3 +129,3 @@

* [pinkbike.com](http://pinkbike.com/)
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/vacancy/software-engineer-5/))
* [Holiday Extras](http://www.holidayextras.co.uk/) (they are [hiring](http://join.holidayextras.co.uk/))
* [Newscope](http://newscope.com/) (they are [hiring](http://www.newscope.com/stellenangebote))

@@ -860,3 +861,3 @@

query events into a [Readable](http://nodejs.org/api/stream.html#stream_class_stream_readable)
Streams2[Streams2](http://blog.nodejs.org/2012/12/20/streams2/) object. This
[Streams2](http://blog.nodejs.org/2012/12/20/streams2/) object. This
stream can easily be piped downstream and provides automatic pause/resume,

@@ -981,4 +982,4 @@ based on downstream congestion and the optional `highWaterMark`. The

connection.query('INSERT INTO posts SET title=?', title, function(err, result) {
if (err) {
connection.rollback(function() {
if (err) {
return connection.rollback(function() {
throw err;

@@ -988,18 +989,18 @@ });

var log = 'Post ' + result.insertId + ' added';
var log = 'Post ' + result.insertId + ' added';
connection.query('INSERT INTO log SET data=?', log, function(err, result) {
if (err) {
connection.rollback(function() {
connection.query('INSERT INTO log SET data=?', log, function(err, result) {
if (err) {
return connection.rollback(function() {
throw err;
});
}
connection.commit(function(err) {
if (err) {
connection.rollback(function() {
connection.commit(function(err) {
if (err) {
return connection.rollback(function() {
throw err;
});
}
console.log('success!');
});
console.log('success!');
});
});

@@ -1006,0 +1007,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc