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.5 to 2.1.0

lib/cmd/handshake/auth/clear-password-auth.js

10

lib/cmd/batch-bulk.js

@@ -103,9 +103,6 @@ 'use strict';

//********************************************
flushed =
this.writeParam(this.packet, value, this.opts, this.info) || flushed;
flushed = this.writeParam(this.packet, value, this.opts, this.info) || flushed;
}
const last = this.valueIdx === this.values.length;
flushed =
this.packet.mark(last, last ? null : this.values[this.valueIdx]) ||
flushed;
flushed = this.packet.mark(last, last ? null : this.values[this.valueIdx]) || flushed;
}

@@ -117,4 +114,3 @@

} else {
if (this.sending && this.valueIdx === this.values.length)
this.emit('send_end');
if (this.sending && this.valueIdx === this.values.length) this.emit('send_end');
this.sending = false;

@@ -121,0 +117,0 @@ }

@@ -52,6 +52,3 @@ 'use strict';

if (this.opts.namedPlaceholders) {
this.parseResults = Parse.splitRewritableNamedParameterQuery(
this.sql,
this.initialValues
);
this.parseResults = Parse.splitRewritableNamedParameterQuery(this.sql, this.initialValues);
this.values = this.parseResults.values;

@@ -91,4 +88,3 @@ } else {

const value = this.valueRow[i];
flushed =
this.packet.writeString(this.parseResults.partList[i + 1]) || flushed;
flushed = this.packet.writeString(this.parseResults.partList[i + 1]) || flushed;
if (value === null) {

@@ -133,13 +129,7 @@ flushed = this.packet.writeStringAscii('NULL') || flushed;

//********************************************
flushed =
this.writeParam(this.packet, value, this.opts, this.info) ||
flushed;
flushed = this.writeParam(this.packet, value, this.opts, this.info) || flushed;
}
}
this.packet.writeString(
this.parseResults.partList[this.parseResults.partList.length - 2]
);
this.packet.mark(
!this.parseResults.reWritable || this.valueIdx === this.values.length
);
this.packet.writeString(this.parseResults.partList[this.parseResults.partList.length - 2]);
this.packet.mark(!this.parseResults.reWritable || this.valueIdx === this.values.length);
}

@@ -152,4 +142,3 @@

} else {
if (this.sending && this.valueIdx === this.values.length)
this.emit('send_end');
if (this.sending && this.valueIdx === this.values.length) this.emit('send_end');
this.sending = false;

@@ -333,10 +322,7 @@ }

flushed =
packet.writeString(
this.parseResults.partList[this.parseResults.partList.length - 2]
) || flushed;
packet.writeString(this.parseResults.partList[this.parseResults.partList.length - 2]) ||
flushed;
flushed =
packet.mark(
!this.parseResults.reWritable ||
this.valueIdx === this.values.length
) || flushed;
packet.mark(!this.parseResults.reWritable || this.valueIdx === this.values.length) ||
flushed;
if (this.valueIdx < this.values.length) {

@@ -354,6 +340,3 @@ // still remaining rows

flushed =
packet.writeString(
this.parseResults.partList[this.currentParam + 1]
) || flushed;
flushed = packet.writeString(this.parseResults.partList[this.currentParam + 1]) || flushed;
const value = this.valueRow[this.currentParam];

@@ -360,0 +343,0 @@

@@ -5,3 +5,4 @@ 'use strict';

const Capabilities = require('../const/capabilities');
const NativePasswordAuth = require('./handshake/auth/native_password_auth');
const Ed25519PasswordAuth = require('./handshake/auth/ed25519-password-auth');
const NativePasswordAuth = require('./handshake/auth/native-password-auth');
const Collations = require('../const/collations');

@@ -26,8 +27,9 @@ const Handshake = require('./handshake/handshake');

case '':
authToken = NativePasswordAuth.encryptPassword(
this.opts.password,
info.seed
);
authToken = NativePasswordAuth.encryptPassword(this.opts.password, info.seed);
break;
case 'client_ed25519':
authToken = Ed25519PasswordAuth.encryptPassword(this.opts.password, info.seed);
break;
default:

@@ -64,6 +66,3 @@ authToken = Buffer.alloc(0);

if (
this.opts.connectAttributes &&
info.serverCapabilities & Capabilities.CONNECT_ATTRS
) {
if (this.opts.connectAttributes && info.serverCapabilities & Capabilities.CONNECT_ATTRS) {
out.writeInt8(0xfc);

@@ -73,3 +72,3 @@ let initPos = out.pos; //save position, assuming connection attributes length will be less than 2 bytes length

const encoding = this.opts.collation.encoding;
const encoding = this.opts.collation.charset;

@@ -119,16 +118,24 @@ writeParam(out, '_client_name', encoding);

if (this.opts.charset && typeof this.opts.charset === 'string') {
this.opts.collation = Collations.fromName(
this.opts.charset.toUpperCase()
);
if (opt.charset && typeof opt.charset === 'string') {
this.opts.collation = Collations.fromCharset(opt.charset.toLowerCase());
if (this.opts.collation === undefined) {
this.opts.collation = Collations.fromName(opt.charset.toUpperCase());
if (this.opts.collation !== undefined) {
console.log(
"warning: please use option 'collation' " +
"in replacement of 'charset' when using a collation name ('" +
opt.charset +
"')\n" +
"(collation looks like 'UTF8MB4_UNICODE_CI', charset like 'utf8')."
);
}
}
if (this.opts.collation === undefined)
throw new RangeError("Unknown charset '" + this.opts.charset + "'");
const initialResolve = this.resolve;
this.resolve = err => {
if (!err) connOpts.collation = this.opts.collation;
initialResolve(err);
};
throw new RangeError("Unknown charset '" + opt.charset + "'");
} else if (opt.collation && typeof opt.collation === 'string') {
this.opts.collation = Collations.fromName(opt.collation.toUpperCase());
if (this.opts.collation === undefined)
throw new RangeError("Unknown collation '" + opt.collation + "'");
} else {
this.opts.collation =
Collations.fromIndex(this.opts.charsetNumber) || connOpts.collation;
this.opts.collation = Collations.fromIndex(opt.charsetNumber) || Collations.fromIndex(224); //UTF8MB4_UNICODE_CI;
}

@@ -135,0 +142,0 @@ connOpts.password = opt.password;

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

module.exports.parseColumn = function(packet, clientEncoding) {
module.exports.parseColumn = function(packet) {
const initial = packet.pos + 4; //skip 'def'

@@ -29,15 +29,15 @@ packet.positionFromEnd(12); //fixed length field

flags: flags,
db: getStringProperty.bind(this, packet, initial, clientEncoding, 0),
schema: getStringProperty.bind(this, packet, initial, clientEncoding, 0),
table: getStringProperty.bind(this, packet, initial, clientEncoding, 1),
orgTable: getStringProperty.bind(this, packet, initial, clientEncoding, 2),
name: getStringProperty.bind(this, packet, initial, clientEncoding, 3),
orgName: getStringProperty.bind(this, packet, initial, clientEncoding, 4)
db: getStringProperty.bind(this, packet, initial, 0),
schema: getStringProperty.bind(this, packet, initial, 0),
table: getStringProperty.bind(this, packet, initial, 1),
orgTable: getStringProperty.bind(this, packet, initial, 2),
name: getStringProperty.bind(this, packet, initial, 3),
orgName: getStringProperty.bind(this, packet, initial, 4)
};
};
function getStringProperty(packet, initial, clientEncoding, index) {
function getStringProperty(packet, initial, index) {
packet.forceOffset(initial);
for (let j = 0; j < index; j++) packet.skipLengthCodedNumber();
return packet.readStringLengthEncoded(clientEncoding);
return packet.readStringLength();
}

@@ -85,13 +85,13 @@ 'use strict';

const subSubPacket = subPacket.subPacketLengthEncoded();
const variable = subSubPacket.readStringLengthEncoded(
opts.collation.encoding
);
const value = subSubPacket.readStringLengthEncoded(
opts.collation.encoding
);
const variable = subSubPacket.readStringLength();
const value = subSubPacket.readStringLength();
switch (variable) {
case 'character_set_client':
opts.collation = Collations.fromEncoding(value);
out.changeEncoding(opts.collation);
opts.collation = Collations.fromCharset(value);
if (opts.collation === undefined) {
this.throwError(new Error("unknown charset : '" + value + "'"), info);
return;
}
opts.emit('collation', opts.collation);
break;

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

const subSubPacket2 = subPacket.subPacketLengthEncoded();
info.database = subSubPacket2.readStringLengthEncoded(
opts.collation.encoding
);
info.database = subSubPacket2.readStringLength();
break;

@@ -111,0 +109,0 @@ }

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

flushed = out.writeInt8(0x00);
flushed =
out.writeLengthEncodedString(String(value.toSqlString())) ||
flushed;
flushed = out.writeLengthEncodedString(String(value.toSqlString())) || flushed;
} else {

@@ -62,5 +60,4 @@ if (

flushed =
out.writeLengthEncodedBuffer(
Buffer.concat([Buffer.from([0, 0, 0, 0]), geoBuff])
) || flushed;
out.writeLengthEncodedBuffer(Buffer.concat([Buffer.from([0, 0, 0, 0]), geoBuff])) ||
flushed;
} else {

@@ -72,4 +69,3 @@ flushed = out.writeInt8(0x01); //NULL

flushed = out.writeInt8(0x00);
flushed =
out.writeLengthEncodedString(JSON.stringify(value)) || flushed;
flushed = out.writeLengthEncodedString(JSON.stringify(value)) || flushed;
}

@@ -204,5 +200,3 @@ }

for (let i = 0; i < coordinateLength; i++) {
const tmpBuf = this.getBufferFromGeometryValue(
value.geometries[i]
);
const tmpBuf = this.getBufferFromGeometryValue(value.geometries[i]);
if (tmpBuf == null) break;

@@ -224,6 +218,3 @@ subArrays.push(tmpBuf);

for (let i = 0; i < coordinateLength; i++) {
const tmpBuf = this.getBufferFromGeometryValue(
value.coordinates[i],
type
);
const tmpBuf = this.getBufferFromGeometryValue(value.coordinates[i], type);
if (tmpBuf == null) break;

@@ -230,0 +221,0 @@ subArrays.push(tmpBuf);

@@ -45,2 +45,9 @@ 'use strict';

out.writeStringAscii(value.toString());
} else if (Array.isArray(value)) {
out.writeStringAscii('(');
for (let i = 0; i < value.length; i++) {
if (i !== 0) out.writeStringAscii(',');
this.writeParam(out, value[i], opts, info);
}
out.writeStringAscii(')');
} else {

@@ -168,34 +175,19 @@ if (

case 'LineString':
st +=
'LINESTRING(' +
this.geoArrayPointToString(geo[i].coordinates) +
')';
st += 'LINESTRING(' + this.geoArrayPointToString(geo[i].coordinates) + ')';
break;
case 'Polygon':
st +=
'POLYGON(' +
this.geoMultiArrayPointToString(geo[i].coordinates) +
')';
st += 'POLYGON(' + this.geoMultiArrayPointToString(geo[i].coordinates) + ')';
break;
case 'MultiPoint':
st +=
'MULTIPOINT(' +
this.geoArrayPointToString(geo[i].coordinates) +
')';
st += 'MULTIPOINT(' + this.geoArrayPointToString(geo[i].coordinates) + ')';
break;
case 'MultiLineString':
st +=
'MULTILINESTRING(' +
this.geoMultiArrayPointToString(geo[i].coordinates) +
')';
st += 'MULTILINESTRING(' + this.geoMultiArrayPointToString(geo[i].coordinates) + ')';
break;
case 'MultiPolygon':
st +=
'MULTIPOLYGON(' +
this.geoMultiPolygonToString(geo[i].coordinates) +
')';
st += 'MULTIPOLYGON(' + this.geoMultiPolygonToString(geo[i].coordinates) + ')';
break;

@@ -211,6 +203,3 @@ }

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

@@ -224,4 +213,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]) + ')';
}

@@ -242,7 +230,3 @@ return st;

if (!coords) return '';
return (
(isNaN(coords[0]) ? '' : coords[0]) +
' ' +
(isNaN(coords[1]) ? '' : coords[1])
);
return (isNaN(coords[0]) ? '' : coords[0]) + ' ' + (isNaN(coords[1]) ? '' : coords[1]);
}

@@ -276,9 +260,3 @@

for (let i = 0; i < this._columnCount; i++) {
row[this.tableHeader[i]] = this._getValue(
i,
columns[i],
this.opts,
connOpts,
packet
);
row[this.tableHeader[i]] = this._getValue(i, columns[i], this.opts, connOpts, packet);
}

@@ -289,4 +267,3 @@ return row;

castTextWrapper(column, opts, connOpts, packet) {
column.string = () =>
packet.readStringLengthEncoded(connOpts.collation.encoding);
column.string = () => packet.readStringLength();
column.buffer = () => packet.readBufferLengthEncoded();

@@ -302,11 +279,5 @@ column.float = () => packet.readFloatLengthCoded();

column.decimal = () =>
packet.readDecimalLengthEncoded(
opts.supportBigNumbers,
opts.bigNumberStrings
);
packet.readDecimalLengthEncoded(opts.supportBigNumbers, opts.bigNumberStrings);
column.date = () =>
packet.readDecimalLengthEncoded(
opts.supportBigNumbers,
opts.bigNumberStrings
);
packet.readDecimalLengthEncoded(opts.supportBigNumbers, opts.bigNumberStrings);
column.geometry = () => {

@@ -354,6 +325,3 @@ return column.readGeometry();

case FieldType.NEWDECIMAL:
return packet.readDecimalLengthEncoded(
opts.supportBigNumbers,
opts.bigNumberStrings
);
return packet.readDecimalLengthEncoded(opts.supportBigNumbers, opts.bigNumberStrings);
case FieldType.DATE:

@@ -382,5 +350,3 @@ if (opts.dateStrings) {

}
const string = packet.readStringLengthEncoded(
connOpts.collation.encoding
);
const string = packet.readStringLength();
if (column.flags & 2048) {

@@ -400,9 +366,3 @@ //SET

"'" +
(year > 999
? year
: year > 99
? '0' + year
: year > 9
? '00' + year
: '000' + year) +
(year > 999 ? year : year > 99 ? '0' + year : year > 9 ? '00' + year : '000' + year) +
'-' +

@@ -409,0 +369,0 @@ (mon < 10 ? '0' : '') +

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

}
if (opts.permitConnectionWhenExpired) {
capabilities |= Capabilities.CAN_HANDLE_EXPIRED_PASSWORDS;
}
info.clientCapabilities = capabilities;
};

@@ -5,3 +5,4 @@ 'use strict';

const Iconv = require('iconv-lite');
const NativePasswordAuth = require('./auth/native_password_auth');
const NativePasswordAuth = require('./auth/native-password-auth');
const Ed25519PasswordAuth = require('./auth/ed25519-password-auth');
const driverVersion = require('../../../package.json').version;

@@ -29,2 +30,5 @@ const os = require('os');

break;
case 'client_ed25519':
authToken = Ed25519PasswordAuth.encryptPassword(opts.password, info.seed);
break;

@@ -69,6 +73,3 @@ default:

if (
opts.connectAttributes &&
info.serverCapabilities & Capabilities.CONNECT_ATTRS
) {
if (opts.connectAttributes && info.serverCapabilities & Capabilities.CONNECT_ATTRS) {
out.writeInt8(0xfc);

@@ -78,3 +79,3 @@ let initPos = out.pos; //save position, assuming connection attributes length will be less than 2 bytes length

const encoding = opts.collation.encoding;
const encoding = opts.collation.charset;

@@ -81,0 +82,0 @@ writeParam(out, '_client_name', encoding);

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

this.onPacketReceive = this.parseHandshakeInit;
this.plugin = this;
}

@@ -42,9 +43,3 @@

function() {
ClientHandshakeResponse.send(
this,
out,
opts,
handshake.pluginName,
info
);
ClientHandshakeResponse.send(this, out, opts, handshake.pluginName, info);
}.bind(this)

@@ -87,8 +82,6 @@ );

case 0xfe:
this.plugin.onPacketReceive = null;
this.plugin.emit('send_end');
this.plugin.emit('end');
this.dispatchAuthSwitchRequest(packet, out, opts, info);
this.resolve = null;
this.reject = null;
this.onPacketReceive = null;
this.emit('send_end');
this.emit('end');
return;

@@ -104,4 +97,4 @@

info.status = packet.readUInt16();
this.emit('send_end');
return this.successEnd();
this.plugin.emit('send_end');
return this.plugin.successEnd();

@@ -114,3 +107,3 @@ //*********************************************************************************************************

authErr.fatal = true;
return this.throwError(authErr, info);
return this.plugin.throwError(authErr, info);

@@ -159,3 +152,4 @@ //*********************************************************************************************************

pluginName,
this.sequenceNo,
this.plugin.sequenceNo,
this.plugin.compressSequenceNo,
pluginData,

@@ -166,3 +160,4 @@ info,

this.resolve,
this.reject
this.reject,
this.handshakeResult.bind(this)
);

@@ -183,3 +178,4 @@

} else {
this._addCommand(plugin, false);
this.plugin = plugin;
this._addCommand(this.plugin, false);
}

@@ -191,2 +187,3 @@ }

