New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mysql2

Package Overview
Dependencies
Maintainers
3
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mysql2 - npm Package Compare versions

Comparing version 3.12.1-canary.be22202e to 3.12.1-canary.e70160b7

10

index.js

@@ -48,3 +48,3 @@ 'use strict';

'createConnectionPromise',
() => require('./promise.js').createConnection,
() => require('./promise.js').createConnection
);

@@ -54,3 +54,3 @@

'createPoolPromise',
() => require('./promise.js').createPool,
() => require('./promise.js').createPool
);

@@ -60,3 +60,3 @@

'createPoolClusterPromise',
() => require('./promise.js').createPoolCluster,
() => require('./promise.js').createPoolCluster
);

@@ -67,7 +67,7 @@

exports.__defineGetter__('Charsets', () =>
require('./lib/constants/charsets.js'),
require('./lib/constants/charsets.js')
);
exports.__defineGetter__('CharsetToEncoding', () =>
require('./lib/constants/charset_encodings.js'),
require('./lib/constants/charset_encodings.js')
);

@@ -74,0 +74,0 @@

@@ -61,3 +61,3 @@ 'use strict';

exports.calculateTokenFromPasswordSha = function(
exports.calculateTokenFromPasswordSha = function (
passwordSha,

@@ -77,3 +77,3 @@ scramble1,

exports.verifyToken = function(publicSeed1, publicSeed2, token, doubleSha) {
exports.verifyToken = function (publicSeed1, publicSeed2, token, doubleSha) {
const hashStage1 = xor(token, sha1(publicSeed1, publicSeed2, doubleSha));

@@ -84,3 +84,3 @@ const candidateHash2 = sha1(hashStage1);

exports.doubleSha1 = function(password) {
exports.doubleSha1 = function (password) {
return sha1(sha1(password));

@@ -87,0 +87,0 @@ };

@@ -35,73 +35,75 @@ 'use strict';

function encrypt(password, scramble, key) {
const stage1 = xorRotating(
Buffer.from(`${password}\0`, 'utf8'),
scramble
const stage1 = xorRotating(Buffer.from(`${password}\0`, 'utf8'), scramble);
return crypto.publicEncrypt(
{
key,
padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
},
stage1
);
return crypto.publicEncrypt({
key,
padding: crypto.constants.RSA_PKCS1_OAEP_PADDING
}, stage1);
}
module.exports = (pluginOptions = {}) => ({ connection }) => {
let state = 0;
let scramble = null;
module.exports =
(pluginOptions = {}) =>
({ connection }) => {
let state = 0;
let scramble = null;
const password = connection.config.password;
const password = connection.config.password;
const authWithKey = serverKey => {
const _password = encrypt(password, scramble, serverKey);
state = STATE_FINAL;
return _password;
};
const authWithKey = (serverKey) => {
const _password = encrypt(password, scramble, serverKey);
state = STATE_FINAL;
return _password;
};
return data => {
switch (state) {
case STATE_INITIAL:
scramble = data.slice(0, 20);
state = STATE_TOKEN_SENT;
return calculateToken(password, scramble);
return (data) => {
switch (state) {
case STATE_INITIAL:
scramble = data.slice(0, 20);
state = STATE_TOKEN_SENT;
return calculateToken(password, scramble);
case STATE_TOKEN_SENT:
if (FAST_AUTH_SUCCESS_PACKET.equals(data)) {
state = STATE_FINAL;
return null;
}
if (PERFORM_FULL_AUTHENTICATION_PACKET.equals(data)) {
const isSecureConnection =
typeof pluginOptions.overrideIsSecure === 'undefined'
? connection.config.ssl || connection.config.socketPath
: pluginOptions.overrideIsSecure;
if (isSecureConnection) {
case STATE_TOKEN_SENT:
if (FAST_AUTH_SUCCESS_PACKET.equals(data)) {
state = STATE_FINAL;
return Buffer.from(`${password}\0`, 'utf8');
return null;
}
// if client provides key we can save one extra roundrip on first connection
if (pluginOptions.serverPublicKey) {
return authWithKey(pluginOptions.serverPublicKey);
if (PERFORM_FULL_AUTHENTICATION_PACKET.equals(data)) {
const isSecureConnection =
typeof pluginOptions.overrideIsSecure === 'undefined'
? connection.config.ssl || connection.config.socketPath
: pluginOptions.overrideIsSecure;
if (isSecureConnection) {
state = STATE_FINAL;
return Buffer.from(`${password}\0`, 'utf8');
}
// if client provides key we can save one extra roundrip on first connection
if (pluginOptions.serverPublicKey) {
return authWithKey(pluginOptions.serverPublicKey);
}
state = STATE_WAIT_SERVER_KEY;
return REQUEST_SERVER_KEY_PACKET;
}
throw new Error(
`Invalid AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_TOKEN_SENT state.`
);
case STATE_WAIT_SERVER_KEY:
if (pluginOptions.onServerPublicKey) {
pluginOptions.onServerPublicKey(data);
}
return authWithKey(data);
case STATE_FINAL:
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_FINAL state.`
);
}
state = STATE_WAIT_SERVER_KEY;
return REQUEST_SERVER_KEY_PACKET;
}
throw new Error(
`Invalid AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_TOKEN_SENT state.`
);
case STATE_WAIT_SERVER_KEY:
if (pluginOptions.onServerPublicKey) {
pluginOptions.onServerPublicKey(data);
}
return authWithKey(data);
case STATE_FINAL:
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_FINAL state.`
);
}
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in state ${state}`
);
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in state ${state}`
);
};
};
};

@@ -10,10 +10,10 @@ ##

caching_sha2_password: mysql.authPlugins.caching_sha2_password({
onServerPublikKey: function(key) {
onServerPublikKey: function (key) {
console.log(key);
},
serverPublicKey: 'xxxyyy',
overrideIsSecure: true //
})
}
overrideIsSecure: true, //
}),
},
});
```

@@ -7,3 +7,3 @@ 'use strict';

const create_mysql_clear_password_plugin = pluginOptions =>
const create_mysql_clear_password_plugin = (pluginOptions) =>
function mysql_clear_password_plugin({ connection, command }) {

@@ -10,0 +10,0 @@ const password =

@@ -6,28 +6,30 @@ 'use strict';

module.exports = pluginOptions => ({ connection, command }) => {
const password =
command.password || pluginOptions.password || connection.config.password;
const passwordSha1 =
command.passwordSha1 ||
pluginOptions.passwordSha1 ||
connection.config.passwordSha1;
return data => {
const authPluginData1 = data.slice(0, 8);
const authPluginData2 = data.slice(8, 20);
let authToken;
if (passwordSha1) {
authToken = auth41.calculateTokenFromPasswordSha(
passwordSha1,
authPluginData1,
authPluginData2
);
} else {
authToken = auth41.calculateToken(
password,
authPluginData1,
authPluginData2
);
}
return authToken;
module.exports =
(pluginOptions) =>
({ connection, command }) => {
const password =
command.password || pluginOptions.password || connection.config.password;
const passwordSha1 =
command.passwordSha1 ||
pluginOptions.passwordSha1 ||
connection.config.passwordSha1;
return (data) => {
const authPluginData1 = data.slice(0, 8);
const authPluginData2 = data.slice(8, 20);
let authToken;
if (passwordSha1) {
authToken = auth41.calculateTokenFromPasswordSha(
passwordSha1,
authPluginData1,
authPluginData2
);
} else {
authToken = auth41.calculateToken(
password,
authPluginData1,
authPluginData2
);
}
return authToken;
};
};
};

@@ -14,48 +14,47 @@ 'use strict';

function encrypt(password, scramble, key) {
const stage1 = xorRotating(
Buffer.from(`${password}\0`, 'utf8'),
scramble
);
const stage1 = xorRotating(Buffer.from(`${password}\0`, 'utf8'), scramble);
return crypto.publicEncrypt(key, stage1);
}
module.exports = (pluginOptions = {}) => ({ connection }) => {
let state = 0;
let scramble = null;
module.exports =
(pluginOptions = {}) =>
({ connection }) => {
let state = 0;
let scramble = null;
const password = connection.config.password;
const password = connection.config.password;
const authWithKey = serverKey => {
const _password = encrypt(password, scramble, serverKey);
state = STATE_FINAL;
return _password;
};
const authWithKey = (serverKey) => {
const _password = encrypt(password, scramble, serverKey);
state = STATE_FINAL;
return _password;
};
return data => {
switch (state) {
case STATE_INITIAL:
scramble = data.slice(0, 20);
// if client provides key we can save one extra roundrip on first connection
if (pluginOptions.serverPublicKey) {
return authWithKey(pluginOptions.serverPublicKey);
}
return (data) => {
switch (state) {
case STATE_INITIAL:
scramble = data.slice(0, 20);
// if client provides key we can save one extra roundrip on first connection
if (pluginOptions.serverPublicKey) {
return authWithKey(pluginOptions.serverPublicKey);
}
state = STATE_WAIT_SERVER_KEY;
return REQUEST_SERVER_KEY_PACKET;
state = STATE_WAIT_SERVER_KEY;
return REQUEST_SERVER_KEY_PACKET;
case STATE_WAIT_SERVER_KEY:
if (pluginOptions.onServerPublicKey) {
pluginOptions.onServerPublicKey(data);
}
return authWithKey(data);
case STATE_FINAL:
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_FINAL state.`
);
}
case STATE_WAIT_SERVER_KEY:
if (pluginOptions.onServerPublicKey) {
pluginOptions.onServerPublicKey(data);
}
return authWithKey(data);
case STATE_FINAL:
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in STATE_FINAL state.`
);
}
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in state ${state}`
);
throw new Error(
`Unexpected data in AuthMoreData packet received by ${PLUGIN_NAME} plugin in state ${state}`
);
};
};
};

