Skip to content

Commit 5c756ba

Browse files
committed
Merge branch 'release/2.0.2-rc'
2 parents eec1857 + fe3837e commit 5c756ba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3832
-796
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
.idea/
33
node_modules
44
/nodejs_mariadb.iml
5+
/coverage/
6+
/.nyc_output/

.travis.yml

Lines changed: 57 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,85 @@ sudo: false
22
language: node_js
33

44
services:
5-
- docker
5+
- docker
66

77
addons:
88
hosts:
9-
- mariadb.example.com
9+
- mariadb.example.com
1010

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

1717
install:
18-
# generate SSL certificates
19-
- mkdir tmp
20-
- chmod +x .travis/gen-ssl.sh
21-
- chmod +x .travis/build/build.sh
22-
- chmod +x .travis/build/docker-entrypoint.sh
23-
- chmod 777 .travis/build/
24-
- .travis/gen-ssl.sh mariadb.example.com tmp
25-
- export PROJ_PATH=`pwd`
26-
- export SSLCERT=$PROJ_PATH/tmp
27-
- export TEST_SSL_CA_FILE=$SSLCERT/server.crt
28-
- export TEST_SSL_CLIENT_KEY_FILE=$SSLCERT/client.key
29-
- export TEST_SSL_CLIENT_CERT_FILE=$SSLCERT/client.crt
30-
- export TEST_SSL_CLIENT_KEYSTORE_FILE=$SSLCERT/client-keystore.p12
18+
# generate SSL certificates
19+
- mkdir tmp
20+
- chmod +x .travis/gen-ssl.sh
21+
- chmod +x .travis/build/build.sh
22+
- chmod +x .travis/build/docker-entrypoint.sh
23+
- chmod 777 .travis/build/
24+
- .travis/gen-ssl.sh mariadb.example.com tmp
25+
- export PROJ_PATH=`pwd`
26+
- export SSLCERT=$PROJ_PATH/tmp
27+
- export TEST_SSL_CA_FILE=$SSLCERT/server.crt
28+
- export TEST_SSL_CLIENT_KEY_FILE=$SSLCERT/client.key
29+
- export TEST_SSL_CLIENT_CERT_FILE=$SSLCERT/client.crt
30+
- export TEST_SSL_CLIENT_KEYSTORE_FILE=$SSLCERT/client-keystore.p12
3131

3232
env:
3333
global:
3434
- TEST_PORT=3305
3535
- TEST_HOST=mariadb.example.com
3636
- MUST_USE_TCPIP=1
37+
- RUN_LONG_TEST=1
3738