packSeq,
compressPackSeq,
pluginData,

@@ -197,3 +194,4 @@ info,

authResolve,
authReject
authReject,
multiAuthResolver
) {

@@ -203,15 +201,18 @@ let pluginAuth;

case 'mysql_native_password':
pluginAuth = require('./auth/native_password_auth.js');
pluginAuth = require('./auth/native-password-auth.js');
break;
case 'mysql_clear_password':
pluginAuth = require('./auth/clear_password_auth.js');
pluginAuth = require('./auth/clear-password-auth.js');
break;
case 'client_ed25519':
pluginAuth = require('./auth/ed25519-password-auth.js');
break;
case 'dialog':
pluginAuth = require('./auth/pam_password_auth.js');
pluginAuth = require('./auth/pam-password-auth.js');
break;
//TODO "auth_gssapi_client"
//TODO "client_ed25519"

@@ -221,3 +222,10 @@ default:

}
return new pluginAuth(packSeq, pluginData, authResolve, authReject);
return new pluginAuth(
packSeq,
compressPackSeq,
pluginData,
authResolve,
authReject,
multiAuthResolver
);
}

@@ -224,0 +232,0 @@ }

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

info.serverVersion.mariaDb = true;
info.serverVersion.raw = info.serverVersion.raw.substring(
'5.5.5-'.length
);
info.serverVersion.raw = info.serverVersion.raw.substring('5.5.5-'.length);
} else {

@@ -55,0 +53,0 @@ //Support for MDEV-7780 faking server version

@@ -51,5 +51,3 @@ 'use strict';

this.queryParts = Parse.splitQuery(this.sql);
this.values = Array.isArray(this.initialValues)
? this.initialValues
: [this.initialValues];
this.values = Array.isArray(this.initialValues) ? this.initialValues : [this.initialValues];
if (!this.validateParameters(info)) return;

@@ -127,6 +125,3 @@ }

this.throwNewError(
'Parameter at position ' +
(this.values.length + 1) +
' is not set\n' +
this.displaySql(),
'Parameter at position ' + (this.values.length + 1) + ' is not set\n' + this.displaySql(),
false,

@@ -145,6 +140,3 @@ info,

this.throwNewError(
'Parameter at position ' +
(i + 1) +
' is undefined\n' +
this.displaySql(),
'Parameter at position ' + (i + 1) + ' is undefined\n' + this.displaySql(),
false,

@@ -151,0 +143,0 @@ info,

@@ -5,4 +5,2 @@ 'use strict';

const ServerStatus = require('../const/server-status');
const StateChange = require('../const/state-change');
const Collations = require('../const/collations');
const ColumnDefinition = require('./column-definition');

@@ -98,16 +96,6 @@ const Errors = require('../misc/errors');

this.opts = {
typeCast:
cmdOpts.typeCast != undefined ? cmdOpts.typeCast : connOpts.typeCast,
rowsAsArray:
cmdOpts.rowsAsArray != undefined
? cmdOpts.rowsAsArray
: connOpts.rowsAsArray,
nestTables:
cmdOpts.nestTables != undefined
? cmdOpts.nestTables
: connOpts.nestTables,
dateStrings:
cmdOpts.dateStrings != undefined
? cmdOpts.dateStrings
: connOpts.dateStrings,
typeCast: cmdOpts.typeCast != undefined ? cmdOpts.typeCast : connOpts.typeCast,
rowsAsArray: cmdOpts.rowsAsArray != undefined ? cmdOpts.rowsAsArray : connOpts.rowsAsArray,
nestTables: cmdOpts.nestTables != undefined ? cmdOpts.nestTables : connOpts.nestTables,
dateStrings: cmdOpts.dateStrings != undefined ? cmdOpts.dateStrings : connOpts.dateStrings,
tz: cmdOpts.tz != undefined ? cmdOpts.tz : connOpts.tz,

@@ -131,5 +119,3 @@ namedPlaceholders:

bigNumberStrings:
cmdOpts.bigNumberStrings != undefined
? cmdOpts.bigNumberStrings
: connOpts.bigNumberStrings
cmdOpts.bigNumberStrings != undefined ? cmdOpts.bigNumberStrings : connOpts.bigNumberStrings
};

@@ -180,6 +166,4 @@ }

if (this.columnNo > 0)
return (this.onPacketReceive = this.skipColumnsPacket);
if (this.parameterNo > 0)
return (this.onPacketReceive = this.skipParameterPacket);
if (this.columnNo > 0) return (this.onPacketReceive = this.skipColumnsPacket);
if (this.parameterNo > 0) return (this.onPacketReceive = this.skipParameterPacket);
return this.success();

@@ -212,4 +196,3 @@

if (info.eofDeprecated) {
if (this.parameterNo > 0)
return (this.onPacketReceive = this.skipParameterPacket);
if (this.parameterNo > 0) return (this.onPacketReceive = this.skipParameterPacket);
this.success();

@@ -222,4 +205,3 @@ }

skipEofPacket(packet, out, opts, info) {
if (this.parameterNo > 0)
return (this.onPacketReceive = this.skipParameterPacket);
if (this.parameterNo > 0) return (this.onPacketReceive = this.skipParameterPacket);
this.success();

@@ -254,6 +236,3 @@ }

if (this._columns.length !== this._columnCount) {
const column = ColumnDefinition.parseColumn(
packet,
opts.collation.encoding
);
const column = ColumnDefinition.parseColumn(packet);
this._columns.push(column);

@@ -271,5 +250,3 @@ }

this.tableHeader[i] =
this._columns[i].table() +
this.opts.nestTables +
this._columns[i].name();
this._columns[i].table() + this.opts.nestTables + this._columns[i].name();
}