@@ -114,3 +114,3 @@ // This file was modified by Oracle on June 1, 2021.

this._protocolError = new Error(
'Connection lost: The server closed the connection.',
'Connection lost: The server closed the connection.'
);

@@ -154,3 +154,3 @@ this._protocolError.fatal = true;

timeoutHandler,
this.config.connectTimeout,
this.config.connectTimeout
);

@@ -162,3 +162,3 @@ }

const err = new Error(
"Can't add new command when connection is in closed state",
"Can't add new command when connection is in closed state"
);

@@ -299,6 +299,6 @@ err.fatal = true;

console.log(
`${this._internalId} ${this.connectionId} <== ${this._command._commandName}#${this._command.stateName()}(${[this.sequenceId, packet._name, packet.length()].join(',')})`,
`${this._internalId} ${this.connectionId} <== ${this._command._commandName}#${this._command.stateName()}(${[this.sequenceId, packet._name, packet.length()].join(',')})`
);
console.log(
`${this._internalId} ${this.connectionId} <== ${packet.buffer.toString('hex')}`,
`${this._internalId} ${this.connectionId} <== ${packet.buffer.toString('hex')}`
);

@@ -311,6 +311,6 @@ }

console.log(
`${this._internalId} ${this.connectionId} <== Writing large packet, raw content not written:`,
`${this._internalId} ${this.connectionId} <== Writing large packet, raw content not written:`
);
console.log(
`${this._internalId} ${this.connectionId} <== ${this._command._commandName}#${this._command.stateName()}(${[this.sequenceId, packet._name, packet.length()].join(',')})`,
`${this._internalId} ${this.connectionId} <== ${this._command._commandName}#${this._command.stateName()}(${[this.sequenceId, packet._name, packet.length()].join(',')})`
);

@@ -364,4 +364,4 @@ }

: function () {
return undefined;
},
return undefined;
},
secureContext,

@@ -379,3 +379,3 @@ isServer: false,

servername,
cert,
cert
);

@@ -389,3 +389,3 @@ if (serverIdentityCheckError) {

onSecure();
},
}
);

@@ -435,3 +435,3 @@ // error handler for secure socket

.slice(packet.offset, packet.offset + packet.length())
.toString('hex')}`,
.toString('hex')}`
);

@@ -446,3 +446,3 @@ console.trace();

console.log(
`${this._internalId} ${this.connectionId} ==> ${commandName}#${stateName}(${[packet.sequenceId, packet.type(), packet.length()].join(',')})`,
`${this._internalId} ${this.connectionId} ==> ${commandName}#${stateName}(${[packet.sequenceId, packet.type(), packet.length()].join(',')})`
);

@@ -461,3 +461,3 @@ }

'Unexpected packet while no commands in the queue',
'PROTOCOL_UNEXPECTED_PACKET',
'PROTOCOL_UNEXPECTED_PACKET'
);

@@ -472,3 +472,3 @@ }

const err = new Error(
`Warning: got packets out of order. Expected ${this.sequenceId} but received ${packet.sequenceId}`,
`Warning: got packets out of order. Expected ${this.sequenceId} but received ${packet.sequenceId}`
);

@@ -525,3 +525,3 @@ err.expected = this.sequenceId;

values,
this.config.timezone,
this.config.timezone
);

@@ -538,3 +538,3 @@ }

this.config.stringifyObjects,
this.config.timezone,
this.config.timezone
);

@@ -582,3 +582,3 @@ }

cmdQuery.sql,
cmdQuery.values !== undefined ? cmdQuery.values : [],
cmdQuery.values !== undefined ? cmdQuery.values : []
);

@@ -664,3 +664,3 @@ cmdQuery.sql = rawSql;

throw new TypeError(
'Bind parameters must be array if namedPlaceholders parameter is not enabled',
'Bind parameters must be array if namedPlaceholders parameter is not enabled'
);

@@ -672,3 +672,3 @@ }

throw new TypeError(
'Bind parameters must be array if namedPlaceholders parameter is not enabled',
'Bind parameters must be array if namedPlaceholders parameter is not enabled'
);

@@ -678,3 +678,3 @@ }

throw new TypeError(
'Bind parameters must not contain undefined. To pass SQL NULL specify JS null',
'Bind parameters must not contain undefined. To pass SQL NULL specify JS null'
);

@@ -684,3 +684,3 @@ }

throw new TypeError(
'Bind parameters must not contain function(s). To pass the body of a function as a string call .toString() first',
'Bind parameters must not contain function(s). To pass the body of a function as a string call .toString() first'
);

@@ -748,4 +748,4 @@ }

}
},
),
}
)
);

@@ -855,3 +855,3 @@ }

this.writePacket(
Packets.ColumnDefinition.toPacket(column, this.serverConfig.encoding),
Packets.ColumnDefinition.toPacket(column, this.serverConfig.encoding)
);

@@ -865,3 +865,3 @@ });

this.writePacket(
Packets.TextRow.toPacket(column, this.serverConfig.encoding),
Packets.TextRow.toPacket(column, this.serverConfig.encoding)
);

@@ -872,3 +872,3 @@ }

this.writePacket(
Packets.BinaryRow.toPacket(column, this.serverConfig.encoding),
Packets.BinaryRow.toPacket(column, this.serverConfig.encoding)
);

@@ -875,0 +875,0 @@ }

@@ -37,3 +37,3 @@ 'use strict';

'restored to default conn.end() behavior. Use ' +
'conn.release() instead.',
'conn.release() instead.'
);

@@ -40,0 +40,0 @@ this.emit('warn', err);

@@ -133,3 +133,3 @@ 'use strict';

cb,
this.config.connectionConfig,
this.config.connectionConfig
);

@@ -217,3 +217,3 @@ if (typeof cmdQuery.namedPlaceholders === 'undefined') {

this.config.connectionConfig.stringifyObjects,
this.config.connectionConfig.timezone,
this.config.connectionConfig.timezone
);

