Skip to content

Commit 16f1f39

Browse files
author
yq
authored
Merge branch 'sidorares:master' into release-idle-connection
2 parents 9f6909f + d065991 commit 16f1f39

Some content is hidden

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

60 files changed

+2541
-318
lines changed

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

Changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2.3.3 ( 14/11/2021 )
2+
- no changes compared to 2.3.3-rc.0
3+
4+
2.3.3-rc.0 ( 5/11/2021 )
5+
- fix ColumnDefinition.db is broken when
6+
encoding is not utf-8 #1423
7+
- typeCast: Fix field.length to be number #1427, #1426
8+
- initiall support for coverage reporting in CI #1425
9+
- fix performance regression for results with #1445, #1432
10+
large (300+) number of columns
11+
12+
113
2.3.2 ( 16/10/2021 )
214
- fix regression causing typeCast + JSON field
315
to error #1418, #1420

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
[![Node.js Version][node-version-image]][node-version-url]
77
[![Linux Build][travis-image]][travis-url]
88
[![Windows Build][appveyor-image]][appveyor-url]
9-
[![License][license-image]][license-url]
9+
[![License][license-image]][license-url]
10+
11+
[简体中文 Simplified Chinese](./documentation_zh-cn/)
1012

1113
> MySQL client for Node.js with focus on performance. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, ssl [much more](https://github.com/sidorares/node-mysql2/tree/master/documentation)
1214

documentation/Authentication-Switch.md

Lines changed: 82 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,46 @@
11
# Authentication switch request
22

3-
During connection phase the server may ask client to switch to a different auth method.
4-
If `authSwitchHandler` connection config option is set it must be a function that receive
5-
switch request data and respond via callback. Note that if `mysql_native_password` method is
6-
requested it will be handled internally according to [Authentication::Native41]( https://dev.mysql.com/doc/internals/en/secure-password-authentication.html#packet-Authentication::Native41) and
7-
`authSwitchHandler` won't be invoked. `authSwitchHandler` MAY be called multiple times if
8-
plugin algorithm requires multiple roundtrips of data exchange between client and server.
9-
First invocation always has `({pluginName, pluginData})` signature, following calls - `({pluginData})`.
10-
The client respond with opaque blob matching requested plugin via `callback(null, data: Buffer)`.
3+
During the connection phase the server may ask the client to switch to a different auth method.
4+
If the `authPlugins` connection config option is set, it must be an object where each key
5+
is the name of a potential authentication plugin requested by the server, and the corresponding
6+
value must be a function that optionally receives the connection config options and returns
7+
another function, which in turn, optionally receives the switch request data.
8+
9+
The plugin is loaded with a `({user,password,...})` signature, and each call has a `(pluginData)`
10+
signature. Each call should make the plugin return any additional authentication data (`Buffer`)
11+
that should be sent back to the server, either synchronously or asynchronously using a `Promise`,
12+
or should yield an error accordingly.
1113

1214
Example: (imaginary `ssh-key-auth` plugin) pseudo code
1315

16+
```js
17+
const conn = mysql.createConnection({
18+
user: 'test_user',
19+
password: 'test',
20+
database: 'test_database',
21+
authPlugins: {
22+
'ssh-key-auth': function ({password}) {
23+
return function (pluginData) {
24+
return getPrivate(key)
25+
.then(key => {
26+
const response = encrypt(key, password, pluginData);
27+
// continue handshake by sending response data
28+
return response;
29+
})
30+
.catch(err => {
31+
// throw error to propagate error to connect/changeUser handlers
32+
});
33+
};
34+
}
35+
}
36+
});
37+
```
38+
39+
There is also a deprecated API where if a `authSwitchHandler` connection config option is set
40+
it must be a function that receives switch request data and responds via a callback. In this case,
41+
the first invocation always has a `({pluginName, pluginData})` signature, following calls - `({pluginData})`.
42+
The client replies with an opaque blob matching the requested plugin via `callback(null, data: Buffer)`.
43+
1444
```js
1545
const conn = mysql.createConnection({
1646
user: 'test_user',
@@ -33,4 +63,47 @@ const conn = mysql.createConnection({
3363
});
3464
```
3565

36-
Initial handshake always performed using `mysql_native_password` plugin. This will be possible to override in the future versions.
66+
The initial handshake is always performed using `mysql_native_password` plugin. This will be possible to override in future versions.
67+
68+
Note that if the `mysql_native_password` method is requested it will be handled internally according
69+
to [Authentication::Native41]( https://dev.mysql.com/doc/internals/en/secure-password-authentication.html#packet-Authentication::Native41)
70+
and no `authPlugins` function or the `authSwitchHandler` will be invoked.
71+
72+
These MAY be called multiple times if the plugin algorithm requires multiple roundtrips of data
73+
exchange between client and server.
74+
75+
## Multi-factor authentication
76+
77+
If the user requires multi-factor authentication in the server, the client will receive a `AuthNextFactor`
78+
request, which is similar in structure to the regular authentication switch request and contains the name
79+
and possible initial data for the additional authentication factor plugin (up to 3). Additional passwords
80+
can be provided using the connection config options - `password2` and `password3`. Again, for each
81+
authentication factor, multiple roundtrips of data exchange can be required by the plugin algoritm.
82+
83+
```js
84+
const conn = mysql.createConnection({
85+
user: 'test_user',
86+
password: 'secret1',
87+
password2: 'secret2',
88+
password3: 'secret3',
89+
database: 'test_database',
90+
authPlugins: {
91+
// password1 === password
92+
'auth-plugin1': function ({password1}) {
93+
return function (serverPluginData) {
94+
return clientPluginData(password1, serverPluginData);
95+
};
96+
},
97+
'auth-plugin2': function ({password2}) {
98+
return function (serverPluginData) {
99+
return clientPluginData(password2, serverPluginData);
100+
};
101+
},
102+
'auth-plugin3': function ({password3}) {
103+
return function (serverPluginData) {
104+
return clientPluginData(password3, serverPluginData);
105+
};
106+
}
107+
}
108+
});
109+
```

documentation/Prepared-Statements.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ connection.execute('select 1 + ? + ? as result', [5, 6], (err, rows) => {
1313
// close cached statement for 'select 1 + ? + ? as result'. noop if not in cache
1414
connection.unprepare('select 1 + ? + ? as result');
1515
```
16+
Note that `connection.execute()` will cache the prepared statement for better performance, remove the cache with `connection.unprepare()` when you're done.
1617

1718
## Manual prepare / execute
1819

20+
Manually prepared statements doesn't comes with LRU cache and SHOULD be closed using `statement.close()` instead of `connection.unprepare()`.
21+
1922
```js
2023
connection.prepare('select ? + ? as tests', (err, statement) => {
2124
// statement.parameters - array of column definitions, length === number of params, here 2
@@ -27,6 +30,7 @@ connection.prepare('select ? + ? as tests', (err, statement) => {
2730
// -> [ { tests: 3 } ]
2831
});
2932

33+
// don't use connection.unprepare(), it won't work!
3034
// note that there is no callback here. There is no statement close ack at protocol level.
3135
statement.close();
3236
});

documentation/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You need to check corresponding field's zeroFill flag and convert to string manu
4141
- [Wire protocol documentation](http://dev.mysql.com/doc/internals/en/client-server-protocol.html)
4242
- [node-mysql](https://github.com/mysqljs/mysql) - Most popular node.js mysql client library
4343
- [node-mariasql](https://github.com/mscdex/node-mariasql/) - Bindings to libmariasql. One of the fastest clients
44-
- [node-libmysqlclident](https://github.com/Sannis/node-mysql-libmysqlclient) - Bindings to libmysqlclient
44+
- [node-libmysqlclient](https://github.com/Sannis/node-mysql-libmysqlclient) - Bindings to libmysqlclient
4545
- [go-mysql](https://github.com/siddontang/go-mysql) - MySQL Go client (prepared statements, binlog protocol, server)
4646

4747
## Benchmarks

0 commit comments

Comments
 (0)