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

mariadb

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mariadb - npm Package Compare versions

Comparing version 2.0.2-rc to 2.0.3

LICENSE

2

lib/cmd/batch-bulk.js

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

const BulkPacket = require("../io/bulk-packet");
const QUOTE = 0x27;

@@ -232,3 +231,2 @@ /**

this.emit("end", this.firstError);
return;
} else {

@@ -235,0 +233,0 @@ this._responseIndex++;

@@ -180,3 +180,2 @@ "use strict";

this.emit("end", this.firstError);
return;
}

@@ -241,3 +240,2 @@ } else {

this.emit("end", this.firstError);
return;
} else {

@@ -244,0 +242,0 @@ this._responseIndex++;

@@ -86,3 +86,3 @@ "use strict";

geoBuff = Buffer.allocUnsafe(21);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(1, 1); //wkbPoint

@@ -107,3 +107,3 @@ if (

geoBuff = Buffer.allocUnsafe(9 + 16 * pointNumber);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(2, 1); //wkbLineString

@@ -138,3 +138,3 @@ geoBuff.writeInt32LE(pointNumber, 5);

geoBuff = Buffer.allocUnsafe(9 + size);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(3, 1); //wkbPolygon

@@ -173,3 +173,3 @@ geoBuff.writeInt32LE(numRings, 5);

geoBuff = Buffer.allocUnsafe(9);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(4, 1); //wkbMultiPoint

@@ -181,3 +181,3 @@ break;

geoBuff = Buffer.allocUnsafe(9);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(5, 1); //wkbMultiLineString

@@ -189,3 +189,3 @@ break;

geoBuff = Buffer.allocUnsafe(9);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(6, 1); //wkbMultiPolygon

@@ -196,3 +196,3 @@ break;

geoBuff = Buffer.allocUnsafe(9);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(7, 1); //wkbGeometryCollection

@@ -242,3 +242,3 @@

geoBuff = Buffer.allocUnsafe(21);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(1, 1); //wkbPoint

@@ -255,3 +255,3 @@ geoBuff.writeDoubleLE(value[0], 5); //X

geoBuff = Buffer.allocUnsafe(9 + 16 * pointNumber);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(2, 1); //wkbLineString

@@ -285,3 +285,3 @@ geoBuff.writeInt32LE(pointNumber, 5);

geoBuff = Buffer.allocUnsafe(9 + size);
geoBuff.writeInt8(0x01); //LITTLE ENDIAN
geoBuff.writeInt8(0x01, 0); //LITTLE ENDIAN
geoBuff.writeInt32LE(3, 1); //wkbPolygon

@@ -288,0 +288,0 @@ geoBuff.writeInt32LE(numRings, 5);

@@ -157,3 +157,3 @@ "use strict";

//GeoJSON format.
st += i != 0 ? "," : "";
st += i !== 0 ? "," : "";
switch (geo[i].type) {

@@ -192,3 +192,3 @@ case "Point":

for (let i = 0; i < coords.length; i++) {
st += (i != 0 ? ",(" : "(") + this.geoMultiArrayPointToString(coords[i]) + ")";
st += (i !== 0 ? ",(" : "(") + this.geoMultiArrayPointToString(coords[i]) + ")";
}

@@ -202,3 +202,3 @@ return st;

for (let i = 0; i < coords.length; i++) {
st += (i != 0 ? ",(" : "(") + this.geoArrayPointToString(coords[i]) + ")";
st += (i !== 0 ? ",(" : "(") + this.geoArrayPointToString(coords[i]) + ")";
}

@@ -212,3 +212,3 @@ return st;

for (let i = 0; i < coords.length; i++) {
st += (i != 0 ? "," : "") + this.geoPointToString(coords[i]);
st += (i !== 0 ? "," : "") + this.geoPointToString(coords[i]);
}

@@ -288,5 +288,3 @@ return st;

column,
function() {
return this.readRowData(index, column, opts, connOpts, packet);
}.bind(this)
this.readRowData.bind(this, index, column, opts, connOpts, packet)
);

@@ -293,0 +291,0 @@ }

@@ -10,3 +10,2 @@ const Command = require("../../command");

super(resolve, reject);
this.pluginData = pluginData;
this.sequenceNo = packSeq;

@@ -13,0 +12,0 @@ }

const Command = require("../../command");
const Utils = require("../../../misc/utils");

@@ -4,0 +3,0 @@ /**

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

parseHandshakeInit(packet, out, opts, info) {
if (packet.peek() == 0xff) {
if (packet.peek() === 0xff) {
//in case that some host is not permit to connect server

@@ -147,5 +147,3 @@ const authErr = packet.readError(info);

const authSwitchHandler = opts.authSwitchHandler || this.defaultAuthSwitchHandler();
authSwitchHandler.call(
this,
const plugin = Handshake.pluginHandler(
pluginName,

@@ -160,40 +158,42 @@ this.sequenceNo,

);
if (!plugin) {
this.reject(
Errors.createError(
"Client does not support authentication protocol '" +
pluginName +
"' requested by server. ",
true,
info,
"08004",
Errors.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED
)
);
} else {
this._addCommand(plugin, false);
}
}
defaultAuthSwitchHandler() {
return (pluginName, packSeq, pluginData, info, opts, out, authResolv, authReject) => {
let pluginAuth;
switch (pluginName) {
case "mysql_native_password":
pluginAuth = require("./auth/native_password_auth.js");
break;
static pluginHandler(pluginName, packSeq, pluginData, info, opts, out, authResolve, authReject) {
let pluginAuth;
switch (pluginName) {
case "mysql_native_password":
pluginAuth = require("./auth/native_password_auth.js");
break;
case "mysql_clear_password":
pluginAuth = require("./auth/clear_password_auth.js");
break;
case "mysql_clear_password":
pluginAuth = require("./auth/clear_password_auth.js");
break;
case "dialog":
pluginAuth = require("./auth/pam_password_auth.js");
break;
case "dialog":
pluginAuth = require("./auth/pam_password_auth.js");
break;
//TODO "auth_gssapi_client"
//TODO "client_ed25519"
//TODO "auth_gssapi_client"
//TODO "client_ed25519"
default:
authReject(
Errors.createError(
"Client does not support authentication protocol '" +
pluginName +
"' requested by server. ",
true,
info,
"08004",
Errors.ER_AUTHENTICATION_PLUGIN_NOT_SUPPORTED
)
);
return;
}
const plugin = new pluginAuth(packSeq, pluginData, authResolv, authReject);
this._addCommand(plugin, false);
};
default:
return null;
}
return new pluginAuth(packSeq, pluginData, authResolve, authReject);
}

@@ -200,0 +200,0 @@ }

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

readPingResponsePacket(packet, out, opts, info) {
if (packet.peek() != 0x00) {
if (packet.peek() !== 0x00) {
return this.throwNewError(

@@ -38,0 +38,0 @@ "unexpected packet",

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

readResetResponsePacket(packet, out, opts, info) {
if (packet.peek() != 0x00) {
if (packet.peek() !== 0x00) {
return this.throwNewError(

@@ -38,0 +38,0 @@ "unexpected packet",

@@ -224,2 +224,10 @@ "use strict";

return this.throwError(err, info);
//*********************************************************************************************************
//* Unexpected response
//*********************************************************************************************************
default:
info.status |= ServerStatus.STATUS_IN_TRANS;
this.onPacketReceive = this.readResponsePacket;
return this.throwError(Errors.ER_UNEXPECTED_PACKET, info);
}

@@ -316,3 +324,3 @@ }

readIntermediateEOF(packet, out, opts, info) {
if (packet.peek() != 0xfe) {
if (packet.peek() !== 0xfe) {
return this.throwNewError(

@@ -435,3 +443,3 @@ "Error in protocol, expected EOF packet",

let param = values[key];
sqlMsg = this.logParam(sqlMsg, param);
sqlMsg = ResultSet.logParam(sqlMsg, param);
if (sqlMsg.length > this.opts.debugLen) {

@@ -448,3 +456,3 @@ sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + "...";

let param = values[i];
sqlMsg = this.logParam(sqlMsg, param);
sqlMsg = ResultSet.logParam(sqlMsg, param);
if (sqlMsg.length > this.opts.debugLen) {

@@ -498,3 +506,3 @@ sqlMsg = sqlMsg.substr(0, this.opts.debugLen) + "...";

logParam(sqlMsg, param) {
static logParam(sqlMsg, param) {
if (!param) {

@@ -501,0 +509,0 @@ sqlMsg += param === undefined ? "undefined" : "null";

@@ -16,5 +16,3 @@ "use strict";

objectMode: true,
read: () => {
socket.resume();
}
read: () => {}
});

@@ -26,2 +24,6 @@

this.on("error", function(err) {
this.inStream.emit("error", err);
});
this.on("end", function(err) {

@@ -34,5 +36,3 @@ if (err) this.inStream.emit("error", err);

handleNewRows(row) {
if (!this.inStream.push(row)) {
this.socket.pause();
}
this.inStream.push(row);
}

@@ -39,0 +39,0 @@ }

@@ -59,2 +59,8 @@ "use strict";

this.pipelining = opts.pipelining;
if (opts.permitLocalInfile === true && this.pipelining) {
throw new Error(
"enabling options `permitLocalInfile` and " +
"`pipelining` is not possible, options are incompatible."
);
}
this.permitLocalInfile = this.pipelining ? false : opts.permitLocalInfile || false;

@@ -78,3 +84,3 @@ }

} else {
const matched = this.timezone.match(/([\+\-\s])(\d\d):?(\d\d)?/);
const matched = this.timezone.match(/([+\-\s])(\d\d):?(\d\d)?/);
if (!matched) {

@@ -92,3 +98,3 @@ throw new RangeError(

this.typeCast = opts.typeCast;
if (this.typeCast != undefined && typeof this.typeCast !== "function") {
if (this.typeCast !== undefined && typeof this.typeCast !== "function") {
this.typeCast = undefined;

@@ -95,0 +101,0 @@ }

@@ -264,6 +264,3 @@ "use strict";

this.isValid = () => {
//authentication not terminated
if (_status === Status.CONNECTED) return true;
return false;
return _status === Status.CONNECTED;
};

@@ -274,3 +271,2 @@

*
* @param callback when done
* @returns {Promise} promise

@@ -280,3 +276,3 @@ */

