oceanbase 0.0.1
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/License +19 -0
- package/README.md +250 -0
- package/index.d.ts +1 -0
- package/index.js +77 -0
- package/lib/auth_41.js +95 -0
- package/lib/auth_plugins/caching_sha2_password.js +108 -0
- package/lib/auth_plugins/caching_sha2_password.md +18 -0
- package/lib/auth_plugins/index.js +8 -0
- package/lib/auth_plugins/mysql_clear_password.js +17 -0
- package/lib/auth_plugins/mysql_native_password.js +34 -0
- package/lib/auth_plugins/sha256_password.js +68 -0
- package/lib/base/connection.js +978 -0
- package/lib/base/pool.js +237 -0
- package/lib/base/pool_connection.js +70 -0
- package/lib/commands/auth_switch.js +111 -0
- package/lib/commands/binlog_dump.js +109 -0
- package/lib/commands/change_user.js +68 -0
- package/lib/commands/client_handshake.js +241 -0
- package/lib/commands/close_statement.js +18 -0
- package/lib/commands/command.js +54 -0
- package/lib/commands/execute.js +112 -0
- package/lib/commands/index.js +27 -0
- package/lib/commands/ping.js +36 -0
- package/lib/commands/prepare.js +143 -0
- package/lib/commands/query.js +366 -0
- package/lib/commands/quit.js +29 -0
- package/lib/commands/register_slave.js +27 -0
- package/lib/commands/server_handshake.js +203 -0
- package/lib/compressed_protocol.js +127 -0
- package/lib/connection.js +12 -0
- package/lib/connection_config.js +326 -0
- package/lib/constants/charset_encodings.js +316 -0
- package/lib/constants/charsets.js +317 -0
- package/lib/constants/client.js +40 -0
- package/lib/constants/commands.js +36 -0
- package/lib/constants/cursor.js +8 -0
- package/lib/constants/encoding_charset.js +50 -0
- package/lib/constants/errors.js +3973 -0
- package/lib/constants/field_flags.js +20 -0
- package/lib/constants/server_status.js +44 -0
- package/lib/constants/session_track.js +11 -0
- package/lib/constants/ssl_profiles.js +11 -0
- package/lib/constants/types.js +64 -0
- package/lib/create_connection.js +10 -0
- package/lib/create_pool.js +10 -0
- package/lib/create_pool_cluster.js +9 -0
- package/lib/helpers.js +86 -0
- package/lib/packet_parser.js +195 -0
- package/lib/packets/auth_next_factor.js +35 -0
- package/lib/packets/auth_switch_request.js +38 -0
- package/lib/packets/auth_switch_request_more_data.js +33 -0
- package/lib/packets/auth_switch_response.js +30 -0
- package/lib/packets/binary_row.js +95 -0
- package/lib/packets/binlog_dump.js +33 -0
- package/lib/packets/binlog_query_statusvars.js +115 -0
- package/lib/packets/change_user.js +97 -0
- package/lib/packets/close_statement.js +21 -0
- package/lib/packets/column_definition.js +291 -0
- package/lib/packets/execute.js +214 -0
- package/lib/packets/handshake.js +112 -0
- package/lib/packets/handshake_response.js +144 -0
- package/lib/packets/index.js +152 -0
- package/lib/packets/packet.js +931 -0
- package/lib/packets/prepare_statement.js +27 -0
- package/lib/packets/prepared_statement_header.js +16 -0
- package/lib/packets/query.js +27 -0
- package/lib/packets/register_slave.js +46 -0
- package/lib/packets/resultset_header.js +124 -0
- package/lib/packets/ssl_request.js +25 -0
- package/lib/packets/text_row.js +47 -0
- package/lib/parsers/binary_parser.js +235 -0
- package/lib/parsers/parser_cache.js +68 -0
- package/lib/parsers/static_binary_parser.js +213 -0
- package/lib/parsers/static_text_parser.js +152 -0
- package/lib/parsers/string.js +50 -0
- package/lib/parsers/text_parser.js +214 -0
- package/lib/pool.js +12 -0
- package/lib/pool_cluster.js +369 -0
- package/lib/pool_config.js +30 -0
- package/lib/pool_connection.js +12 -0
- package/lib/promise/connection.js +222 -0
- package/lib/promise/inherit_events.js +27 -0
- package/lib/promise/make_done_cb.js +19 -0
- package/lib/promise/pool.js +112 -0
- package/lib/promise/pool_cluster.js +54 -0
- package/lib/promise/pool_connection.js +19 -0
- package/lib/promise/prepared_statement_info.js +32 -0
- package/lib/results_stream.js +38 -0
- package/lib/server.js +37 -0
- package/package.json +80 -0
- package/promise.d.ts +131 -0
- package/promise.js +202 -0
- package/typings/mysql/LICENSE.txt +15 -0
- package/typings/mysql/index.d.ts +95 -0
- package/typings/mysql/info.txt +1 -0
- package/typings/mysql/lib/Auth.d.ts +30 -0
- package/typings/mysql/lib/Connection.d.ts +453 -0
- package/typings/mysql/lib/Pool.d.ts +69 -0
- package/typings/mysql/lib/PoolCluster.d.ts +90 -0
- package/typings/mysql/lib/PoolConnection.d.ts +10 -0
- package/typings/mysql/lib/Server.d.ts +11 -0
- package/typings/mysql/lib/constants/CharsetToEncoding.d.ts +8 -0
- package/typings/mysql/lib/constants/Charsets.d.ts +326 -0
- package/typings/mysql/lib/constants/Types.d.ts +70 -0
- package/typings/mysql/lib/constants/index.d.ts +5 -0
- package/typings/mysql/lib/parsers/ParserCache.d.ts +4 -0
- package/typings/mysql/lib/parsers/index.d.ts +18 -0
- package/typings/mysql/lib/parsers/typeCast.d.ts +54 -0
- package/typings/mysql/lib/protocol/packets/Field.d.ts +10 -0
- package/typings/mysql/lib/protocol/packets/FieldPacket.d.ts +27 -0
- package/typings/mysql/lib/protocol/packets/OkPacket.d.ts +23 -0
- package/typings/mysql/lib/protocol/packets/ProcedurePacket.d.ts +13 -0
- package/typings/mysql/lib/protocol/packets/ResultSetHeader.d.ts +18 -0
- package/typings/mysql/lib/protocol/packets/RowDataPacket.d.ts +9 -0
- package/typings/mysql/lib/protocol/packets/index.d.ts +28 -0
- package/typings/mysql/lib/protocol/packets/params/ErrorPacketParams.d.ts +6 -0
- package/typings/mysql/lib/protocol/packets/params/OkPacketParams.d.ts +9 -0
- package/typings/mysql/lib/protocol/sequences/ExecutableBase.d.ts +40 -0
- package/typings/mysql/lib/protocol/sequences/Prepare.d.ts +65 -0
- package/typings/mysql/lib/protocol/sequences/Query.d.ts +170 -0
- package/typings/mysql/lib/protocol/sequences/QueryableBase.d.ts +40 -0
- package/typings/mysql/lib/protocol/sequences/Sequence.d.ts +5 -0
- package/typings/mysql/lib/protocol/sequences/promise/ExecutableBase.d.ts +21 -0
- package/typings/mysql/lib/protocol/sequences/promise/QueryableBase.d.ts +21 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Sequence } from './Sequence.js';
|
|
2
|
+
import { Query, QueryError, StreamOptions } from '../sequences/Query.js';
|
|
3
|
+
import {
|
|
4
|
+
OkPacket,
|
|
5
|
+
FieldPacket,
|
|
6
|
+
RowDataPacket,
|
|
7
|
+
ResultSetHeader,
|
|
8
|
+
} from '../packets/index.js';
|
|
9
|
+
import { Readable } from 'stream';
|
|
10
|
+
|
|
11
|
+
export class PrepareStatementInfo {
|
|
12
|
+
close(): void;
|
|
13
|
+
execute<
|
|
14
|
+
T extends
|
|
15
|
+
| RowDataPacket[][]
|
|
16
|
+
| RowDataPacket[]
|
|
17
|
+
| OkPacket
|
|
18
|
+
| OkPacket[]
|
|
19
|
+
| ResultSetHeader,
|
|
20
|
+
>(
|
|
21
|
+
parameters: any | any[] | { [param: string]: any },
|
|
22
|
+
callback?: (err: QueryError | null, result: T, fields: FieldPacket[]) => any
|
|
23
|
+
): Query;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class Prepare extends Sequence {
|
|
27
|
+
/**
|
|
28
|
+
* The SQL for a constructed query
|
|
29
|
+
*/
|
|
30
|
+
sql: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Emits a query packet to start the query
|
|
34
|
+
*/
|
|
35
|
+
start(): void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Determines the packet class to use given the first byte of the packet.
|
|
39
|
+
*
|
|
40
|
+
* @param firstByte The first byte of the packet
|
|
41
|
+
* @param parser The packet parser
|
|
42
|
+
*/
|
|
43
|
+
determinePacket(firstByte: number, parser: any): any;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Creates a Readable stream with the given options
|
|
47
|
+
*
|
|
48
|
+
* @param options The options for the stream.
|
|
49
|
+
*/
|
|
50
|
+
stream(options?: StreamOptions): Readable;
|
|
51
|
+
|
|
52
|
+
on(event: string, listener: (args: []) => void): this;
|
|
53
|
+
on(event: 'error', listener: (err: QueryError) => any): this;
|
|
54
|
+
on(
|
|
55
|
+
event: 'fields',
|
|
56
|
+
listener: (fields: FieldPacket, index: number) => any
|
|
57
|
+
): this;
|
|
58
|
+
on(
|
|
59
|
+
event: 'result',
|
|
60
|
+
listener: (result: RowDataPacket | OkPacket, index: number) => any
|
|
61
|
+
): this;
|
|
62
|
+
on(event: 'end', listener: () => any): this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export { Prepare };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Sequence } from './Sequence.js';
|
|
2
|
+
import { OkPacket, RowDataPacket, FieldPacket } from '../packets/index.js';
|
|
3
|
+
import { Readable } from 'stream';
|
|
4
|
+
import { TypeCast } from '../../parsers/typeCast.js';
|
|
5
|
+
|
|
6
|
+
export interface QueryOptions {
|
|
7
|
+
/**
|
|
8
|
+
* The SQL for the query
|
|
9
|
+
*/
|
|
10
|
+
sql: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The values for the query
|
|
14
|
+
*/
|
|
15
|
+
values?: any | any[] | { [param: string]: any };
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This overrides the namedPlaceholders option set at the connection level.
|
|
19
|
+
*/
|
|
20
|
+
namedPlaceholders?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Every operation takes an optional inactivity timeout option. This allows you to specify appropriate timeouts for
|
|
24
|
+
* operations. It is important to note that these timeouts are not part of the MySQL protocol, and rather timeout
|
|
25
|
+
* operations through the client. This means that when a timeout is reached, the connection it occurred on will be
|
|
26
|
+
* destroyed and no further operations can be performed.
|
|
27
|
+
*/
|
|
28
|
+
timeout?: number;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Either a boolean or string. If true, tables will be nested objects. If string (e.g. '_'), tables will be
|
|
32
|
+
* nested as tableName_fieldName
|
|
33
|
+
*/
|
|
34
|
+
nestTables?: any;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Determines if column values should be converted to native JavaScript types.
|
|
38
|
+
*
|
|
39
|
+
* @default true
|
|
40
|
+
*
|
|
41
|
+
* It is not recommended (and may go away / change in the future) to disable type casting, but you can currently do so on either the connection or query level.
|
|
42
|
+
*
|
|
43
|
+
* ---
|
|
44
|
+
*
|
|
45
|
+
* You can also specify a function to do the type casting yourself:
|
|
46
|
+
* ```ts
|
|
47
|
+
* (field: Field, next: () => unknown) => {
|
|
48
|
+
* return next();
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* ---
|
|
53
|
+
*
|
|
54
|
+
* **WARNING:**
|
|
55
|
+
*
|
|
56
|
+
* YOU MUST INVOKE the parser using one of these three field functions in your custom typeCast callback. They can only be called once:
|
|
57
|
+
*
|
|
58
|
+
* ```js
|
|
59
|
+
* field.string();
|
|
60
|
+
* field.buffer();
|
|
61
|
+
* field.geometry();
|
|
62
|
+
* ```
|
|
63
|
+
|
|
64
|
+
* Which are aliases for:
|
|
65
|
+
*
|
|
66
|
+
* ```js
|
|
67
|
+
* parser.parseLengthCodedString();
|
|
68
|
+
* parser.parseLengthCodedBuffer();
|
|
69
|
+
* parser.parseGeometryValue();
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* You can find which field function you need to use by looking at `RowDataPacket.prototype._typeCast`.
|
|
73
|
+
*/
|
|
74
|
+
typeCast?: TypeCast;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This overrides the same option set at the connection level.
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
rowsAsArray?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* By specifying a function that returns a readable stream, an arbitrary stream can be sent when sending a local fs file.
|
|
84
|
+
*/
|
|
85
|
+
infileStreamFactory?: (path: string) => Readable;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface StreamOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Sets the max buffer size in objects of a stream
|
|
91
|
+
*/
|
|
92
|
+
highWaterMark?: number;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The object mode of the stream is always set to `true`
|
|
96
|
+
*/
|
|
97
|
+
objectMode?: true;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface QueryError extends NodeJS.ErrnoException {
|
|
101
|
+
/**
|
|
102
|
+
* Either a MySQL server error (e.g. 'ER_ACCESS_DENIED_ERROR'),
|
|
103
|
+
* a node.js error (e.g. 'ECONNREFUSED') or an internal error
|
|
104
|
+
* (e.g. 'PROTOCOL_CONNECTION_LOST').
|
|
105
|
+
*/
|
|
106
|
+
code: string;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The sql state marker
|
|
110
|
+
*/
|
|
111
|
+
sqlStateMarker?: string;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The sql state
|
|
115
|
+
*/
|
|
116
|
+
sqlState?: string;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The field count
|
|
120
|
+
*/
|
|
121
|
+
fieldCount?: number;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Boolean, indicating if this error is terminal to the connection object.
|
|
125
|
+
*/
|
|
126
|
+
fatal: boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare class Query extends Sequence {
|
|
130
|
+
/**
|
|
131
|
+
* The SQL for a constructed query
|
|
132
|
+
*/
|
|
133
|
+
sql: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Emits a query packet to start the query
|
|
137
|
+
*/
|
|
138
|
+
start(): void;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Determines the packet class to use given the first byte of the packet.
|
|
142
|
+
*
|
|
143
|
+
* @param firstByte The first byte of the packet
|
|
144
|
+
* @param parser The packet parser
|
|
145
|
+
*/
|
|
146
|
+
determinePacket(firstByte: number, parser: any): any;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Creates a Readable stream with the given options
|
|
150
|
+
*
|
|
151
|
+
* @param options The options for the stream.
|
|
152
|
+
*/
|
|
153
|
+
stream(options?: StreamOptions): Readable;
|
|
154
|
+
|
|
155
|
+
on(event: string, listener: (...args: any[]) => void): this;
|
|
156
|
+
on(event: 'error', listener: (err: QueryError) => any): this;
|
|
157
|
+
on(
|
|
158
|
+
event: 'fields',
|
|
159
|
+
listener: (fields: FieldPacket, index: number) => any
|
|
160
|
+
): this;
|
|
161
|
+
on(
|
|
162
|
+
event: 'result',
|
|
163
|
+
listener: (result: RowDataPacket | OkPacket, index: number) => any
|
|
164
|
+
): this;
|
|
165
|
+
on(event: 'end', listener: () => any): this;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export type QueryableConstructor<T = object> = new (...args: any[]) => T;
|
|
169
|
+
|
|
170
|
+
export { Query };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FieldPacket, QueryResult } from '../packets/index.js';
|
|
2
|
+
import {
|
|
3
|
+
Query,
|
|
4
|
+
QueryError,
|
|
5
|
+
QueryOptions,
|
|
6
|
+
QueryableConstructor,
|
|
7
|
+
} from './Query.js';
|
|
8
|
+
|
|
9
|
+
export declare function QueryableBase<T extends QueryableConstructor>(
|
|
10
|
+
Base?: T
|
|
11
|
+
): {
|
|
12
|
+
new (...args: any[]): {
|
|
13
|
+
query<T extends QueryResult>(
|
|
14
|
+
sql: string,
|
|
15
|
+
callback?:
|
|
16
|
+
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
|
|
17
|
+
| undefined
|
|
18
|
+
): Query;
|
|
19
|
+
query<T extends QueryResult>(
|
|
20
|
+
sql: string,
|
|
21
|
+
values: any,
|
|
22
|
+
callback?:
|
|
23
|
+
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
|
|
24
|
+
| undefined
|
|
25
|
+
): Query;
|
|
26
|
+
query<T extends QueryResult>(
|
|
27
|
+
options: QueryOptions,
|
|
28
|
+
callback?:
|
|
29
|
+
| ((err: QueryError | null, result: T, fields?: FieldPacket[]) => any)
|
|
30
|
+
| undefined
|
|
31
|
+
): Query;
|
|
32
|
+
query<T extends QueryResult>(
|
|
33
|
+
options: QueryOptions,
|
|
34
|
+
values: any,
|
|
35
|
+
callback?:
|
|
36
|
+
| ((err: QueryError | null, result: T, fields: FieldPacket[]) => any)
|
|
37
|
+
| undefined
|
|
38
|
+
): Query;
|
|
39
|
+
};
|
|
40
|
+
} & T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FieldPacket, QueryResult } from '../../packets/index.js';
|
|
2
|
+
import { QueryOptions, QueryableConstructor } from '../Query.js';
|
|
3
|
+
|
|
4
|
+
export declare function ExecutableBase<T extends QueryableConstructor>(
|
|
5
|
+
Base?: T
|
|
6
|
+
): {
|
|
7
|
+
new (...args: any[]): {
|
|
8
|
+
execute<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
|
|
9
|
+
execute<T extends QueryResult>(
|
|
10
|
+
sql: string,
|
|
11
|
+
values: any
|
|
12
|
+
): Promise<[T, FieldPacket[]]>;
|
|
13
|
+
execute<T extends QueryResult>(
|
|
14
|
+
options: QueryOptions
|
|
15
|
+
): Promise<[T, FieldPacket[]]>;
|
|
16
|
+
execute<T extends QueryResult>(
|
|
17
|
+
options: QueryOptions,
|
|
18
|
+
values: any
|
|
19
|
+
): Promise<[T, FieldPacket[]]>;
|
|
20
|
+
};
|
|
21
|
+
} & T;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FieldPacket, QueryResult } from '../../packets/index.js';
|
|
2
|
+
import { QueryOptions, QueryableConstructor } from '../Query.js';
|
|
3
|
+
|
|
4
|
+
export declare function QueryableBase<T extends QueryableConstructor>(
|
|
5
|
+
Base?: T
|
|
6
|
+
): {
|
|
7
|
+
new (...args: any[]): {
|
|
8
|
+
query<T extends QueryResult>(sql: string): Promise<[T, FieldPacket[]]>;
|
|
9
|
+
query<T extends QueryResult>(
|
|
10
|
+
sql: string,
|
|
11
|
+
values: any
|
|
12
|
+
): Promise<[T, FieldPacket[]]>;
|
|
13
|
+
query<T extends QueryResult>(
|
|
14
|
+
options: QueryOptions
|
|
15
|
+
): Promise<[T, FieldPacket[]]>;
|
|
16
|
+
query<T extends QueryResult>(
|
|
17
|
+
options: QueryOptions,
|
|
18
|
+
values: any
|
|
19
|
+
): Promise<[T, FieldPacket[]]>;
|
|
20
|
+
};
|
|
21
|
+
} & T;
|