Skip to content

Commit

Permalink
Merge branch 'release/2.0.2-rc'
Browse files Browse the repository at this point in the history
  • Loading branch information
rusher committed Dec 11, 2018
2 parents eec1857 + fe3837e commit 5c756ba
Show file tree
Hide file tree
Showing 45 changed files with 3,832 additions and 796 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
.idea/
node_modules
/nodejs_mariadb.iml
/coverage/
/.nyc_output/
120 changes: 57 additions & 63 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,91 +2,85 @@ sudo: false
language: node_js

services:
- docker
- docker

addons:
hosts:
- mariadb.example.com
- mariadb.example.com

before_script:
# Disable services enabled by default
- sudo /etc/init.d/mysql stop
# Disable services enabled by default
- sudo /etc/init.d/mysql stop
before_install:
- chmod +x .travis/script.sh
- chmod +x .travis/script.sh

install:
# generate SSL certificates
- mkdir tmp
- chmod +x .travis/gen-ssl.sh
- chmod +x .travis/build/build.sh
- chmod +x .travis/build/docker-entrypoint.sh
- chmod 777 .travis/build/
- .travis/gen-ssl.sh mariadb.example.com tmp
- export PROJ_PATH=`pwd`
- export SSLCERT=$PROJ_PATH/tmp
- export TEST_SSL_CA_FILE=$SSLCERT/server.crt
- export TEST_SSL_CLIENT_KEY_FILE=$SSLCERT/client.key
- export TEST_SSL_CLIENT_CERT_FILE=$SSLCERT/client.crt
- export TEST_SSL_CLIENT_KEYSTORE_FILE=$SSLCERT/client-keystore.p12
# generate SSL certificates
- mkdir tmp
- chmod +x .travis/gen-ssl.sh
- chmod +x .travis/build/build.sh
- chmod +x .travis/build/docker-entrypoint.sh
- chmod 777 .travis/build/
- .travis/gen-ssl.sh mariadb.example.com tmp
- export PROJ_PATH=`pwd`
- export SSLCERT=$PROJ_PATH/tmp
- export TEST_SSL_CA_FILE=$SSLCERT/server.crt
- export TEST_SSL_CLIENT_KEY_FILE=$SSLCERT/client.key
- export TEST_SSL_CLIENT_CERT_FILE=$SSLCERT/client.crt
- export TEST_SSL_CLIENT_KEYSTORE_FILE=$SSLCERT/client-keystore.p12

env:
global:
- TEST_PORT=3305
- TEST_HOST=mariadb.example.com
- MUST_USE_TCPIP=1
- RUN_LONG_TEST=1

matrix:
allow_failures:
- node_js: "node"
env: DB=build
- node_js: "node"
env: DB=build
include:
- node_js: "node"
env: DB=build
- node_js: "6"
env: DB=mariadb:10.3 SKIP_LEAK=1
- node_js: "8"
env: DB=mariadb:10.3
- node_js: "10"
env: DB=mariadb:10.3
- node_js: "node"
env: DB=mariadb:10.3
- node_js: "node"
env: DB=mariadb:10.3 TEST_LONG=1
- node_js: "node"
env: DB=mariadb:10.3 LINT=1
- node_js: "node"
env: DB=mariadb:10.3 BENCH=1
- node_js: "node"
env: DB=mariadb:10.3 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2
- node_js: "node"
env: DB=mariadb:5.5
- node_js: "node"
env: DB=mariadb:10.0
- node_js: "node"
env: DB=mariadb:10.1
- node_js: "node"
env: DB=mariadb:10.2
- node_js: "node"
env: DB=mysql:5.5
- node_js: "node"
env: DB=mysql:5.6
- node_js: "node"
env: DB=mysql:5.7
- node_js: "node"
env: DB=mysql:8.0

cache:
directories:
- node_modules
- node_js: "node"
env: DB=build
- node_js: "6"
env: DB=mariadb:10.3 SKIP_LEAK=1
- node_js: "8"
env: DB=mariadb:10.3
- node_js: "10"
env: DB=mariadb:10.3
- node_js: "node"
env: DB=mariadb:10.3
- node_js: "node"
env: DB=mariadb:10.3 LINT=1
- node_js: "node"
env: DB=mariadb:10.3 BENCH=1
- node_js: "node"
env: DB=mariadb:10.3 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2
- node_js: "node"
env: DB=mariadb:5.5
- node_js: "node"
env: DB=mariadb:10.0
- node_js: "node"
env: DB=mariadb:10.1
- node_js: "node"
env: DB=mariadb:10.2
- node_js: "node"
env: DB=mysql:5.5
- node_js: "node"
env: DB=mysql:5.6
- node_js: "node"
env: DB=mysql:5.7
- node_js: "node"
env: DB=mysql:8.0

notifications:
email: false

script:
- npm install
- npm install coveralls
- .travis/script.sh
- npm install
- npm install nyc -g
- .travis/script.sh

