node-firebird 2.3.3 → 2.4.0
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 +544 -6
- package/lib/callback.d.ts +20 -0
- package/lib/callback.js +6 -16
- package/lib/firebird.msg.json +1370 -1370
- package/lib/gdscodes.d.ts +1519 -1520
- package/lib/gdscodes.js +5 -5
- package/lib/ieee754-decimal.d.ts +38 -0
- package/lib/ieee754-decimal.js +71 -118
- package/lib/index.d.ts +37 -338
- package/lib/index.js +97 -86
- package/lib/messages.d.ts +6 -0
- package/lib/messages.js +135 -162
- package/lib/pool.d.ts +23 -0
- package/lib/pool.js +34 -47
- package/lib/srp.d.ts +51 -0
- package/lib/srp.js +62 -72
- package/lib/types.d.ts +375 -0
- package/lib/types.js +22 -0
- package/lib/unix-crypt.d.ts +1 -0
- package/lib/unix-crypt.js +126 -152
- package/lib/utils.d.ts +16 -0
- package/lib/utils.js +24 -48
- package/lib/wire/connection.d.ts +100 -0
- package/lib/wire/connection.js +1029 -1009
- package/lib/wire/const.d.ts +567 -0
- package/lib/wire/const.js +620 -599
- package/lib/wire/database.d.ts +57 -0
- package/lib/wire/database.js +111 -108
- package/lib/wire/eventConnection.d.ts +16 -0
- package/lib/wire/eventConnection.js +29 -31
- package/lib/wire/fbEventManager.d.ts +45 -0
- package/lib/wire/fbEventManager.js +38 -57
- package/lib/wire/serialize.d.ts +97 -0
- package/lib/wire/serialize.js +42 -141
- package/lib/wire/service.d.ts +66 -0
- package/lib/wire/service.js +374 -401
- package/lib/wire/socket.d.ts +59 -0
- package/lib/wire/socket.js +79 -40
- package/lib/wire/statement.d.ts +25 -0
- package/lib/wire/statement.js +13 -9
- package/lib/wire/transaction.d.ts +21 -0
- package/lib/wire/transaction.js +33 -61
- package/lib/wire/xsqlvar.d.ts +175 -0
- package/lib/wire/xsqlvar.js +169 -269
- package/package.json +12 -4
- package/src/callback.ts +55 -0
- package/{poc/node_modules/node-firebird/lib/gdscodes.js → src/gdscodes.ts} +3 -3
- package/{poc/node_modules/node-firebird/lib/ieee754-decimal.js → src/ieee754-decimal.ts} +7 -14
- package/src/index.ts +157 -0
- package/{poc/node_modules/node-firebird/lib/messages.js → src/messages.ts} +163 -162
- package/src/pool.ts +209 -0
- package/{poc/node_modules/node-firebird/lib/srp.js → src/srp.ts} +74 -33
- package/src/types.ts +419 -0
- package/{poc/node_modules/node-firebird/lib/unix-crypt.js → src/unix-crypt.ts} +6 -12
- package/{poc/node_modules/node-firebird/lib/utils.js → src/utils.ts} +11 -20
- package/{poc/node_modules/node-firebird/lib/wire/connection.js → src/wire/connection.ts} +611 -129
- package/{poc/node_modules/node-firebird/lib/wire/const.js → src/wire/const.ts} +96 -9
- package/{poc/node_modules/node-firebird/lib/wire/database.js → src/wire/database.ts} +110 -44
- package/{poc/node_modules/node-firebird/lib/wire/eventConnection.js → src/wire/eventConnection.ts} +29 -14
- package/{poc/node_modules/node-firebird/lib/wire/fbEventManager.js → src/wire/fbEventManager.ts} +39 -30
- package/{poc/node_modules/node-firebird/lib/wire/serialize.js → src/wire/serialize.ts} +78 -59
- package/{poc/node_modules/node-firebird/lib/wire/service.js → src/wire/service.ts} +90 -88
- package/src/wire/socket.ts +262 -0
- package/src/wire/statement.ts +71 -0
- package/{poc/node_modules/node-firebird/lib/wire/transaction.js → src/wire/transaction.ts} +25 -19
- package/{poc/node_modules/node-firebird/lib/wire/xsqlvar.js → src/wire/xsqlvar.ts} +244 -143
- package/.eslintrc.json +0 -12
- package/.github/workflows/codeql.yml +0 -76
- package/.github/workflows/node.js.yml +0 -95
- package/BIGINT_MIGRATION.md +0 -374
- package/CI_DEBUGGING_GUIDE.md +0 -148
- package/ENCRYPTION_CALLBACK.md +0 -152
- package/FIREBIRD_LOG_FEATURE.md +0 -145
- package/MINIMAL_CHANGES_SUMMARY.md +0 -136
- package/PR_SUMMARY.md +0 -96
- package/ROADMAP.md +0 -223
- package/SRP_PROTOCOL.md +0 -482
- package/poc/README.md +0 -160
- package/poc/helpers.js +0 -59
- package/poc/node_modules/.package-lock.json +0 -14
- package/poc/node_modules/node-firebird/.eslintrc.json +0 -12
- package/poc/node_modules/node-firebird/.github/workflows/codeql.yml +0 -76
- package/poc/node_modules/node-firebird/.github/workflows/node.js.yml +0 -95
- package/poc/node_modules/node-firebird/BIGINT_MIGRATION.md +0 -374
- package/poc/node_modules/node-firebird/CI_DEBUGGING_GUIDE.md +0 -148
- package/poc/node_modules/node-firebird/ENCRYPTION_CALLBACK.md +0 -152
- package/poc/node_modules/node-firebird/FIREBIRD_LOG_FEATURE.md +0 -145
- package/poc/node_modules/node-firebird/LICENSE +0 -373
- package/poc/node_modules/node-firebird/MINIMAL_CHANGES_SUMMARY.md +0 -136
- package/poc/node_modules/node-firebird/PR_SUMMARY.md +0 -96
- package/poc/node_modules/node-firebird/README.md +0 -794
- package/poc/node_modules/node-firebird/ROADMAP.md +0 -223
- package/poc/node_modules/node-firebird/SRP_PROTOCOL.md +0 -482
- package/poc/node_modules/node-firebird/lib/callback.js +0 -38
- package/poc/node_modules/node-firebird/lib/gdscodes.d.ts +0 -1524
- package/poc/node_modules/node-firebird/lib/index.d.ts +0 -316
- package/poc/node_modules/node-firebird/lib/index.js +0 -128
- package/poc/node_modules/node-firebird/lib/pool.js +0 -108
- package/poc/node_modules/node-firebird/lib/wire/socket.js +0 -175
- package/poc/node_modules/node-firebird/lib/wire/statement.js +0 -48
- package/poc/node_modules/node-firebird/package.json +0 -38
- package/poc/node_modules/node-firebird/vitest.config.js +0 -24
- package/poc/package-lock.json +0 -21
- package/poc/package.json +0 -12
- package/poc/reproduce-fixed.js +0 -150
- package/poc/reproduce.js +0 -133
- package/vitest.config.js +0 -27
- /package/{poc/node_modules/node-firebird/lib → src}/firebird.msg +0 -0
- /package/{poc/node_modules/node-firebird/lib → src}/firebird.msg.json +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import Const from './const';
|
|
2
|
+
import type { XdrReader, XdrWriter, BlrWriter } from './serialize';
|
|
2
3
|
|
|
3
4
|
/***************************************
|
|
4
5
|
*
|
|
@@ -13,17 +14,105 @@ const
|
|
|
13
14
|
TimeCoeff = 86400000,
|
|
14
15
|
MsPerMinute = 60000;
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Maps Firebird character-set names (upper-case) to the Node.js Buffer
|
|
19
|
+
* encoding string used by Buffer.toString() / Buffer.from().
|
|
20
|
+
*
|
|
21
|
+
* Firebird stores CHAR/VARCHAR data in the on-wire character set of the
|
|
22
|
+
* column (or the connection character set for NONE/unspecified columns).
|
|
23
|
+
* We must decode raw bytes with the matching Node.js encoding so that
|
|
24
|
+
* characters outside ASCII are reproduced correctly.
|
|
25
|
+
*
|
|
26
|
+
* Commonly used Firebird charsets not listed here fall back to the
|
|
27
|
+
* connection-level DEFAULT_ENCODING (typically 'utf8').
|
|
28
|
+
*/
|
|
29
|
+
const FirebirdToNodeEncoding = Object.freeze({
|
|
30
|
+
UTF8: 'utf8',
|
|
31
|
+
UNICODE_FSS: 'utf8',
|
|
32
|
+
WIN1252: 'latin1',
|
|
33
|
+
ISO8859_1: 'latin1',
|
|
34
|
+
LATIN1: 'latin1',
|
|
35
|
+
ASCII: 'ascii',
|
|
36
|
+
NONE: 'latin1', // unspecified charset – treat as binary-safe latin1
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const FirebirdCharsetWidths = {
|
|
40
|
+
'UTF8': 4,
|
|
41
|
+
'UNICODE_FSS': 3,
|
|
42
|
+
'SJIS': 2,
|
|
43
|
+
'EUCJ': 2
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function getFirebirdCharsetWidth(charset?: string): number {
|
|
47
|
+
if (!charset) return 4;
|
|
48
|
+
const upper = charset.toUpperCase();
|
|
49
|
+
return FirebirdCharsetWidths[upper] || 1;
|
|
50
|
+
}
|
|
17
51
|
|
|
18
|
-
|
|
19
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the Node.js Buffer encoding to use when decoding text from a
|
|
54
|
+
* Firebird response buffer.
|
|
55
|
+
*
|
|
56
|
+
* @param {object|null} options Connection options object (may be falsy).
|
|
57
|
+
* @returns {string} A Node.js-compatible encoding string.
|
|
58
|
+
*/
|
|
59
|
+
function resolveTextEncoding(options?: any): BufferEncoding {
|
|
60
|
+
const encoding = (options && options.encoding)
|
|
61
|
+
? options.encoding.toUpperCase()
|
|
62
|
+
: Const.DEFAULT_ENCODING;
|
|
63
|
+
return (FirebirdToNodeEncoding[encoding] || Const.DEFAULT_ENCODING.toLowerCase()) as BufferEncoding;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//------------------------------------------------------
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Common shape of all SQLVar descriptor objects. The metadata properties
|
|
70
|
+
* are populated externally (in connection.ts) from the op_prepare_statement
|
|
71
|
+
* describe response before decode()/calcBlr() are called.
|
|
72
|
+
*/
|
|
73
|
+
export abstract class SQLVarBase {
|
|
74
|
+
type: number;
|
|
75
|
+
subType: number;
|
|
76
|
+
scale: number;
|
|
77
|
+
length: number;
|
|
78
|
+
nullable: boolean;
|
|
79
|
+
field?: string;
|
|
80
|
+
relation?: string;
|
|
81
|
+
relationSchema?: string;
|
|
82
|
+
alias?: string;
|
|
83
|
+
relationAlias?: string;
|
|
84
|
+
owner?: string;
|
|
85
|
+
charSetId?: number;
|
|
86
|
+
collationId?: number;
|
|
87
|
+
|
|
88
|
+
abstract decode(data: XdrReader, lowerV13: boolean, options?: any): any;
|
|
89
|
+
abstract calcBlr(blr: BlrWriter): void;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//------------------------------------------------------
|
|
93
|
+
|
|
94
|
+
export class SQLVarText extends SQLVarBase {
|
|
95
|
+
decode(data: XdrReader, lowerV13: boolean, options?: any) {
|
|
20
96
|
let ret;
|
|
97
|
+
const textEncoding = resolveTextEncoding(options);
|
|
21
98
|
if (this.subType > 1) {
|
|
22
99
|
// ToDo: with column charset
|
|
23
|
-
ret = data.readText(this.length,
|
|
100
|
+
ret = data.readText(this.length, textEncoding);
|
|
101
|
+
const encoding = options && options.encoding ? options.encoding : 'UTF8';
|
|
102
|
+
const width = getFirebirdCharsetWidth(encoding);
|
|
103
|
+
const charLength = Math.floor(this.length / width);
|
|
104
|
+
if (ret.length > charLength) {
|
|
105
|
+
ret = ret.substring(0, charLength);
|
|
106
|
+
}
|
|
24
107
|
} else if (this.subType === 0) {
|
|
25
108
|
// without charset definition
|
|
26
|
-
ret = data.readText(this.length,
|
|
109
|
+
ret = data.readText(this.length, textEncoding);
|
|
110
|
+
const encoding = options && options.encoding ? options.encoding : 'UTF8';
|
|
111
|
+
const width = getFirebirdCharsetWidth(encoding);
|
|
112
|
+
const charLength = Math.floor(this.length / width);
|
|
113
|
+
if (ret.length > charLength) {
|
|
114
|
+
ret = ret.substring(0, charLength);
|
|
115
|
+
}
|
|
27
116
|
} else {
|
|
28
117
|
ret = data.readBuffer(this.length);
|
|
29
118
|
}
|
|
@@ -35,7 +124,7 @@ class SQLVarText {
|
|
|
35
124
|
return null;
|
|
36
125
|
}
|
|
37
126
|
|
|
38
|
-
calcBlr(blr) {
|
|
127
|
+
calcBlr(blr: BlrWriter): void {
|
|
39
128
|
blr.addByte(Const.blr_text);
|
|
40
129
|
blr.addWord(this.length);
|
|
41
130
|
}
|
|
@@ -43,20 +132,21 @@ class SQLVarText {
|
|
|
43
132
|
|
|
44
133
|
//------------------------------------------------------
|
|
45
134
|
|
|
46
|
-
class SQLVarNull extends SQLVarText {
|
|
135
|
+
export class SQLVarNull extends SQLVarText {
|
|
47
136
|
}
|
|
48
137
|
|
|
49
138
|
//------------------------------------------------------
|
|
50
139
|
|
|
51
|
-
class SQLVarString {
|
|
52
|
-
decode(data, lowerV13) {
|
|
140
|
+
export class SQLVarString extends SQLVarBase {
|
|
141
|
+
decode(data: XdrReader, lowerV13: boolean, options?: any) {
|
|
53
142
|
let ret;
|
|
143
|
+
const textEncoding = resolveTextEncoding(options);
|
|
54
144
|
if (this.subType > 1) {
|
|
55
145
|
// ToDo: with column charset
|
|
56
|
-
ret = data.readString(
|
|
146
|
+
ret = data.readString(textEncoding);
|
|
57
147
|
} else if (this.subType === 0) {
|
|
58
148
|
// without charset definition
|
|
59
|
-
ret = data.readString(
|
|
149
|
+
ret = data.readString(textEncoding);
|
|
60
150
|
} else {
|
|
61
151
|
ret = data.readBuffer();
|
|
62
152
|
}
|
|
@@ -68,7 +158,7 @@ class SQLVarString {
|
|
|
68
158
|
return null;
|
|
69
159
|
}
|
|
70
160
|
|
|
71
|
-
calcBlr(blr) {
|
|
161
|
+
calcBlr(blr: BlrWriter): void {
|
|
72
162
|
blr.addByte(Const.blr_varying);
|
|
73
163
|
blr.addWord(this.length);
|
|
74
164
|
}
|
|
@@ -76,8 +166,8 @@ class SQLVarString {
|
|
|
76
166
|
|
|
77
167
|
//------------------------------------------------------
|
|
78
168
|
|
|
79
|
-
class SQLVarQuad {
|
|
80
|
-
decode(data, lowerV13) {
|
|
169
|
+
export class SQLVarQuad extends SQLVarBase {
|
|
170
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
81
171
|
var ret = data.readQuad();
|
|
82
172
|
|
|
83
173
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -86,7 +176,7 @@ class SQLVarQuad {
|
|
|
86
176
|
return null;
|
|
87
177
|
}
|
|
88
178
|
|
|
89
|
-
calcBlr(blr) {
|
|
179
|
+
calcBlr(blr: BlrWriter): void {
|
|
90
180
|
blr.addByte(Const.blr_quad);
|
|
91
181
|
blr.addShort(this.scale);
|
|
92
182
|
}
|
|
@@ -94,8 +184,8 @@ class SQLVarQuad {
|
|
|
94
184
|
|
|
95
185
|
//------------------------------------------------------
|
|
96
186
|
|
|
97
|
-
class SQLVarBlob extends SQLVarQuad {
|
|
98
|
-
calcBlr(blr) {
|
|
187
|
+
export class SQLVarBlob extends SQLVarQuad {
|
|
188
|
+
calcBlr(blr: BlrWriter): void {
|
|
99
189
|
blr.addByte(Const.blr_quad);
|
|
100
190
|
blr.addShort(0);
|
|
101
191
|
}
|
|
@@ -103,8 +193,8 @@ class SQLVarBlob extends SQLVarQuad {
|
|
|
103
193
|
|
|
104
194
|
//------------------------------------------------------
|
|
105
195
|
|
|
106
|
-
class SQLVarArray extends SQLVarQuad {
|
|
107
|
-
calcBlr(blr) {
|
|
196
|
+
export class SQLVarArray extends SQLVarQuad {
|
|
197
|
+
calcBlr(blr: BlrWriter): void {
|
|
108
198
|
blr.addByte(Const.blr_quad);
|
|
109
199
|
blr.addShort(0);
|
|
110
200
|
}
|
|
@@ -112,8 +202,8 @@ class SQLVarArray extends SQLVarQuad {
|
|
|
112
202
|
|
|
113
203
|
//------------------------------------------------------
|
|
114
204
|
|
|
115
|
-
class SQLVarInt {
|
|
116
|
-
decode(data, lowerV13) {
|
|
205
|
+
export class SQLVarInt extends SQLVarBase {
|
|
206
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
117
207
|
var ret = data.readInt();
|
|
118
208
|
|
|
119
209
|
if (this.scale) {
|
|
@@ -127,7 +217,7 @@ class SQLVarInt {
|
|
|
127
217
|
return null;
|
|
128
218
|
}
|
|
129
219
|
|
|
130
|
-
calcBlr(blr) {
|
|
220
|
+
calcBlr(blr: BlrWriter): void {
|
|
131
221
|
blr.addByte(Const.blr_long);
|
|
132
222
|
blr.addShort(this.scale);
|
|
133
223
|
}
|
|
@@ -135,8 +225,8 @@ class SQLVarInt {
|
|
|
135
225
|
|
|
136
226
|
//------------------------------------------------------
|
|
137
227
|
|
|
138
|
-
class SQLVarShort extends SQLVarInt {
|
|
139
|
-
calcBlr(blr) {
|
|
228
|
+
export class SQLVarShort extends SQLVarInt {
|
|
229
|
+
calcBlr(blr: BlrWriter): void {
|
|
140
230
|
blr.addByte(Const.blr_short);
|
|
141
231
|
blr.addShort(this.scale);
|
|
142
232
|
}
|
|
@@ -144,8 +234,8 @@ class SQLVarShort extends SQLVarInt {
|
|
|
144
234
|
|
|
145
235
|
//------------------------------------------------------
|
|
146
236
|
|
|
147
|
-
class SQLVarInt64 {
|
|
148
|
-
decode(data, lowerV13) {
|
|
237
|
+
export class SQLVarInt64 extends SQLVarBase {
|
|
238
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
149
239
|
var ret = data.readInt64();
|
|
150
240
|
|
|
151
241
|
if (this.scale) {
|
|
@@ -158,7 +248,7 @@ class SQLVarInt64 {
|
|
|
158
248
|
return null;
|
|
159
249
|
}
|
|
160
250
|
|
|
161
|
-
calcBlr(blr) {
|
|
251
|
+
calcBlr(blr: BlrWriter): void {
|
|
162
252
|
blr.addByte(Const.blr_int64);
|
|
163
253
|
blr.addShort(this.scale);
|
|
164
254
|
}
|
|
@@ -166,12 +256,13 @@ class SQLVarInt64 {
|
|
|
166
256
|
|
|
167
257
|
//------------------------------------------------------
|
|
168
258
|
|
|
169
|
-
class SQLVarInt128 {
|
|
170
|
-
decode(data, lowerV13) {
|
|
259
|
+
export class SQLVarInt128 extends SQLVarBase {
|
|
260
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
171
261
|
var retBigInt = BigInt(data.readInt128())
|
|
262
|
+
let ret: string | number;
|
|
172
263
|
|
|
173
264
|
if (retBigInt > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
174
|
-
|
|
265
|
+
ret = retBigInt.toString();
|
|
175
266
|
|
|
176
267
|
var integerPart = ret.slice(0, Math.abs(this.scale) * -1)
|
|
177
268
|
var decimalPart = ret.slice(Math.abs(this.scale) * -1)
|
|
@@ -180,7 +271,7 @@ class SQLVarInt128 {
|
|
|
180
271
|
|
|
181
272
|
ret = `${integerPart}.${decimalPart}`
|
|
182
273
|
} else {
|
|
183
|
-
|
|
274
|
+
ret = Number(retBigInt);
|
|
184
275
|
ret = ret / ScaleDivisor[Math.abs(this.scale)];
|
|
185
276
|
}
|
|
186
277
|
|
|
@@ -191,7 +282,7 @@ class SQLVarInt128 {
|
|
|
191
282
|
return null;
|
|
192
283
|
}
|
|
193
284
|
|
|
194
|
-
calcBlr(blr) {
|
|
285
|
+
calcBlr(blr: BlrWriter): void {
|
|
195
286
|
blr.addByte(Const.blr_int128);
|
|
196
287
|
blr.addShort(this.scale);
|
|
197
288
|
}
|
|
@@ -199,8 +290,8 @@ class SQLVarInt128 {
|
|
|
199
290
|
|
|
200
291
|
//------------------------------------------------------
|
|
201
292
|
|
|
202
|
-
class SQLVarDecFloat16 {
|
|
203
|
-
decode(data, lowerV13) {
|
|
293
|
+
export class SQLVarDecFloat16 extends SQLVarBase {
|
|
294
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
204
295
|
var ret = data.readDecFloat16();
|
|
205
296
|
|
|
206
297
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -210,7 +301,7 @@ class SQLVarDecFloat16 {
|
|
|
210
301
|
return null;
|
|
211
302
|
}
|
|
212
303
|
|
|
213
|
-
calcBlr(blr) {
|
|
304
|
+
calcBlr(blr: BlrWriter): void {
|
|
214
305
|
blr.addByte(Const.blr_dec64);
|
|
215
306
|
blr.addShort(0);
|
|
216
307
|
}
|
|
@@ -218,8 +309,8 @@ class SQLVarDecFloat16 {
|
|
|
218
309
|
|
|
219
310
|
//------------------------------------------------------
|
|
220
311
|
|
|
221
|
-
class SQLVarDecFloat34 {
|
|
222
|
-
decode(data, lowerV13) {
|
|
312
|
+
export class SQLVarDecFloat34 extends SQLVarBase {
|
|
313
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
223
314
|
var ret = data.readDecFloat34();
|
|
224
315
|
|
|
225
316
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -229,7 +320,7 @@ class SQLVarDecFloat34 {
|
|
|
229
320
|
return null;
|
|
230
321
|
}
|
|
231
322
|
|
|
232
|
-
calcBlr(blr) {
|
|
323
|
+
calcBlr(blr: BlrWriter): void {
|
|
233
324
|
blr.addByte(Const.blr_dec128);
|
|
234
325
|
blr.addShort(0);
|
|
235
326
|
}
|
|
@@ -237,8 +328,8 @@ class SQLVarDecFloat34 {
|
|
|
237
328
|
|
|
238
329
|
//------------------------------------------------------
|
|
239
330
|
|
|
240
|
-
class SQLVarFloat {
|
|
241
|
-
decode(data, lowerV13) {
|
|
331
|
+
export class SQLVarFloat extends SQLVarBase {
|
|
332
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
242
333
|
var ret = data.readFloat();
|
|
243
334
|
|
|
244
335
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -248,15 +339,15 @@ class SQLVarFloat {
|
|
|
248
339
|
return null;
|
|
249
340
|
}
|
|
250
341
|
|
|
251
|
-
calcBlr(blr) {
|
|
342
|
+
calcBlr(blr: BlrWriter): void {
|
|
252
343
|
blr.addByte(Const.blr_float);
|
|
253
344
|
}
|
|
254
345
|
}
|
|
255
346
|
|
|
256
347
|
//------------------------------------------------------
|
|
257
348
|
|
|
258
|
-
class SQLVarDouble {
|
|
259
|
-
decode(data, lowerV13) {
|
|
349
|
+
export class SQLVarDouble extends SQLVarBase {
|
|
350
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
260
351
|
var ret = data.readDouble();
|
|
261
352
|
|
|
262
353
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -266,15 +357,15 @@ class SQLVarDouble {
|
|
|
266
357
|
return null;
|
|
267
358
|
}
|
|
268
359
|
|
|
269
|
-
calcBlr(blr) {
|
|
360
|
+
calcBlr(blr: BlrWriter): void {
|
|
270
361
|
blr.addByte(Const.blr_double);
|
|
271
362
|
}
|
|
272
363
|
}
|
|
273
364
|
|
|
274
365
|
//------------------------------------------------------
|
|
275
366
|
|
|
276
|
-
class SQLVarDate {
|
|
277
|
-
decode(data, lowerV13) {
|
|
367
|
+
export class SQLVarDate extends SQLVarBase {
|
|
368
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
278
369
|
var ret = data.readInt();
|
|
279
370
|
|
|
280
371
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -286,15 +377,15 @@ class SQLVarDate {
|
|
|
286
377
|
return null;
|
|
287
378
|
}
|
|
288
379
|
|
|
289
|
-
calcBlr(blr) {
|
|
380
|
+
calcBlr(blr: BlrWriter): void {
|
|
290
381
|
blr.addByte(Const.blr_sql_date);
|
|
291
382
|
}
|
|
292
383
|
}
|
|
293
384
|
|
|
294
385
|
//------------------------------------------------------
|
|
295
386
|
|
|
296
|
-
class SQLVarTime {
|
|
297
|
-
decode(data, lowerV13) {
|
|
387
|
+
export class SQLVarTime extends SQLVarBase {
|
|
388
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
298
389
|
var ret = data.readUInt();
|
|
299
390
|
|
|
300
391
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -305,15 +396,15 @@ class SQLVarTime {
|
|
|
305
396
|
return null;
|
|
306
397
|
}
|
|
307
398
|
|
|
308
|
-
calcBlr(blr) {
|
|
399
|
+
calcBlr(blr: BlrWriter): void {
|
|
309
400
|
blr.addByte(Const.blr_sql_time);
|
|
310
401
|
}
|
|
311
402
|
}
|
|
312
403
|
|
|
313
404
|
//------------------------------------------------------
|
|
314
405
|
|
|
315
|
-
class SQLVarTimeStamp {
|
|
316
|
-
decode(data, lowerV13) {
|
|
406
|
+
export class SQLVarTimeStamp extends SQLVarBase {
|
|
407
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
317
408
|
var date = data.readInt();
|
|
318
409
|
var time = data.readUInt();
|
|
319
410
|
|
|
@@ -326,15 +417,15 @@ class SQLVarTimeStamp {
|
|
|
326
417
|
return null;
|
|
327
418
|
}
|
|
328
419
|
|
|
329
|
-
calcBlr(blr) {
|
|
420
|
+
calcBlr(blr: BlrWriter): void {
|
|
330
421
|
blr.addByte(Const.blr_timestamp);
|
|
331
422
|
}
|
|
332
423
|
}
|
|
333
424
|
|
|
334
425
|
//------------------------------------------------------
|
|
335
426
|
|
|
336
|
-
class SQLVarTimeTz {
|
|
337
|
-
decode(data, lowerV13) {
|
|
427
|
+
export class SQLVarTimeTz extends SQLVarBase {
|
|
428
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
338
429
|
var time = data.readUInt();
|
|
339
430
|
data.readInt(); // skip timezone info
|
|
340
431
|
|
|
@@ -346,15 +437,15 @@ class SQLVarTimeTz {
|
|
|
346
437
|
return null;
|
|
347
438
|
}
|
|
348
439
|
|
|
349
|
-
calcBlr(blr) {
|
|
440
|
+
calcBlr(blr: BlrWriter): void {
|
|
350
441
|
blr.addByte(Const.blr_sql_time_tz);
|
|
351
442
|
}
|
|
352
443
|
}
|
|
353
444
|
|
|
354
445
|
//------------------------------------------------------
|
|
355
446
|
|
|
356
|
-
class SQLVarTimeTzEx extends SQLVarTimeTz {
|
|
357
|
-
decode(data, lowerV13) {
|
|
447
|
+
export class SQLVarTimeTzEx extends SQLVarTimeTz {
|
|
448
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
358
449
|
var time = data.readUInt();
|
|
359
450
|
data.readInt(); // skip timezone info
|
|
360
451
|
data.readInt(); // skip ext_offset
|
|
@@ -367,15 +458,15 @@ class SQLVarTimeTzEx extends SQLVarTimeTz {
|
|
|
367
458
|
return null;
|
|
368
459
|
}
|
|
369
460
|
|
|
370
|
-
calcBlr(blr) {
|
|
461
|
+
calcBlr(blr: BlrWriter): void {
|
|
371
462
|
blr.addByte(Const.blr_ex_time_tz);
|
|
372
463
|
}
|
|
373
464
|
}
|
|
374
465
|
|
|
375
466
|
//------------------------------------------------------
|
|
376
467
|
|
|
377
|
-
class SQLVarTimeStampTz {
|
|
378
|
-
decode(data, lowerV13) {
|
|
468
|
+
export class SQLVarTimeStampTz extends SQLVarBase {
|
|
469
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
379
470
|
var date = data.readInt();
|
|
380
471
|
var time = data.readUInt();
|
|
381
472
|
data.readInt(); // skip timezone info
|
|
@@ -389,15 +480,15 @@ class SQLVarTimeStampTz {
|
|
|
389
480
|
return null;
|
|
390
481
|
}
|
|
391
482
|
|
|
392
|
-
calcBlr(blr) {
|
|
483
|
+
calcBlr(blr: BlrWriter): void {
|
|
393
484
|
blr.addByte(Const.blr_timestamp_tz);
|
|
394
485
|
}
|
|
395
486
|
}
|
|
396
487
|
|
|
397
488
|
//------------------------------------------------------
|
|
398
489
|
|
|
399
|
-
class SQLVarTimeStampTzEx extends SQLVarTimeStampTz {
|
|
400
|
-
decode(data, lowerV13) {
|
|
490
|
+
export class SQLVarTimeStampTzEx extends SQLVarTimeStampTz {
|
|
491
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
401
492
|
var date = data.readInt();
|
|
402
493
|
var time = data.readUInt();
|
|
403
494
|
data.readInt(); // skip timezone info
|
|
@@ -412,15 +503,15 @@ class SQLVarTimeStampTzEx extends SQLVarTimeStampTz {
|
|
|
412
503
|
return null;
|
|
413
504
|
}
|
|
414
505
|
|
|
415
|
-
calcBlr(blr) {
|
|
506
|
+
calcBlr(blr: BlrWriter): void {
|
|
416
507
|
blr.addByte(Const.blr_ex_timestamp_tz);
|
|
417
508
|
}
|
|
418
509
|
}
|
|
419
510
|
|
|
420
511
|
//------------------------------------------------------
|
|
421
512
|
|
|
422
|
-
class SQLVarBoolean {
|
|
423
|
-
decode(data, lowerV13) {
|
|
513
|
+
export class SQLVarBoolean extends SQLVarBase {
|
|
514
|
+
decode(data: XdrReader, lowerV13: boolean) {
|
|
424
515
|
var ret = data.readInt();
|
|
425
516
|
|
|
426
517
|
if (!lowerV13 || !data.readInt()) {
|
|
@@ -429,24 +520,26 @@ class SQLVarBoolean {
|
|
|
429
520
|
return null;
|
|
430
521
|
}
|
|
431
522
|
|
|
432
|
-
calcBlr(blr) {
|
|
523
|
+
calcBlr(blr: BlrWriter): void {
|
|
433
524
|
blr.addByte(Const.blr_bool);
|
|
434
525
|
}
|
|
435
526
|
}
|
|
436
527
|
|
|
437
528
|
//------------------------------------------------------
|
|
438
529
|
|
|
439
|
-
class SQLParamInt {
|
|
440
|
-
|
|
530
|
+
export class SQLParamInt {
|
|
531
|
+
value: any;
|
|
532
|
+
|
|
533
|
+
constructor(value: any) {
|
|
441
534
|
this.value = value;
|
|
442
535
|
}
|
|
443
536
|
|
|
444
|
-
calcBlr(blr) {
|
|
537
|
+
calcBlr(blr: BlrWriter): void {
|
|
445
538
|
blr.addByte(Const.blr_long);
|
|
446
539
|
blr.addShort(0);
|
|
447
540
|
}
|
|
448
541
|
|
|
449
|
-
encode(data) {
|
|
542
|
+
encode(data: XdrWriter): void {
|
|
450
543
|
if (this.value != null) {
|
|
451
544
|
data.addInt(this.value);
|
|
452
545
|
} else {
|
|
@@ -458,17 +551,19 @@ class SQLParamInt {
|
|
|
458
551
|
|
|
459
552
|
//------------------------------------------------------
|
|
460
553
|
|
|
461
|
-
class SQLParamInt64 {
|
|
462
|
-
|
|
554
|
+
export class SQLParamInt64 {
|
|
555
|
+
value: any;
|
|
556
|
+
|
|
557
|
+
constructor(value: any) {
|
|
463
558
|
this.value = value;
|
|
464
559
|
}
|
|
465
560
|
|
|
466
|
-
calcBlr(blr) {
|
|
561
|
+
calcBlr(blr: BlrWriter): void {
|
|
467
562
|
blr.addByte(Const.blr_int64);
|
|
468
563
|
blr.addShort(0);
|
|
469
564
|
}
|
|
470
565
|
|
|
471
|
-
encode(data) {
|
|
566
|
+
encode(data: XdrWriter): void {
|
|
472
567
|
if (this.value != null) {
|
|
473
568
|
data.addInt64(this.value);
|
|
474
569
|
} else {
|
|
@@ -480,17 +575,19 @@ class SQLParamInt64 {
|
|
|
480
575
|
|
|
481
576
|
//------------------------------------------------------
|
|
482
577
|
|
|
483
|
-
class SQLParamInt128 {
|
|
484
|
-
|
|
578
|
+
export class SQLParamInt128 {
|
|
579
|
+
value: any;
|
|
580
|
+
|
|
581
|
+
constructor(value: any) {
|
|
485
582
|
this.value = value;
|
|
486
583
|
}
|
|
487
584
|
|
|
488
|
-
calcBlr(blr) {
|
|
585
|
+
calcBlr(blr: BlrWriter): void {
|
|
489
586
|
blr.addByte(Const.blr_int128);
|
|
490
587
|
blr.addShort(0);
|
|
491
588
|
}
|
|
492
589
|
|
|
493
|
-
encode(data) {
|
|
590
|
+
encode(data: XdrWriter): void {
|
|
494
591
|
if (this.value != null) {
|
|
495
592
|
data.addInt128(this.value);
|
|
496
593
|
} else {
|
|
@@ -502,17 +599,19 @@ class SQLParamInt128 {
|
|
|
502
599
|
|
|
503
600
|
//------------------------------------------------------
|
|
504
601
|
|
|
505
|
-
class SQLParamDecFloat16 {
|
|
506
|
-
|
|
602
|
+
export class SQLParamDecFloat16 {
|
|
603
|
+
value: any;
|
|
604
|
+
|
|
605
|
+
constructor(value: any) {
|
|
507
606
|
this.value = value;
|
|
508
607
|
}
|
|
509
608
|
|
|
510
|
-
calcBlr(blr) {
|
|
609
|
+
calcBlr(blr: BlrWriter): void {
|
|
511
610
|
blr.addByte(Const.blr_dec64);
|
|
512
611
|
blr.addShort(0);
|
|
513
612
|
}
|
|
514
613
|
|
|
515
|
-
encode(data) {
|
|
614
|
+
encode(data: XdrWriter): void {
|
|
516
615
|
if (this.value != null) {
|
|
517
616
|
data.addDecFloat16(this.value);
|
|
518
617
|
} else {
|
|
@@ -524,17 +623,19 @@ class SQLParamDecFloat16 {
|
|
|
524
623
|
|
|
525
624
|
//------------------------------------------------------
|
|
526
625
|
|
|
527
|
-
class SQLParamDecFloat34 {
|
|
528
|
-
|
|
626
|
+
export class SQLParamDecFloat34 {
|
|
627
|
+
value: any;
|
|
628
|
+
|
|
629
|
+
constructor(value: any) {
|
|
529
630
|
this.value = value;
|
|
530
631
|
}
|
|
531
632
|
|
|
532
|
-
calcBlr(blr) {
|
|
633
|
+
calcBlr(blr: BlrWriter): void {
|
|
533
634
|
blr.addByte(Const.blr_dec128);
|
|
534
635
|
blr.addShort(0);
|
|
535
636
|
}
|
|
536
637
|
|
|
537
|
-
encode(data) {
|
|
638
|
+
encode(data: XdrWriter): void {
|
|
538
639
|
if (this.value != null) {
|
|
539
640
|
data.addDecFloat34(this.value);
|
|
540
641
|
} else {
|
|
@@ -546,12 +647,14 @@ class SQLParamDecFloat34 {
|
|
|
546
647
|
|
|
547
648
|
//------------------------------------------------------
|
|
548
649
|
|
|
549
|
-
class SQLParamDouble {
|
|
550
|
-
|
|
650
|
+
export class SQLParamDouble {
|
|
651
|
+
value: any;
|
|
652
|
+
|
|
653
|
+
constructor(value: any) {
|
|
551
654
|
this.value = value;
|
|
552
655
|
}
|
|
553
656
|
|
|
554
|
-
encode(data) {
|
|
657
|
+
encode(data: XdrWriter): void {
|
|
555
658
|
if (this.value != null) {
|
|
556
659
|
data.addDouble(this.value);
|
|
557
660
|
} else {
|
|
@@ -560,19 +663,21 @@ class SQLParamDouble {
|
|
|
560
663
|
}
|
|
561
664
|
}
|
|
562
665
|
|
|
563
|
-
calcBlr(blr) {
|
|
666
|
+
calcBlr(blr: BlrWriter): void {
|
|
564
667
|
blr.addByte(Const.blr_double);
|
|
565
668
|
}
|
|
566
669
|
}
|
|
567
670
|
|
|
568
671
|
//------------------------------------------------------
|
|
569
672
|
|
|
570
|
-
class SQLParamString {
|
|
571
|
-
|
|
673
|
+
export class SQLParamString {
|
|
674
|
+
value: any;
|
|
675
|
+
|
|
676
|
+
constructor(value: any) {
|
|
572
677
|
this.value = value;
|
|
573
678
|
}
|
|
574
679
|
|
|
575
|
-
encode(data) {
|
|
680
|
+
encode(data: XdrWriter): void {
|
|
576
681
|
if (this.value != null) {
|
|
577
682
|
data.addText(this.value, Const.DEFAULT_ENCODING);
|
|
578
683
|
} else {
|
|
@@ -580,7 +685,7 @@ class SQLParamString {
|
|
|
580
685
|
}
|
|
581
686
|
}
|
|
582
687
|
|
|
583
|
-
calcBlr(blr) {
|
|
688
|
+
calcBlr(blr: BlrWriter): void {
|
|
584
689
|
blr.addByte(Const.blr_text);
|
|
585
690
|
var len = this.value ? Buffer.byteLength(this.value, Const.DEFAULT_ENCODING) : 0;
|
|
586
691
|
blr.addWord(len);
|
|
@@ -589,12 +694,38 @@ class SQLParamString {
|
|
|
589
694
|
|
|
590
695
|
//------------------------------------------------------
|
|
591
696
|
|
|
592
|
-
class
|
|
593
|
-
|
|
697
|
+
export class SQLParamBuffer {
|
|
698
|
+
value: any;
|
|
699
|
+
|
|
700
|
+
constructor(value: any) {
|
|
701
|
+
this.value = value;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
encode(data: XdrWriter): void {
|
|
705
|
+
if (this.value != null) {
|
|
706
|
+
data.addParamBuffer(this.value);
|
|
707
|
+
} else {
|
|
708
|
+
data.addInt(1);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
calcBlr(blr: BlrWriter): void {
|
|
713
|
+
blr.addByte(Const.blr_text);
|
|
714
|
+
var len = this.value ? this.value.length : 0;
|
|
715
|
+
blr.addWord(len);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
//------------------------------------------------------
|
|
720
|
+
|
|
721
|
+
export class SQLParamQuad {
|
|
722
|
+
value: any;
|
|
723
|
+
|
|
724
|
+
constructor(value: any) {
|
|
594
725
|
this.value = value;
|
|
595
726
|
}
|
|
596
727
|
|
|
597
|
-
encode(data) {
|
|
728
|
+
encode(data: XdrWriter): void {
|
|
598
729
|
if (this.value != null) {
|
|
599
730
|
data.addInt(this.value.high);
|
|
600
731
|
data.addInt(this.value.low);
|
|
@@ -605,7 +736,7 @@ class SQLParamQuad {
|
|
|
605
736
|
}
|
|
606
737
|
}
|
|
607
738
|
|
|
608
|
-
calcBlr(blr) {
|
|
739
|
+
calcBlr(blr: BlrWriter): void {
|
|
609
740
|
blr.addByte(Const.blr_quad);
|
|
610
741
|
blr.addShort(0);
|
|
611
742
|
}
|
|
@@ -613,12 +744,14 @@ class SQLParamQuad {
|
|
|
613
744
|
|
|
614
745
|
//------------------------------------------------------
|
|
615
746
|
|
|
616
|
-
class SQLParamDate {
|
|
617
|
-
|
|
747
|
+
export class SQLParamDate {
|
|
748
|
+
value: any;
|
|
749
|
+
|
|
750
|
+
constructor(value: any) {
|
|
618
751
|
this.value = value;
|
|
619
752
|
}
|
|
620
753
|
|
|
621
|
-
encode(data) {
|
|
754
|
+
encode(data: XdrWriter): void {
|
|
622
755
|
if (this.value != null) {
|
|
623
756
|
|
|
624
757
|
var value = this.value.getTime() - this.value.getTimezoneOffset() * MsPerMinute;
|
|
@@ -641,19 +774,21 @@ class SQLParamDate {
|
|
|
641
774
|
}
|
|
642
775
|
}
|
|
643
776
|
|
|
644
|
-
calcBlr(blr) {
|
|
777
|
+
calcBlr(blr: BlrWriter): void {
|
|
645
778
|
blr.addByte(Const.blr_timestamp);
|
|
646
779
|
}
|
|
647
780
|
}
|
|
648
781
|
|
|
649
782
|
//------------------------------------------------------
|
|
650
783
|
|
|
651
|
-
class SQLParamBool {
|
|
652
|
-
|
|
784
|
+
export class SQLParamBool {
|
|
785
|
+
value: any;
|
|
786
|
+
|
|
787
|
+
constructor(value: any) {
|
|
653
788
|
this.value = value;
|
|
654
789
|
}
|
|
655
790
|
|
|
656
|
-
encode(data) {
|
|
791
|
+
encode(data: XdrWriter): void {
|
|
657
792
|
if (this.value != null) {
|
|
658
793
|
data.addInt(this.value ? 1 : 0);
|
|
659
794
|
} else {
|
|
@@ -662,42 +797,8 @@ class SQLParamBool {
|
|
|
662
797
|
}
|
|
663
798
|
}
|
|
664
799
|
|
|
665
|
-
calcBlr(blr) {
|
|
800
|
+
calcBlr(blr: BlrWriter): void {
|
|
666
801
|
blr.addByte(Const.blr_short);
|
|
667
802
|
blr.addShort(0);
|
|
668
803
|
}
|
|
669
804
|
}
|
|
670
|
-
|
|
671
|
-
module.exports = {
|
|
672
|
-
SQLVarArray,
|
|
673
|
-
SQLVarDate,
|
|
674
|
-
SQLVarBlob,
|
|
675
|
-
SQLVarBoolean,
|
|
676
|
-
SQLVarDouble,
|
|
677
|
-
SQLVarInt,
|
|
678
|
-
SQLVarInt64,
|
|
679
|
-
SQLVarInt128,
|
|
680
|
-
SQLVarDecFloat16,
|
|
681
|
-
SQLVarDecFloat34,
|
|
682
|
-
SQLVarFloat,
|
|
683
|
-
SQLVarNull,
|
|
684
|
-
SQLVarShort,
|
|
685
|
-
SQLVarString,
|
|
686
|
-
SQLVarText,
|
|
687
|
-
SQLVarTime,
|
|
688
|
-
SQLVarTimeStamp,
|
|
689
|
-
SQLVarTimeTz,
|
|
690
|
-
SQLVarTimeTzEx,
|
|
691
|
-
SQLVarTimeStampTz,
|
|
692
|
-
SQLVarTimeStampTzEx,
|
|
693
|
-
SQLParamBool,
|
|
694
|
-
SQLParamDate,
|
|
695
|
-
SQLParamDouble,
|
|
696
|
-
SQLParamInt,
|
|
697
|
-
SQLParamInt64,
|
|
698
|
-
SQLParamInt128,
|
|
699
|
-
SQLParamDecFloat16,
|
|
700
|
-
SQLParamDecFloat34,
|
|
701
|
-
SQLParamQuad,
|
|
702
|
-
SQLParamString,
|
|
703
|
-
};
|