_addCommand = _addCommandDisabled;
if (this.timeout) clearTimeout(this.timeout);
clearTimeout(_timeout);

@@ -321,4 +317,4 @@ if (

_addCommand = _addCommandDisabled;
if (this.timeout) clearTimeout(this.timeout);
if (_status !== Status.CLOSING && _status != Status.CLOSED) {
clearTimeout(_timeout);
if (_status !== Status.CLOSING && _status !== Status.CLOSED) {
_status = Status.CLOSING;

@@ -584,3 +580,3 @@ _sendQueue.clear();

//ensure that there is no stream object
if (_values != undefined) {
if (_values !== undefined) {
const values = Array.isArray(_values) ? _values : [_values];

@@ -592,3 +588,3 @@ const paramLen = Array.isArray(values[0]) ? values[0].length : 1;

if (!Array.isArray(row)) row = [row];
if (paramLen != row.length) {
if (paramLen !== row.length) {
useBulk = false;

@@ -669,3 +665,4 @@ break;

for (let k = 0; k < keys.length; ++k) {
sessionQuery += (k != 0 ? "," : "") + "@@" + keys[k].replace(/[^a-z0-9_]/gi, "") + "=?";
sessionQuery +=
(k !== 0 ? "," : "") + "@@" + keys[k].replace(/[^a-z0-9_]/gi, "") + "=?";
values.push(opts.sessionVariables[keys[k]]);

@@ -739,11 +736,7 @@ }

} else {
_socket = Net.connect(
opts.port,
opts.host
);
_socket = Net.connect(opts.port, opts.host);
}
if (opts.connectTimeout) {
const handler = _connectTimeoutReached.bind(this, authFailHandler);
this.timeout = setTimeout(handler, opts.connectTimeout);
_timeout = setTimeout(_connectTimeoutReached, opts.connectTimeout, authFailHandler);
}

@@ -759,3 +752,3 @@

function() {
if (this.timeout) clearTimeout(this.timeout);
clearTimeout(_timeout);
if (_status === Status.CONNECTING) {

@@ -809,3 +802,3 @@ _status = Status.AUTHENTICATING;

const errorInitialQueries = err => {
if (!err.fatal) this.end();
if (!err.fatal) this.end().catch(err => {});
process.nextTick(rejected, err);

@@ -842,2 +835,3 @@ };

*
* @param rejected rejected function when error
* @param callback callback function when done

@@ -854,6 +848,3 @@ * @private

try {
const secureSocket = tls.connect(
sslOption,
callback
);
const secureSocket = tls.connect(sslOption, callback);

@@ -935,4 +926,5 @@ secureSocket.on("data", _in.onData.bind(_in));

let cmdReceive;
while ((cmdReceive = _receiveQueue.peek())) {
//Command in progress => must execute query
//or if no command in progress, can rely on status to know if query is needed
if (_receiveQueue.peekFront() || info.status & ServerStatus.STATUS_IN_TRANS) {
return new Promise(function(resolve, reject) {

@@ -944,11 +936,2 @@ const cmd = new Query(resolve, reject, null, opts, sql, null);

}
//no command in progress, rely on status to know if query is needed
if (info.status & ServerStatus.STATUS_IN_TRANS) {
return new Promise(function(resolve, reject) {
const cmd = new Query(resolve, reject, null, opts, sql, null);
if (opts.trace) Error.captureStackTrace(cmd);
_addCommand(cmd);
});
}
return Promise.resolve();

@@ -963,4 +946,4 @@ };

const _connectTimeoutReached = function(authFailHandler) {
this.timeout = null;
const handshake = _receiveQueue.peek();
_timeout = null;
const handshake = _receiveQueue.peekFront();
authFailHandler(

@@ -1006,3 +989,3 @@ Errors.createError(

if (_sendQueue.isEmpty() && _status === Status.CONNECTED) {
if (_receiveQueue.peek()) {
if (_receiveQueue.peekFront()) {
_receiveQueue.push(cmd);

@@ -1100,3 +1083,3 @@ _sendQueue.push(cmd);

case Status.AUTHENTICATING:
const currentCmd = _receiveQueue.peek();
const currentCmd = _receiveQueue.peekFront();
if (currentCmd && currentCmd.stack && err) {

@@ -1117,3 +1100,3 @@ err.stack +=

*
* @param err error
* @param self current connection
* @private

@@ -1173,3 +1156,3 @@ */

errorThrownByCmd = true;
process.nextTick(receiveCmd.throwError.bind(receiveCmd), err, info);
setImmediate(receiveCmd.throwError.bind(receiveCmd), err, info);
}

@@ -1225,2 +1208,3 @@ }

let _socket = null;
let _timeout = null;
let _addCommand = _addCommandEnable;

@@ -1227,0 +1211,0 @@ const _fatalError = _fatalErrorHandler(this);

@@ -7,7 +7,6 @@ "use strict";

class Collation {
constructor(index, name, encoding, maxlen) {
constructor(index, name, encoding, maxLength) {
this.index = index;
this.name = name;
this.encoding = encoding;
this.maxlen = maxlen;
}

@@ -14,0 +13,0 @@

@@ -47,3 +47,3 @@ "use strict";

datatypeChanged(row) {
if (this.datatypes.length != row.length) return true;
if (this.datatypes.length !== row.length) return true;
for (let r = 0; r < row.length; r++) {

@@ -319,8 +319,8 @@ if (row[r] !== null) {

//reserve position for length indicator
const maxlen = str.length * 3;
const maxLen = str.length * 3;
let lengthPos;
if (maxlen < 0xfb) {
if (maxLen < 0xfb) {
lengthPos = this.pos;
this.pos++;
} else if (maxlen < 65536) {
} else if (maxLen < 65536) {
this.buf[this.pos++] = 0xfc;

@@ -339,5 +339,5 @@ lengthPos = this.pos;

const realLen = this.pos - prevPos;
if (maxlen < 0xfb) {
if (maxLen < 0xfb) {
this.buf[lengthPos] = realLen;
} else if (maxlen < 65536) {
} else if (maxLen < 65536) {
this.buf[lengthPos] = realLen;

@@ -451,3 +451,3 @@ this.buf[lengthPos + 1] = realLen >>> 8;

this.pos +
(this.singleQuerySequenceNo != undefined
(this.singleQuerySequenceNo !== undefined
? (this.singleQuerySequenceNo + 1) * MAX_BUFFER_SIZE

@@ -557,3 +557,3 @@ : 0);

this.out.pos = this.pos;
if (this.singleQuerySequenceNo != undefined) {
if (this.singleQuerySequenceNo !== undefined) {
this.out.cmd.sequenceNo = this.singleQuerySequenceNo;

@@ -566,3 +566,3 @@ this.out.cmd.compressSequenceNo = this.singleQueryCompressSequenceNo;

this.out.flushBuffer(ended);
if (this.singleQuerySequenceNo != undefined) {
if (this.singleQuerySequenceNo !== undefined) {
this.singleQuerySequenceNo = this.out.cmd.sequenceNo;

@@ -569,0 +569,0 @@ this.singleQueryCompressSequenceNo = this.out.cmd.compressSequenceNo;

@@ -139,3 +139,3 @@ "use strict";

this.buf = remainingLen
? this.allocateBuffer(remainingLen)
? CompressionOutputStream.allocateBuffer(remainingLen)
: Buffer.allocUnsafe(SMALL_BUFFER_SIZE);

@@ -145,3 +145,3 @@ this.pos = 7;

allocateBuffer(len) {
static allocateBuffer(len) {
if (len + 4 < SMALL_BUFFER_SIZE) {

@@ -148,0 +148,0 @@ return Buffer.allocUnsafe(SMALL_BUFFER_SIZE);

@@ -227,3 +227,3 @@ "use strict";

let cnt = 0;
while (this.remaining() > 0 && this.buf[this.pos++] != 0) {
while (this.remaining() > 0 && this.buf[this.pos++] !== 0) {
cnt++;

@@ -494,3 +494,3 @@ }

if (sql) msg += "\n" + sql;
let fatal = sqlState.startsWith("08") || sqlState === "70100";
let fatal = sqlState.startsWith("08") || sqlState == "70100";
if (fatal) {

@@ -497,0 +497,0 @@ const packetMsgs = info.getLastPackets();

@@ -40,7 +40,7 @@ const Errors = require("../misc/errors");

case "*":
if (state === State.Normal && lastChar === "/") state = State.SlashStarComment;
if (state === State.Normal && lastChar == "/") state = State.SlashStarComment;
break;
case "/":
if (state === State.SlashStarComment && lastChar === "*") state = State.Normal;
if (state === State.SlashStarComment && lastChar == "*") state = State.Normal;
break;

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

case "-":
if (state === State.Normal && lastChar === "-") {
if (state === State.Normal && lastChar == "-") {
state = State.EOLComment;

@@ -152,7 +152,7 @@ }

case "*":
if (state === State.Normal && lastChar === "/") state = State.SlashStarComment;
if (state === State.Normal && lastChar == "/") state = State.SlashStarComment;
break;
case "/":
if (state === State.SlashStarComment && lastChar === "*") state = State.Normal;
if (state === State.SlashStarComment && lastChar == "*") state = State.Normal;
break;

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

case "-":
if (state === State.Normal && lastChar === "-") {
if (state === State.Normal && lastChar == "-") {
state = State.EOLComment;

@@ -314,3 +314,3 @@ }

case "*":
if (state === State.Normal && lastChar === "/") {
if (state === State.Normal && lastChar == "/") {
state = State.SlashStarComment;

@@ -321,3 +321,3 @@ }

case "/":
if (state === State.SlashStarComment && lastChar === "*") {
if (state === State.SlashStarComment && lastChar == "*") {
state = State.Normal;

@@ -334,3 +334,3 @@ }

case "-":
if (state === State.Normal && lastChar === "-") {
if (state === State.Normal && lastChar == "-") {
state = State.EOLComment;

@@ -440,3 +440,3 @@ }

!preValuePart1 &&
(lastChar === ")" || lastChar <= " ") &&
(lastChar == ")" || lastChar <= " ") &&
sql.length > idx + 6 &&

@@ -487,3 +487,3 @@ (sql.charAt(idx) === "a" || sql.charAt(idx) === "A") &&

isInParenthesis--;
if (isInParenthesis == 0 && preValuePart2 !== null && postValuePart === null) {
if (isInParenthesis === 0 && preValuePart2 !== null && postValuePart === null) {
postValuePart = sql.substring(lastParameterPosition, idx);

@@ -511,3 +511,3 @@ lastParameterPosition = idx;

//multiple queries
if (state == State.Normal && semicolon && car >= " ") {
if (state === State.Normal && semicolon && car >= " ") {
reWritablePrepare = false;

@@ -586,7 +586,7 @@ multipleQueriesPrepare = true;

case "*":
if (state === State.Normal && lastChar === "/") state = State.SlashStarComment;
if (state === State.Normal && lastChar == "/") state = State.SlashStarComment;
break;
case "/":
if (state === State.SlashStarComment && lastChar === "*") state = State.Normal;
if (state === State.SlashStarComment && lastChar == "*") state = State.Normal;
break;

@@ -599,3 +599,3 @@

case "-":
if (state === State.Normal && lastChar === "-") {
if (state === State.Normal && lastChar == "-") {
state = State.EOLComment;

@@ -748,3 +748,3 @@ }

case "*":
if (state === State.Normal && lastChar === "/") {
if (state === State.Normal && lastChar == "/") {
state = State.SlashStarComment;

@@ -755,3 +755,3 @@ }

case "/":
if (state === State.SlashStarComment && lastChar === "*") {
if (state === State.SlashStarComment && lastChar == "*") {
state = State.Normal;

@@ -768,3 +768,3 @@ }

case "-":
if (state === State.Normal && lastChar === "-") {
if (state === State.Normal && lastChar == "-") {
state = State.EOLComment;

@@ -894,3 +894,3 @@ }

!preValuePart1 &&
(lastChar === ")" || lastChar <= " ") &&
(lastChar == ")" || lastChar <= " ") &&
sql.length > idx + 6 &&

@@ -941,3 +941,3 @@ (sql.charAt(idx) === "a" || sql.charAt(idx) === "A") &&

isInParenthesis--;
if (isInParenthesis == 0 && preValuePart2 !== null && postValuePart === null) {
if (isInParenthesis === 0 && preValuePart2 !== null && postValuePart === null) {
postValuePart = sql.substring(lastParameterPosition, idx);

@@ -965,3 +965,3 @@ lastParameterPosition = idx;

//multiple queries
if (state == State.Normal && semicolon && car >= " ") {
if (state === State.Normal && semicolon && car >= " ") {
reWritablePrepare = false;

@@ -968,0 +968,0 @@ multipleQueriesPrepare = true;

@@ -108,2 +108,3 @@ "use strict";

* @param avoidNodeKey failing node
* @param lastError last error
* @return {Promise}

@@ -155,2 +156,3 @@ * @private

* @param selector node selector ('RR','RANDOM' or 'ORDER')
* @param callback callback function
* @param avoidNodeKey failing node

@@ -188,3 +190,3 @@ * @private

* @param pattern pattern
* @return {Json}
* @return {*}
* @private

@@ -191,0 +193,0 @@ */

@@ -74,3 +74,3 @@ "use strict";

if (firstTaskTimeout) clearTimeout(firstTaskTimeout);
firstTaskTimeout = clearTimeout(firstTaskTimeout);

@@ -156,3 +156,3 @@ //reject all waiting task

}
checkPoolSize(pool);
return getIdleValidConnection().then(

@@ -169,3 +169,4 @@ conn => {

if (!connectionInCreation && opts.connectionLimit > pool.totalConnections()) {
addConnectionToPool(this);
connectionInCreation = true;
addConnectionToPool(pool);
}

@@ -270,3 +271,3 @@ //connections are all used, stack demand.

taskQueue.shift();
task.reject(
process.nextTick(task.reject,
Errors.createError(

@@ -297,2 +298,3 @@ "retrieve connection from pool timeout",

this.activatePool = function() {
connectionInCreation = true;
addConnectionToPool(this);

@@ -302,6 +304,31 @@ };

/**
* Will throw an error to current task if pool fail to connect.
* or log if no waiting task.
*
* @param pool current pool
* @param err connection error
*/
const handleConnectionError = function(pool, err) {
if (pool.totalConnections() === 0) {
const task = taskQueue.shift();
if (task) {
firstTaskTimeout = clearTimeout(firstTaskTimeout);
process.nextTick(task.reject, err);
resetTimeoutToNextTask();
}
} else {
console.error("pool fail to create connection (" + err.message + ")");
}
connectionInCreation = false;
if (taskQueue.size() > 0 || !err.errno || err.errno !== 1045) {
// in case of wrong authentication, not relaunching automatic connection creation.
checkPoolSize(pool);
}
};
/**
* Add connection to pool.
*/
const addConnectionToPoolPromise = function(pool) {
connectionInCreation = true;
const conn = new Connection(opts.connOptions);

@@ -329,3 +356,3 @@ conn

idleConnections.push(conn);
process.nextTick(handleTaskQueue.bind(self));
process.nextTick(handleTaskQueue);
}

@@ -354,3 +381,3 @@ return Promise.resolve();

idleConnections.push(conn);
process.nextTick(handleTaskQueue.bind(self));
process.nextTick(handleTaskQueue);
}

@@ -365,7 +392,7 @@ return Promise.resolve();

.then(() => {
checkPoolSize.apply(self);
checkPoolSize(self);
return Promise.resolve();
})
.catch(() => {
checkPoolSize.apply(self);
checkPoolSize(self);
return Promise.resolve();

@@ -386,4 +413,3 @@ });

.catch(err => {
connectionInCreation = false;
checkPoolSize.apply(pool);
handleConnectionError(pool, err);
});

@@ -396,8 +422,6 @@ };

const addConnectionCallbackToPool = function(pool) {
connectionInCreation = true;
const conn = new ConnectionCallback(opts.connOptions);
conn.connect(err => {
if (err) {
connectionInCreation = false;
checkPoolSize.apply(pool);
handleConnectionError(pool, err);
} else {

@@ -411,3 +435,2 @@ if (closed) {

conn.end = function(cb) {
if (opts.noControlAfterUse) {

@@ -420,3 +443,3 @@ conn.lastUse = Date.now();

idleConnections.push(conn);
process.nextTick(handleTaskQueue.bind(self));
process.nextTick(handleTaskQueue);
}

@@ -441,3 +464,3 @@ if (cb) cb();

initialEndFct(err => {});
checkPoolSize.apply(self);
checkPoolSize(self);
} else {

@@ -450,3 +473,3 @@ conn.lastUse = Date.now();

idleConnections.push(conn);
process.nextTick(handleTaskQueue.bind(self));
process.nextTick(handleTaskQueue);
}

@@ -473,4 +496,5 @@ }

*
* @param conn new connection
* @param self current pool
* @param conn new connection
* @param self current pool
* @param fctOverlay overlay function
*/

@@ -486,3 +510,3 @@ const overlayNewConnection = function(conn, self, fctOverlay) {

initialDestroyFct();
checkPoolSize.apply(self);
checkPoolSize(self);
};

@@ -496,3 +520,3 @@

delete activeConnections[conn.threadId];
while ((currConn = idleConnections.peekAt(idx)) != undefined) {
while ((currConn = idleConnections.peekAt(idx))) {
if (currConn === conn) {

@@ -508,8 +532,8 @@ idleConnections.removeOne(idx);

}
checkPoolSize.apply(self);
checkPoolSize(self);
});
connectionInCreation = false;
checkPoolSize.apply(self);
handleTaskQueue.apply(self);
checkPoolSize(self);
handleTaskQueue();
};

@@ -520,6 +544,6 @@

*/
const checkPoolSize = function() {
if (!connectionInCreation && this.totalConnections() < opts.connectionLimit && !closed) {
const checkPoolSize = function(pool) {
if (!connectionInCreation && pool.totalConnections() < opts.connectionLimit && !closed) {
connectionInCreation = true;
process.nextTick(addConnectionToPool, this);
process.nextTick(addConnectionToPool, pool);
}

@@ -532,6 +556,3 @@ };

const handleTaskQueue = function() {
if (firstTaskTimeout) {
clearTimeout(firstTaskTimeout);
firstTaskTimeout = null;
}
firstTaskTimeout = clearTimeout(firstTaskTimeout);
const task = taskQueue.shift();

@@ -538,0 +559,0 @@ if (task) {

{
"name": "mariadb",
"version": "2.0.2-rc",
"version": "2.0.3",
"description": "fast mariadb/mysql connector.",

@@ -5,0 +5,0 @@ "main": "promise.js",

@@ -82,3 +82,3 @@ <p align="center">

const mariadb = require('mariadb');
const pool = mariadb.createPool({host: 'mydb.com', user:' myUser', connectionLimit: 5});
const pool = mariadb.createPool({host: 'mydb.com', user: 'myUser', connectionLimit: 5});
pool.getConnection()

@@ -142,4 +142,2 @@ .then(conn => {

* Query Timeouts
* Bulk Insertion, (that is, fast batch).
* [Sequelize](https://github.com/sequelize/sequelize) integration

@@ -146,0 +144,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