after_success:
- if [ -z "$BENCH" ] ; then npm i nyc -g; fi
- if [ -z "$BENCH" ] ; then npm run coveralls; fi
- if [ -z "$BENCH" ] ; then npm run coverage:report; fi
11 changes: 11 additions & 0 deletions .travis/entrypoint/dbinit.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE USER 'bob'@'%';
GRANT ALL ON *.* TO 'bob'@'%' with grant option;

CREATE USER 'boby'@'%' identified by 'hey';
GRANT ALL ON *.* TO 'boby'@'%' with grant option;

INSTALL PLUGIN pam SONAME 'auth_pam';

FLUSH PRIVILEGES;

CREATE DATABASE test2;
4 changes: 2 additions & 2 deletions .travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if [ "$DB" = "build" ] ; then
docker build -t build:latest --label build .travis/build/
fi

export ENTRYPOINT=$PROJ_PATH/.travis/entrypoint
if [ -n "$MAXSCALE_VERSION" ] ; then
###################################################################################################################
# launch Maxscale with one server
Expand All @@ -21,7 +22,6 @@ if [ -n "$MAXSCALE_VERSION" ] ; then
docker-compose -f ${COMPOSE_FILE} build
docker-compose -f ${COMPOSE_FILE} up -d
else
export ENTRYPOINT=$PROJ_PATH/.travis/entrypoint
docker-compose -f .travis/docker-compose.yml up -d
fi

Expand All @@ -41,7 +41,7 @@ if [ -z "$MAXSCALE_VERSION" ] ; then
fi