@@ -226,3 +226,3 @@ }

this.config.connectionConfig.stringifyObjects,
this.config.connectionConfig.timezone,
this.config.connectionConfig.timezone
);

@@ -229,0 +229,0 @@ }

@@ -18,3 +18,3 @@ // This file was modified by Oracle on July 5, 2021.

mysql_native_password: mysql_native_password({}),
mysql_clear_password: mysql_clear_password({})
mysql_clear_password: mysql_clear_password({}),
};

@@ -37,5 +37,4 @@

function authSwitchRequest(packet, connection, command) {
const { pluginName, pluginData } = Packets.AuthSwitchRequest.fromPacket(
packet
);
const { pluginName, pluginData } =
Packets.AuthSwitchRequest.fromPacket(packet);
let authPlugin =

@@ -69,9 +68,11 @@ connection.config.authPlugins && connection.config.authPlugins[pluginName];

connection._authPlugin = authPlugin({ connection, command });
Promise.resolve(connection._authPlugin(pluginData)).then(data => {
if (data) {
connection.writePacket(new Packets.AuthSwitchResponse(data).toPacket());
}
}).catch(err => {
authSwitchPluginError(err, command);
});
Promise.resolve(connection._authPlugin(pluginData))
.then((data) => {
if (data) {
connection.writePacket(new Packets.AuthSwitchResponse(data).toPacket());
}
})
.catch((err) => {
authSwitchPluginError(err, command);
});
}

@@ -99,9 +100,11 @@

}
Promise.resolve(connection._authPlugin(data)).then(data => {
if (data) {
connection.writePacket(new Packets.AuthSwitchResponse(data).toPacket());
}
}).catch(err => {
authSwitchPluginError(err, command);
});
Promise.resolve(connection._authPlugin(data))
.then((data) => {
if (data) {
connection.writePacket(new Packets.AuthSwitchResponse(data).toPacket());
}
})
.catch((err) => {
authSwitchPluginError(err, command);
});
}

@@ -111,3 +114,3 @@

authSwitchRequest,
authSwitchRequestMoreData
authSwitchRequestMoreData,
};

@@ -49,3 +49,3 @@ 'use strict';

event = {
name: 'UNKNOWN'
name: 'UNKNOWN',
};

@@ -52,0 +52,0 @@ }

@@ -40,3 +40,3 @@ // This file was modified by Oracle on September 21, 2021.

authPluginData1: connection._handshakePacket.authPluginData1,
authPluginData2: connection._handshakePacket.authPluginData2
authPluginData2: connection._handshakePacket.authPluginData2,
});

@@ -52,3 +52,5 @@ this.currentConfig.user = this.user;

// check if the server supports multi-factor authentication
const multiFactorAuthentication = connection.serverCapabilityFlags & ClientConstants.MULTI_FACTOR_AUTHENTICATION;
const multiFactorAuthentication =
connection.serverCapabilityFlags &
ClientConstants.MULTI_FACTOR_AUTHENTICATION;
if (multiFactorAuthentication) {

@@ -55,0 +57,0 @@ // if the server supports multi-factor authentication, we enable it in

@@ -70,3 +70,3 @@ // This file was modified by Oracle on June 17, 2021.

this.database = connection.config.database;
this.autPluginName = this.handshake.autPluginName;
this.authPluginName = this.handshake.authPluginName;
const handshakeResponse = new Packets.HandshakeResponse({

@@ -82,3 +82,3 @@ flags: this.clientFlags,

compress: connection.config.compress,
connectAttributes: connection.config.connectAttributes
connectAttributes: connection.config.connectAttributes,
});

@@ -110,3 +110,3 @@ connection.writePacket(handshakeResponse.toPacket());

handshakeInit(helloPacket, connection) {
this.on('error', e => {
this.on('error', (e) => {
connection._fatalError = e;

@@ -133,3 +133,4 @@ connection._protocolError = e;

const multiFactorAuthentication =
this.handshake.capabilityFlags & ClientConstants.MULTI_FACTOR_AUTHENTICATION;
this.handshake.capabilityFlags &
ClientConstants.MULTI_FACTOR_AUTHENTICATION;
this.clientFlags = this.clientFlags | multiFactorAuthentication;

@@ -153,3 +154,3 @@ // use compression only if requested by client and supported by server

this.sendSSLRequest(connection);
connection.startTLS(err => {
connection.startTLS((err) => {
// after connection is secure

@@ -192,3 +193,4 @@ if (err) {

// corresponding password (if there is one)
connection.config.password = this[`password${this.authenticationFactor}`];
connection.config.password =
this[`password${this.authenticationFactor}`];
// update the current authentication factor

@@ -234,4 +236,4 @@ this.authenticationFactor += 1;

if (connection.config.compress) {
const enableCompression = require('../compressed_protocol.js')
.enableCompression;
const enableCompression =
require('../compressed_protocol.js').enableCompression;
enableCompression(connection);

@@ -238,0 +240,0 @@ }

@@ -48,6 +48,5 @@ 'use strict';

return false;
}
}
this.emit('end');
return true;
}

@@ -54,0 +53,0 @@ }

@@ -50,3 +50,3 @@ 'use strict';

connection.config.charsetNumber,
connection.config.timezone,
connection.config.timezone
);

@@ -77,3 +77,3 @@ //For reasons why this try-catch is here, please see

packet,
connection.clientEncoding,
connection.clientEncoding
);

@@ -97,3 +97,3 @@ this._receivedFieldsCount++;

this._fields[this._resultIndex],
connection,
connection
))();

@@ -100,0 +100,0 @@ return Execute.prototype.row;

@@ -26,3 +26,3 @@ 'use strict';

ChangeUser,
Quit
Quit,
};

@@ -72,5 +72,6 @@ 'use strict';

return Prepare.prototype.readParameter;
} if (this.fieldCount > 0) {
}
if (this.fieldCount > 0) {
return Prepare.prototype.readField;
}
}
return this.prepareDone(connection);

@@ -116,5 +117,4 @@ }

return Prepare.prototype.readField;
}
}
return this.prepareDone(connection);
}

@@ -121,0 +121,0 @@

@@ -59,3 +59,3 @@ 'use strict';

this.sql,
connection.config.charsetNumber,
connection.config.charsetNumber
);

@@ -125,3 +125,3 @@ connection.writePacket(cmdPacket.toPacket(1));

console.log(
` Resultset header received, expecting ${rs.fieldCount} column definition packets`,
` Resultset header received, expecting ${rs.fieldCount} column definition packets`
);

@@ -146,3 +146,3 @@ }

this._localStreamError = new Error(
`As a result of LOCAL INFILE command server wants to read ${path} file, but as of v2.0 you must provide streamFactory option returning ReadStream.`,
`As a result of LOCAL INFILE command server wants to read ${path} file, but as of v2.0 you must provide streamFactory option returning ReadStream.`
);

@@ -166,3 +166,3 @@ connection.writePacket(EmptyPacket);

connection.writePacket(
new Packets.Packet(0, dataWithHeader, 0, dataWithHeader.length),
new Packets.Packet(0, dataWithHeader, 0, dataWithHeader.length)
);

@@ -204,3 +204,3 @@ };

packet,
connection.clientEncoding,
connection.clientEncoding
);

@@ -227,3 +227,3 @@ this._fields[this._resultIndex].push(field);

this.options,
connection.config,
connection.config
))(fields);

@@ -260,3 +260,3 @@ }

this._fields[this._resultIndex],
this.options,
this.options
);

