@m2k-5f/pgtx 2.7.3 → 2.8.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 +24 -13
- package/dist/connection.d.ts +1 -1
- package/dist/connection.d.ts.map +1 -1
- package/dist/connection.js +105 -65
- package/dist/error.d.ts +2 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +11 -0
- package/dist/protocol/connection-request-writer.d.ts +87 -4
- package/dist/protocol/connection-request-writer.d.ts.map +1 -1
- package/dist/protocol/connection-request-writer.js +310 -86
- package/dist/protocol/connection-response-reader.d.ts +72 -15
- package/dist/protocol/connection-response-reader.d.ts.map +1 -1
- package/dist/protocol/connection-response-reader.js +264 -246
- package/dist/protocol/constants.js +8 -8
- package/dist/protocol/types.d.ts +14 -0
- package/dist/protocol/types.d.ts.map +1 -0
- package/dist/protocol/types.js +264 -0
- package/dist/query.d.ts +23 -9
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +32 -10
- package/package.json +1 -1
|
@@ -1,15 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createBindTypeError } from "../error";
|
|
2
2
|
import { DataTypeOids, RequestTypes } from "./constants";
|
|
3
|
+
import { handlers } from "./types";
|
|
3
4
|
const POSTGRES_EPOCH = Date.UTC(2000, 0, 1);
|
|
4
5
|
export class ConnectionRequestBuffer {
|
|
5
|
-
constructor(buffer, offset = 0, lastRequestLenByteOffset = 0) {
|
|
6
|
+
constructor(buffer, offset = 0, lastRequestLenByteOffset = 0, _markedCaret = 0) {
|
|
6
7
|
this.buffer = buffer;
|
|
7
8
|
this.offset = offset;
|
|
8
9
|
this.lastRequestLenByteOffset = lastRequestLenByteOffset;
|
|
10
|
+
this._markedCaret = _markedCaret;
|
|
9
11
|
}
|
|
10
12
|
static new(capacity) {
|
|
11
13
|
return new ConnectionRequestBuffer(Buffer.allocUnsafe(capacity));
|
|
12
14
|
}
|
|
15
|
+
get isEmpty() {
|
|
16
|
+
return !this.buffer.length;
|
|
17
|
+
}
|
|
18
|
+
get hasMore() {
|
|
19
|
+
return !!this.buffer.length;
|
|
20
|
+
}
|
|
21
|
+
mark() {
|
|
22
|
+
this._markedCaret = this.offset;
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
rollback() {
|
|
26
|
+
this.offset = this._markedCaret;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
13
29
|
ensureCapacity(needed) {
|
|
14
30
|
const required = needed + this.offset;
|
|
15
31
|
if (required <= this.buffer.length)
|
|
@@ -195,11 +211,17 @@ export class ConnectionRequestBuffer {
|
|
|
195
211
|
.endRequest();
|
|
196
212
|
return this;
|
|
197
213
|
}
|
|
214
|
+
// ------ Binary writers of js values into Bind parameters ------
|
|
198
215
|
writeBinaryBool(value) {
|
|
199
216
|
this.writeInt32(1);
|
|
200
217
|
this.writeByte(value ? 1 : 0);
|
|
201
218
|
return this;
|
|
202
219
|
}
|
|
220
|
+
writeBinaryString(value) {
|
|
221
|
+
this.writeInt32(Buffer.byteLength(value));
|
|
222
|
+
this.writeString(value);
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
203
225
|
writeBinaryInt2(value) {
|
|
204
226
|
this.writeInt32(2);
|
|
205
227
|
this.writeInt16(value);
|
|
@@ -241,107 +263,309 @@ export class ConnectionRequestBuffer {
|
|
|
241
263
|
this.writeBigInt64(micros);
|
|
242
264
|
return this;
|
|
243
265
|
}
|
|
244
|
-
|
|
245
|
-
this.writeInt32(
|
|
266
|
+
writeBinaryPoint(value) {
|
|
267
|
+
this.writeInt32(16);
|
|
268
|
+
this.writeFloat64(value.x);
|
|
269
|
+
this.writeFloat64(value.y);
|
|
270
|
+
return this;
|
|
271
|
+
}
|
|
272
|
+
writeBinaryNumeric(value) {
|
|
273
|
+
const negative = value.startsWith('-');
|
|
274
|
+
const unsigned = negative ? value.slice(1) : value;
|
|
275
|
+
const [intPartRaw, fracPartRaw = ''] = unsigned.split('.');
|
|
276
|
+
const intPart = intPartRaw === '' ? '0' : intPartRaw;
|
|
277
|
+
const fracPart = fracPartRaw;
|
|
278
|
+
const dscale = fracPart.length;
|
|
279
|
+
const intPad = (4 - (intPart.length % 4)) % 4;
|
|
280
|
+
const paddedInt = '0'.repeat(intPad) + intPart;
|
|
281
|
+
const fracPad = (4 - (fracPart.length % 4)) % 4;
|
|
282
|
+
const paddedFrac = fracPart + '0'.repeat(fracPad);
|
|
283
|
+
const digitsStr = paddedInt + paddedFrac;
|
|
284
|
+
const digits = [];
|
|
285
|
+
for (let i = 0; i < digitsStr.length; i += 4) {
|
|
286
|
+
digits.push(parseInt(digitsStr.slice(i, i + 4), 10));
|
|
287
|
+
}
|
|
288
|
+
let weight = paddedInt.length / 4 - 1;
|
|
289
|
+
let start = 0;
|
|
290
|
+
while (start < digits.length && digits[start] === 0) {
|
|
291
|
+
start++;
|
|
292
|
+
weight--;
|
|
293
|
+
}
|
|
294
|
+
let end = digits.length;
|
|
295
|
+
while (end > start && digits[end - 1] === 0) {
|
|
296
|
+
end--;
|
|
297
|
+
}
|
|
298
|
+
const trimmed = digits.slice(start, end);
|
|
299
|
+
const isZero = trimmed.length === 0;
|
|
300
|
+
this.writeInt32(8 + trimmed.length * 2);
|
|
301
|
+
this.writeInt16(trimmed.length);
|
|
302
|
+
this.writeInt16(isZero ? 0 : weight);
|
|
303
|
+
this.writeUInt16(negative && !isZero ? 0x4000 : 0x0000);
|
|
304
|
+
this.writeUInt16(dscale);
|
|
305
|
+
for (const digit of trimmed) {
|
|
306
|
+
this.writeInt16(digit);
|
|
307
|
+
}
|
|
308
|
+
return this;
|
|
309
|
+
}
|
|
310
|
+
writeBinaryDate(value) {
|
|
311
|
+
const days = Math.round((Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate()) - POSTGRES_EPOCH)
|
|
312
|
+
/ 86400000);
|
|
313
|
+
this.writeInt32(4);
|
|
314
|
+
this.writeInt32(days);
|
|
315
|
+
return this;
|
|
316
|
+
}
|
|
317
|
+
writeBinaryTime(value) {
|
|
318
|
+
const [time, ms] = value.split('.');
|
|
319
|
+
const [hours, minutes, seconds] = time.split(':').map(Number);
|
|
320
|
+
const micros = (hours * 3600000 +
|
|
321
|
+
minutes * 60000 +
|
|
322
|
+
seconds * 1000 +
|
|
323
|
+
Number(ms)) *
|
|
324
|
+
1000;
|
|
325
|
+
this.writeInt32(8);
|
|
326
|
+
this.writeBigInt64(BigInt(micros));
|
|
327
|
+
return this;
|
|
328
|
+
}
|
|
329
|
+
writeBinaryTimetz(value) {
|
|
330
|
+
const time = value.slice(0, 12);
|
|
331
|
+
const offset = value.slice(12);
|
|
332
|
+
const [hours, minutes, seconds] = time
|
|
333
|
+
.slice(0, 8)
|
|
334
|
+
.split(':')
|
|
335
|
+
.map(Number);
|
|
336
|
+
const ms = Number(time.slice(9, 12));
|
|
337
|
+
const sign = offset[0];
|
|
338
|
+
const offHours = Number(offset.slice(1, 3));
|
|
339
|
+
const offMinutes = Number(offset.slice(4, 6));
|
|
340
|
+
const micros = (hours * 3600000 +
|
|
341
|
+
minutes * 60000 +
|
|
342
|
+
seconds * 1000 +
|
|
343
|
+
ms) *
|
|
344
|
+
1000;
|
|
345
|
+
const offsetSeconds = (offHours * 60 + offMinutes) * 60 * (sign === '+' ? -1 : 1);
|
|
346
|
+
this.writeInt32(12);
|
|
347
|
+
this.writeBigInt64(BigInt(micros));
|
|
348
|
+
this.writeInt32(offsetSeconds);
|
|
349
|
+
return this;
|
|
350
|
+
}
|
|
351
|
+
writeBinaryInterval(value) {
|
|
352
|
+
this.writeInt32(16);
|
|
353
|
+
this.writeBigInt64(typeof value.microseconds === 'bigint'
|
|
354
|
+
? value.microseconds
|
|
355
|
+
: BigInt(value.microseconds));
|
|
356
|
+
this.writeInt32(value.days);
|
|
357
|
+
this.writeInt32(value.months);
|
|
358
|
+
return this;
|
|
359
|
+
}
|
|
360
|
+
writeBinaryJson(value) {
|
|
361
|
+
const json = typeof value === 'string' ? value : JSON.stringify(value);
|
|
362
|
+
this.writeInt32(Buffer.byteLength(json));
|
|
363
|
+
this.writeString(json);
|
|
364
|
+
return this;
|
|
365
|
+
}
|
|
366
|
+
writeBinaryJsonb(value) {
|
|
367
|
+
const json = typeof value === 'string' ? value : JSON.stringify(value);
|
|
368
|
+
const byteLen = Buffer.byteLength(json);
|
|
369
|
+
this.writeInt32(byteLen + 1);
|
|
370
|
+
this.writeByte(1);
|
|
371
|
+
this.writeString(json);
|
|
372
|
+
return this;
|
|
373
|
+
}
|
|
374
|
+
writeBinaryUuid(value) {
|
|
375
|
+
const hex = value.replace(/-/g, '');
|
|
376
|
+
this.writeInt32(16);
|
|
377
|
+
this.writeBytes(Buffer.from(hex, 'hex'));
|
|
378
|
+
return this;
|
|
379
|
+
}
|
|
380
|
+
ipv4ToBytes(addr) {
|
|
381
|
+
return Uint8Array.from(addr.split('.').map(Number));
|
|
382
|
+
}
|
|
383
|
+
ipv6ToBytes(addr) {
|
|
384
|
+
const [head, tail] = addr.split('::');
|
|
385
|
+
const headParts = head ? head.split(':') : [];
|
|
386
|
+
const tailParts = tail !== undefined ? (tail ? tail.split(':') : []) : [];
|
|
387
|
+
const missing = 8 - headParts.length - tailParts.length;
|
|
388
|
+
const groups = [...headParts, ...Array(Math.max(missing, 0)).fill('0'), ...tailParts];
|
|
389
|
+
const bytes = new Uint8Array(16);
|
|
390
|
+
groups.forEach((g, i) => {
|
|
391
|
+
const val = parseInt(g || '0', 16);
|
|
392
|
+
bytes[i * 2] = (val >> 8) & 0xff;
|
|
393
|
+
bytes[i * 2 + 1] = val & 0xff;
|
|
394
|
+
});
|
|
395
|
+
return bytes;
|
|
396
|
+
}
|
|
397
|
+
writeBinaryInet(value, isCidr = false) {
|
|
398
|
+
const [addr, prefixStr] = value.split('/');
|
|
399
|
+
const isIPv6 = addr.includes(':');
|
|
400
|
+
const family = isIPv6 ? ConnectionRequestBuffer.PGSQL_AF_INET6 : ConnectionRequestBuffer.PGSQL_AF_INET;
|
|
401
|
+
const addrBytes = isIPv6 ? this.ipv6ToBytes(addr) : this.ipv4ToBytes(addr);
|
|
402
|
+
const bits = prefixStr !== undefined ? parseInt(prefixStr, 10) : (isIPv6 ? 128 : 32);
|
|
403
|
+
this.writeInt32(4 + addrBytes.length);
|
|
404
|
+
this.writeByte(family);
|
|
405
|
+
this.writeByte(bits);
|
|
406
|
+
this.writeByte(isCidr ? 1 : 0);
|
|
407
|
+
this.writeByte(addrBytes.length);
|
|
408
|
+
this.writeBytes(addrBytes);
|
|
409
|
+
return this;
|
|
410
|
+
}
|
|
411
|
+
writeBinaryCidr(value) {
|
|
412
|
+
return this.writeBinaryInet(value, true);
|
|
413
|
+
}
|
|
414
|
+
writeBinaryMacaddr(value) {
|
|
415
|
+
const bytes = Uint8Array.from(value.split(':').map(h => parseInt(h, 16)));
|
|
416
|
+
this.writeInt32(6);
|
|
417
|
+
this.writeBytes(bytes);
|
|
418
|
+
return this;
|
|
419
|
+
}
|
|
420
|
+
writeBinaryOid(value) {
|
|
421
|
+
this.writeInt32(4);
|
|
422
|
+
this.writeUInt32(value);
|
|
246
423
|
return this;
|
|
247
424
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
425
|
+
writeBinaryXid(value) {
|
|
426
|
+
return this.writeBinaryOid(value);
|
|
427
|
+
}
|
|
428
|
+
writeBinaryCid(value) {
|
|
429
|
+
return this.writeBinaryOid(value);
|
|
430
|
+
}
|
|
431
|
+
writeBinaryRegproc(value) {
|
|
432
|
+
return this.writeBinaryOid(value);
|
|
433
|
+
}
|
|
434
|
+
writeBinaryLseg(value) {
|
|
435
|
+
this.writeInt32(32);
|
|
436
|
+
this.writeFloat64(value.a.x);
|
|
437
|
+
this.writeFloat64(value.a.y);
|
|
438
|
+
this.writeFloat64(value.b.x);
|
|
439
|
+
this.writeFloat64(value.b.y);
|
|
440
|
+
return this;
|
|
441
|
+
}
|
|
442
|
+
writeBinaryPath(value) {
|
|
443
|
+
this.writeInt32(1 + 4 + value.points.length * 16);
|
|
444
|
+
this.writeByte(value.closed ? 1 : 0);
|
|
445
|
+
this.writeInt32(value.points.length);
|
|
446
|
+
for (const p of value.points) {
|
|
447
|
+
this.writeFloat64(p.x);
|
|
448
|
+
this.writeFloat64(p.y);
|
|
251
449
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
Number.isSafeInteger(value)));
|
|
269
|
-
case DataTypeOids.Float4:
|
|
270
|
-
case DataTypeOids.Float8:
|
|
271
|
-
return (typeof value === "number" &&
|
|
272
|
-
Number.isFinite(value));
|
|
273
|
-
case DataTypeOids.Bytea:
|
|
274
|
-
return (Buffer.isBuffer(value) ||
|
|
275
|
-
value instanceof Uint8Array);
|
|
276
|
-
case DataTypeOids.Timestamp:
|
|
277
|
-
case DataTypeOids.Timestamptz:
|
|
278
|
-
return value instanceof Date;
|
|
279
|
-
default:
|
|
280
|
-
return false;
|
|
450
|
+
return this;
|
|
451
|
+
}
|
|
452
|
+
writeBinaryBox(value) {
|
|
453
|
+
this.writeInt32(32);
|
|
454
|
+
this.writeFloat64(value.high.x);
|
|
455
|
+
this.writeFloat64(value.high.y);
|
|
456
|
+
this.writeFloat64(value.low.x);
|
|
457
|
+
this.writeFloat64(value.low.y);
|
|
458
|
+
return this;
|
|
459
|
+
}
|
|
460
|
+
writeBinaryPolygon(value) {
|
|
461
|
+
this.writeInt32(4 + value.points.length * 16);
|
|
462
|
+
this.writeInt32(value.points.length);
|
|
463
|
+
for (const p of value.points) {
|
|
464
|
+
this.writeFloat64(p.x);
|
|
465
|
+
this.writeFloat64(p.y);
|
|
281
466
|
}
|
|
467
|
+
return this;
|
|
468
|
+
}
|
|
469
|
+
writeBinaryLine(value) {
|
|
470
|
+
this.writeInt32(24);
|
|
471
|
+
this.writeFloat64(value.a);
|
|
472
|
+
this.writeFloat64(value.b);
|
|
473
|
+
this.writeFloat64(value.c);
|
|
474
|
+
return this;
|
|
475
|
+
}
|
|
476
|
+
writeLengthPrefixed(writeContent) {
|
|
477
|
+
this.ensureCapacity(4);
|
|
478
|
+
const lengthOffset = this.offset;
|
|
479
|
+
this.writeInt32(0);
|
|
480
|
+
const contentStart = this.offset;
|
|
481
|
+
writeContent();
|
|
482
|
+
const length = this.offset - contentStart;
|
|
483
|
+
this.buffer.writeInt32BE(length, lengthOffset);
|
|
484
|
+
return this;
|
|
485
|
+
}
|
|
486
|
+
writeBinaryArray(arr, elementOid, elementWriter) {
|
|
487
|
+
const hasNull = arr.some(v => v == null);
|
|
488
|
+
this.writeLengthPrefixed(() => {
|
|
489
|
+
this.writeInt32(1);
|
|
490
|
+
this.writeInt32(hasNull ? 1 : 0);
|
|
491
|
+
this.writeInt32(elementOid);
|
|
492
|
+
this.writeInt32(arr.length);
|
|
493
|
+
this.writeInt32(1);
|
|
494
|
+
for (const val of arr) {
|
|
495
|
+
if (val == null) {
|
|
496
|
+
this.writeNull();
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
elementWriter(val);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
return this;
|
|
504
|
+
}
|
|
505
|
+
writeBinaryBoolArray(value) {
|
|
506
|
+
return this.writeBinaryArray(value, DataTypeOids.Bool, v => this.writeBinaryBool(v));
|
|
507
|
+
}
|
|
508
|
+
writeBinaryInt2Array(value) {
|
|
509
|
+
return this.writeBinaryArray(value, DataTypeOids.Int2, v => this.writeBinaryInt2(v));
|
|
510
|
+
}
|
|
511
|
+
writeBinaryInt4Array(value) {
|
|
512
|
+
return this.writeBinaryArray(value, DataTypeOids.Int4, v => this.writeBinaryInt4(v));
|
|
513
|
+
}
|
|
514
|
+
writeBinaryInt8Array(value) {
|
|
515
|
+
return this.writeBinaryArray(value, DataTypeOids.Int8, v => typeof v === 'bigint' ? this.writeBinaryBigInt8(v) : this.writeBinaryInt8(v));
|
|
516
|
+
}
|
|
517
|
+
writeBinaryTextArray(value) {
|
|
518
|
+
return this.writeBinaryArray(value, DataTypeOids.Text, v => this.writeBinaryString(v));
|
|
519
|
+
}
|
|
520
|
+
writeBinaryVarcharArray(value) {
|
|
521
|
+
return this.writeBinaryArray(value, DataTypeOids.Varchar, v => this.writeBinaryString(v));
|
|
282
522
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
523
|
+
writeBinaryJsonArray(value) {
|
|
524
|
+
return this.writeBinaryArray(value, DataTypeOids.Json, v => this.writeBinaryJson(v));
|
|
525
|
+
}
|
|
526
|
+
writeBinaryJsonbArray(value) {
|
|
527
|
+
return this.writeBinaryArray(value, DataTypeOids.Jsonb, v => this.writeBinaryJsonb(v));
|
|
528
|
+
}
|
|
529
|
+
writeBinaryUuidArray(value) {
|
|
530
|
+
return this.writeBinaryArray(value, DataTypeOids.Uuid, v => this.writeBinaryUuid(v));
|
|
531
|
+
}
|
|
532
|
+
writeBinaryNumericArray(value) {
|
|
533
|
+
return this.writeBinaryArray(value, DataTypeOids.Numeric, v => this.writeBinaryNumeric(v));
|
|
534
|
+
}
|
|
535
|
+
writeNull() {
|
|
536
|
+
this.writeInt32(-1);
|
|
537
|
+
return this;
|
|
538
|
+
}
|
|
539
|
+
writeBind(portName, meta, params) {
|
|
540
|
+
this.mark();
|
|
541
|
+
this.startRequest(RequestTypes.Bind)
|
|
286
542
|
.writeCString(portName)
|
|
287
|
-
.writeCString(
|
|
543
|
+
.writeCString(meta.statement)
|
|
288
544
|
.writeInt16(params.length);
|
|
289
|
-
for (
|
|
290
|
-
|
|
545
|
+
for (let i = 0; i < params.length; i++) {
|
|
546
|
+
this.writeInt16(1);
|
|
291
547
|
}
|
|
292
|
-
|
|
548
|
+
this.writeInt16(params.length);
|
|
293
549
|
for (let i = 0; i < params.length; i++) {
|
|
294
550
|
const value = params[i];
|
|
551
|
+
const oid = meta.parameters[i];
|
|
295
552
|
if (value == null) {
|
|
296
|
-
|
|
553
|
+
this.writeNull();
|
|
297
554
|
continue;
|
|
298
555
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
break;
|
|
304
|
-
case DataTypeOids.Int2:
|
|
305
|
-
request.writeBinaryInt2(value);
|
|
306
|
-
break;
|
|
307
|
-
case DataTypeOids.Int4:
|
|
308
|
-
request.writeBinaryInt4(value);
|
|
309
|
-
break;
|
|
310
|
-
case DataTypeOids.Int8:
|
|
311
|
-
typeof value === "bigint"
|
|
312
|
-
? request.writeBinaryBigInt8(value)
|
|
313
|
-
: request.writeBinaryInt8(value);
|
|
314
|
-
break;
|
|
315
|
-
case DataTypeOids.Float4:
|
|
316
|
-
request.writeBinaryFloat4(value);
|
|
317
|
-
break;
|
|
318
|
-
case DataTypeOids.Float8:
|
|
319
|
-
request.writeBinaryFloat8(value);
|
|
320
|
-
break;
|
|
321
|
-
case DataTypeOids.Bytea:
|
|
322
|
-
request.writeBinaryBytea(value);
|
|
323
|
-
break;
|
|
324
|
-
case DataTypeOids.Timestamp:
|
|
325
|
-
case DataTypeOids.Timestamptz:
|
|
326
|
-
request.writeBinaryTimestamp(value);
|
|
327
|
-
break;
|
|
328
|
-
}
|
|
329
|
-
continue;
|
|
330
|
-
}
|
|
331
|
-
const prepared = prepareValue(value);
|
|
332
|
-
if (prepared === null) {
|
|
333
|
-
request.writeNull();
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
request
|
|
337
|
-
.writeInt32(Buffer.byteLength(prepared))
|
|
338
|
-
.writeString(prepared);
|
|
556
|
+
const handler = handlers[oid];
|
|
557
|
+
if (!handler || !handler.validate(value)) {
|
|
558
|
+
this.rollback();
|
|
559
|
+
return createBindTypeError(i, oid, value);
|
|
339
560
|
}
|
|
561
|
+
handler.write(this, value);
|
|
340
562
|
}
|
|
341
|
-
|
|
563
|
+
this
|
|
342
564
|
.writeInt16(1)
|
|
343
565
|
.writeInt16(1)
|
|
344
566
|
.endRequest();
|
|
345
|
-
return
|
|
567
|
+
return null;
|
|
346
568
|
}
|
|
347
569
|
}
|
|
570
|
+
ConnectionRequestBuffer.PGSQL_AF_INET = 2;
|
|
571
|
+
ConnectionRequestBuffer.PGSQL_AF_INET6 = 3;
|
|
@@ -6,29 +6,24 @@ export declare class ConnectionResponseBuffer {
|
|
|
6
6
|
private caret;
|
|
7
7
|
private constructor();
|
|
8
8
|
static from(buffer: Buffer): ConnectionResponseBuffer;
|
|
9
|
+
hasMore(): boolean;
|
|
10
|
+
skipBytes(byteCount: number): void;
|
|
11
|
+
hasFullPacket(): boolean;
|
|
12
|
+
getResidualBuffer(): Buffer<ArrayBufferLike>;
|
|
9
13
|
readChar(): string;
|
|
10
14
|
readInt32(): number;
|
|
11
15
|
readInt16(): number;
|
|
12
16
|
readCString(): string;
|
|
13
17
|
readRawString(length: number): string;
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
readUInt16(): number;
|
|
19
|
+
readUInt32(): number;
|
|
20
|
+
readFloat32(): number;
|
|
21
|
+
readFloat64(): number;
|
|
16
22
|
readByte(): number;
|
|
17
|
-
|
|
18
|
-
readBinaryTime(): string;
|
|
19
|
-
skipBytes(byteCount: number): void;
|
|
20
|
-
hasFullPacket(): boolean;
|
|
21
|
-
getResidualBuffer(): Buffer<ArrayBufferLike>;
|
|
23
|
+
readBytes(length: number): Buffer<ArrayBuffer>;
|
|
22
24
|
readBool(): boolean;
|
|
23
25
|
readBigInt64(): bigint;
|
|
24
26
|
readInt64(): number;
|
|
25
|
-
readNumeric(): string;
|
|
26
|
-
readBinaryTimetz(): string;
|
|
27
|
-
readFloat32(): number;
|
|
28
|
-
readFloat64(): number;
|
|
29
|
-
readUuid(): string;
|
|
30
|
-
readBytes(length: number): Buffer<ArrayBuffer>;
|
|
31
|
-
getBufferHash(length: number): number;
|
|
32
27
|
readType(): {
|
|
33
28
|
type: ResponseType;
|
|
34
29
|
length: number;
|
|
@@ -48,12 +43,74 @@ export declare class ConnectionResponseBuffer {
|
|
|
48
43
|
readSaslMechanisms(): string[];
|
|
49
44
|
readSaslMessage(length: number): string;
|
|
50
45
|
readRowDescription(): ColumnDescription[];
|
|
51
|
-
readDataRow(descriptions: ColumnDescription[], int8toBigint: boolean): Record<string, any>;
|
|
52
46
|
readNotificationResponse(): {
|
|
53
47
|
name: ChannelName;
|
|
54
48
|
payload: string;
|
|
55
49
|
};
|
|
56
50
|
readCommandComplete(): string;
|
|
57
51
|
readParameterDescription(): ParameterDescription;
|
|
52
|
+
readBinaryDate(): Date;
|
|
53
|
+
readBinaryTimestamp(): Date;
|
|
54
|
+
readBinaryTime(): string;
|
|
55
|
+
readBinaryTimetz(): string;
|
|
56
|
+
readBinaryNumeric(): string;
|
|
57
|
+
readBinaryInterval(): {
|
|
58
|
+
months: number;
|
|
59
|
+
days: number;
|
|
60
|
+
microseconds: bigint;
|
|
61
|
+
};
|
|
62
|
+
readBinaryJson(fieldLength: number): unknown;
|
|
63
|
+
readBinaryJsonb(fieldLength: number): unknown;
|
|
64
|
+
readBinaryMacaddr(): string;
|
|
65
|
+
readBinaryOid(): number;
|
|
66
|
+
readBinaryXid(): number;
|
|
67
|
+
readBinaryCid(): number;
|
|
68
|
+
readBinaryRegproc(): number;
|
|
69
|
+
readBinaryLseg(): {
|
|
70
|
+
a: {
|
|
71
|
+
x: number;
|
|
72
|
+
y: number;
|
|
73
|
+
};
|
|
74
|
+
b: {
|
|
75
|
+
x: number;
|
|
76
|
+
y: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
readBinaryPath(): {
|
|
80
|
+
closed: boolean;
|
|
81
|
+
points: {
|
|
82
|
+
x: number;
|
|
83
|
+
y: number;
|
|
84
|
+
}[];
|
|
85
|
+
};
|
|
86
|
+
readBinaryBox(): {
|
|
87
|
+
high: {
|
|
88
|
+
x: number;
|
|
89
|
+
y: number;
|
|
90
|
+
};
|
|
91
|
+
low: {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
readBinaryPolygon(): {
|
|
97
|
+
points: {
|
|
98
|
+
x: number;
|
|
99
|
+
y: number;
|
|
100
|
+
}[];
|
|
101
|
+
};
|
|
102
|
+
readBinaryLine(): {
|
|
103
|
+
a: number;
|
|
104
|
+
b: number;
|
|
105
|
+
c: number;
|
|
106
|
+
};
|
|
107
|
+
readBinaryUuid(): string;
|
|
108
|
+
readBinaryArray(fieldLength: number, elementParser: (length: number) => any): any[];
|
|
109
|
+
readBinaryInet(fieldLength: number): string;
|
|
110
|
+
readBinaryPoint(): {
|
|
111
|
+
x: number;
|
|
112
|
+
y: number;
|
|
113
|
+
};
|
|
114
|
+
readDataRow(descriptions: ColumnDescription[], int8toBigint: boolean): Record<string, any>;
|
|
58
115
|
}
|
|
59
116
|
//# sourceMappingURL=connection-response-reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-response-reader.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-response-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACxH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"connection-response-reader.d.ts","sourceRoot":"","sources":["../../src/protocol/connection-response-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAyC,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACxH,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAC/E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAMxC,qBAAa,wBAAwB;IAI7B,OAAO,CAAC,MA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