if [ -n "$LINT" ] ; then npm run test:lint; fi
if [ -z "$BENCH$LINT" ] ; then npm run test:base; fi
if [ -z "$BENCH$LINT" ] ; then npm run coverage:test; fi
if [ -n "$BENCH" ] ; then
npm install promise-mysql mysql2
npm install microtime
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Linux Build](https://travis-ci.org/MariaDB/mariadb-connector-nodejs.svg?branch=master)](https://travis-ci.org/MariaDB/mariadb-connector-nodejs)
[![Windows status](https://ci.appveyor.com/api/projects/status/bcg7yy4iy9viq08t/branch/master?svg=true)](https://ci.appveyor.com/project/rusher/mariadb-connector-nodejs)
[![License (LGPL version 2.1)](https://img.shields.io/badge/license-GNU%20LGPL%20version%202.1-green.svg?style=flat-square)](http://opensource.org/licenses/LGPL-2.1)
[![Coverage Status](https://coveralls.io/repos/github/MariaDB/mariadb-connector-nodejs/badge.svg?branch=master)](https://coveralls.io/github/MariaDB/mariadb-connector-nodejs?branch=master)
[![codecov](https://codecov.io/gh/MariaDB/mariadb-connector-nodejs/branch/master/graph/badge.svg)](https://codecov.io/gh/MariaDB/mariadb-connector-nodejs)

**Non-blocking MariaDB and MySQL client for Node.js.**

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const launchBenchs = function(path) {
console.error(err);
return;
}
let bench = new Bench();
const bench = new Bench();
//launch all benchmarks
for (let i = 0; i < list.length; i++) {
console.log("benchmark: ./benchs/" + list[i]);
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/common_benchmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ function Bench() {
const config = conf.baseConfig;
config.charsetNumber = 224;
config.trace = false;
//To benchmark same pool implementation than mysql/mysql2
//standard implementation rollback/reset connection after use
config.noControlAfterUse = true;

const poolConfig = Object.assign({ connectionLimit: 4 }, config);
// config.debug = true;
Expand Down
1 change: 1 addition & 0 deletions documentation/callback-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Specific options for pools are :
| **`acquireTimeout`** | Timeout to get a new connection from pool in ms. |*integer* | 10000 |
| **`connectionLimit`** | Maximum number of connection in pool. |*integer* | 10 |
| **`minDelayValidation`** | When asking a connection to pool, the pool will validate the connection state. "minDelayValidation" permits disabling this validation if the connection has been borrowed recently avoiding useless verifications in case of frequent reuse of connections. 0 means validation is done each time the connection is asked. (in ms) |*integer*| 500|
| **`noControlAfterUse`** | After giving back connection to pool (connection.end) connector will reset or rollback connection to ensure a valid state. This option permit to disable those controls|*boolean*| false|


### `createPoolCluster(options) → PoolCluster`
Expand Down
23 changes: 23 additions & 0 deletions documentation/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
#### 2.0.2-rc - 11-12-2018

##### Changes

* new option `noControlAfterUse` permitting to disable reset or rollback when giving back a connection pool.

##### Correction

* using option `connectAttributes` value `_server_host` is correctly filled on Performance Schema.
* batch improvement
* error thrown when no values
* BULK better handling when socket error during process
* Object with toSqlString function parameter support
* null value correction when using BULK
* timezone correction when not using "local" default values
* now support very long parameter (> 16M)
* rewrite support "\\" in parameter
* `timezone` option parsing correction (correctly handle negative values)
* test coverage improvement
* minor performance improvement
* pool end() now correctly wait for all connections ending


#### 2.0.1-alpha - 15-11-2018

* [CONJS-52] (Bug) Commit not executed when in transaction and autocommit is enabled
Expand Down
2 changes: 2 additions & 0 deletions documentation/promise-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ Specific options for pools are :
| **`acquireTimeout`** | Timeout to get a new connection from pool in ms. |*integer* | 10000 |
| **`connectionLimit`** | Maximum number of connection in pool. |*integer* | 10 |
| **`minDelayValidation`** | When asking a connection to pool, the pool will validate the connection state. "minDelayValidation" permits disabling this validation if the connection has been borrowed recently avoiding useless verifications in case of frequent reuse of connections. 0 means validation is done each time the connection is asked. (in ms) |*integer*| 500|
| **`noControlAfterUse`** | After giving back connection to pool (connection.end) connector will reset or rollback connection to ensure a valid state. This option permit to disable those controls|*boolean*| false|



### `createPoolCluster(options) → PoolCluster`
Expand Down
43 changes: 23 additions & 20 deletions lib/cmd/batch-bulk.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,24 @@ class BatchBulk extends CommonBinary {
this.info = info;
if (!this.initialValues) {
this.emit("send_end");
this.throwError(
Errors.createError(
"Batch must have values set\n" + this.displaySql(),
false,
info,
"HY000",
Errors.ER_BATCH_WITH_NO_VALUES
),
info
const err = Errors.createError(
"Batch must have values set\n" + this.displaySql(),
false,
info,
"HY000",
Errors.ER_BATCH_WITH_NO_VALUES,
this.stack,
false
);
this.onPacketReceive = null;
this.resolve = null;
process.nextTick(this.reject, err);
this.reject = null;
this.emit("end", err);
this.sending = false;
return;
}

this.initialValues = Array.isArray(this.initialValues)
? this.initialValues
: [this.initialValues];
Expand Down Expand Up @@ -139,12 +144,14 @@ class BatchBulk extends CommonBinary {

if (!this.sending && this.packet.waitingResponseNo === 0) {
//send COM_STMT_CLOSE packet
this.sequenceNo = -1;
this.compressSequenceNo = -1;
this.out.startPacket(this);
this.out.writeInt8(0x19);
this.out.writeInt32(this.statementId);
this.out.flushBuffer(true);
if (!this.firstError || !this.firstError.fatal) {
this.sequenceNo = -1;
this.compressSequenceNo = -1;
this.out.startPacket(this);
this.out.writeInt8(0x19);
this.out.writeInt32(this.statementId);
this.out.flushBuffer(true);
}
this.sending = false;
this.emit("send_end");

Expand Down Expand Up @@ -208,7 +215,7 @@ class BatchBulk extends CommonBinary {
this.resolve = null;

//send COM_STMT_CLOSE packet
if (this.statementId) {
if (!err.fatal && this.statementId) {
this.sequenceNo = -1;
this.compressSequenceNo = -1;
this.out.startPacket(this);
Expand Down Expand Up @@ -238,10 +245,6 @@ class BatchBulk extends CommonBinary {
//validate parameter size.
for (let r = 0; r < this.values.length; r++) {
let val = this.values[r];
if (!Array.isArray(val)) {
val = [val];
this.values[r] = val;
}

//validate parameter is defined.
for (let i = 0; i < val.length; i++) {
Expand Down
28 changes: 16 additions & 12 deletions lib/cmd/batch-rewrite.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,20 @@ class BatchRewrite extends CommonText {
this.info = info;
if (!this.initialValues) {
this.emit("send_end");
this.throwError(
Errors.createError(
"Batch must have values set\n" + this.displaySql(),
false,
info,
"HY000",
Errors.ER_BATCH_WITH_NO_VALUES
),
info
const err = Errors.createError(
"Batch must have values set\n" + this.displaySql(),
false,
info,
"HY000",
Errors.ER_BATCH_WITH_NO_VALUES,
this.stack,
false
);
this.onPacketReceive = null;
this.resolve = null;
process.nextTick(this.reject, err);
this.reject = null;
this.emit("end", err);
this.sending = false;
return;
}
Expand Down Expand Up @@ -77,7 +81,7 @@ class BatchRewrite extends CommonText {
//********************************************
// send params
//********************************************
const len = this.valueRow.length;
const len = this.parseResults.partList.length - 3;
for (let i = 0; i < len; i++) {
const value = this.valueRow[i];
flushed = this.packet.writeString(this.parseResults.partList[i + 1]) || flushed;
Expand Down Expand Up @@ -255,7 +259,7 @@ class BatchRewrite extends CommonText {
this.values[r] = val;
}

if (this.parseResults.length - 3 > val.length) {
if (this.parseResults.partList.length - 3 > val.length) {
this.emit("send_end");
this.throwNewError(
"Parameter at position " +
Expand All @@ -273,7 +277,7 @@ class BatchRewrite extends CommonText {
}

//validate parameter is defined.
for (let i = 0; i < this.parseResults.length - 3; i++) {
for (let i = 0; i < this.parseResults.partList.length - 3; i++) {
if (val[i] === undefined) {
this.emit("send_end");
this.throwNewError(
Expand Down
Loading

0 comments on commit 5c756ba

Please sign in to comment.