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

mariadb

Package Overview
Dependencies
Maintainers
3
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 3.0.1 to 3.0.2

check-node.js

4

callback.js
'use strict';
const pkg = require('./package.json');
require('please-upgrade-node')(pkg);
require('./check-node');
const ConnectionCallback = require('./lib/connection-callback');

@@ -6,0 +6,0 @@ const ClusterCallback = require('./lib/cluster-callback');

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

if (!this.sending && this.bulkPacketNo === 0) {
this.prepare.close();
this.packet = null;

@@ -446,3 +445,2 @@ if (this.firstError) {

this.resolve = null;
this.prepare.close();
this.emit('send_end');

@@ -449,0 +447,0 @@ process.nextTick(this.reject, this.firstError);

@@ -29,3 +29,3 @@ // noinspection JSBitwiseOperatorUsage

case '':
authToken = NativePasswordAuth.encryptPassword(pwd, info.seed, 'sha1');
authToken = NativePasswordAuth.encryptSha1Password(pwd, info.seed);
break;

@@ -32,0 +32,0 @@ case 'client_ed25519':

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

class CachedPrepareResultPacket extends PrepareResultPacket {
constructor(statementId, parameters, columns, database, sql, placeHolderIndex, executePromise, emitter, conOpts) {
super(statementId, parameters, columns, database, sql, placeHolderIndex, executePromise, emitter, conOpts);
constructor(statementId, parameters, columns, database, sql, placeHolderIndex, conn, conOpts) {
super(statementId, parameters, columns, database, sql, placeHolderIndex, conn, conOpts);
this.cached = true;

@@ -14,0 +14,0 @@ this.use = 1;

'use strict';
const CommandParameter = require('../../command-parameter');
const Errors = require('../../misc/errors');
const ExecuteStream = require('../execute-stream');

@@ -9,4 +11,4 @@ /**

class PrepareResultPacket {
#connExecutePromise;
constructor(statementId, parameters, columns, database, sql, placeHolderIndex, executePromise, emitter, conOpts) {
#conn;
constructor(statementId, parameters, columns, database, sql, placeHolderIndex, conn, conOpts) {
this.id = statementId;

@@ -19,4 +21,3 @@ this.parameters = parameters;

this._placeHolderIndex = placeHolderIndex;
this.#connExecutePromise = executePromise;
this.emitter = emitter;
this.#conn = conn;
this.conOpts = conOpts;

@@ -33,5 +34,24 @@ }

}
if (this.closed) {
const error = Errors.createError(
`Execute fails, prepare command as already been closed`,
Errors.ER_PREPARE_CLOSED,
null,
'22000',
this.query
);
if (!_cb) {
return Promise.reject(error);
} else {
_cb(error);
return;
}
}
const cmdParam = new CommandParameter(this.query, values, _opts, cb);
if (stack) cmdParam.stack = stack;
const promise = new Promise((resolve, reject) => this.#connExecutePromise(cmdParam, this, resolve, reject));
const conn = this.#conn;
const promise = new Promise((resolve, reject) => conn.executePromise.call(conn, cmdParam, this, resolve, reject));
if (!_cb) {

@@ -49,6 +69,41 @@ return promise;

executeStream(values, opts, cb, stack) {
let _opts = opts,
_cb = cb;
if (typeof _opts === 'function') {
_cb = _opts;
_opts = undefined;
}
if (this.closed) {
const error = Errors.createError(
`Execute fails, prepare command as already been closed`,
Errors.ER_PREPARE_CLOSED,
null,
'22000',
this.query
);
if (!_cb) {
throw error;
} else {
_cb(error);
return;
}
}
const cmdParam = new CommandParameter(this.query, values, _opts, cb);
if (stack) cmdParam.stack = stack;
const cmd = new ExecuteStream(cmdParam, this.#conn.opts, this, this.#conn.socket);
if (this.#conn.opts.logger.error) cmd.on('error', this.#conn.opts.logger.error);
this.#conn.addCommand(cmd);
return cmd.inStream;
}
close() {
if (!this.closed) {
this.closed = true;
this.emitter.emit('close_prepare', this);
this.#conn.emit('close_prepare', this);
}

@@ -55,0 +110,0 @@ }

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

default:
// skip data
const len = subPacket.readUnsignedLength();
if (len) {
subPacket.skip(len);
}
subPacket.skip(subPacket.readUnsignedLength());
break;

@@ -73,15 +69,31 @@ }

db() {
return this.#stringParser.packet.readString(this.#stringParser.dbOffset, this.#stringParser.dbLength);
return this.#stringParser.readString(
this.#stringParser.buf,
this.#stringParser.dbOffset,
this.#stringParser.dbLength
);
}
schema() {
return this.#stringParser.packet.readString(this.#stringParser.dbOffset, this.#stringParser.dbLength);
return this.#stringParser.readString(
this.#stringParser.buf,
this.#stringParser.dbOffset,
this.#stringParser.dbLength
);
}
table() {
return this.#stringParser.packet.readString(this.#stringParser.tableOffset, this.#stringParser.tableLength);
return this.#stringParser.readString(
this.#stringParser.buf,
this.#stringParser.tableOffset,
this.#stringParser.tableLength
);
}
orgTable() {
return this.#stringParser.packet.readString(this.#stringParser.orgTableOffset, this.#stringParser.orgTableLength);
return this.#stringParser.readString(
this.#stringParser.buf,
this.#stringParser.orgTableOffset,
this.#stringParser.orgTableLength
);
}

@@ -94,3 +106,7 @@

orgName() {
return this.#stringParser.packet.readString(this.#stringParser.orgNameOffset, this.#stringParser.orgNameLength);
return this.#stringParser.readString(
this.#stringParser.buf,
this.#stringParser.orgNameOffset,
this.#stringParser.orgNameLength
);
}

@@ -113,28 +129,35 @@

constructor(packet) {
const initPos = packet.pos;
packet.skip(4); // skip 'def'
this.dbLength = packet.readUnsignedLength();
this.dbOffset = packet.pos;
this.dbOffset = packet.pos - initPos;
packet.skip(this.dbLength);
this.tableLength = packet.readUnsignedLength();
this.tableOffset = packet.pos;
this.tableOffset = packet.pos - initPos;
packet.skip(this.tableLength);
this.orgTableLength = packet.readUnsignedLength();
this.orgTableOffset = packet.pos;
this.orgTableOffset = packet.pos - initPos;
packet.skip(this.orgTableLength);
this.nameLength = packet.readUnsignedLength();
this.nameOffset = packet.pos;
this.nameOffset = packet.pos - initPos;
packet.skip(this.nameLength);
this.orgNameLength = packet.readUnsignedLength();
this.orgNameOffset = packet.pos;
this.orgNameOffset = packet.pos - initPos;
packet.skip(this.orgNameLength);
this.packet = packet;
//copy buffer since cannot rely on socket onData chunk buffer that can be reused
const saveBuf = Buffer.alloc(packet.end - initPos);
packet.buf.copy(saveBuf, 0, initPos, packet.end);
this.buf = saveBuf;
this.readString = packet.readString;
}
name = function () {
return this.packet.readString(this.nameOffset, this.nameLength);
return this.readString(this.buf, this.nameOffset, this.nameLength);
};

@@ -149,12 +172,13 @@ }

constructor(packet) {
const initPos = packet.pos;
packet.skip(4); // skip 'def'
this.dbLength = packet.readUnsignedLength();
this.dbOffset = packet.pos;
this.dbOffset = packet.pos - initPos;
packet.skip(this.dbLength);
this.tableLength = packet.readUnsignedLength();
this.tableOffset = packet.pos;
this.tableOffset = packet.pos - initPos;
packet.skip(this.tableLength);
this.orgTableLength = packet.readUnsignedLength();
this.orgTableOffset = packet.pos;
this.orgTableOffset = packet.pos - initPos;
packet.skip(this.orgTableLength);

@@ -165,6 +189,10 @@

this.orgNameLength = packet.readUnsignedLength();
this.orgNameOffset = packet.pos;
this.orgNameOffset = packet.pos - initPos;
packet.skip(this.orgNameLength);
this.packet = packet;
//copy buffer since cannot rely on socket onData chunk buffer that can be reused
const saveBuf = Buffer.alloc(packet.end - initPos);
packet.buf.copy(saveBuf, 0, initPos, packet.end);
this.buf = saveBuf;
this.readString = packet.readString;
}

@@ -171,0 +199,0 @@

const PluginAuth = require('./plugin-auth');
const fs = require('fs');
const crypto = require('crypto');
const Errors = require('../../../misc/errors');
const NativePasswordAuth = require('./native-password-auth');
const Sha256PasswordAuth = require('./sha256-password-auth');

@@ -36,3 +34,3 @@

const truncatedSeed = this.pluginData.slice(0, this.pluginData.length - 1);
const encPwd = NativePasswordAuth.encryptPassword(opts.password, truncatedSeed, 'sha256');
const encPwd = Sha256PasswordAuth.encryptSha256Password(opts.password, truncatedSeed);
out.startPacket(this);

@@ -54,4 +52,4 @@ if (encPwd.length > 0) {

// success authentication
this.emit('send_end');
return this.successSend(packet, out, opts, info);
// an OK_Packet will follow
return;

@@ -111,10 +109,2 @@ case 0x04:

static sendSha256PwdPacket(cmd, pluginData, publicKey, password, out) {
const truncatedSeed = pluginData.slice(0, pluginData.length - 1);
out.startPacket(cmd);
const enc = Sha256PasswordAuth.encrypt(truncatedSeed, password, publicKey);
out.writeBuffer(enc, 0, enc.length);
out.flushPacket();
}
response(packet, out, opts, info) {

@@ -121,0 +111,0 @@ const marker = packet.peek();

@@ -11,2 +11,3 @@ const PluginAuth = require('./plugin-auth');

this.sequenceNo = packSeq;
this.counter = 0;
}

@@ -19,3 +20,3 @@

if (Array.isArray(pwd)) {
out.writeString(pwd[0]);
out.writeString(pwd[this.counter++]);
} else {

@@ -22,0 +23,0 @@ out.writeString(pwd);

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

const data = this.pluginData.slice(0, 20);
let authToken = NativePasswordAuth.encryptPassword(opts.password, data, 'sha1');
let authToken = NativePasswordAuth.encryptSha1Password(opts.password, data);

@@ -34,11 +34,11 @@ out.startPacket(this);

static encryptPassword(password, seed, algorithm) {
static encryptSha1Password(password, seed) {
if (!password) return Buffer.alloc(0);
let hash = Crypto.createHash(algorithm);
let hash = Crypto.createHash('sha1');
let stage1 = hash.update(password, 'utf8').digest();
hash = Crypto.createHash(algorithm);
hash = Crypto.createHash('sha1');
let stage2 = hash.update(stage1).digest();
hash = Crypto.createHash(algorithm);
hash = Crypto.createHash('sha1');

@@ -45,0 +45,0 @@ hash.update(seed);

@@ -5,2 +5,3 @@ const PluginAuth = require('./plugin-auth');

const Errors = require('../../../misc/errors');
const Crypto = require('crypto');

@@ -95,2 +96,24 @@ /**

static encryptSha256Password(password, seed) {
if (!password) return Buffer.alloc(0);
let hash = Crypto.createHash('sha256');
let stage1 = hash.update(password, 'utf8').digest();
hash = Crypto.createHash('sha256');
let stage2 = hash.update(stage1).digest();
hash = Crypto.createHash('sha256');
// order is different than sha 1 !!!!!
hash.update(stage2);
hash.update(seed);
let digest = hash.digest();
let returnBytes = Buffer.allocUnsafe(digest.length);
for (let i = 0; i < digest.length; i++) {
returnBytes[i] = stage1[i] ^ digest[i];
}
return returnBytes;
}
// encrypt password with public key

@@ -97,0 +120,0 @@ static encrypt(seed, password, publicKey) {

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

default:
authToken = NativePasswordAuth.encryptPassword(pwd, info.seed, 'sha1');
authToken = NativePasswordAuth.encryptSha1Password(pwd, info.seed);
authPlugin = 'mysql_native_password';

@@ -41,0 +41,0 @@ break;

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

this._columns = this.prepare.columns;
this.emit('fields', this._columns);
this.setParser();

@@ -117,3 +118,11 @@ return (this.onPacketReceive = info.eofDeprecated ? this.readResultSetRow : this.readIntermediateEOF);

}
this.success(this._responseIndex === 0 ? this._rows[0] : this._rows);
if (this.opts.metaAsArray) {
if (!this._meta) {
this._meta = new Array(this._responseIndex);
}
this._meta[this._responseIndex] = null;
this.success(this._responseIndex === 0 ? [this._rows[0], this._meta[0]] : [this._rows, this._meta]);
} else {
this.success(this._responseIndex === 0 ? this._rows[0] : this._rows);
}
} catch (e) {

@@ -371,3 +380,3 @@ this.onPacketReceive = info.status & ServerStatus.MORE_RESULTS_EXISTS ? this.readResponsePacket : null;

if (opts.metaAsArray) {
if (this.opts.metaAsArray) {
//return promise object as array :

@@ -374,0 +383,0 @@ // example for SELECT 1 =>

@@ -13,8 +13,7 @@ 'use strict';

class Prepare extends Parser {
constructor(resolve, reject, connOpts, cmdParam, executePromise, emitter) {
constructor(resolve, reject, connOpts, cmdParam, conn) {
super(resolve, reject, connOpts, cmdParam);
this.encoder = new BinaryEncoder(this.opts);
this.binary = true;
this.executePromise = executePromise;
this.emitter = emitter;
this.conn = conn;
}

@@ -30,4 +29,2 @@

start(out, opts, info) {
if (opts.logger.query) opts.logger.query(`PREPARE: ${this.sql}`);
this.onPacketReceive = this.readPrepareResultPacket;
// check in cache if enabled

@@ -43,2 +40,4 @@ if (info._prepareCache) {

}
if (opts.logger.query) opts.logger.query(`PREPARE: ${this.sql}`);
this.onPacketReceive = this.readPrepareResultPacket;

@@ -69,4 +68,3 @@ if (this.opts.namedPlaceholders) {

this.placeHolderIndex,
this.executePromise,
this.emitter,
this.conn,
opts

@@ -83,4 +81,3 @@ );

this.placeHolderIndex,
this.executePromise,
this.emitter,
this.conn,
opts

@@ -87,0 +84,0 @@ );

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

this.connectionLimit = opts.connectionLimit === undefined ? 10 : opts.connectionLimit;
this.idleTimeout = opts.idleTimeout || 1800;
this.idleTimeout = opts.idleTimeout === undefined ? 1800 : opts.idleTimeout;
this.leakDetectionTimeout = opts.leakDetectionTimeout || 0;

@@ -28,0 +28,0 @@ this.initializationTimeout = opts.initializationTimeout === undefined ? 30000 : opts.initializationTimeout;

@@ -28,10 +28,5 @@ 'use strict';

release = (cb) => {
this.#conn.release(
() => {
if (cb) cb();
},
(err) => {
if (cb) cb(err);
}
);
this.#conn.release(() => {
if (cb) cb();
});
};

@@ -121,14 +116,21 @@

static _QUERY_CMD(conn, cmdParam) {
const cmd = new Query(
cmdParam.callback
? (rows) => {
const meta = rows.meta;
delete rows.meta;
cmdParam.callback(null, rows, meta);
}
: () => {},
cmdParam.callback ? cmdParam.callback : () => {},
conn.opts,
cmdParam
);
let cmd;
if (cmdParam.callback) {
cmdParam.opts = cmdParam.opts ? Object.assign(cmdParam.opts, { metaAsArray: true }) : { metaAsArray: true };
cmd = new Query(
([rows, meta]) => {
cmdParam.callback(null, rows, meta);
},
cmdParam.callback,
conn.opts,
cmdParam
);
} else {
cmd = new Query(
() => {},
() => {},
conn.opts,
cmdParam
);
}

@@ -171,10 +173,9 @@ cmd.handleNewRows = (row) => {

static _EXECUTE_CMD(conn, cmdParam) {
new Promise(conn.prepare.bind(conn, cmdParam, conn.executePromise.bind(conn)))
new Promise(conn.prepare.bind(conn, cmdParam))
.then((prepare) => {
return prepare.execute(cmdParam.values, cmdParam.opts, null, cmdParam.stack).then((res) => {
const opts = cmdParam.opts ? Object.assign(cmdParam.opts, { metaAsArray: true }) : { metaAsArray: true };
return prepare.execute(cmdParam.values, opts, null, cmdParam.stack).then(([rows, meta]) => {
prepare.close();
if (cmdParam.callback) {
const meta = res.meta;
delete res.meta;
cmdParam.callback(null, res, meta);
cmdParam.callback(null, rows, meta);
}

@@ -199,3 +200,3 @@ });

if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
return new Promise(this.#conn.prepare.bind(this.#conn, cmdParam, this.#conn.executePromise.bind(this.#conn)))
return new Promise(this.#conn.prepare.bind(this.#conn, cmdParam))
.then((prepare) => {

@@ -202,0 +203,0 @@ if (callback) callback(null, prepare, null);

@@ -90,6 +90,2 @@ 'use strict';

static _QUERY_CMD(conn, cmdParam) {
return new Promise(conn.query.bind(conn, cmdParam));
}
static _PARAM(options, sql, values) {

@@ -115,3 +111,3 @@ let _cmdOpt,

static _EXECUTE_CMD(conn, cmdParam) {
return new Promise(conn.prepare.bind(conn, cmdParam, conn.executePromise.bind(conn)))
return new Promise(conn.prepare.bind(conn, cmdParam))
.then((prepare) => {

@@ -139,3 +135,3 @@ return prepare.execute(cmdParam.values, cmdParam.opts, null, cmdParam.stack).then((res) => {

if (this.#conn.opts.trace) Error.captureStackTrace(cmdParam);
return new Promise(this.#conn.prepare.bind(this.#conn, cmdParam, this.#conn.executePromise.bind(this.#conn)));
return new Promise(this.#conn.prepare.bind(this.#conn, cmdParam));
}

@@ -142,0 +138,0 @@

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

if (this.opts.prepareCacheLength > 0) {
this.info._prepareCache.onEviction = (key, value) => value.unCache();
}
this.on(

@@ -178,3 +175,3 @@ 'close_prepare',

return new Promise(this.prepare.bind(this, cmdParam, this.executePromise.bind(this))).then((prepare) => {
return new Promise(this.prepare.bind(this, cmdParam)).then((prepare) => {
const usePlaceHolder = (cmdParam.opts && cmdParam.opts.namedPlaceholders) || this.opts.namedPlaceholders;

@@ -248,2 +245,3 @@ let vals;

function (err) {
prepare.close();
if (this.opts.logger.error) this.opts.logger.error(err);

@@ -329,3 +327,33 @@ reject(err);

) {
const resetCmd = new Reset(cmdParam, resolve, reject);
const conn = this;
const resetCmd = new Reset(
cmdParam,
() => {
let prom = Promise.resolve();
// handle timezone
if (conn.opts.timezone !== 'auto' && conn.opts.tz && !conn.opts.skipSetTimezone) {
let tz = conn.opts.tz;
if (conn.opts.tz === 'Etc/UTC') {
tz = '+00:00';
} else if (conn.opts.tz.startsWith('Etc/GMT')) {
let zone = moment.tz.zone(conn.opts.tz);
tz = zone.abbrs[0] + ':00';
}
prom = new Promise(conn.query.bind(this, new CommandParameter('SET time_zone=?', [tz]))).catch((err) => {
if (conn.opts.logger.error) conn.opts.logger.error(err);
console.log(
`warning: setting timezone '${conn.opts.tz}' fails on server.\n look at https://mariadb.com/kb/en/mysql_tzinfo_to_sql/ to load IANA timezone.\nSetting timezone can be disabled with option \`skipSetTimezone\``
);
return Promise.resolve();
});
}
// re-execute init query / session query timeout
prom
.then(conn.executeInitQuery.bind(conn))
.then(conn.executeSessionTimeout.bind(conn))
.then(resolve)
.catch(reject);
},
reject
);
this.addCommand(resetCmd);

@@ -1268,5 +1296,13 @@ return;

prepare(cmdParam, executeFct, resolve, reject) {
prepare(cmdParam, resolve, reject) {
if (!cmdParam.sql)
return reject(Errors.createError('sql parameter is mandatory', Errors.ER_UNDEFINED_SQL, this.info, 'HY000'));
if (this.sendQueue.isEmpty() || !this.receiveQueue.peekFront()) {
// no command in queue, database is then considered ok, and cache can be search right now
const cache = this.info.prepareFromCache(cmdParam.sql);
if (cache) {
return resolve(cache);
}
}
const cmd = new Prepare(

@@ -1280,3 +1316,2 @@ resolve,

cmdParam,
executeFct,
this

@@ -1283,0 +1318,0 @@ );

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

* File generated using test/tools/generate-mariadb.js
* from MariaDB 10.5
* from MariaDB 10.9
*

@@ -73,3 +73,2 @@ * !!!!!! DO NOT CHANGE MANUALLY !!!!!!

codes[182] = 'HA_FTS_INVALID_DOCID';
codes[183] = 'HA_ERR_TABLE_IN_FK_CHECK';
codes[184] = 'HA_ERR_TABLESPACE_EXISTS';

@@ -88,2 +87,4 @@ codes[185] = 'HA_ERR_TOO_MANY_FIELDS';

codes[196] = 'HA_ERR_SEQUENCE_RUN_OUT';
codes[197] = 'HA_ERR_COMMIT_ERROR';
codes[198] = 'HA_ERR_PARTITION_LIST';
codes[1000] = 'ER_HASHCHK';

@@ -161,3 +162,3 @@ codes[1001] = 'ER_NISAMCHK';

codes[1071] = 'ER_TOO_LONG_KEY';
codes[1072] = 'ER_KEY_COLUMN_DOES_NOT_EXITS';
codes[1072] = 'ER_KEY_COLUMN_DOES_NOT_EXIST';
codes[1073] = 'ER_BLOB_USED_AS_KEY';

@@ -266,3 +267,3 @@ codes[1074] = 'ER_TOO_BIG_FIELDLENGTH';

codes[1175] = 'ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE';
codes[1176] = 'ER_KEY_DOES_NOT_EXITS';
codes[1176] = 'ER_KEY_DOES_NOT_EXISTS';
codes[1177] = 'ER_CHECK_NO_SUCH_TABLE';

@@ -597,4 +598,4 @@ codes[1178] = 'ER_CHECK_NOT_IMPLEMENTED';

codes[1505] = 'ER_PARTITION_MGMT_ON_NONPARTITIONED';
codes[1506] = 'ER_FOREIGN_KEY_ON_PARTITIONED';
codes[1507] = 'ER_DROP_PARTITION_NON_EXISTENT';
codes[1506] = 'ER_FEATURE_NOT_SUPPORTED_WITH_PARTITIONING';
codes[1507] = 'ER_PARTITION_DOES_NOT_EXIST';
codes[1508] = 'ER_DROP_LAST_PARTITION';

@@ -817,4 +818,4 @@ codes[1509] = 'ER_COALESCE_ONLY_ON_HASH_PARTITION';

codes[1724] = 'ER_BINLOG_UNSAFE_INSERT_TWO_KEYS';
codes[1725] = 'ER_TABLE_IN_FK_CHECK';
codes[1726] = 'ER_UNUSED_1';
codes[1725] = 'ER_UNUSED_28';
codes[1726] = 'ER_VERS_NOT_ALLOWED';
codes[1727] = 'ER_BINLOG_UNSAFE_AUTOINC_NOT_FIRST';

@@ -1118,4 +1119,4 @@ codes[1728] = 'ER_CANNOT_LOAD_FROM_TABLE_V2';

codes[3060] = 'ER_ALTER_OPERATION_NOT_SUPPORTED_REASON_GIS';
codes[4000] = 'ER_COMMULTI_BADCONTEXT';
codes[4001] = 'ER_BAD_COMMAND_IN_MULTI';
codes[4000] = 'ER_UNUSED_26';
codes[4001] = 'ER_UNUSED_27';
codes[4002] = 'ER_WITH_COL_WRONG_LIST';

@@ -1166,3 +1167,3 @@ codes[4003] = 'ER_TOO_MANY_DEFINITIONS_IN_WITH_CLAUSE';

codes[4046] = 'ER_JSON_ONE_OR_ALL';
codes[4047] = 'ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE';
codes[4047] = 'ER_UNSUPPORTED_COMPRESSED_TABLE';
codes[4048] = 'ER_GEOJSON_INCORRECT';

@@ -1290,3 +1291,23 @@ codes[4049] = 'ER_GEOJSON_TOO_FEW_POINTS';

codes[4169] = 'ER_NO_AUTOINCREMENT_WITH_UNIQUE';
codes[4170] = 'ER_KEY_CONTAINS_PERIOD_FIELDS';
codes[4171] = 'ER_KEY_CANT_HAVE_WITHOUT_OVERLAPS';
codes[4172] = 'ER_NOT_ALLOWED_IN_THIS_CONTEXT';
codes[4173] = 'ER_DATA_WAS_COMMITED_UNDER_ROLLBACK';
codes[4174] = 'ER_PK_INDEX_CANT_BE_IGNORED';
codes[4175] = 'ER_BINLOG_UNSAFE_SKIP_LOCKED';
codes[4176] = 'ER_JSON_TABLE_ERROR_ON_FIELD';
codes[4177] = 'ER_JSON_TABLE_ALIAS_REQUIRED';
codes[4178] = 'ER_JSON_TABLE_SCALAR_EXPECTED';
codes[4179] = 'ER_JSON_TABLE_MULTIPLE_MATCHES';
codes[4180] = 'ER_WITH_TIES_NEEDS_ORDER';
codes[4181] = 'ER_REMOVED_ORPHAN_TRIGGER';
codes[4182] = 'ER_STORAGE_ENGINE_DISABLED';
codes[4183] = 'WARN_SFORMAT_ERROR';
codes[4184] = 'ER_PARTITION_CONVERT_SUBPARTITIONED';
codes[4185] = 'ER_PROVIDER_NOT_LOADED';
codes[4186] = 'ER_JSON_HISTOGRAM_PARSE_FAILED';
codes[4187] = 'ER_SF_OUT_INOUT_ARG_NOT_ALLOWED';
codes[4188] = 'ER_INCONSISTENT_SLAVE_TEMP_TABLE';
codes[4189] = 'ER_VERS_HIST_PART_FAILED';
module.exports.codes = codes;

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

readString(beg, len) {
return this.buf.toString(this.encoding, beg, beg + len);
readString(buf, beg, len) {
return buf.toString(this.encoding, beg, beg + len);
}

@@ -29,0 +29,0 @@

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

readString(beg, len) {
return Iconv.decode(this.buf.slice(beg, beg + len), this.encoding);
readString(buf, beg, len) {
return Iconv.decode(buf.slice(beg, beg + len), this.encoding);
}

@@ -28,0 +28,0 @@

'use strict';
const QuickLRU = require('@alloc/quick-lru');
const LRU = require('lru-cache');

@@ -10,7 +10,26 @@ class ConnectionInformation {

this.serverCapabilities = null;
this.database = opts.database;
if (opts.prepareCacheLength > 0) {
this._prepareCache = new QuickLRU({ maxSize: opts.prepareCacheLength });
this._prepareCache = new LRU({
max: opts.prepareCacheLength,
dispose: (value, key) => value.unCache()
});
this.prepareFromCache = this.prepareFromCacheEnable;
} else {
this.prepareFromCache = (sql) => {
return null;
};
}
}
prepareFromCacheEnable(sql) {
const key = this.database + '|' + sql;
const cachedItem = this._prepareCache.get(key);
if (cachedItem) {
cachedItem.incrementUse();
return cachedItem;
}
return null;
}
hasMinVersion(major, minor, patch) {

@@ -17,0 +36,0 @@ if (!this.serverVersion) throw new Error('cannot know if server version until connection is established');

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

module.exports.ER_PARSING_PRECISION = 45050;
module.exports.ER_PREPARE_CLOSED = 45051;

@@ -137,0 +138,0 @@ const keys = Object.keys(module.exports);

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

conn.forceEnd = conn.end;
conn.release = function (resolve, reject) {
conn.release = function (resolve) {
if (pool.#closed || !conn.isValid()) {

@@ -440,3 +440,3 @@ pool._destroy(conn);

for (const [key, value] of Object.entries(this.#activeConnections)) {
if (value.leaked) counter++;
if (value && value.leaked) counter++;
}

@@ -443,0 +443,0 @@ return counter;

{
"name": "mariadb",
"version": "3.0.1",
"version": "3.0.2",
"description": "fast mariadb or mysql connector.",

@@ -19,5 +19,7 @@ "main": "promise.js",

"test:prettier": "prettier --write \"{tools,lib,test,benchmarks}/**/*.js\"",
"coverage": "npm run coverage:test && npm run coverage:report",
"coverage": "npm run coverage:test && npm run coverage:create && npm run coverage:send",
"coverage:test": "nyc mocha --no-parallel --timeout 5000 \"test/**/*.js\"",
"coverage:report": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
"coverage:report": "npm run coverage:create && npm run coverage:send",
"coverage:create": "nyc report --reporter=text-lcov > coverage.lcov",
"coverage:send": "./codecov --disable=gcov",
"benchmark": "node benchmarks/benchmarks-all.js",

@@ -41,2 +43,3 @@ "generate": "node ./tools/generate-mariadb.js"

"promise.js",
"check-node.js",
"callback.js"

@@ -50,29 +53,27 @@ ],

"dependencies": {
"@alloc/quick-lru": "^5.2.0",
"@types/geojson": "^7946.0.8",
"@types/node": "^17.0.10",
"denque": "^2.0.1",
"@types/geojson": "^7946.0.10",
"@types/node": "^17.0.45",
"denque": "^2.1.0",
"iconv-lite": "^0.6.3",
"moment-timezone": "^0.5.34",
"please-upgrade-node": "^3.2.0"
"lru-cache": "^7.14.0",
"moment-timezone": "^0.5.38"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"benchmark": "^2.1.4",
"chai": "^4.3.4",
"chai": "^4.3.6",
"chalk": "^4.1.2",
"codecov": "^3.8.2",
"dom-parser": "^0.1.6",
"error-stack-parser": "^2.0.6",
"eslint": "^8.7.0",
"error-stack-parser": "^2.1.4",
"eslint": "^8.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-markdown": "^2.2.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-prettier": "^4.2.1",
"mocha": "^9.2.0",
"mocha-lcov-reporter": "^1.3.0",
"nyc": "^15.1.0",
"prettier": "^2.5.1",
"typescript": "^4.5.5",
"winston": "^3.4.0"
"prettier": "^2.7.1",
"typescript": "^4.7.4",
"winston": "^3.8.1"
},

@@ -79,0 +80,0 @@ "bugs": {

'use strict';
const pkg = require('./package.json');
require('please-upgrade-node')(pkg);
require('./check-node');

@@ -6,0 +5,0 @@ const Connection = require('./lib/connection');

@@ -138,2 +138,9 @@ /* eslint-disable @typescript-eslint/no-explicit-any */

/**
* Throw if conversion to Number is not safe.
*
* Default: false;
*/
checkNumberRange?: boolean;
/**
* Configure logger

@@ -358,2 +365,9 @@ */

stream?: (callback?: typeof StreamCallback) => void;
/**
* Compatibility option, causes Promise to return an array object,
* `[rows, metadata]` rather than the rows as JSON objects with a `meta` property.
* Default to false.
*/
metaAsArray?: boolean;
}

@@ -527,2 +541,7 @@

execute(values?: any): Promise<any>;
/**
* Execute query returning a Readable Object that will emit columns/data/end/error events
* to permit streaming big result-set
*/
queryStream(values?: any): stream.Readable;
close(): void;

@@ -669,2 +688,3 @@ }

export interface Pool {
closed: boolean;
/**

@@ -671,0 +691,0 @@ * Retrieve a connection from pool.

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