@@ -263,0 +263,0 @@ } catch (err) {

@@ -26,3 +26,3 @@ 'use strict';

this.serverHello = serverHelloPacket;
serverHelloPacket.setScrambleData(err => {
serverHelloPacket.setScrambleData((err) => {
if (err) {

@@ -50,3 +50,3 @@ connection.emit('error', new Error('Error generating random bytes'));

authPluginData2: this.serverHello.authPluginData2,
authToken: clientHelloReply.authToken
authToken: clientHelloReply.authToken,
},

@@ -62,3 +62,3 @@ (err, mysqlError) => {

message: mysqlError.message || '',
code: mysqlError.code || 1045
code: mysqlError.code || 1045,
});

@@ -93,4 +93,3 @@ connection.close();

code: Errors.HA_ERR_INTERNAL_ERROR,
message:
'No query handler for prepared statements.'
message: 'No query handler for prepared statements.',
});

@@ -101,9 +100,15 @@ }

if (connection.listeners('stmt_execute').length) {
const { stmtId, flags, iterationCount, values } = Packets.Execute.fromPacket(packet, encoding);
connection.emit('stmt_execute', stmtId, flags, iterationCount, values);
const { stmtId, flags, iterationCount, values } =
Packets.Execute.fromPacket(packet, encoding);
connection.emit(
'stmt_execute',
stmtId,
flags,
iterationCount,
values
);
} else {
connection.writeError({
code: Errors.HA_ERR_INTERNAL_ERROR,
message:
'No query handler for execute statements.'
message: 'No query handler for execute statements.',
});

@@ -130,13 +135,14 @@ }

const query = packet.readString(undefined, encoding);
if (this._isStatement(query, 'PREPARE') || this._isStatement(query, 'SET')) {
if (
this._isStatement(query, 'PREPARE') ||
this._isStatement(query, 'SET')
) {
connection.emit('stmt_prepare', query);
}
else if (this._isStatement(query, 'EXECUTE')) {
} else if (this._isStatement(query, 'EXECUTE')) {
connection.emit('stmt_execute', null, null, null, null, query);
}
else connection.emit('query', query);
} else connection.emit('query', query);
} else {
connection.writeError({
code: Errors.HA_ERR_INTERNAL_ERROR,
message: 'No query handler'
message: 'No query handler',
});

@@ -154,3 +160,3 @@ }

message:
'As of MySQL 5.7.11, COM_FIELD_LIST is deprecated and will be removed in a future version of MySQL.'
'As of MySQL 5.7.11, COM_FIELD_LIST is deprecated and will be removed in a future version of MySQL.',
});

@@ -157,0 +163,0 @@ }

@@ -16,3 +16,3 @@ 'use strict';

