Comparing version 0.10.5 to 0.10.6
@@ -29,2 +29,3 @@ var Command = require('./command'); | ||
database: connection.config.database, | ||
charsetNumber: connection.config.charsetNumber, | ||
authPluginData1: this.handshake.authPluginData1, | ||
@@ -31,0 +32,0 @@ authPluginData2: this.handshake.authPluginData2, |
@@ -62,2 +62,4 @@ var FieldFlags = require('./constants/field_flags'); | ||
case Types.DATETIME: | ||
case Types.TIMESTAMP: | ||
case Types.NEWDATE: | ||
return "packet.readDateTime();"; | ||
@@ -64,0 +66,0 @@ case Types.DECIMAL: |
@@ -38,2 +38,3 @@ var Types = require('./constants/types'); | ||
case Types.DATETIME: | ||
case Types.TIMESTAMP: | ||
return "new Date(packet.readLengthCodedString());"; | ||
@@ -40,0 +41,0 @@ default: |
@@ -85,3 +85,13 @@ var net = require('net'); | ||
this.stream.on('end', function() { | ||
connection.emit('end', connection._protocolError); | ||
// we need to set this flag everywhere where we want connaction to close | ||
if (connection._closing) | ||
return; | ||
if (!connection._protocolError) // no particular error message before disconnect | ||
connection._protocolError = 'PROTOCOL_CONNECTION_LOST' | ||
var err = new Error('Connection lost: The server closed the connection.'); | ||
err.fatal = true; | ||
err.code = connection._protocolError; | ||
connection.emit('error', err); | ||
}); | ||
@@ -379,4 +389,6 @@ if (!this.config.isServer) { | ||
// TODO: implement COM_QUIT command | ||
var self = this; | ||
var endCmd = { connection: this }; | ||
endCmd.execute = function() { | ||
self._closing = true; | ||
this.connection.stream.end(); | ||
@@ -383,0 +395,0 @@ if (callback) |
@@ -49,2 +49,3 @@ var ClientConstants = require('../constants/client'); | ||
this.authToken = token(this.password, this.authPluginData1, this.authPluginData2); | ||
this.charsetNumber = handshake.charsetNumber; | ||
} | ||
@@ -54,4 +55,2 @@ | ||
{ | ||
var characterSet = Charsets.UTF8_GENERAL_CI; | ||
if (typeof this.user != 'string') | ||
@@ -71,3 +70,3 @@ throw new Error('"user" connection config prperty must be a string'); | ||
packet.writeInt32(0); // max packet size. todo: move to config | ||
packet.writeInt8(characterSet); | ||
packet.writeInt8(this.charsetNumber); | ||
packet.skip(23); | ||
@@ -74,0 +73,0 @@ packet.writeNullTerminatedString(this.user); |
@@ -169,3 +169,3 @@ //var BigNumber = require("bignumber.js"); | ||
} | ||
return new Date(y, m, d, H, M, S, ms); | ||
return new Date(y, m-1, d, H, M, S, ms); | ||
}; | ||
@@ -317,3 +317,3 @@ | ||
if (this.buffer[this.offset] == 0x23) | ||
sqlState = this.readBuffer(5).toString(); | ||
sqlState = this.readBuffer(6).toString(); | ||
var message = this.readString(); | ||
@@ -320,0 +320,0 @@ var err = new Error(message); |
@@ -104,3 +104,3 @@ | ||
connection._realEnd = connection.end; | ||
connection.end = function(cb) { | ||
connection.release = function(cb) { | ||
self.releaseConnection(connection); | ||
@@ -107,0 +107,0 @@ if (cb) cb(); |
@@ -11,2 +11,3 @@ var net = require('net'); | ||
// TODO: inherit Server from net.Server | ||
function Server() | ||
@@ -13,0 +14,0 @@ { |
{ | ||
"name": "mysql2", | ||
"version": "0.10.5", | ||
"version": "0.10.6", | ||
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS", | ||
@@ -17,3 +17,5 @@ "main": "index.js", | ||
"keywords": [ | ||
"mysql", "client", "server" | ||
"mysql", | ||
"client", | ||
"server" | ||
], | ||
@@ -20,0 +22,0 @@ "author": "Andrey Sidorov <sidorares@yandex.ru>", |
@@ -50,3 +50,3 @@ module.exports.createConnection = function(args, callback) { | ||
multipleStatements: args ? args.multipleStatements : false, | ||
port: process.env.MYSQL_PORT || 3306 | ||
port: (args && args.port) || process.env.MYSQL_PORT || 3306 | ||
}); | ||
@@ -75,4 +75,37 @@ }; | ||
module.exports.createServer = function(cb) { | ||
var server = require('../index.js').createServer(); | ||
server.on('connection', function(conn) { | ||
conn.on('error', function() { | ||
// we are here when client drops connection | ||
}); | ||
conn.serverHandshake({ | ||
protocolVersion: 10, | ||
serverVersion: 'node.js rocks', | ||
connectionId: 1234, | ||
statusFlags: 2, | ||
characterSet: 8, | ||
capabilityFlags: 0xffffff | ||
}); | ||
conn.on('query', function(sql) { | ||
conn.writeTextResult([ { '1': '1' } ], [ { catalog: 'def', | ||
schema: '', | ||
table: '', | ||
orgTable: '', | ||
name: '1', | ||
orgName: '', | ||
characterSet: 63, | ||
columnLength: 1, | ||
columnType: 8, | ||
flags: 129, | ||
decimals: 0 } ]); | ||
}); | ||
//conn.on('end', ); | ||
}); | ||
server.listen(3307, undefined, undefined, cb); | ||
return server; | ||
} | ||
module.exports.hrdiff = function(t1, t2) { | ||
return t2[1] - t1[1] + (t2[0] - t1[0])*1e9; | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
221506
108
5202