3839
matrix:
3940
allow_failures:
40-
- node_js: "node"
41-
env: DB=build
41+
- node_js: "node"
42+
env: DB=build
4243
include:
43-
- node_js: "node"
44-
env: DB=build
45-
- node_js: "6"
46-
env: DB=mariadb:10.3 SKIP_LEAK=1
47-
- node_js: "8"
48-
env: DB=mariadb:10.3
49-
- node_js: "10"
50-
env: DB=mariadb:10.3
51-
- node_js: "node"
52-
env: DB=mariadb:10.3
53-
- node_js: "node"
54-
env: DB=mariadb:10.3 TEST_LONG=1
55-
- node_js: "node"
56-
env: DB=mariadb:10.3 LINT=1
57-
- node_js: "node"
58-
env: DB=mariadb:10.3 BENCH=1
59-
- node_js: "node"
60-
env: DB=mariadb:10.3 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2
61-
- node_js: "node"
62-
env: DB=mariadb:5.5
63-
- node_js: "node"
64-
env: DB=mariadb:10.0
65-
- node_js: "node"
66-
env: DB=mariadb:10.1
67-
- node_js: "node"
68-
env: DB=mariadb:10.2
69-
- node_js: "node"
70-
env: DB=mysql:5.5
71-
- node_js: "node"
72-
env: DB=mysql:5.6
73-
- node_js: "node"
74-
env: DB=mysql:5.7
75-
- node_js: "node"
76-
env: DB=mysql:8.0
77-
78-
cache:
79-
directories:
80-
- node_modules
44+
- node_js: "node"
45+
env: DB=build
46+
- node_js: "6"
47+
env: DB=mariadb:10.3 SKIP_LEAK=1
48+
- node_js: "8"
49+
env: DB=mariadb:10.3
50+
- node_js: "10"
51+
env: DB=mariadb:10.3
52+
- node_js: "node"
53+
env: DB=mariadb:10.3
54+
- node_js: "node"
55+
env: DB=mariadb:10.3 LINT=1
56+
- node_js: "node"
57+
env: DB=mariadb:10.3 BENCH=1
58+
- node_js: "node"
59+
env: DB=mariadb:10.3 MAXSCALE_VERSION=2.2.9 TEST_PORT=4007 TEST_USER=bob TEXT_DATABASE=test2
60+
- node_js: "node"
61+
env: DB=mariadb:5.5
62+
- node_js: "node"
63+
env: DB=mariadb:10.0
64+
- node_js: "node"
65+
env: DB=mariadb:10.1
66+
- node_js: "node"
67+
env: DB=mariadb:10.2
68+
- node_js: "node"
69+
env: DB=mysql:5.5
70+
- node_js: "node"
71+
env: DB=mysql:5.6
72+
- node_js: "node"
73+
env: DB=mysql:5.7
74+
- node_js: "node"
75+
env: DB=mysql:8.0
8176

8277
notifications:
8378
email: false
8479

8580
script:
86-
- npm install
87-
- npm install coveralls
88-
- .travis/script.sh
81+
- npm install
82+
- npm install nyc -g
83+
- .travis/script.sh
8984

9085
after_success:
91-
- if [ -z "$BENCH" ] ; then npm i nyc -g; fi
92-
- if [ -z "$BENCH" ] ; then npm run coveralls; fi
86+
- if [ -z "$BENCH" ] ; then npm run coverage:report; fi

.travis/entrypoint/dbinit.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE USER 'bob'@'%';
2+
GRANT ALL ON *.* TO 'bob'@'%' with grant option;
3+
4+
CREATE USER 'boby'@'%' identified by 'hey';
5+
GRANT ALL ON *.* TO 'boby'@'%' with grant option;
6+
7+
INSTALL PLUGIN pam SONAME 'auth_pam';
8+
9+
FLUSH PRIVILEGES;
10+
11+
CREATE DATABASE test2;

.travis/script.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if [ "$DB" = "build" ] ; then
1212
docker build -t build:latest --label build .travis/build/
1313
fi
1414

15+
export ENTRYPOINT=$PROJ_PATH/.travis/entrypoint
1516
if [ -n "$MAXSCALE_VERSION" ] ; then
1617
###################################################################################################################
1718
# launch Maxscale with one server
@@ -21,7 +22,6 @@ if [ -n "$MAXSCALE_VERSION" ] ; then
2122
docker-compose -f ${COMPOSE_FILE} build
2223
docker-compose -f ${COMPOSE_FILE} up -d
2324
else
24-
export ENTRYPOINT=$PROJ_PATH/.travis/entrypoint
2525
docker-compose -f .travis/docker-compose.yml up -d
2626
fi
2727

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

