mysql2 3.3.0 → 3.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/index.d.ts +2 -1
- package/lib/connection.js +5 -4
- package/lib/connection_config.js +1 -1
- package/lib/parsers/parser_cache.js +1 -1
- package/package.json +1 -1
- package/promise.d.ts +1 -3
- package/typings/mysql/index.d.ts +2 -2
- package/typings/mysql/lib/Connection.d.ts +4 -2
- package/typings/mysql/lib/Pool.d.ts +9 -4
package/README.md
CHANGED
|
@@ -134,7 +134,9 @@ const pool = mysql.createPool({
|
|
|
134
134
|
connectionLimit: 10,
|
|
135
135
|
maxIdle: 10, // max idle connections, the default value is the same as `connectionLimit`
|
|
136
136
|
idleTimeout: 60000, // idle connections timeout, in milliseconds, the default value 60000
|
|
137
|
-
queueLimit: 0
|
|
137
|
+
queueLimit: 0,
|
|
138
|
+
enableKeepAlive: true,
|
|
139
|
+
keepAliveInitialDelay: 0
|
|
138
140
|
});
|
|
139
141
|
```
|
|
140
142
|
The pool does not create all connections upfront but creates them on demand until the connection limit is reached.
|
package/index.d.ts
CHANGED
|
@@ -78,6 +78,7 @@ export interface Connection extends mysql.Connection {
|
|
|
78
78
|
writeEof(warnings?: number, statusFlags?: number): void;
|
|
79
79
|
writeTextResult(rows?: Array<any>, columns?: Array<any>): void;
|
|
80
80
|
writePacket(packet: any): void;
|
|
81
|
+
promise(promiseImpl?: PromiseConstructor): PromiseConnection;
|
|
81
82
|
sequenceId: number;
|
|
82
83
|
}
|
|
83
84
|
|
|
@@ -157,7 +158,7 @@ export interface Pool extends mysql.Connection {
|
|
|
157
158
|
on(event: 'enqueue', listener: () => any): this;
|
|
158
159
|
unprepare(sql: string): mysql.PrepareStatementInfo;
|
|
159
160
|
prepare(sql: string, callback?: (err: mysql.QueryError | null, statement: mysql.PrepareStatementInfo) => any): mysql.Prepare;
|
|
160
|
-
|
|
161
|
+
promise(promiseImpl?: PromiseConstructor): PromisePoolConnection;
|
|
161
162
|
config: mysql.PoolOptions;
|
|
162
163
|
}
|
|
163
164
|
|
package/lib/connection.js
CHANGED
|
@@ -22,7 +22,7 @@ const EventEmitter = require('events').EventEmitter;
|
|
|
22
22
|
const Readable = require('stream').Readable;
|
|
23
23
|
const Queue = require('denque');
|
|
24
24
|
const SqlString = require('sqlstring');
|
|
25
|
-
const LRU = require('lru-cache');
|
|
25
|
+
const LRU = require('lru-cache').default;
|
|
26
26
|
|
|
27
27
|
const PacketParser = require('./packet_parser.js');
|
|
28
28
|
const Packets = require('./packets/index.js');
|
|
@@ -52,9 +52,10 @@ class Connection extends EventEmitter {
|
|
|
52
52
|
opts.config.host
|
|
53
53
|
);
|
|
54
54
|
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
// Optionally enable keep-alive on the socket.
|
|
56
|
+
if (this.config.enableKeepAlive) {
|
|
57
|
+
this.stream.setKeepAlive(true, this.config.keepAliveInitialDelay);
|
|
58
|
+
}
|
|
58
59
|
|
|
59
60
|
// Enable TCP_NODELAY flag. This is needed so that the network packets
|
|
60
61
|
// are sent immediately to the server
|
package/lib/connection_config.js
CHANGED
|
@@ -115,7 +115,7 @@ class ConnectionConfig {
|
|
|
115
115
|
this.debug = options.debug;
|
|
116
116
|
this.trace = options.trace !== false;
|
|
117
117
|
this.stringifyObjects = options.stringifyObjects || false;
|
|
118
|
-
this.enableKeepAlive =
|
|
118
|
+
this.enableKeepAlive = options.enableKeepAlive !== false;
|
|
119
119
|
this.keepAliveInitialDelay = options.keepAliveInitialDelay || 0;
|
|
120
120
|
if (
|
|
121
121
|
options.timezone &&
|
package/package.json
CHANGED
package/promise.d.ts
CHANGED
|
@@ -84,6 +84,7 @@ export interface Connection extends EventEmitter {
|
|
|
84
84
|
|
|
85
85
|
export interface PoolConnection extends Connection {
|
|
86
86
|
connection: Connection;
|
|
87
|
+
getConnection(): Promise<PoolConnection>;
|
|
87
88
|
release(): void;
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -153,6 +154,3 @@ export interface PreparedStatementInfo {
|
|
|
153
154
|
execute(parameters: any[]): Promise<[RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader, FieldPacket[]]>;
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
export interface PromisePoolConnection extends Connection {
|
|
157
|
-
destroy(): any;
|
|
158
|
-
}
|
package/typings/mysql/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ import BasePrepare = require('./lib/protocol/sequences/Prepare');
|
|
|
12
12
|
import {QueryOptions, StreamOptions, QueryError} from './lib/protocol/sequences/Query';
|
|
13
13
|
import {PrepareStatementInfo} from './lib/protocol/sequences/Prepare';
|
|
14
14
|
import Server = require('./lib/Server');
|
|
15
|
-
import { Pool as PromisePool } from '../../promise';
|
|
15
|
+
import { Pool as PromisePool, Connection as PromiseConnection } from '../../promise';
|
|
16
16
|
|
|
17
17
|
export function createConnection(connectionUri: string): Connection;
|
|
18
18
|
export function createConnection(config: BaseConnection.ConnectionOptions): Connection;
|
|
@@ -41,7 +41,7 @@ export * from './lib/protocol/packets/index';
|
|
|
41
41
|
|
|
42
42
|
// Expose class interfaces
|
|
43
43
|
export interface Connection extends BaseConnection {
|
|
44
|
-
promise(promiseImpl?: PromiseConstructor):
|
|
44
|
+
promise(promiseImpl?: PromiseConstructor): PromiseConnection;
|
|
45
45
|
}
|
|
46
46
|
export interface PoolConnection extends BasePoolConnection {}
|
|
47
47
|
export interface Pool extends BasePool {}
|
|
@@ -289,9 +289,11 @@ declare class Connection extends EventEmitter {
|
|
|
289
289
|
|
|
290
290
|
rollback(callback: (err: Query.QueryError | null) => void): void;
|
|
291
291
|
|
|
292
|
-
execute(sql: string, callback?: (err:
|
|
292
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(sql: string, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
293
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(sql: string, values: any | any[] | { [param: string]: any }, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
294
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(options: Query.QueryOptions, callback?: (err: Query.QueryError | null, result: T, fields?: FieldPacket[]) => any): Query;
|
|
295
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(options: Query.QueryOptions, values: any | any[] | { [param: string]: any }, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
293
296
|
|
|
294
|
-
execute(sql: string, values: any | any[] | { [param: string]: any }, callback?: (err: any, rows: Array<any>, fields: Array<any>) => any): any;
|
|
295
297
|
|
|
296
298
|
unprepare(sql: string): any;
|
|
297
299
|
|
|
@@ -4,6 +4,7 @@ import {OkPacket, RowDataPacket, FieldPacket, ResultSetHeader} from './protocol/
|
|
|
4
4
|
import Connection = require('./Connection');
|
|
5
5
|
import PoolConnection = require('./PoolConnection');
|
|
6
6
|
import {EventEmitter} from 'events';
|
|
7
|
+
import {PoolConnection as PromisePoolConnection} from '../../../promise';
|
|
7
8
|
|
|
8
9
|
declare namespace Pool {
|
|
9
10
|
|
|
@@ -43,13 +44,12 @@ declare namespace Pool {
|
|
|
43
44
|
queueLimit?: number;
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* Enable keep-alive on the socket.
|
|
47
|
-
* user can enable it and supply an initial delay.
|
|
47
|
+
* Enable keep-alive on the socket. (Default: true)
|
|
48
48
|
*/
|
|
49
49
|
enableKeepAlive?: boolean;
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* If keep-alive is enabled users can supply an initial delay.
|
|
52
|
+
* If keep-alive is enabled users can supply an initial delay. (Default: 0)
|
|
53
53
|
*/
|
|
54
54
|
keepAliveInitialDelay?: number;
|
|
55
55
|
}
|
|
@@ -66,12 +66,17 @@ declare class Pool extends EventEmitter {
|
|
|
66
66
|
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(options: Query.QueryOptions, callback?: (err: Query.QueryError | null, result: T, fields?: FieldPacket[]) => any): Query;
|
|
67
67
|
query<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(options: Query.QueryOptions, values: any | any[] | { [param: string]: any }, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
68
68
|
|
|
69
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(sql: string, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
70
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(sql: string, values: any | any[] | { [param: string]: any }, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
71
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(options: Query.QueryOptions, callback?: (err: Query.QueryError | null, result: T, fields?: FieldPacket[]) => any): Query;
|
|
72
|
+
execute<T extends RowDataPacket[][] | RowDataPacket[] | OkPacket | OkPacket[] | ResultSetHeader>(options: Query.QueryOptions, values: any | any[] | { [param: string]: any }, callback?: (err: Query.QueryError | null, result: T, fields: FieldPacket[]) => any): Query;
|
|
73
|
+
|
|
69
74
|
end(callback?: (err: NodeJS.ErrnoException | null, ...args: any[]) => any): void;
|
|
70
75
|
|
|
71
76
|
on(event: string, listener: Function): this;
|
|
72
77
|
on(event: 'connection', listener: (connection: PoolConnection) => any): this;
|
|
73
78
|
|
|
74
|
-
promise(promiseImpl?:
|
|
79
|
+
promise(promiseImpl?: PromiseConstructor): PromisePoolConnection;
|
|
75
80
|
}
|
|
76
81
|
|
|
77
82
|
export = Pool;
|