if (deflatedLength !== 0) {
connection.inflateQueue.push(task => {
connection.inflateQueue.push((task) => {
zlib.inflate(body, (err, data) => {

@@ -29,3 +29,3 @@ if (err) {

} else {
connection.inflateQueue.push(task => {
connection.inflateQueue.push((task) => {
connection._bumpCompressedSequenceId(packet.numPackets);

@@ -67,4 +67,4 @@ connection._inflatedPacketsParser.execute(body);

// to assemble uncompressed result sequentially
(function(seqId) {
connection.deflateQueue.push(task => {
(function (seqId) {
connection.deflateQueue.push((task) => {
zlib.deflate(buffer, (err, compressed) => {

@@ -112,7 +112,7 @@ if (err) {

connection._handleCompressedPacket = handleCompressedPacket;
connection._inflatedPacketsParser = new PacketParser(p => {
connection._inflatedPacketsParser = new PacketParser((p) => {
connection.handlePacket(p);
}, 4);
connection._inflatedPacketsParser._lastPacket = 0;
connection.packetParser = new PacketParser(packet => {
connection.packetParser = new PacketParser((packet) => {
connection._handleCompressedPacket(packet);

@@ -130,3 +130,3 @@ }, 7);

module.exports = {
enableCompression: enableCompression
enableCompression: enableCompression,
};

@@ -91,3 +91,3 @@ // This file was modified by Oracle on September 21, 2021.

console.error(
`Ignoring invalid configuration option passed to Connection: ${key}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`,
`Ignoring invalid configuration option passed to Connection: ${key}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`
);

@@ -136,3 +136,3 @@ }

console.error(
`Ignoring invalid timezone passed to Connection: ${options.timezone}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`,
`Ignoring invalid timezone passed to Connection: ${options.timezone}. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection`
);

@@ -166,3 +166,3 @@ // SqlStrings falls back to UTC on invalid timezone

throw new TypeError(
`SSL profile must be an object, instead it's a ${typeof this.ssl}`,
`SSL profile must be an object, instead it's a ${typeof this.ssl}`
);

@@ -182,3 +182,3 @@ }

ConnectionConfig.getDefaultFlags(options),
options.flags || '',
options.flags || ''
);

@@ -185,0 +185,0 @@ // Default connection attributes

@@ -315,3 +315,3 @@ 'use strict';

'utf8',
'utf8'
'utf8',
];

@@ -35,3 +35,3 @@ 'use strict';

BINLOG_DUMP_GTID: 0x1e,
UNKNOWN: 0xff // bad!
UNKNOWN: 0xff, // bad!
};

@@ -7,3 +7,3 @@ 'use strict';

FOR_UPDATE: 2,
SCROLLABLE: 3
SCROLLABLE: 3,
};

@@ -48,3 +48,3 @@ 'use strict';

eucjpms: 97,
gb18030: 248
gb18030: 248,
};
'use strict';
module.exports = {
0x00: 'DECIMAL', // aka DECIMAL
0x00: 'DECIMAL', // aka DECIMAL
0x01: 'TINY', // aka TINYINT, 1 byte

@@ -31,6 +31,5 @@ 0x02: 'SHORT', // aka SMALLINT, 2 bytes

0xfe: 'STRING', // aka CHAR, BINARY
0xff: 'GEOMETRY' // aka GEOMETRY
0xff: 'GEOMETRY', // aka GEOMETRY
};
// Manually extracted from mysql-5.5.23/include/mysql_com.h

@@ -37,0 +36,0 @@ // some more info here: http://dev.mysql.com/doc/refman/5.5/en/c-api-prepared-statement-type-codes.html

@@ -80,3 +80,3 @@ 'use strict';

throw new Error(
`The field name (${field}) can't be the same as an object's private property.`,
`The field name (${field}) can't be the same as an object's private property.`
);

@@ -83,0 +83,0 @@ }

@@ -182,5 +182,5 @@ 'use strict';

return this.executePayload(chunk.slice(2));
}
}
this.execute = PacketParser.prototype.executeHeader3;
return null;

@@ -187,0 +187,0 @@ }

@@ -30,3 +30,3 @@ // Copyright (c) 2021, Oracle and/or its affiliates.

pluginName: name,
pluginData: data
pluginData: data,
});

@@ -33,0 +33,0 @@ }

@@ -33,3 +33,3 @@ 'use strict';

pluginName: name,
pluginData: data
pluginData: data,
});

@@ -36,0 +36,0 @@ }

@@ -17,3 +17,3 @@ 'use strict';

let length = 0;
columns.forEach(val => {
columns.forEach((val) => {
if (val === null || typeof val === 'undefined') {

@@ -36,3 +36,3 @@ ++length;

let bitValue = 1;
columns.forEach(parameter => {
columns.forEach((parameter) => {
if (parameter.type === Types.NULL) {

@@ -52,3 +52,3 @@ bitmap += bitValue;

columns.forEach(val => {
columns.forEach((val) => {
if (val === null) {

@@ -55,0 +55,0 @@ packet.writeNull();

@@ -19,3 +19,3 @@ 'use strict';

UPDATED_DB_NAMES: 12,
MICROSECONDS: 3
MICROSECONDS: 3,
};

@@ -22,0 +22,0 @@

@@ -42,3 +42,3 @@ 'use strict';

serializeToBuffer(buffer) {
const isSet = flag => this.flags & ClientConstants[flag];
const isSet = (flag) => this.flags & ClientConstants[flag];
const packet = new Packet(0, buffer, 0, buffer.length);

@@ -45,0 +45,0 @@ packet.offset = 4;

@@ -73,3 +73,3 @@ 'use strict';

flags: this.flags,
decimals: this.decimals
decimals: this.decimals,
};

@@ -139,3 +139,4 @@ }

typeName = 'TEXT';
} else if (this.columnLength === 1020) { // 255*4
} else if (this.columnLength === 1020) {
// 255*4
typeName = 'TINYTEXT';

@@ -147,7 +148,8 @@ } else {

// TODO: check for non-utf8mb4 encoding
typeName = `VARCHAR(${Math.ceil(this.columnLength/4)})`;
typeName = `VARCHAR(${Math.ceil(this.columnLength / 4)})`;
} else if (typeName === 'TINY') {
if (
(this.columnLength === 3 && isUnsigned) ||
(this.columnLength === 4 && !isUnsigned) ) {
(this.columnLength === 4 && !isUnsigned)
) {
typeName = 'TINYINT';

@@ -171,5 +173,4 @@ } else {

}
} else if (typeName === 'LONG') {
if (isUnsigned && this.columnLength === 10) {
if (isUnsigned && this.columnLength === 10) {
typeName = 'INT';

@@ -231,3 +232,3 @@ } else if (!isUnsigned && this.columnLength === 11) {

let length = 17; // = 4 padding + 1 + 12 for the rest
fields.forEach(field => {
fields.forEach((field) => {
length += Packet.lengthCodedStringLength(

@@ -265,5 +266,5 @@ column[field],

const addString = function(name) {
const addString = function (name) {
Object.defineProperty(ColumnDefinition.prototype, name, {
get: function() {
get: function () {
const start = this[`_${name}Start`];

@@ -282,7 +283,7 @@ const end = start + this[`_${name}Length`];

configurable: false,
enumerable: false
enumerable: false,
});
return val;
}
},
});

@@ -289,0 +290,0 @@ };

@@ -24,3 +24,3 @@ 'use strict';

let length;
let writer = function(value) {
let writer = function (value) {
// eslint-disable-next-line no-invalid-this

@@ -51,3 +51,3 @@ return Packet.prototype.writeLengthCodedString.call(this, value, encoding);

length = 12;
writer = function(value) {
writer = function (value) {
// eslint-disable-next-line no-invalid-this

@@ -93,13 +93,16 @@ return Packet.prototype.writeDate.call(this, value, timezone);

while (i < packet.end - 1) {
if((packet.buffer[i+1] === Types.VAR_STRING
|| packet.buffer[i+1] === Types.NULL
|| packet.buffer[i+1] === Types.DOUBLE
|| packet.buffer[i+1] === Types.TINY
|| packet.buffer[i+1] === Types.DATETIME
|| packet.buffer[i+1] === Types.JSON) && packet.buffer[i] === 1 && packet.buffer[i+2] === 0) {
if (
(packet.buffer[i + 1] === Types.VAR_STRING ||
packet.buffer[i + 1] === Types.NULL ||
packet.buffer[i + 1] === Types.DOUBLE ||
packet.buffer[i + 1] === Types.TINY ||
packet.buffer[i + 1] === Types.DATETIME ||
packet.buffer[i + 1] === Types.JSON) &&
packet.buffer[i] === 1 &&
packet.buffer[i + 2] === 0
) {
break;
} else {
packet.readInt8();
}
else {
packet.readInt8()
}
i++;

@@ -110,9 +113,12 @@ }

for(let i = packet.offset + 1; i < packet.end - 1; i++) {
if((packet.buffer[i] === Types.VAR_STRING
|| packet.buffer[i] === Types.NULL
|| packet.buffer[i] === Types.DOUBLE
|| packet.buffer[i] === Types.TINY
|| packet.buffer[i] === Types.DATETIME
|| packet.buffer[i] === Types.JSON) && packet.buffer[i + 1] === 0) {
for (let i = packet.offset + 1; i < packet.end - 1; i++) {
if (
(packet.buffer[i] === Types.VAR_STRING ||
packet.buffer[i] === Types.NULL ||
packet.buffer[i] === Types.DOUBLE ||
packet.buffer[i] === Types.TINY ||
packet.buffer[i] === Types.DATETIME ||
packet.buffer[i] === Types.JSON) &&
packet.buffer[i + 1] === 0
) {
types.push(packet.buffer[i]);

@@ -126,21 +132,17 @@ packet.skip(2);

const values = [];
for(let i = 0; i < types.length; i++) {
if(types[i] === Types.VAR_STRING) {
values.push(packet.readLengthCodedString(encoding))
for (let i = 0; i < types.length; i++) {
if (types[i] === Types.VAR_STRING) {
values.push(packet.readLengthCodedString(encoding));
} else if (types[i] === Types.DOUBLE) {
values.push(packet.readDouble());
} else if (types[i] === Types.TINY) {
values.push(packet.readInt8());
} else if (types[i] === Types.DATETIME) {
values.push(packet.readDateTime());
} else if (types[i] === Types.JSON) {
values.push(JSON.parse(packet.readLengthCodedString(encoding)));
}
else if(types[i] === Types.DOUBLE) {
values.push(packet.readDouble())
if (types[i] === Types.NULL) {
values.push(null);
}
else if(types[i] === Types.TINY) {
values.push(packet.readInt8())
}
else if(types[i] === Types.DATETIME) {
values.push(packet.readDateTime())
}
else if(types[i] === Types.JSON) {
values.push(JSON.parse(packet.readLengthCodedString(encoding)))
}
if(types[i] === Types.NULL) {
values.push(null)
}
}

@@ -165,3 +167,3 @@

length += 2 * this.parameters.length; // type byte for each parameter if new-params-bound-flag is set
parameters = this.parameters.map(value =>
parameters = this.parameters.map((value) =>
toParameter(value, this.encoding, this.timezone)

@@ -184,3 +186,3 @@ );

let bitValue = 1;
parameters.forEach(parameter => {
parameters.forEach((parameter) => {
if (parameter.type === Types.NULL) {

@@ -204,3 +206,3 @@ bitmap += bitValue;

// Write parameter types
parameters.forEach(parameter => {
parameters.forEach((parameter) => {
packet.writeInt8(parameter.type); // field type

@@ -210,3 +212,3 @@ packet.writeInt8(0); // parameter flag

// Write parameter values
parameters.forEach(parameter => {
parameters.forEach((parameter) => {
if (parameter.type !== Types.NULL) {

@@ -213,0 +215,0 @@ parameter.writer.call(packet, parameter.value);

@@ -41,3 +41,3 @@ 'use strict';

serializeResponse(buffer) {
const isSet = flag => this.clientFlags & ClientConstants[flag];
const isSet = (flag) => this.clientFlags & ClientConstants[flag];
const packet = new Packet(0, buffer, 0, buffer.length);

@@ -136,5 +136,4 @@ packet.offset = 4;

while (packet.offset < keysEnd) {
attrs[
packet.readLengthCodedString(encoding)
] = packet.readLengthCodedString(encoding);
attrs[packet.readLengthCodedString(encoding)] =
packet.readLengthCodedString(encoding);
}

@@ -141,0 +140,0 @@ args.connectAttributes = attrs;

@@ -18,3 +18,3 @@ 'use strict';

this.statusFlags = args.statusFlags;
this.autPluginName = args.autPluginName;
this.authPluginName = args.authPluginName;
}

@@ -106,3 +106,3 @@

if (args.capabilityFlags & ClientConstants.PLUGIN_AUTH) {
args.autPluginName = packet.readNullTerminatedString('ascii');
args.authPluginName = packet.readNullTerminatedString('ascii');
}

@@ -109,0 +109,0 @@

@@ -53,3 +53,3 @@ // This file was modified by Oracle on June 1, 2021.

SSLRequest,
TextRow
TextRow,
};

@@ -62,3 +62,3 @@ Object.entries(ctorMap).forEach(([name, ctor]) => {

const old = ctor.prototype.toPacket;
ctor.prototype.toPacket = function() {
ctor.prototype.toPacket = function () {
const p = old.call(this);

@@ -65,0 +65,0 @@ p._name = name;

@@ -325,3 +325,3 @@ // This file was modified by Oracle on June 1, 2021.

leftPad(2, M),
leftPad(2, S)
leftPad(2, S),
].join(':')}`;

@@ -921,3 +921,3 @@ } else if (columnType === Types.DATETIME) {

static MockBuffer() {
const noop = function () { };
const noop = function () {};
const res = Buffer.alloc(0);

@@ -924,0 +924,0 @@ for (const op in NativeBuffer.prototype) {

@@ -18,3 +18,3 @@ 'use strict';

const flags = connection._handshakePacket.capabilityFlags;
const isSet = function(flag) {
const isSet = function (flag) {
return flags & ClientConstants[flag];

@@ -55,3 +55,3 @@ };

gtids: [],
trackStateChange: null
trackStateChange: null,
};

@@ -75,5 +75,4 @@ }

} else if (type === sessionInfoTypes.STATE_CHANGE) {
stateChanges.trackStateChange = packet.readLengthCodedString(
encoding
);
stateChanges.trackStateChange =
packet.readLengthCodedString(encoding);
} else if (type === sessionInfoTypes.STATE_GTIDS) {

@@ -80,0 +79,0 @@ // TODO: find if the first length coded string means anything. Usually comes as empty

@@ -22,3 +22,3 @@ 'use strict';

let length = 0;
columns.forEach(val => {
columns.forEach((val) => {
if (val === null || typeof val === 'undefined') {

@@ -33,3 +33,3 @@ ++length;

packet.offset = 4;
columns.forEach(val => {
columns.forEach((val) => {
if (val === null) {

@@ -36,0 +36,0 @@ packet.writeNull();

@@ -16,6 +16,6 @@ 'use strict';

const supportBigNumbers = Boolean(
options.supportBigNumbers || config.supportBigNumbers,
options.supportBigNumbers || config.supportBigNumbers
);
const bigNumberStrings = Boolean(
options.bigNumberStrings || config.bigNumberStrings,
options.bigNumberStrings || config.bigNumberStrings
);

@@ -65,3 +65,5 @@ const timezone = options.timezone || config.timezone;

// see https://github.com/sidorares/node-mysql2/issues/409
return config.jsonStrings ? 'packet.readLengthCodedString("utf8")' : 'JSON.parse(packet.readLengthCodedString("utf8"));';
return config.jsonStrings
? 'packet.readLengthCodedString("utf8")'
: 'JSON.parse(packet.readLengthCodedString("utf8"));';
case Types.LONGLONG:

@@ -105,3 +107,3 @@ if (!supportBigNumbers) {

console.warn(
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``,
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``
);

@@ -112,3 +114,3 @@ }

[Types.DATETIME, Types.NEWDATE, Types.TIMESTAMP, Types.DATE].includes(
field.columnType,
field.columnType
)

@@ -201,3 +203,3 @@ ) {

parserFn(
`${lvalue} = options.typeCast(${fieldWrapperVar}, function() { return ${readCode} });`,
`${lvalue} = options.typeCast(${fieldWrapperVar}, function() { return ${readCode} });`
);

@@ -224,3 +226,3 @@ } else {

'Compiled binary protocol row parser',
parserFn.toString(),
parserFn.toString()
);

@@ -227,0 +229,0 @@ }

@@ -16,6 +16,6 @@ 'use strict';

const supportBigNumbers = Boolean(
options.supportBigNumbers || config.supportBigNumbers,
options.supportBigNumbers || config.supportBigNumbers
);
const bigNumberStrings = Boolean(
options.bigNumberStrings || config.bigNumberStrings,
options.bigNumberStrings || config.bigNumberStrings
);

@@ -48,6 +48,6 @@ const timezone = options.timezone || config.timezone;

? packet.readDateTimeString(
parseInt(field.decimals, 10),
null,
field.columnType,
)
parseInt(field.decimals, 10),
null,
field.columnType
)
: packet.readDateTime(timezone);

@@ -123,57 +123,57 @@ case Types.TIME:

? typeCast(
{
type: typeNames[field.columnType],
length: field.columnLength,
db: field.schema,
table: field.table,
name: field.name,
string: function (encoding = field.encoding) {
if (
field.columnType === Types.JSON &&
{
type: typeNames[field.columnType],
length: field.columnLength,
db: field.schema,
table: field.table,
name: field.name,
string: function (encoding = field.encoding) {
if (
field.columnType === Types.JSON &&
encoding === field.encoding
) {
// Since for JSON columns mysql always returns charset 63 (BINARY),
// we have to handle it according to JSON specs and use "utf8",
// see https://github.com/sidorares/node-mysql2/issues/1661
console.warn(
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``,
);
}
) {
// Since for JSON columns mysql always returns charset 63 (BINARY),
// we have to handle it according to JSON specs and use "utf8",
// see https://github.com/sidorares/node-mysql2/issues/1661
console.warn(
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``
);
}
if (
[
Types.DATETIME,
Types.NEWDATE,
Types.TIMESTAMP,
Types.DATE,
].includes(field.columnType)
) {
return packet.readDateTimeString(
parseInt(field.decimals, 10),
);
}
if (
[
Types.DATETIME,
Types.NEWDATE,
Types.TIMESTAMP,
Types.DATE,
].includes(field.columnType)
) {
return packet.readDateTimeString(
parseInt(field.decimals, 10)
);
}
if (field.columnType === Types.TINY) {
const unsigned = field.flags & FieldFlags.UNSIGNED;
if (field.columnType === Types.TINY) {
const unsigned = field.flags & FieldFlags.UNSIGNED;
return String(
unsigned ? packet.readInt8() : packet.readSInt8(),
);
}
return String(
unsigned ? packet.readInt8() : packet.readSInt8()
);
}
if (field.columnType === Types.TIME) {
return packet.readTimeString();
}
if (field.columnType === Types.TIME) {
return packet.readTimeString();
}
return packet.readLengthCodedString(encoding);
return packet.readLengthCodedString(encoding);
},
buffer: function () {
return packet.readLengthCodedBuffer();
},
geometry: function () {
return packet.parseGeometryValue();
},
},
buffer: function () {
return packet.readLengthCodedBuffer();
},
geometry: function () {
return packet.parseGeometryValue();
},
},
next,
)
next
)
: next();

@@ -187,3 +187,3 @@ }

field.table + options.nestTables + field.name,
false,
false
);

@@ -190,0 +190,0 @@ result[key] = value;

@@ -14,6 +14,6 @@ 'use strict';

const supportBigNumbers = Boolean(
options.supportBigNumbers || config.supportBigNumbers,
options.supportBigNumbers || config.supportBigNumbers
);
const bigNumberStrings = Boolean(
options.bigNumberStrings || config.bigNumberStrings,
options.bigNumberStrings || config.bigNumberStrings
);

@@ -90,3 +90,3 @@ const timezone = options.timezone || config.timezone;

console.warn(
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``,
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``
);

@@ -93,0 +93,0 @@ }

@@ -16,6 +16,6 @@ 'use strict';

const supportBigNumbers = Boolean(
options.supportBigNumbers || config.supportBigNumbers,
options.supportBigNumbers || config.supportBigNumbers
);
const bigNumberStrings = Boolean(
options.bigNumberStrings || config.bigNumberStrings,
options.bigNumberStrings || config.bigNumberStrings
);

@@ -64,3 +64,3 @@ const timezone = options.timezone || config.timezone;

case Types.VECTOR:
return 'packet.parseVector()';
return 'packet.parseVector()';
case Types.JSON:

@@ -70,3 +70,5 @@ // Since for JSON columns mysql always returns charset 63 (BINARY),

// see https://github.com/sidorares/node-mysql2/issues/409
return config.jsonStrings ? 'packet.readLengthCodedString("utf8")' : 'JSON.parse(packet.readLengthCodedString("utf8"))';
return config.jsonStrings
? 'packet.readLengthCodedString("utf8")'
: 'JSON.parse(packet.readLengthCodedString("utf8"))';
default:

@@ -102,3 +104,3 @@ if (charset === Charsets.BINARY) {

console.warn(
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``,
`typeCast: JSON column "${field.name}" is interpreted as BINARY by default, recommended to manually set utf8 encoding: \`field.string("utf8")\``
);

@@ -184,7 +186,7 @@ }

config,
options,
options
);
if (typeof options.typeCast === 'function') {
parserFn(
`${lvalue} = options.typeCast(this.wrap${i}, function() { return ${readCode} });`,
`${lvalue} = options.typeCast(this.wrap${i}, function() { return ${readCode} });`
);

@@ -204,3 +206,3 @@ } else {

'Compiled text protocol row parser',
parserFn.toString(),
parserFn.toString()
);

@@ -207,0 +209,0 @@ }

@@ -24,3 +24,3 @@ 'use strict';

return (clusterIds) => clusterIds[0];
}
},
};

@@ -187,3 +187,3 @@

pool: new Pool({ config: new PoolConfig(config) }),
_offlineUntil: 0
_offlineUntil: 0,
};

@@ -227,6 +227,6 @@ this._serviceableNodeIds.push(id);

: (err) => {
if (err) {
throw err;
}
};
if (err) {
throw err;
}
};
if (this._closed) {

@@ -233,0 +233,0 @@ process.nextTick(cb);

@@ -32,3 +32,3 @@ 'use strict';

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -51,3 +51,3 @@ }

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -152,3 +152,3 @@ }

statement,
promiseImpl,
promiseImpl
);

@@ -205,3 +205,3 @@ resolve(wrappedStatement);

this.connection,
arguments,
arguments
);

@@ -208,0 +208,0 @@ };

@@ -15,3 +15,3 @@ 'use strict';

target.emit.apply(target, args);
}),
})
);

@@ -18,0 +18,0 @@ }

@@ -7,3 +7,2 @@ 'use strict';

class PromisePoolNamespace {
constructor(poolNamespace, thePromise) {

@@ -32,3 +31,3 @@ this.poolNamespace = poolNamespace;

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -47,3 +46,3 @@ }

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -50,0 +49,0 @@ }

@@ -14,3 +14,3 @@ 'use strict';

this.connection,
arguments,
arguments
);

@@ -17,0 +17,0 @@ }

@@ -39,3 +39,3 @@ 'use strict';

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -58,3 +58,3 @@ }

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -61,0 +61,0 @@ }

@@ -6,4 +6,4 @@ 'use strict';

// copy-paste from https://github.com/mysqljs/mysql/blob/master/lib/protocol/sequences/Query.js
module.exports = function(command, connectionStream) {
command.stream = function(options) {
module.exports = function (command, connectionStream) {
command.stream = function (options) {
let stream;

@@ -14,5 +14,5 @@

(stream = new Readable(options)),
(stream._read = function() {
connectionStream.resume();
});
(stream._read = function () {
connectionStream.resume();
});

@@ -26,3 +26,3 @@ this.on('result', (row, i) => {

this.on('error', err => {
this.on('error', (err) => {
stream.emit('error', err); // Pass on any errors

@@ -29,0 +29,0 @@ });

@@ -20,3 +20,3 @@ 'use strict';

stream: socket,
isServer: true
isServer: true,
});

@@ -23,0 +23,0 @@ const connection = new Connection({ config: connectionConfig });

{
"name": "mysql2",
"version": "3.12.1-canary.be22202e",
"version": "3.12.1-canary.e70160b7",
"description": "fast mysql driver. Implements core protocol, prepared statements, ssl and compression in native JS",

@@ -9,8 +9,4 @@ "main": "index.js",

"scripts": {
"lint": "npm run lint:docs && npm run lint:code",
"lint:code": "eslint index.js promise.js index.d.ts promise.d.ts \"typings/**/*.ts\" \"lib/**/*.js\" \"test/**/*.{js,cjs,mjs,ts}\" \"benchmarks/**/*.js\"",
"lint:fix": "npm run lint:docs -- --fix &&npm run lint:code -- --fix",
"lint:docs": "eslint Contributing.md README.md",
"lint:typings": "npx prettier --check ./typings",
"lint:tests": "npx prettier --check ./test",
"lint": "eslint . && prettier --check .",
"lint:fix": "eslint --fix && prettier --write .",
"test": "poku -d -r=verbose --sequential test/esm test/unit test/integration",

@@ -22,4 +18,2 @@ "test:bun": "bun poku -d --sequential test/esm test/unit test/integration",

"benchmark": "node ./benchmarks/benchmark.js",
"prettier": "prettier --single-quote --trailing-comma none --write \"{lib,test}/**/*.js\"",
"prettier:docs": "prettier --single-quote --trailing-comma none --write README.md",
"precommit": "lint-staged",

@@ -31,3 +25,3 @@ "eslint-check": "eslint --print-config .eslintrc | eslint-config-prettier-check",

"*.js": [
"prettier --single-quote --trailing-comma none --write",
"npm run lint:fix",
"git add"

@@ -77,5 +71,8 @@ ]

"devDependencies": {
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.21.0",
"@eslint/markdown": "^6.2.2",
"@types/node": "^22.0.0",
"@typescript-eslint/eslint-plugin": "^5.42.1",
"@typescript-eslint/parser": "^5.42.1",
"@typescript-eslint/eslint-plugin": "^8.26.0",
"@typescript-eslint/parser": "^8.26.0",
"assert-diff": "^3.0.2",

@@ -85,6 +82,7 @@ "benchmark": "^2.1.4",

"error-stack-parser": "^2.0.3",
"eslint": "^8.27.0",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-async-await": "0.0.0",
"eslint-plugin-markdown": "^5.0.0",
"eslint-config-prettier": "^10.0.2",
"eslint-plugin-async-await": "^0.0.0",
"eslint-plugin-markdown": "^5.1.0",
"eslint-plugin-prettier": "^5.2.3",
"globals": "^16.0.0",
"lint-staged": "^15.0.1",

@@ -91,0 +89,0 @@ "poku": "^3.0.0",

@@ -21,3 +21,3 @@ import { EventEmitter } from 'events';

declare class QueryableAndExecutableBase extends QueryableBaseClass(
ExecutableBaseClass(EventEmitter),
ExecutableBaseClass(EventEmitter)
) {}

@@ -28,3 +28,3 @@

execute(
parameters: any | any[] | { [param: string]: any },
parameters: any | any[] | { [param: string]: any }
): Promise<

@@ -127,3 +127,3 @@ [

export function createConnection(
config: ConnectionOptions,
config: ConnectionOptions
): Promise<Connection>;

@@ -130,0 +130,0 @@

@@ -25,3 +25,3 @@ 'use strict';

'Use promise-enabled node version or pass userland Promise' +
" implementation as parameter, for example: { Promise: require('bluebird') }",
" implementation as parameter, for example: { Promise: require('bluebird') }"
);

@@ -53,3 +53,3 @@ }

'Use promise-enabled node version or pass userland Promise' +
" implementation as parameter, for example: { Promise: require('bluebird') }",
" implementation as parameter, for example: { Promise: require('bluebird') }"
);

@@ -66,3 +66,3 @@ }

this.Promise = thePromise || Promise;
inheritEvents(poolCluster, this, ['warn', 'remove' , 'online', 'offline']);
inheritEvents(poolCluster, this, ['warn', 'remove', 'online', 'offline']);
}

@@ -82,3 +82,3 @@

}
},
}
);

@@ -93,3 +93,3 @@ });

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -108,3 +108,3 @@ }

throw new Error(
'Callback function is not available with promise clients.',
'Callback function is not available with promise clients.'
);

@@ -121,3 +121,3 @@ }

this.poolCluster.of(pattern, selector),
this.Promise,
this.Promise
);

@@ -161,3 +161,3 @@ }

this.poolCluster,
arguments,
arguments
);

@@ -177,3 +177,3 @@ };

'Use promise-enabled node version or pass userland Promise' +
" implementation as parameter, for example: { Promise: require('bluebird') }",
" implementation as parameter, for example: { Promise: require('bluebird') }"
);

@@ -198,7 +198,7 @@ }

exports.__defineGetter__('Charsets', () =>
require('./lib/constants/charsets.js'),
require('./lib/constants/charsets.js')
);
exports.__defineGetter__('CharsetToEncoding', () =>
require('./lib/constants/charset_encodings.js'),
require('./lib/constants/charset_encodings.js')
);

@@ -205,0 +205,0 @@

@@ -63,3 +63,3 @@ /**

stringifyObjects?: boolean,
timeZone?: TimeZone,
timeZone?: TimeZone
): string;

@@ -74,3 +74,3 @@

stringifyObjects?: boolean,
timeZone?: TimeZone,
timeZone?: TimeZone
): string;

@@ -77,0 +77,0 @@

@@ -8,3 +8,3 @@ import { RsaPublicKey, RsaPrivateKey, KeyLike } from 'crypto';

}) => (
pluginData: Buffer,
pluginData: Buffer
) => Promise<string> | string | Buffer | Promise<Buffer> | null;

@@ -11,0 +11,0 @@

@@ -356,7 +356,3 @@ // This file was modified by Oracle on November 04, 2021.

sql: string,
callback?: (
err: QueryError | null,
result: T,
fields: FieldPacket[],
) => any,
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
): Query;

@@ -373,7 +369,3 @@ static createQuery<

values: any | any[] | { [param: string]: any },
callback?: (
err: QueryError | null,
result: T,
fields: FieldPacket[],
) => any,
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
): Query;

@@ -389,3 +381,3 @@

options: ConnectionOptions,
callback?: (err: QueryError | null) => void,
callback?: (err: QueryError | null) => void
): void;

@@ -415,3 +407,3 @@

sql: string,
callback?: (err: QueryError | null, statement: PrepareStatementInfo) => any,
callback?: (err: QueryError | null, statement: PrepareStatementInfo) => any
): Prepare;

@@ -418,0 +410,0 @@

@@ -46,4 +46,4 @@ import { EventEmitter } from 'events';

err: NodeJS.ErrnoException | null,
connection: PoolConnection,
) => any,
connection: PoolConnection
) => any
): void;

@@ -54,3 +54,3 @@

end(
callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any,
callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any
): void;

@@ -57,0 +57,0 @@

@@ -9,3 +9,3 @@ import { EventEmitter } from 'events';

declare class QueryableAndExecutableBase extends QueryableBaseClass(
ExecutableBaseClass(EventEmitter),
ExecutableBaseClass(EventEmitter)
) {}

@@ -44,4 +44,4 @@

err: NodeJS.ErrnoException | null,
connection: PoolConnection,
) => any,
connection: PoolConnection
) => any
): void;

@@ -64,4 +64,4 @@ }

err: NodeJS.ErrnoException | null,
connection: PoolConnection,
) => void,
connection: PoolConnection
) => void
): void;

@@ -72,4 +72,4 @@ getConnection(

err: NodeJS.ErrnoException | null,
connection: PoolConnection,
) => void,
connection: PoolConnection
) => void
): void;

@@ -81,4 +81,4 @@ getConnection(

err: NodeJS.ErrnoException | null,
connection: PoolConnection,
) => void,
connection: PoolConnection
) => void
): void;

@@ -85,0 +85,0 @@

@@ -10,3 +10,3 @@ import { FieldPacket, QueryResult } from '../packets/index.js';

export declare function ExecutableBase<T extends QueryableConstructor>(
Base?: T,
Base?: T
): {

@@ -18,3 +18,3 @@ new (...args: any[]): {

| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined,
| undefined
): Query;

@@ -26,3 +26,3 @@ execute<T extends QueryResult>(

| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined,
| undefined
): Query;

@@ -33,3 +33,3 @@ execute<T extends QueryResult>(

| ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
| undefined,
| undefined
): Query;

@@ -41,5 +41,5 @@ execute<T extends QueryResult>(

| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined,
| undefined
): Query;
};
} & T;

@@ -22,7 +22,3 @@ import { Sequence } from './Sequence.js';

parameters: any | any[] | { [param: string]: any },
callback?: (
err: QueryError | null,
result: T,
fields: FieldPacket[],
) => any,
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
): Query;

@@ -61,7 +57,7 @@ }

event: 'fields',
listener: (fields: FieldPacket, index: number) => any,
listener: (fields: FieldPacket, index: number) => any
): this;
on(
event: 'result',
listener: (result: RowDataPacket | OkPacket, index: number) => any,
listener: (result: RowDataPacket | OkPacket, index: number) => any
): this;

@@ -68,0 +64,0 @@ on(event: 'end', listener: () => any): this;

@@ -5,3 +5,3 @@ import { FieldPacket, QueryResult } from '../../packets/index.js';

export declare function ExecutableBase<T extends QueryableConstructor>(
Base?: T,
Base?: T
): {

@@ -12,12 +12,12 @@ new (...args: any[]): {

sql: string,
values: any,
values: any
): Promise<[T, FieldPacket[]]>;
execute<T extends QueryResult>(
options: QueryOptions,
options: QueryOptions
): Promise<[T, FieldPacket[]]>;
execute<T extends QueryResult>(
options: QueryOptions,
values: any,
values: any
): Promise<[T, FieldPacket[]]>;
};
} & T;

@@ -5,3 +5,3 @@ import { FieldPacket, QueryResult } from '../../packets/index.js';

export declare function QueryableBase<T extends QueryableConstructor>(
Base?: T,
Base?: T
): {

@@ -12,12 +12,12 @@ new (...args: any[]): {

sql: string,
values: any,
values: any
): Promise<[T, FieldPacket[]]>;
query<T extends QueryResult>(
options: QueryOptions,
options: QueryOptions
): Promise<[T, FieldPacket[]]>;
query<T extends QueryResult>(
options: QueryOptions,
values: any,
values: any
): Promise<[T, FieldPacket[]]>;
};
} & T;

@@ -159,7 +159,7 @@ import { Sequence } from './Sequence.js';

event: 'fields',
listener: (fields: FieldPacket, index: number) => any,
listener: (fields: FieldPacket, index: number) => any
): this;
on(
event: 'result',
listener: (result: RowDataPacket | OkPacket, index: number) => any,
listener: (result: RowDataPacket | OkPacket, index: number) => any
): this;

@@ -166,0 +166,0 @@ on(event: 'end', listener: () => any): this;

@@ -10,3 +10,3 @@ import { FieldPacket, QueryResult } from '../packets/index.js';

export declare function QueryableBase<T extends QueryableConstructor>(
Base?: T,
Base?: T
): {

@@ -18,3 +18,3 @@ new (...args: any[]): {

| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined,
| undefined
): Query;

@@ -26,3 +26,3 @@ query<T extends QueryResult>(

| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined,
| undefined
): Query;

@@ -33,3 +33,3 @@ query<T extends QueryResult>(

| ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
| undefined,
| undefined
): Query;

@@ -41,5 +41,5 @@ query<T extends QueryResult>(

| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
| undefined,
| undefined
): Query;
};
} & T;

Sorry, the diff of this file is too big to display

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