4343
if [ -n "$LINT" ] ; then npm run test:lint; fi
44-
if [ -z "$BENCH$LINT" ] ; then npm run test:base; fi
44+
if [ -z "$BENCH$LINT" ] ; then npm run coverage:test; fi
4545
if [ -n "$BENCH" ] ; then
4646
npm install promise-mysql mysql2
4747
npm install microtime

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
[![Linux Build](https://travis-ci.org/MariaDB/mariadb-connector-nodejs.svg?branch=master)](https://travis-ci.org/MariaDB/mariadb-connector-nodejs)
1010
[![Windows status](https://ci.appveyor.com/api/projects/status/bcg7yy4iy9viq08t/branch/master?svg=true)](https://ci.appveyor.com/project/rusher/mariadb-connector-nodejs)
1111
[![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)
12-
[![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)
12+
[![codecov](https://codecov.io/gh/MariaDB/mariadb-connector-nodejs/branch/master/graph/badge.svg)](https://codecov.io/gh/MariaDB/mariadb-connector-nodejs)
1313

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

benchmarks/benchmarks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const launchBenchs = function(path) {
88
console.error(err);
99
return;
1010
}
11-
let bench = new Bench();
11+
const bench = new Bench();
1212
//launch all benchmarks
1313
for (let i = 0; i < list.length; i++) {
1414
console.log("benchmark: ./benchs/" + list[i]);

benchmarks/common_benchmarks.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ function Bench() {
5757
const config = conf.baseConfig;
5858
config.charsetNumber = 224;
5959
config.trace = false;
60+
//To benchmark same pool implementation than mysql/mysql2
61+
//standard implementation rollback/reset connection after use
62+
config.noControlAfterUse = true;
6063

6164
const poolConfig = Object.assign({ connectionLimit: 4 }, config);
6265
// config.debug = true;

documentation/callback-api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Specific options for pools are :
184184
| **`acquireTimeout`** | Timeout to get a new connection from pool in ms. |*integer* | 10000 |
185185
| **`connectionLimit`** | Maximum number of connection in pool. |*integer* | 10 |
186186
| **`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|
187+
| **`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|
187188

188189

189190
### `createPoolCluster(options) → PoolCluster`

documentation/changelog.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
#### 2.0.2-rc - 11-12-2018
2+
3+
##### Changes
4+
5+
* new option `noControlAfterUse` permitting to disable reset or rollback when giving back a connection pool.
6+
7+
##### Correction
8+
9+
* using option `connectAttributes` value `_server_host` is correctly filled on Performance Schema.
10+
* batch improvement
11+
* error thrown when no values
12+
* BULK better handling when socket error during process
13+
* Object with toSqlString function parameter support
14+
* null value correction when using BULK
15+
* timezone correction when not using "local" default values
16+
* now support very long parameter (> 16M)
17+
* rewrite support "\\" in parameter
18+
* `timezone` option parsing correction (correctly handle negative values)
19+
* test coverage improvement
20+
* minor performance improvement
21+
* pool end() now correctly wait for all connections ending
22+
23+
124
#### 2.0.1-alpha - 15-11-2018
225

326
* [CONJS-52] (Bug) Commit not executed when in transaction and autocommit is enabled

documentation/promise-api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ Specific options for pools are :
217217
| **`acquireTimeout`** | Timeout to get a new connection from pool in ms. |*integer* | 10000 |
218218
| **`connectionLimit`** | Maximum number of connection in pool. |*integer* | 10 |
219219
| **`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|
220+
| **`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|
221+
220222

221223

222224
### `createPoolCluster(options) → PoolCluster`

lib/cmd/batch-bulk.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,24 @@ class BatchBulk extends CommonBinary {
2828
this.info = info;
2929
if (!this.initialValues) {
3030
this.emit("send_end");
31-
this.throwError(
32-
Errors.createError(
33-
"Batch must have values set\n" + this.displaySql(),
34-
false,
35-
info,
36-
"HY000",
37-
Errors.ER_BATCH_WITH_NO_VALUES
38-
),
39-
info
31+
const err = Errors.createError(
32+
"Batch must have values set\n" + this.displaySql(),
33+
false,
34+
info,
35+
"HY000",
36+
Errors.ER_BATCH_WITH_NO_VALUES,
37+
this.stack,
38+
false
4039
);
40+
this.onPacketReceive = null;
41+
this.resolve = null;
42+
process.nextTick(this.reject, err);
43+
this.reject = null;
44+
this.emit("end", err);
4145
this.sending = false;
4246
return;
4347
}
48+
4449
this.initialValues = Array.isArray(this.initialValues)
4550
? this.initialValues
4651
: [this.initialValues];
@@ -139,12 +144,14 @@ class BatchBulk extends CommonBinary {
139144

140145
if (!this.sending && this.packet.waitingResponseNo === 0) {
141146
//send COM_STMT_CLOSE packet
142-
this.sequenceNo = -1;
143-
this.compressSequenceNo = -1;
144-
this.out.startPacket(this);
145-
this.out.writeInt8(0x19);
146-
this.out.writeInt32(this.statementId);
147-
this.out.flushBuffer(true);
147+
if (!this.firstError || !this.firstError.fatal) {
148+
this.sequenceNo = -1;
149+
this.compressSequenceNo = -1;
150+
this.out.startPacket(this);
151+
this.out.writeInt8(0x19);
152+
this.out.writeInt32(this.statementId);
153+
this.out.flushBuffer(true);
154+
}
148155
this.sending = false;
149156
this.emit("send_end");
150157

@@ -208,7 +215,7 @@ class BatchBulk extends CommonBinary {
208215
this.resolve = null;
209216

210217
//send COM_STMT_CLOSE packet
211-
if (this.statementId) {
218+
if (!err.fatal && this.statementId) {
212219
this.sequenceNo = -1;
213220
this.compressSequenceNo = -1;
214221
this.out.startPacket(this);
@@ -238,10 +245,6 @@ class BatchBulk extends CommonBinary {
238245
//validate parameter size.
239246
for (let r = 0; r < this.values.length; r++) {
240247
let val = this.values[r];
241-
if (!Array.isArray(val)) {
242-
val = [val];
243-
this.values[r] = val;
244-
}
245248

246249
//validate parameter is defined.
247250
for (let i = 0; i < val.length; i++) {

lib/cmd/batch-rewrite.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ class BatchRewrite extends CommonText {
2727
this.info = info;
2828
if (!this.initialValues) {
2929
this.emit("send_end");
30-
this.throwError(
31-
Errors.createError(
32-
"Batch must have values set\n" + this.displaySql(),
33-
false,
34-
info,
35-
"HY000",
36-
Errors.ER_BATCH_WITH_NO_VALUES
37-
),
38-
info
30+
const err = Errors.createError(
31+
"Batch must have values set\n" + this.displaySql(),
32+
false,
33+
info,
34+
"HY000",
35+
Errors.ER_BATCH_WITH_NO_VALUES,
36+
this.stack,
37+
false
3938
);
39+
this.onPacketReceive = null;
40+
this.resolve = null;
41+
process.nextTick(this.reject, err);
42+
this.reject = null;
43+
this.emit("end", err);
4044
this.sending = false;
4145
return;
4246
}
@@ -77,7 +81,7 @@ class BatchRewrite extends CommonText {
7781
//********************************************
7882
// send params
7983
//********************************************
80-
const len = this.valueRow.length;
84+
const len = this.parseResults.partList.length - 3;
8185
for (let i = 0; i < len; i++) {
8286
const value = this.valueRow[i];
8387
flushed = this.packet.writeString(this.parseResults.partList[i + 1]) || flushed;
@@ -255,7 +259,7 @@ class BatchRewrite extends CommonText {
255259
this.values[r] = val;
256260
}
257261

258-
if (this.parseResults.length - 3 > val.length) {
262+
if (this.parseResults.partList.length - 3 > val.length) {
259263
this.emit("send_end");
260264
this.throwNewError(
261265
"Parameter at position " +
@@ -273,7 +277,7 @@ class BatchRewrite extends CommonText {
273277
}
274278

275279
//validate parameter is defined.
276-
for (let i = 0; i < this.parseResults.length - 3; i++) {
280+
for (let i = 0; i < this.parseResults.partList.length - 3; i++) {
277281
if (val[i] === undefined) {
278282
this.emit("send_end");
279283
this.throwNewError(

0 commit comments

Comments
 (0)