@@ -279,6 +256,3 @@ } else if (this.opts.nestTables === true) {

for (let i = 0; i < this._columnCount; i++) {
this.tableHeader[i] = [
this._columns[i].table(),
this._columns[i].name()
];
this.tableHeader[i] = [this._columns[i].table(), this._columns[i].name()];
}

@@ -384,6 +358,3 @@ }

if (
info.status & ServerStatus.MORE_RESULTS_EXISTS ||
this.isOutParameter
) {
if (info.status & ServerStatus.MORE_RESULTS_EXISTS || this.isOutParameter) {
this._responseIndex++;

@@ -393,5 +364,3 @@ return (this.onPacketReceive = this.readResponsePacket);

this.success(
this._responseIndex === 0
? [this._rows[0], this._meta[0]]
: [this._rows, this._meta]
this._responseIndex === 0 ? [this._rows[0], this._meta[0]] : [this._rows, this._meta]
);

@@ -406,6 +375,3 @@ } else {

this._rows[this._responseIndex].meta = this._columns;
if (
info.status & ServerStatus.MORE_RESULTS_EXISTS ||
this.isOutParameter
) {
if (info.status & ServerStatus.MORE_RESULTS_EXISTS || this.isOutParameter) {
this._responseIndex++;

@@ -503,31 +469,26 @@ return (this.onPacketReceive = this.readResponsePacket);

fs.access(fileName, (fs.constants || fs).R_OK, err => {
if (err) {
out.writeEmptyPacket();
const error = Errors.createError(
'LOCAL INFILE command failed: ' + err.message,
false,
info,
'22000',
Errors.ER_LOCAL_INFILE_NOT_READABLE
);
process.nextTick(this.reject, error);
this.reject = null;
this.resolve = null;
return (this.onPacketReceive = this.readResponsePacket);
// this.sequenceNo = 2;
// this.compressSequenceNo = 2;
const stream = fs.createReadStream(fileName);
stream.on('error', err => {
out.writeEmptyPacket();
const error = Errors.createError(
'LOCAL INFILE command failed: ' + err.message,
false,
info,
'22000',
Errors.ER_LOCAL_INFILE_NOT_READABLE
);
process.nextTick(this.reject, error);
this.reject = null;
this.resolve = null;
});
stream.on('data', chunk => {
out.writeBuffer(chunk, 0, chunk.length);
});
stream.on('end', () => {
if (!out.isEmpty()) {
out.flushBuffer(false);
}
// this.sequenceNo = 2;
// this.compressSequenceNo = 2;
const stream = fs.createReadStream(fileName);
stream.on('data', chunk => {
out.writeBuffer(chunk, 0, chunk.length);
});
stream.on('end', () => {
if (!out.isEmpty()) {
out.flushBuffer(false);
}
out.writeEmptyPacket();
});
out.writeEmptyPacket();
});

@@ -543,4 +504,3 @@ this.onPacketReceive = this.readResponsePacket;

case 'Buffer':
sqlMsg +=
'0x' + param.toString('hex', 0, Math.min(1024, param.length)) + '';
sqlMsg += '0x' + param.toString('hex', 0, Math.min(1024, param.length)) + '';
break;

@@ -547,0 +507,0 @@

@@ -29,8 +29,23 @@ 'use strict';

if (opts.charset && typeof opts.charset === 'string') {
this.collation = Collations.fromName(opts.charset.toUpperCase());
this.collation = Collations.fromCharset(opts.charset.toLowerCase());
if (this.collation === undefined) {
this.collation = Collations.fromName(opts.charset.toUpperCase());
if (this.collation !== undefined) {
console.log(
"warning: please use option 'collation' " +
"in replacement of 'charset' when using a collation name ('" +
opts.charset +
"')\n" +
"(collation looks like 'UTF8MB4_UNICODE_CI', charset like 'utf8')."
);
}
}
if (this.collation === undefined)
throw new RangeError("Unknown charset '" + opts.charset + "'");
} else if (opts.collation && typeof opts.collation === 'string') {
this.collation = Collations.fromName(opts.collation.toUpperCase());
if (this.collation === undefined)
throw new RangeError("Unknown collation '" + opts.collation + "'");
} else {
this.collation =
Collations.fromIndex(opts.charsetNumber) || Collations.fromIndex(224); //UTF8MB4_UNICODE_CI;
this.collation = Collations.fromIndex(opts.charsetNumber) || Collations.fromIndex(224); //UTF8MB4_UNICODE_CI;
}

@@ -40,6 +55,4 @@ this.compress = opts.compress || false;

this.connectAttributes = opts.connectAttributes || false;
this.connectTimeout =
opts.connectTimeout === undefined ? 10000 : opts.connectTimeout;
this.socketTimeout =
opts.socketTimeout === undefined ? 0 : opts.socketTimeout;
this.connectTimeout = opts.connectTimeout === undefined ? 10000 : opts.connectTimeout;
this.socketTimeout = opts.socketTimeout === undefined ? 0 : opts.socketTimeout;
this.database = opts.database;

@@ -57,6 +70,6 @@ this.dateStrings = opts.dateStrings || false;

this.namedPlaceholders = opts.namedPlaceholders || false;
this.nestTables =
opts.nestTables === undefined ? undefined : opts.nestTables;
this.nestTables = opts.nestTables === undefined ? undefined : opts.nestTables;
this.password = opts.password;
this.permitSetMultiParamEntries = opts.permitSetMultiParamEntries || false;
this.permitConnectionWhenExpired = opts.permitConnectionWhenExpired || false;
this.pipelining = opts.pipelining === undefined || opts.pipelining;

@@ -74,5 +87,3 @@ if (opts.pipelining === undefined) {

}
this.permitLocalInfile = this.pipelining
? false
: opts.permitLocalInfile || false;
this.permitLocalInfile = this.pipelining ? false : opts.permitLocalInfile || false;
}

@@ -91,7 +102,3 @@ this.port = opts.port || 3306;

this.timezone = opts.timezone || 'local';
if (
this.timezone &&
this.timezone !== 'local' &&
this.timezone !== 'auto'
) {
if (this.timezone && this.timezone !== 'local' && this.timezone !== 'auto') {
let tzName = this.timezone;

@@ -103,8 +110,4 @@ if (this.timezone === 'Z') {

if (matched) {
const hour =
(matched[1] === '-' ? 1 : -1) * Number.parseInt(matched[2], 10);
const minutes =
matched.length > 2 && matched[3]
? Number.parseInt(matched[3], 10)
: 0;
const hour = (matched[1] === '-' ? 1 : -1) * Number.parseInt(matched[2], 10);
const minutes = matched.length > 2 && matched[3] ? Number.parseInt(matched[3], 10) : 0;
if (minutes > 0) {

@@ -151,5 +154,3 @@ throw new RangeError(

throw new RangeError(
"maxAllowedPacket must be an integer. was '" +
this.maxAllowedPacket +
"'"
"maxAllowedPacket must be an integer. was '" + this.maxAllowedPacket + "'"
);

@@ -166,4 +167,3 @@ }

static parseOptionDataType(opts) {
if (opts.bigNumberStrings)
opts.bigNumberStrings = opts.bigNumberStrings == 'true';
if (opts.bigNumberStrings) opts.bigNumberStrings = opts.bigNumberStrings == 'true';
if (opts.bulk) opts.bulk = opts.bulk == 'true';

@@ -174,6 +174,4 @@ if (opts.logPackets) opts.logPackets = opts.logPackets == 'true';

if (opts.compress) opts.compress = opts.compress == 'true';
if (opts.connectAttributes)
opts.connectAttributes = opts.connectAttributes == 'true';
if (opts.connectTimeout)
opts.connectTimeout = parseInt(opts.connectTimeout);
if (opts.connectAttributes) opts.connectAttributes = opts.connectAttributes == 'true';
if (opts.connectTimeout) opts.connectTimeout = parseInt(opts.connectTimeout);
if (opts.socketTimeout) opts.socketTimeout = parseInt(opts.socketTimeout);

@@ -188,17 +186,12 @@ if (opts.dateStrings) opts.dateStrings = opts.dateStrings == 'true';

if (opts.metaAsArray) opts.metaAsArray = opts.metaAsArray == 'true';
if (opts.multipleStatements)
opts.multipleStatements = opts.multipleStatements == 'true';
if (opts.namedPlaceholders)
opts.namedPlaceholders = opts.namedPlaceholders == 'true';
if (opts.multipleStatements) opts.multipleStatements = opts.multipleStatements == 'true';
if (opts.namedPlaceholders) opts.namedPlaceholders = opts.namedPlaceholders == 'true';
if (opts.nestTables) opts.nestTables = opts.nestTables == 'true';
if (opts.permitSetMultiParamEntries)
opts.permitSetMultiParamEntries =
opts.permitSetMultiParamEntries == 'true';
opts.permitSetMultiParamEntries = opts.permitSetMultiParamEntries == 'true';
if (opts.pipelining) opts.pipelining = opts.pipelining == 'true';
if (opts.rowsAsArray) opts.rowsAsArray = opts.rowsAsArray == 'true';
if (opts.supportBigNumbers)
opts.supportBigNumbers = opts.supportBigNumbers == 'true';
if (opts.supportBigNumbers) opts.supportBigNumbers = opts.supportBigNumbers == 'true';
if (opts.trace) opts.trace = opts.trace == 'true';
if (opts.ssl && (opts.ssl == 'true' || opts.ssl == 'false'))
opts.ssl = opts.ssl == 'true';
if (opts.ssl && (opts.ssl == 'true' || opts.ssl == 'false')) opts.ssl = opts.ssl == 'true';
return opts;

@@ -231,5 +224,3 @@ }

if (equalIdx !== 1) {
options[keyVal.substring(0, equalIdx)] = keyVal.substring(
equalIdx + 1
);
options[keyVal.substring(0, equalIdx)] = keyVal.substring(equalIdx + 1);
}

@@ -236,0 +227,0 @@ });

@@ -11,28 +11,19 @@ 'use strict';

//set data type
if (opts.acquireTimeout)
opts.acquireTimeout = parseInt(opts.acquireTimeout);
if (opts.connectionLimit)
opts.connectionLimit = parseInt(opts.connectionLimit);
if (opts.acquireTimeout) opts.acquireTimeout = parseInt(opts.acquireTimeout);
if (opts.connectionLimit) opts.connectionLimit = parseInt(opts.connectionLimit);
if (opts.idleTimeout) opts.idleTimeout = parseInt(opts.idleTimeout);
if (opts.initializationTimeout)
opts.initializationTimeout = parseInt(opts.initializationTimeout);
if (opts.minDelayValidation)
opts.minDelayValidation = parseInt(opts.minDelayValidation);
if (opts.minDelayValidation) opts.minDelayValidation = parseInt(opts.minDelayValidation);
if (opts.minimumIdle) opts.minimumIdle = parseInt(opts.minimumIdle);
if (opts.noControlAfterUse)
opts.noControlAfterUse = opts.noControlAfterUse == 'true';
if (opts.noControlAfterUse) opts.noControlAfterUse = opts.noControlAfterUse == 'true';
if (opts.resetAfterUse) opts.resetAfterUse = opts.resetAfterUse == 'true';
}
this.acquireTimeout =
opts.acquireTimeout === undefined ? 10000 : opts.acquireTimeout;
this.connectionLimit =
opts.connectionLimit === undefined ? 10 : opts.connectionLimit;
this.acquireTimeout = opts.acquireTimeout === undefined ? 10000 : opts.acquireTimeout;
this.connectionLimit = opts.connectionLimit === undefined ? 10 : opts.connectionLimit;
this.idleTimeout = opts.idleTimeout || 1800;
this.initializationTimeout =
opts.initializationTimeout === undefined
? 30000
: opts.initializationTimeout;
this.minDelayValidation =
opts.minDelayValidation === undefined ? 500 : opts.minDelayValidation;
opts.initializationTimeout === undefined ? 30000 : opts.initializationTimeout;
this.minDelayValidation = opts.minDelayValidation === undefined ? 500 : opts.minDelayValidation;
this.minimumIdle =

@@ -43,11 +34,7 @@ opts.minimumIdle === undefined

this.noControlAfterUse = opts.noControlAfterUse || false;
this.resetAfterUse =
opts.resetAfterUse === undefined ? true : opts.resetAfterUse;
this.resetAfterUse = opts.resetAfterUse === undefined ? true : opts.resetAfterUse;
this.connOptions = new ConnOptions(opts);
if (
this.acquireTimeout > 0 &&
this.connOptions.connectTimeout > this.acquireTimeout
) {
if (this.acquireTimeout > 0 && this.connOptions.connectTimeout > this.acquireTimeout) {
this.connOptions.connectTimeout = this.acquireTimeout;

@@ -54,0 +41,0 @@ }

@@ -113,3 +113,6 @@ 'use strict';

options,
resolve,
res => {
if (options) opts.collation = options.collation;
resolve(res);
},
_authFailHandler.bind(this, reject),

@@ -195,10 +198,3 @@ _addCommand.bind(this)

? new BatchBulk(resolve, reject, _options, opts, _sql, initialValues)
: new BatchRewrite(
resolve,
reject,
_options,
opts,
_sql,
initialValues
);
: new BatchRewrite(resolve, reject, _options, opts, _sql, initialValues);
if (opts.trace) Error.captureStackTrace(cmd);

@@ -265,5 +261,3 @@ _addCommand(cmd);

return Promise.reject(
new Error(
'Reset command not permitted for server ' + this.info.serverVersion
)
new Error('Reset command not permitted for server ' + this.info.serverVersion)
);

@@ -440,5 +434,3 @@ };

if (!info.serverVersion)
throw new Error(
'cannot know if server information until connection is established'
);
throw new Error('cannot know if server information until connection is established');
return info.serverVersion.raw;

@@ -675,6 +667,3 @@ };

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

@@ -697,10 +686,3 @@ }

};
const cmd = new Query(
resolve,
errorHandling,
null,
opts,
sessionQuery,
values
);
const cmd = new Query(resolve, errorHandling, null, opts, sessionQuery, values);
if (opts.trace) Error.captureStackTrace(cmd);

@@ -715,37 +697,35 @@ _addCommand(cmd);

/**
* Asking server timezone if not set
* @returns {Promise<void>|Promise<T | never>}
* Asking server timezone if not set in case of 'auto'
* @returns {Promise<void>}
* @private
*/
const _checkServerTimezone = () => {
if (opts.timezone === 'local' || opts.tz) {
if (opts.timezone !== 'auto') {
return Promise.resolve();
}
return this.query('SELECT @@system_time_zone stz, @@time_zone tz').then(
res => {
const serverTimezone = res[0].tz === 'SYSTEM' ? res[0].stz : res[0].tz;
const serverZone = moment.tz.zone(serverTimezone);
if (serverZone) {
if (serverTimezone === moment.tz.guess()) {
//db server and client use same timezone, avoid any conversion
opts.tz = null;
} else {
opts.tz = moment.tz.setDefault(serverTimezone);
}
return this.query('SELECT @@system_time_zone stz, @@time_zone tz').then(res => {
const serverTimezone = res[0].tz === 'SYSTEM' ? res[0].stz : res[0].tz;
const serverZone = moment.tz.zone(serverTimezone);
if (serverZone) {
if (serverTimezone === moment.tz.guess()) {
//db server and client use same timezone, avoid any conversion
opts.tz = null;
} else {
return Promise.reject(
Errors.createError(
"Automatic timezone setting fails. Server timezone '" +
serverTimezone +
"' does't have a corresponding IANA timezone. Option timezone must be set according to server timezone",
true,
info,
'08S01',
Errors.ER_WRONG_AUTO_TIMEZONE
)
);
opts.tz = moment.tz.setDefault(serverTimezone);
}
return Promise.resolve();
} else {
return Promise.reject(
Errors.createError(
"Automatic timezone setting fails. Server timezone '" +
serverTimezone +
"' does't have a corresponding IANA timezone. Option timezone must be set according to server timezone",
true,
info,
'08S01',
Errors.ER_WRONG_AUTO_TIMEZONE
)
);
}
);
return Promise.resolve();
});
};

@@ -755,5 +735,3 @@

if (opts.initSql) {
const initialArr = Array.isArray(opts.initSql)
? opts.initSql
: [opts.initSql];
const initialArr = Array.isArray(opts.initSql) ? opts.initSql : [opts.initSql];
const initialPromises = [];

@@ -775,10 +753,3 @@ initialArr.forEach(sql => {

};
const cmd = new Query(
resolve,
errorHandling,
null,
opts,
sql,
null
);
const cmd = new Query(resolve, errorHandling, null, opts, sql, null);
if (opts.trace) Error.captureStackTrace(cmd);

@@ -810,7 +781,3 @@ _addCommand(cmd);

if (opts.connectTimeout) {
_timeout = setTimeout(
_connectTimeoutReached,
opts.connectTimeout,
authFailHandler
);
_timeout = setTimeout(_connectTimeoutReached, opts.connectTimeout, authFailHandler);
}

@@ -830,6 +797,3 @@

_socketConnected = true;
_socket.setTimeout(
opts.socketTimeout,
_socketTimeoutReached.bind(this, authFailHandler)
);
_socket.setTimeout(opts.socketTimeout, _socketTimeoutReached.bind(this, authFailHandler));
_socket.setNoDelay(true);

@@ -954,6 +918,3 @@ }

let err = packet.readError(info);
if (
err.fatal &&
(_status !== Status.CLOSING && _status !== Status.CLOSED)
) {
if (err.fatal && (_status !== Status.CLOSING && _status !== Status.CLOSED)) {
this.emit('error', err);

@@ -1008,6 +969,3 @@ this.end();

//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
) {
if (_receiveQueue.peekFront() || info.status & ServerStatus.STATUS_IN_TRANS) {
return new Promise(function(resolve, reject) {

@@ -1048,9 +1006,3 @@ const cmd = new Query(resolve, reject, null, opts, sql, null);

const _socketTimeoutReached = function() {
const err = Errors.createError(
'socket timeout',
true,
info,
'08S01',
Errors.ER_SOCKET_TIMEOUT
);
const err = Errors.createError('socket timeout', true, info, '08S01', Errors.ER_SOCKET_TIMEOUT);
const packetMsgs = info.getLastPackets();

@@ -1173,4 +1125,3 @@ if (packetMsgs !== '') {

err.stack +=
'\n From event:\n' +
currentCmd.stack.substring(currentCmd.stack.indexOf('\n') + 1);
'\n From event:\n' + currentCmd.stack.substring(currentCmd.stack.indexOf('\n') + 1);
}

@@ -1278,2 +1229,3 @@ authFailHandler(err);

_sendQueue.clear();
opts.removeAllListeners();
_out = undefined;

@@ -1288,3 +1240,3 @@ _socket = undefined;

EventEmitter.call(this);
const opts = Object.assign({}, options);
const opts = Object.assign(new EventEmitter(), options);
const info = new ConnectionInformation();

@@ -1300,9 +1252,3 @@ const _sendQueue = new Queue();

let _out = new PacketOutputStream(opts, info);
let _in = new PacketInputStream(
_unexpectedPacket.bind(this),
_receiveQueue,
_out,
opts,
info
);
let _in = new PacketInputStream(_unexpectedPacket.bind(this), _receiveQueue, _out, opts, info);

@@ -1309,0 +1255,0 @@ //add alias threadId for mysql/mysql2 compatibility

@@ -7,12 +7,10 @@ 'use strict';

class Collation {
constructor(index, name, encoding, maxLength) {
constructor(index, name, charset, maxLength) {
this.index = index;
this.name = name;
this.encoding = encoding;
this.charset = charset;
}
static fromEncoding(encoding) {
const val = defaultCharsets[encoding];
if (!val) throw new Error("unknown encoding : '" + encoding + "'");
return val;
static fromCharset(charset) {
return defaultCharsets[charset];
}

@@ -37,4 +35,4 @@

// generated with query :
// SELECT CONCAT('charsets[', CAST(co.ID as char), '] = new Collation(', CAST(co.ID as char), ', "',
// UPPER(co.COLLATION_NAME), '", "', co.CHARACTER_SET_NAME, '",', CAST(ca.MAXLEN as char), ');\n')
// SELECT CONCAT('charsets[', CAST(co.ID as char), '] = new Collation(', CAST(co.ID as char), ', \'',
// UPPER(co.COLLATION_NAME), '\', \'', co.CHARACTER_SET_NAME, '\',', CAST(ca.MAXLEN as char), ');\n')
// FROM information_schema.COLLATIONS co

@@ -299,8 +297,3 @@ // LEFT OUTER JOIN information_schema.CHARACTER_SETS ca ON ca.character_set_name = co.character_set_name

charsets[1054] = new Collation(1054, 'LATIN5_TURKISH_NOPAD_CI', 'latin5', 1);
charsets[1056] = new Collation(
1056,
'ARMSCII8_GENERAL_NOPAD_CI',
'armscii8',
1
);
charsets[1056] = new Collation(1056, 'ARMSCII8_GENERAL_NOPAD_CI', 'armscii8', 1);
charsets[1057] = new Collation(1057, 'UTF8_GENERAL_NOPAD_CI', 'utf8', 3);

@@ -311,8 +304,3 @@ charsets[1059] = new Collation(1059, 'UCS2_GENERAL_NOPAD_CI', 'ucs2', 2);

charsets[1062] = new Collation(1062, 'MACCE_GENERAL_NOPAD_CI', 'macce', 1);
charsets[1063] = new Collation(
1063,
'MACROMAN_GENERAL_NOPAD_CI',
'macroman',
1
);
charsets[1063] = new Collation(1063, 'MACROMAN_GENERAL_NOPAD_CI', 'macroman', 1);
charsets[1064] = new Collation(1064, 'CP852_GENERAL_NOPAD_CI', 'cp852', 1);

@@ -388,3 +376,4 @@ charsets[1065] = new Collation(1065, 'LATIN7_GENERAL_NOPAD_CI', 'latin7', 1);

/**
* set default encoding to charset index.
* Map charset to default collation
*
* created with query:

@@ -391,0 +380,0 @@ * SELECT CONCAT(' defaultCharsets[\'', co.character_set_name , '\'] = charsets[', CAST(co.ID as char), '];')

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

* File generated using test/tools/generate-mariadb.js
* from MariaDB 10.3
* from MariaDB 10.4
*

@@ -188,3 +188,3 @@ * !!!!!! DO NOT CHANGE MANUALLY !!!!!!

codes[1100] = 'ER_TABLE_NOT_LOCKED';
codes[1101] = 'ER_BLOB_CANT_HAVE_DEFAULT';
codes[1101] = 'ER_UNUSED_17';
codes[1102] = 'ER_WRONG_DB_NAME';

@@ -575,3 +575,3 @@ codes[1103] = 'ER_WRONG_TABLE_NAME';

codes[1486] = 'ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR';
codes[1487] = 'ER_NO_CONST_EXPR_IN_RANGE_OR_LIST_ERROR';
codes[1487] = 'ER_NOT_CONSTANT_EXPRESSION';
codes[1488] = 'ER_FIELD_NOT_FOUND_PART_ERROR';

@@ -857,4 +857,3 @@ codes[1489] = 'ER_LIST_OF_FIELDS_ONLY_IN_HASH_ERROR';

codes[1767] = 'ER_GTID_NEXT_IS_NOT_IN_GTID_NEXT_LIST';
codes[1768] =
'ER_CANT_CHANGE_GTID_NEXT_IN_TRANSACTION_WHEN_GTID_NEXT_LIST_IS_NULL';
codes[1768] = 'ER_CANT_CHANGE_GTID_NEXT_IN_TRANSACTION_WHEN_GTID_NEXT_LIST_IS_NULL';
codes[1769] = 'ER_SET_STATEMENT_CANNOT_INVOKE_FUNCTION';

@@ -1237,3 +1236,3 @@ codes[1770] = 'ER_GTID_NEXT_CANT_BE_AUTOMATIC_IF_GTID_NEXT_LIST_IS_NON_NULL';

codes[4121] = 'ER_VERS_RANGE_PROHIBITED';
codes[4122] = 'ER_UNUSED_26';
codes[4122] = 'ER_CONFLICTING_FOR_SYSTEM_TIME';
codes[4123] = 'ER_VERS_TABLE_MUST_HAVE_COLUMNS';

@@ -1253,8 +1252,26 @@ codes[4124] = 'ER_VERS_NOT_VERSIONED';

codes[4136] = 'ER_UNUSED_24';
codes[4137] = 'ER_VERS_TEMPORARY';
codes[4138] = 'ER_VERS_NOT_SUPPORTED';
codes[4137] = 'ER_VERS_NOT_SUPPORTED';
codes[4138] = 'ER_VERS_TRX_PART_HISTORIC_ROW_NOT_SUPPORTED';
codes[4139] = 'ER_INDEX_FILE_FULL';
codes[4140] = 'ER_UPDATED_COLUMN_ONLY_ONCE';
codes[4141] = 'ER_EMPTY_ROW_IN_TVC';
codes[4142] = 'ER_VERS_QUERY_IN_PARTITION';
codes[4143] = 'ER_KEY_DOESNT_SUPPORT';
codes[4144] = 'ER_ALTER_OPERATION_TABLE_OPTIONS_NEED_REBUILD';
codes[4145] = 'ER_BACKUP_LOCK_IS_ACTIVE';
codes[4146] = 'ER_BACKUP_NOT_RUNNING';
codes[4147] = 'ER_BACKUP_WRONG_STAGE';
codes[4148] = 'ER_BACKUP_STAGE_FAILED';
codes[4149] = 'ER_BACKUP_UNKNOWN_STAGE';
codes[4150] = 'ER_USER_IS_BLOCKED';
codes[4151] = 'ER_ACCOUNT_HAS_BEEN_LOCKED';
codes[4152] = 'ER_PERIOD_TEMPORARY_NOT_ALLOWED';
codes[4153] = 'ER_PERIOD_TYPES_MISMATCH';
codes[4154] = 'ER_MORE_THAN_ONE_PERIOD';
codes[4155] = 'ER_PERIOD_FIELD_WRONG_ATTRIBUTES';
codes[4156] = 'ER_PERIOD_NOT_FOUND';
codes[4157] = 'ER_PERIOD_COLUMNS_UPDATED';
codes[4158] = 'ER_PERIOD_CONSTRAINT_DROP';
codes[4159] = 'ER_TOO_LONG_KEYPART';
module.exports.codes = codes;

@@ -29,5 +29,3 @@ 'use strict';

this.haveErrorResponse = false;
this.writeBinaryDate = opts.tz
? this.writeBinaryTimezoneDate
: this.writeBinaryLocalDate;
this.writeBinaryDate = opts.tz ? this.writeBinaryTimezoneDate : this.writeBinaryLocalDate;
if (this.encoding === 'utf8') {

@@ -229,4 +227,3 @@ this.writeLengthEncodedString = this.writeDefaultLengthEncodedString;

//makes buffer bigger (up to 16M)
if (this.buf.length < MAX_BUFFER_SIZE)
flushed = this.growBuffer(valLen * 2);
if (this.buf.length < MAX_BUFFER_SIZE) flushed = this.growBuffer(valLen * 2);

@@ -242,4 +239,3 @@ //data may still be bigger than buffer.

while (tmpPos < valLen) {
if (this.buf.length - this.pos < valLen - tmpPos)
this.growBuffer(valLen - tmpPos);
if (this.buf.length - this.pos < valLen - tmpPos) this.growBuffer(valLen - tmpPos);
const toWrite = Math.min(valLen - tmpPos, this.buf.length - this.pos);

@@ -359,4 +355,3 @@ val.copy(this.buf, this.pos, tmpPos, tmpPos + toWrite);

if (byteLength + 9 > this.buf.length - this.pos) {
if (this.buf.length < MAX_BUFFER_SIZE)
flushed = this.growBuffer(byteLength);
if (this.buf.length < MAX_BUFFER_SIZE) flushed = this.growBuffer(byteLength);

@@ -508,6 +503,3 @@ if (byteLength > this.buf.length - this.pos) {

if (!this.haveErrorResponse) {
if (
this.maxAllowedPacket &&
this.buf.length > this.maxAllowedPacket
) {
if (this.maxAllowedPacket && this.buf.length > this.maxAllowedPacket) {
console.log(

@@ -514,0 +506,0 @@ "will send a packet to server with size > connection option 'maxAllowedPacket' (size send is " +

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

if (cmd) cmd.compressSequenceNo = this.header[3];
const unCompressLen =
this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
const unCompressLen = this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
if (unCompressLen === 0) {

@@ -82,4 +81,3 @@ this.reader.onData(chunk);

this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
this.packetLen =
this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
this.packetLen = this.header[4] | (this.header[5] << 8) | (this.header[6] << 16);
if (this.packetLen === 0) this.packetLen = this.compressPacketLen;

@@ -86,0 +84,0 @@ length = this.compressPacketLen;

@@ -66,6 +66,3 @@ 'use strict';

//filling buffer
let lenToFillBuffer = Math.min(
MAX_BUFFER_SIZE - this.pos,
remainingLen
);
let lenToFillBuffer = Math.min(MAX_BUFFER_SIZE - this.pos, remainingLen);
arr.copy(this.buf, this.pos, off, off + lenToFillBuffer);

@@ -132,10 +129,3 @@ remainingLen -= lenToFillBuffer;

this.info.threadId ? this.info.threadId : -1,
cmd
? cmd.constructor.name +
'(0,' +
this.pos +
'=>' +
compressChunkLen +
')'
: 'unknown',
cmd ? cmd.constructor.name + '(0,' + this.pos + '=>' + compressChunkLen + ')' : 'unknown',
Utils.log(this.opts, compressChunk, 0, compressChunkLen, this.header)

@@ -168,11 +158,3 @@ );

writeEmptyPacket(cmd) {
const emptyBuf = Buffer.from([
0x00,
0x00,
0x00,
cmd.compressSequenceNo,
0x00,
0x00,
0x00
]);
const emptyBuf = Buffer.from([0x00, 0x00, 0x00, cmd.compressSequenceNo, 0x00, 0x00, 0x00]);

@@ -179,0 +161,0 @@ if (this.opts.debugCompress) {

'use strict';
const Packet = require('./packet');
const PacketNodeEncoded = require('./packet-node-encoded');
const PacketIconvEncoded = require('./packet-node-iconv');
const Utils = require('../misc/utils');

@@ -26,4 +28,13 @@

this.partsTotalLen = 0;
this.changeEncoding(this.opts.collation);
this.opts.on('collation', this.changeEncoding.bind(this));
}
changeEncoding(collation) {
this.encoding = collation.charset;
this.packetConstructor = Buffer.isEncoding(this.encoding)
? PacketNodeEncoded
: PacketIconvEncoded;
}
receivePacket(packet) {

@@ -33,9 +44,3 @@ let cmd = this.currentCmd();

if (packet && (this.opts.logPackets || this.opts.debug)) {
const packetStr = Utils.log(
this.opts,
packet.buf,
packet.pos,
packet.end,
this.header
);
const packetStr = Utils.log(this.opts, packet.buf, packet.pos, packet.end, this.header);
if (this.opts.logPackets) {

@@ -113,4 +118,3 @@ this.info.addPacket(

if (this.headerLen === 4) {
this.packetLen =
this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
this.packetLen = this.header[0] + (this.header[1] << 8) + (this.header[2] << 16);
length = this.packetLen;

@@ -133,3 +137,3 @@ break;

this.parts = null;
const packet = new Packet(buf, 0, this.partsTotalLen);
const packet = new this.packetConstructor(buf, 0, this.partsTotalLen, this.encoding);
this.receivePacket(packet);

@@ -139,3 +143,3 @@ }

if (this.packetLen < 0xffffff) {
const packet = new Packet(buf, 0, length);
const packet = new this.packetConstructor(buf, 0, length, this.encoding);
this.receivePacket(packet);

@@ -142,0 +146,0 @@ } else {

@@ -33,6 +33,7 @@ 'use strict';

this.changeEncoding(this.opts.collation);
this.opts.on('collation', this.changeEncoding.bind(this));
}
changeEncoding(collation) {
this.encoding = collation.encoding;
this.encoding = collation.charset;
if (this.encoding === 'utf8') {

@@ -144,6 +145,3 @@ this.writeString = this.writeDefaultBufferString;

//filling buffer
let lenToFillBuffer = Math.min(
MAX_BUFFER_SIZE - this.pos,
remainingLen
);
let lenToFillBuffer = Math.min(MAX_BUFFER_SIZE - this.pos, remainingLen);
arr.copy(this.buf, this.pos, off, off + lenToFillBuffer);

@@ -207,4 +205,3 @@ remainingLen -= lenToFillBuffer;

;
charsOffset < charsLength &&
(currChar = str.charCodeAt(charsOffset)) < 0x80;
charsOffset < charsLength && (currChar = str.charCodeAt(charsOffset)) < 0x80;
charsOffset++

@@ -250,5 +247,3 @@ ) {

const surrogatePairs =
(currChar << 10) +
nextChar +
(0x010000 - (0xd800 << 10) - 0xdc00);
(currChar << 10) + nextChar + (0x010000 - (0xd800 << 10) - 0xdc00);
this.buf[this.pos++] = 0xf0 | (surrogatePairs >> 18);

@@ -359,8 +354,6 @@ this.buf[this.pos++] = 0x80 | ((surrogatePairs >> 12) & 0x3f);

case ZERO_BYTE:
if (this.pos >= this.buf.length)
this.flushBuffer(false, (valLen - i) * 2);
if (this.pos >= this.buf.length) this.flushBuffer(false, (valLen - i) * 2);
this.buf[this.pos++] = SLASH; //add escape slash
}
if (this.pos >= this.buf.length)
this.flushBuffer(false, (valLen - i) * 2);
if (this.pos >= this.buf.length) this.flushBuffer(false, (valLen - i) * 2);
this.buf[this.pos++] = val[i];

@@ -367,0 +360,0 @@ }

@@ -31,8 +31,4 @@ 'use strict';

geoPos += 16;
const x = byteOrder
? geoBuf.readDoubleLE(geoPos - 16)
: geoBuf.readDoubleBE(geoPos - 16);
const y = byteOrder
? geoBuf.readDoubleLE(geoPos - 8)
: geoBuf.readDoubleBE(geoPos - 8);
const x = byteOrder ? geoBuf.readDoubleLE(geoPos - 16) : geoBuf.readDoubleBE(geoPos - 16);
const y = byteOrder ? geoBuf.readDoubleLE(geoPos - 8) : geoBuf.readDoubleBE(geoPos - 8);
return [x, y];

@@ -43,5 +39,3 @@ }

const byteOrder = geoBuf[geoPos++];
const wkbType = byteOrder
? geoBuf.readInt32LE(geoPos)
: geoBuf.readInt32BE(geoPos);
const wkbType = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
geoPos += 4;

@@ -59,5 +53,3 @@ switch (wkbType) {

case 2: //wkbLineString
const pointNumber = byteOrder
? geoBuf.readInt32LE(geoPos)
: geoBuf.readInt32BE(geoPos);
const pointNumber = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
geoPos += 4;

@@ -76,10 +68,6 @@ let coordinates = [];

let polygonCoordinates = [];
const numRings = byteOrder
? geoBuf.readInt32LE(geoPos)
: geoBuf.readInt32BE(geoPos);
const numRings = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
geoPos += 4;
for (let ring = 0; ring < numRings; ring++) {
const pointNumber = byteOrder
? geoBuf.readInt32LE(geoPos)
: geoBuf.readInt32BE(geoPos);
const pointNumber = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
geoPos += 4;

@@ -126,5 +114,3 @@ let linesCoordinates = [];

let coordinates = [];
const number = byteOrder
? geoBuf.readInt32LE(geoPos)
: geoBuf.readInt32BE(geoPos);
const number = byteOrder ? geoBuf.readInt32LE(geoPos) : geoBuf.readInt32BE(geoPos);
geoPos += 4;

@@ -155,7 +141,3 @@ for (let i = 0; i < number; i++) {

readUInt24() {
return (
this.buf[this.pos++] +
(this.buf[this.pos++] << 8) +
(this.buf[this.pos++] << 16)
);
return this.buf[this.pos++] + (this.buf[this.pos++] << 8) + (this.buf[this.pos++] << 16);
}

@@ -257,8 +239,2 @@

readStringRemaining(encoding) {
const str = this.buf.toString(encoding, this.pos, this.end);
this.pos = this.end;
return str;
}
readSignedLength() {

@@ -455,6 +431,3 @@ const type = this.buf[this.pos++];

this.pos +=
2 +
(0xffff &
((this.buf[this.pos] & 0xff) +
((this.buf[this.pos + 1] & 0xff) << 8)));
2 + (0xffff & ((this.buf[this.pos] & 0xff) + ((this.buf[this.pos + 1] & 0xff) << 8)));
return;

@@ -461,0 +434,0 @@ case 253:

@@ -52,4 +52,3 @@ 'use strict';

if (maxAllowedPacket) {
this.maxPacketSize =
Math.min(MAX_BUFFER_SIZE, maxAllowedPacket) - this.endStrLength;
this.maxPacketSize = Math.min(MAX_BUFFER_SIZE, maxAllowedPacket) - this.endStrLength;
} else this.maxPacketSize = 4194304 - this.endStrLength;

@@ -120,6 +119,3 @@

//not enough space remaining
if (
charsLength * 3 + 2 >=
this.buf.length - (this.pos + this.endStrLength)
) {
if (charsLength * 3 + 2 >= this.buf.length - (this.pos + this.endStrLength)) {
let flushed;

@@ -145,4 +141,3 @@ const arr = Buffer.from(str, 'utf8');

;
charsOffset < charsLength &&
(currChar = str.charCodeAt(charsOffset)) < 0x80;
charsOffset < charsLength && (currChar = str.charCodeAt(charsOffset)) < 0x80;
charsOffset++

@@ -188,5 +183,3 @@ ) {

const surrogatePairs =
(currChar << 10) +
nextChar +
(0x010000 - (0xd800 << 10) - 0xdc00);
(currChar << 10) + nextChar + (0x010000 - (0xd800 << 10) - 0xdc00);
this.buf[this.pos++] = 0xf0 | (surrogatePairs >> 18);

@@ -290,4 +283,3 @@ this.buf[this.pos++] = 0x80 | ((surrogatePairs >> 12) & 0x3f);

//makes buffer bigger (up to 16M)
if (this.buf.length < MAX_BUFFER_SIZE)
flushed = this.growBuffer(valLen * 2);
if (this.buf.length < MAX_BUFFER_SIZE) flushed = this.growBuffer(valLen * 2);

@@ -304,4 +296,3 @@ //data may still be bigger than buffer.

case ZERO_BYTE:
if (this.pos >= this.buf.length)
this.flush(false, (valLen - i) * 2);
if (this.pos >= this.buf.length) this.flush(false, (valLen - i) * 2);
this.buf[this.pos++] = SLASH; //add escape slash

@@ -343,6 +334,3 @@ }

//filling buffer
let lenToFillBuffer = Math.min(
MAX_BUFFER_SIZE - this.pos,
remainingLen
);
let lenToFillBuffer = Math.min(MAX_BUFFER_SIZE - this.pos, remainingLen);
arr.copy(this.buf, this.pos, off, off + lenToFillBuffer);

@@ -427,6 +415,3 @@ remainingLen -= lenToFillBuffer;

if (!this.haveErrorResponse) {
if (
this.maxAllowedPacket &&
this.buf.length > this.maxAllowedPacket
) {
if (this.maxAllowedPacket && this.buf.length > this.maxAllowedPacket) {
console.log(

@@ -433,0 +418,0 @@ "will send a packet to server with size > connection option 'maxAllowedPacket' (size send is " +

@@ -40,5 +40,3 @@ 'use strict';

if (!this.serverVersion)
throw new Error(
'cannot know if server version until connection is established'
);
throw new Error('cannot know if server version until connection is established');

@@ -60,5 +58,3 @@ if (!major) throw new Error('a major version must be set');

if (!this.serverVersion)
throw new Error(
'cannot know if server is MariaDB until connection is established'
);
throw new Error('cannot know if server is MariaDB until connection is established');
return this.serverVersion.mariaDb;

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

@@ -29,4 +29,3 @@ 'use strict';

this.stack +=
'\n From event:\n' +
additionalStack.substring(additionalStack.indexOf('\n') + 1);
'\n From event:\n' + additionalStack.substring(additionalStack.indexOf('\n') + 1);
}

@@ -57,11 +56,3 @@ }

) {
return new SQLError(
msg,
fatal,
info,
sqlState,
errno,
additionalStack,
addHeader
);
return new SQLError(msg, fatal, info, sqlState, errno, additionalStack, addHeader);
};

@@ -68,0 +59,0 @@

@@ -40,9 +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;

@@ -128,8 +126,3 @@

*/
module.exports.splitQueryPlaceholder = function(
sql,
info,
initialValues,
displaySql
) {
module.exports.splitQueryPlaceholder = function(sql, info, initialValues, displaySql) {
let partList = [];

@@ -159,9 +152,7 @@ let values = [];

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;

@@ -229,6 +220,3 @@

throw Errors.createError(
"Placeholder '" +
placeholderName +
"' is not defined\n" +
displaySql.call(),
"Placeholder '" + placeholderName + "' is not defined\n" + displaySql.call(),
false,

@@ -432,11 +420,7 @@ info,

idx > 1 &&
(sql.charAt(idx - 2) > ' ' &&
'();><=-+,'.indexOf(sql.charAt(idx - 2)) === -1)
(sql.charAt(idx - 2) > ' ' && '();><=-+,'.indexOf(sql.charAt(idx - 2)) === -1)
) {
break;
}
if (
sql.charAt(idx + 5) > ' ' &&
'();><=-+,'.indexOf(sql.charAt(idx + 5)) === -1
) {
if (sql.charAt(idx + 5) > ' ' && '();><=-+,'.indexOf(sql.charAt(idx + 5)) === -1) {
break;

@@ -500,7 +484,3 @@ }

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

@@ -574,8 +554,3 @@ lastParameterPosition = idx;

module.exports.searchPlaceholder = function(
sql,
info,
initialValues,
displaySql
) {
module.exports.searchPlaceholder = function(sql, info, initialValues, displaySql) {
let sqlPlaceHolder = '';

@@ -608,9 +583,7 @@ const rowNumber = initialValues.length;

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;

@@ -733,6 +706,3 @@

*/
module.exports.splitRewritableNamedParameterQuery = function(
sql,
initialValues
) {
module.exports.splitRewritableNamedParameterQuery = function(sql, initialValues) {
let reWritablePrepare = true;

@@ -901,11 +871,7 @@ let multipleQueriesPrepare = true;

idx > 1 &&
(sql.charAt(idx - 2) > ' ' &&
'();><=-+,'.indexOf(sql.charAt(idx - 2)) === -1)
(sql.charAt(idx - 2) > ' ' && '();><=-+,'.indexOf(sql.charAt(idx - 2)) === -1)
) {
break;
}
if (
sql.charAt(idx + 5) > ' ' &&
'();><=-+,'.indexOf(sql.charAt(idx + 5)) === -1
) {
if (sql.charAt(idx + 5) > ' ' && '();><=-+,'.indexOf(sql.charAt(idx + 5)) === -1) {
break;

@@ -969,7 +935,3 @@ }

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

@@ -1068,5 +1030,3 @@ lastParameterPosition = idx;

if (queryValidator.test(sql) && parameters.length > 0) {
return parameters[0]
.toLowerCase()
.equals("'" + fileName.toLowerCase() + "'");
return parameters[0].toLowerCase() === fileName.toLowerCase();
}

@@ -1073,0 +1033,0 @@ }

@@ -36,5 +36,3 @@ 'use strict';

asciiValue[posHexa++] =
byteValue > 31 && byteValue < 127
? String.fromCharCode(byteValue)
: '.';
byteValue > 31 && byteValue < 127 ? String.fromCharCode(byteValue) : '.';
}

@@ -50,5 +48,3 @@ }

asciiValue[posHexa++] =
byteValue > 31 && byteValue < 127
? String.fromCharCode(byteValue)
: '.';
byteValue > 31 && byteValue < 127 ? String.fromCharCode(byteValue) : '.';

@@ -72,7 +68,3 @@ if (posHexa === 8) out.push(' ');

out.push(
' ',
asciiValue.slice(0, posHexa).join('') + (isLimited ? ' ...' : ''),
'\n'
);
out.push(' ', asciiValue.slice(0, posHexa).join('') + (isLimited ? ' ...' : ''), '\n');
} else if (isLimited) {

@@ -79,0 +71,0 @@ out[out.length - 2] = out[out.length - 2] + ' ...';

@@ -195,4 +195,9 @@ 'use strict';

return getIdleValidConnection(pool).then(
conn => processTask(conn, sql, values, isBatch),
conn => {
pool.emit('acquire', conn);
return processTask(conn, sql, values, isBatch);
},
() => {
process.nextTick(() => pool.emit('enqueue'));
//no idle connection available

@@ -213,7 +218,3 @@ //create a new connection if limit is not reached

if (!firstTaskTimeout) {
firstTaskTimeout = setTimeout(
rejectAndResetTimeout,
opts.acquireTimeout,
task
);
firstTaskTimeout = setTimeout(rejectAndResetTimeout, opts.acquireTimeout, task);
}

@@ -239,6 +240,3 @@ taskQueue.push(task);

activeConnections[conn.threadId] = conn;
if (
opts.minDelayValidation <= 0 ||
Date.now() - conn.lastUse > opts.minDelayValidation
) {
if (opts.minDelayValidation <= 0 || Date.now() - conn.lastUse > opts.minDelayValidation) {
return pingPromise(conn)

@@ -250,3 +248,3 @@ .then(() => {

delete activeConnections[conn.threadId];
pool.emit('remove-conn');
pool.emit('_remove-conn');
return getIdleValidConnection(pool);

@@ -260,3 +258,3 @@ });

delete activeConnections[conn.threadId];
pool.emit('remove-conn');
pool.emit('_remove-conn');
return getIdleValidConnection(pool);

@@ -335,6 +333,3 @@ }

closed ||
(err.errno &&
(err.errno === 1524 ||
err.errno === 1045 ||
err.errno === 1698)) ||
(err.errno && (err.errno === 1524 || err.errno === 1045 || err.errno === 1698)) ||
timeoutEnd < Date.now()

@@ -360,3 +355,3 @@ ) {

initialDestroyFct();
pool.emit('remove-conn');
pool.emit('_remove-conn');
};

@@ -377,15 +372,12 @@

//forcing validation when borrowed next time, even if "minDelayValidation" is not reached.
currConn.lastUse = Math.min(
Date.now() - opts.minDelayValidation,
currConn.lastUse
);
currConn.lastUse = Math.min(Date.now() - opts.minDelayValidation, currConn.lastUse);
}
idx++;
}
pool.emit('remove-conn');
pool.emit('_remove-conn');
});
connectionInCreation = false;
idleConnections.push(conn);
pool.emit('idle-conn');
pool.emit('new-conn');
pool.emit('_idle-conn');
process.nextTick(() => pool.emit('connection', conn));
};

@@ -402,4 +394,5 @@

} else if (conn.isValid()) {
pool.emit('release', conn);
idleConnections.push(conn);
process.nextTick(() => pool.emit('idle-conn'));
process.nextTick(() => pool.emit('_idle-conn'));
} else {

@@ -440,5 +433,3 @@ ensurePoolSize(pool);

} else if (!closed) {
console.error(
`pool fail to create connection (${err.message})`
);
console.error(`pool fail to create connection (${err.message})`);
}

@@ -467,7 +458,3 @@

} else {
firstTaskTimeout = setTimeout(
rejectAndResetTimeout,
nextTask.timeout - currTime,
nextTask
);
firstTaskTimeout = setTimeout(rejectAndResetTimeout, nextTask.timeout - currTime, nextTask);
return;

@@ -501,3 +488,3 @@ }

conn.forceEnd().catch(err => {});
this.emit('remove-conn');
this.emit('_remove-conn');
};

@@ -515,2 +502,3 @@

if (conn) {
this.emit('acquire', conn);
activeConnections[conn.threadId] = conn;

@@ -544,5 +532,5 @@ resetTimeoutToNextTask();

this.on('idle-conn', handleTaskQueue);
this.on('remove-conn', ensurePoolSize.bind(this, this));
this.on('new-conn', ensurePoolSize.bind(this, this));
this.on('_idle-conn', handleTaskQueue.bind(this));
this.on('_remove-conn', ensurePoolSize.bind(this, this));
this.on('connection', ensurePoolSize.bind(this, this));
}

@@ -549,0 +537,0 @@

@@ -114,9 +114,3 @@ 'use strict';

PoolBase.call(
this,
options,
processTaskCallback,
createConnectionPoolCallback,
pingPromise
);
PoolBase.call(this, options, processTaskCallback, createConnectionPoolCallback, pingPromise);

@@ -123,0 +117,0 @@ const getConnectionPromise = this.getConnection.bind(this);

'use strict';
const PoolCluster = require('./pool-cluster');
const util = require('util');

@@ -14,14 +15,7 @@ /**

function PoolClusterCallback(args) {
const cluster = new PoolCluster(args);
cluster.setCallback();
PoolCluster.call(this, args);
this.setCallback();
/**
* Add a new pool node to cluster.
*
* @param id identifier
* @param config pool configuration
*/
this.add = (id, config) => {
cluster.add(id, config);
};
const initialGetConnection = this.getConnection.bind(this);
const initialEnd = this.end.bind(this);

@@ -39,4 +33,3 @@ /**

cluster
.end()
initialEnd()
.then(() => {

@@ -48,16 +41,3 @@ endingFct();

this.of = (pattern, selector) => {
return cluster.of(pattern, selector);
};
/**
* Remove nodes according to pattern.
*
* @param pattern pattern
*/
this.remove = pattern => {
cluster.remove(pattern);
};
/**
* Get connection from available pools matching pattern, according to selector

@@ -83,12 +63,8 @@ *

cluster.getConnection(pat, sel, endingFct);
initialGetConnection(pat, sel, endingFct);
};
}
//*****************************************************************
// internal public testing methods
//*****************************************************************
util.inherits(PoolClusterCallback, PoolCluster);
this.__tests = cluster.__tests;
}
module.exports = PoolClusterCallback;

@@ -8,2 +8,4 @@ 'use strict';

const FilteredPoolCluster = require('./filtered-pool-cluster');
const EventEmitter = require('events');
const util = require('util');

@@ -23,2 +25,3 @@ /**

let nodeCounter = 0;
EventEmitter.call(this);

@@ -72,6 +75,3 @@ /**

this.remove = pattern => {
if (!pattern)
throw new Error(
'pattern parameter in Cluster.remove(pattern) is mandatory'
);
if (!pattern) throw new Error('pattern parameter in Cluster.remove(pattern) is mandatory');

@@ -96,3 +96,3 @@ const regex = RegExp(pattern);

this.getConnection = (pattern, selector) => {
return _getConnection(pattern, selector);
return _getConnection(this, pattern, selector);
};

@@ -104,3 +104,3 @@

this.setCallback = () => {
this.getConnection = _getConnectionCallback;
this.getConnection = _getConnectionCallback.bind(this, this);
_createPool = _createPoolCallback;

@@ -120,3 +120,3 @@ };

*/
const _getConnection = (pattern, selector, avoidNodeKey, lastError) => {
const _getConnection = (cluster, pattern, selector, avoidNodeKey, lastError) => {
const matchingNodeList = _matchingNodes(pattern || /^/);

@@ -132,5 +132,3 @@

if (avoidNodeKey === undefined)
return Promise.reject(
new Error("No node found for pattern '" + pattern + "'")
);
return Promise.reject(new Error("No node found for pattern '" + pattern + "'"));
const errMsg =

@@ -144,6 +142,6 @@ "No Connection available for '" +

const retry = _getConnection.bind(this, pattern, selector);
const retry = _getConnection.bind(this, this, pattern, selector);
try {
const nodeKey = _selectPool(matchingNodeList, selector, avoidNodeKey);
return _handleConnectionError(matchingNodeList, nodeKey, retry);
return _handleConnectionError(cluster, matchingNodeList, nodeKey, retry);
} catch (e) {

@@ -172,8 +170,3 @@ return Promise.reject(e);

*/
const _getConnectionCallback = (
pattern,
selector,
callback,
avoidNodeKey
) => {
const _getConnectionCallback = (cluster, pattern, selector, callback, avoidNodeKey) => {
const matchingNodeList = _matchingNodes(pattern || /^/);

@@ -194,16 +187,6 @@

const retry = _getConnectionCallback.bind(
this,
pattern,
selector,
callback
);
const retry = _getConnectionCallback.bind(this, this, pattern, selector, callback);
try {
const nodeKey = _selectPool(matchingNodeList, selector, avoidNodeKey);
_handleConnectionCallbackError(
matchingNodeList,
nodeKey,
retry,
callback
);
_handleConnectionCallbackError(this, matchingNodeList, nodeKey, retry, callback);
} catch (e) {

@@ -265,5 +248,3 @@ callback(e);

throw new Error(
"Wrong selector value '" +
selector +
"'. Possible values are 'RR','RANDOM' or 'ORDER'"
"Wrong selector value '" + selector + "'. Possible values are 'RR','RANDOM' or 'ORDER'"
);

@@ -274,3 +255,3 @@ }

while (
(avoidNodeKey === nodeKey || nodes[nodeKey].timeout > Date.now()) &&
(avoidNodeKey === nodeKey || nodes[nodeKey].blacklistedUntil > Date.now()) &&
retry < nodeList.length - 1

@@ -323,2 +304,3 @@ ) {

*
* @param cluster current cluster
* @param nodeList current node list

@@ -330,3 +312,3 @@ * @param nodeKey node name to connect

*/
const _handleConnectionError = (nodeList, nodeKey, retryFct) => {
const _handleConnectionError = (cluster, nodeList, nodeKey, retryFct) => {
const node = nodes[nodeKey];

@@ -341,18 +323,21 @@ return node

node.errorCount = node.errorCount ? node.errorCount + 1 : 1;
if (node.errorCount >= opts.removeNodeErrorCount && nodes[nodeKey]) {
if (opts.restoreNodeTimeout === 0) {
delete nodes[nodeKey];
cachedPatterns = {};
delete nodeList.lastRrIdx;
//remove node from configuration if not already removed
node.end().catch(err => {
// dismiss error
});
} else {
node.timeout = Date.now() + opts.restoreNodeTimeout;
}
if (nodeList.length === 0) return Promise.reject(err);
node.blacklistedUntil = Date.now() + opts.restoreNodeTimeout;
if (
opts.removeNodeErrorCount &&
node.errorCount >= opts.removeNodeErrorCount &&
nodes[nodeKey]
) {
delete nodes[nodeKey];
cachedPatterns = {};
delete nodeList.lastRrIdx;
process.nextTick(() => cluster.emit('remove', nodeKey));
//remove node from configuration if not already removed
node.end().catch(err => {
// dismiss error
});
}
if (opts.canRetry) return retryFct(nodeKey, err);
if (nodeList.length !== 0 && opts.canRetry) {
return retryFct(nodeKey, err);
}
return Promise.reject(err);

@@ -365,2 +350,3 @@ });

*
* @param cluster current cluster
* @param nodeList current node list

@@ -372,8 +358,3 @@ * @param nodeKey node name to connect

*/
const _handleConnectionCallbackError = (
nodeList,
nodeKey,
retryFct,
callback
) => {
const _handleConnectionCallbackError = (cluster, nodeList, nodeKey, retryFct, callback) => {
const node = nodes[nodeKey];

@@ -383,14 +364,16 @@ node.getConnection((err, conn) => {

node.errorCount = node.errorCount ? node.errorCount + 1 : 1;
if (node.errorCount >= opts.removeNodeErrorCount && nodes[nodeKey]) {
if (opts.restoreNodeTimeout === 0) {
delete nodes[nodeKey];
cachedPatterns = {};
delete nodeList.lastRrIdx;
//remove node from configuration if not already removed
node.end(() => {
//dismiss error
});
} else {
node.timeout = Date.now() + opts.restoreNodeTimeout;
}
node.blacklistedUntil = Date.now() + opts.restoreNodeTimeout;
if (
opts.removeNodeErrorCount &&
node.errorCount >= opts.removeNodeErrorCount &&
nodes[nodeKey]
) {
delete nodes[nodeKey];
cachedPatterns = {};
delete nodeList.lastRrIdx;
process.nextTick(() => cluster.emit('remove', nodeKey));
//remove node from configuration if not already removed
node.end(() => {
//dismiss error
});
if (nodeList.length === 0) return Promise.reject(err);

@@ -420,2 +403,4 @@ }

util.inherits(PoolCluster, EventEmitter);
module.exports = PoolCluster;

@@ -94,8 +94,4 @@ 'use strict';

PoolBase.call(
this,
options,
processTaskPromise,
createConnectionPoolPromise,
conn => conn.ping()
PoolBase.call(this, options, processTaskPromise, createConnectionPoolPromise, conn =>
conn.ping()
);

@@ -102,0 +98,0 @@ }

{
"name": "mariadb",
"version": "2.0.5",
"version": "2.1.0",
"description": "fast mariadb/mysql connector.",

@@ -48,2 +48,4 @@ "main": "promise.js",

"dependencies": {
"@types/geojson": "^7946.0.7",
"@types/node": "^11.13.15",
"denque": "^1.4.0",

@@ -55,21 +57,19 @@ "iconv-lite": "^0.4.24",

"devDependencies": {
"@types/geojson": "^7946.0.7",
"@types/node": "^11.11.5",
"@typescript-eslint/eslint-plugin": "^1.5.0",
"@typescript-eslint/parser": "^1.5.0",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"benchmark": "^2.1.4",
"chai": "^4.2.0",
"codecov": "^3.2.0",
"codecov": "^3.5.0",
"colors": "^1.3.2",
"dom-parser": "^0.1.6",
"error-stack-parser": "^2.0.1",
"eslint": "^5.15.3",
"eslint-config-prettier": "^4.1.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-markdown": "^1.0.0-rc.0",
"eslint-plugin-prettier": "^3.0.1",
"mocha": "^6.0.2",
"eslint-plugin-prettier": "^3.1.0",
"mocha": "^6.1.4",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^13.3.0",
"prettier": "^1.15.3",
"typescript": "^3.3.4000",
"dom-parser": "^0.1.6"
"nyc": "^14.1.1",
"prettier": "^1.18.2",
"typescript": "^3.5.2"
},

@@ -76,0 +76,0 @@ "bugs": {

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

While there are existing MySQL clients that work with MariaDB, (such as the [`mysql`](https://www.npmjs.com/package/mysql) and [`mysql2`](https://www.npmjs.com/package/mysql2) clients), the MariaDB Node.js Connector offers new functionality, like [Insert Streaming](#insert-streaming) and [Pipelining](#pipelining) while making no compromises on performance.
While there are existing MySQL clients that work with MariaDB, (such as the [`mysql`](https://www.npmjs.com/package/mysql) and [`mysql2`](https://www.npmjs.com/package/mysql2) clients), the MariaDB Node.js Connector offers new functionality, like [Insert Streaming](#insert-streaming), [Pipelining](#pipelining), [ed25519 plugin authentication](https://mariadb.org/history-of-mysql-mariadb-authentication-protocols/) while making no compromises on performance.

@@ -136,10 +137,3 @@ ### Insert Streaming

## Road Map
The Connector remains in development. Here's a list of features being developed for future releases:
* MariaDB `ed25519` plugin authentication
* Query Timeouts
## Contributing

@@ -146,0 +140,0 @@

@@ -14,5 +14,3 @@ // Type definitions for mariadb 2.0

export function createConnection(
connectionUri: string | ConnectionConfig
): Promise<Connection>;
export function createConnection(connectionUri: string | ConnectionConfig): Promise<Connection>;
export function createPool(config: PoolConfig | string): Pool;

@@ -582,33 +580,33 @@ export function createPoolCluster(config?: PoolClusterConfig): PoolCluster;

export const enum Types {
DECIMAL = 0x00, // aka DECIMAL (http://dev.mysql.com/doc/refman/5.0/en/precision-math-decimal-changes.html)
TINY = 0x01, // aka TINYINT, 1 byte
SHORT = 0x02, // aka SMALLINT, 2 bytes
LONG = 0x03, // aka INT, 4 bytes
FLOAT = 0x04, // aka FLOAT, 4-8 bytes
DOUBLE = 0x05, // aka DOUBLE, 8 bytes
NULL = 0x06, // NULL (used for prepared statements, I think)
TIMESTAMP = 0x07, // aka TIMESTAMP
LONGLONG = 0x08, // aka BIGINT, 8 bytes
INT24 = 0x09, // aka MEDIUMINT, 3 bytes
DATE = 0x0a, // aka DATE
TIME = 0x0b, // aka TIME
DATETIME = 0x0c, // aka DATETIME
YEAR = 0x0d, // aka YEAR, 1 byte (don't ask)
NEWDATE = 0x0e, // aka ?
VARCHAR = 0x0f, // aka VARCHAR (?)
BIT = 0x10, // aka BIT, 1-8 byte
TIMESTAMP2 = 0x11, // aka TIMESTAMP with fractional seconds
DATETIME2 = 0x12, // aka DATETIME with fractional seconds
TIME2 = 0x13, // aka TIME with fractional seconds
JSON = 0xf5, // aka JSON
NEWDECIMAL = 0xf6, // aka DECIMAL
ENUM = 0xf7, // aka ENUM
SET = 0xf8, // aka SET
TINY_BLOB = 0xf9, // aka TINYBLOB, TINYTEXT
MEDIUM_BLOB = 0xfa, // aka MEDIUMBLOB, MEDIUMTEXT
LONG_BLOB = 0xfb, // aka LONGBLOG, LONGTEXT
BLOB = 0xfc, // aka BLOB, TEXT
VAR_STRING = 0xfd, // aka VARCHAR, VARBINARY
STRING = 0xfe, // aka CHAR, BINARY
GEOMETRY = 0xff // aka GEOMETRY
DECIMAL = 'DECIMAL',
TINY = 'TINY',
SHORT = 'SHORT',
LONG = 'LONG',
FLOAT = 'FLOAT',
DOUBLE = 'DOUBLE',
NULL = 'NULL',
TIMESTAMP = 'TIMESTAMP',
LONGLONG = 'LONGLONG',
INT24 = 'INT24',
DATE = 'DATE',
TIME = 'TIME',
DATETIME = 'DATETIME',
YEAR = 'YEAR',
NEWDATE = 'NEWDATE',
VARCHAR = 'VARCHAR',
BIT = 'BIT',
TIMESTAMP2 = 'TIMESTAMP2',
DATETIME2 = 'DATETIME2',
TIME2 = 'TIME2',
JSON = 'JSON',
NEWDECIMAL = 'NEWDECIMAL',
ENUM = 'ENUM',
SET = 'SET',
TINY_BLOB = 'TINY_BLOB',
MEDIUM_BLOB = 'MEDIUM_BLOB',
LONG_BLOB = 'LONG_BLOB',
BLOB = 'BLOB',
VAR_STRING = 'VAR_STRING',
STRING = 'STRING',
GEOMETRY = 'GEOMETRY'
}

@@ -615,0 +613,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