@pgxsinkit/pgwasm 0.6.1 → 0.6.3
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 +8 -0
- package/dist/{chunk-jnmd6w7f.js → chunk-4eb2pcfr.js} +18 -3
- package/dist/chunk-4eb2pcfr.js.map +10 -0
- package/dist/{chunk-garmxqte.js → chunk-82r7js5b.js} +101 -21
- package/dist/chunk-82r7js5b.js.map +16 -0
- package/dist/{chunk-c06zjbcj.js → chunk-cgt5pdan.js} +2 -290
- package/dist/chunk-cgt5pdan.js.map +13 -0
- package/dist/{chunk-cpsnmzrf.js → chunk-jwz46twh.js} +14 -2
- package/dist/chunk-jwz46twh.js.map +10 -0
- package/dist/{chunk-d2kpv98r.js → chunk-rqykg4gj.js} +1 -1
- package/dist/{chunk-d2kpv98r.js.map → chunk-rqykg4gj.js.map} +1 -1
- package/dist/{chunk-10ebj4re.js → chunk-rsenqaz0.js} +2 -2
- package/dist/{chunk-10ebj4re.js.map → chunk-rsenqaz0.js.map} +1 -1
- package/dist/chunk-ryjxx1c8.js +303 -0
- package/dist/chunk-ryjxx1c8.js.map +10 -0
- package/dist/core/parse.d.ts.map +1 -1
- package/dist/core/pgwasm.d.ts.map +1 -1
- package/dist/drizzle/codecs.d.ts.map +1 -1
- package/dist/drizzle/driver.d.ts.map +1 -1
- package/dist/drizzle/index.js +2 -2
- package/dist/drizzle/index.js.map +3 -3
- package/dist/drizzle/session.d.ts.map +1 -1
- package/dist/errors.d.ts +5 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -5
- package/dist/index.js.map +1 -1
- package/dist/interface.d.ts +4 -1
- package/dist/interface.d.ts.map +1 -1
- package/dist/live/format-query.d.ts.map +1 -1
- package/dist/live/index.js +5 -5
- package/dist/live/index.js.map +3 -3
- package/dist/opfs/core/mounted-vfs.d.ts +1 -1
- package/dist/opfs/core/mounted-vfs.d.ts.map +1 -1
- package/dist/opfs/index.js +3 -3
- package/dist/opfs/index.js.map +8 -8
- package/dist/protocol/index.d.ts.map +1 -1
- package/dist/protocol/index.js +6 -4
- package/dist/protocol/index.js.map +3 -3
- package/dist/protocol/wire/parser.d.ts.map +1 -1
- package/dist/templating.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/opfs/SKILL.md +1 -1
- package/src/core/data-dir-archive.ts +1 -1
- package/src/core/parse.ts +2 -2
- package/src/core/pgwasm.ts +104 -17
- package/src/drizzle/codecs.ts +2 -2
- package/src/drizzle/driver.ts +1 -1
- package/src/drizzle/session.ts +2 -2
- package/src/errors.ts +10 -1
- package/src/index.ts +1 -0
- package/src/interface.ts +4 -1
- package/src/live/format-query.ts +2 -1
- package/src/opfs/broker/client.ts +4 -4
- package/src/opfs/broker/server.ts +3 -3
- package/src/opfs/core/codec.ts +2 -2
- package/src/opfs/core/metadata-store.ts +6 -6
- package/src/opfs/core/mounted-vfs.ts +1 -1
- package/src/opfs/core/port.ts +1 -1
- package/src/opfs/core/repacked-vfs.ts +6 -6
- package/src/opfs/core/state-machine.ts +3 -3
- package/src/protocol/index.ts +1 -1
- package/src/protocol/wire/parser.ts +4 -4
- package/src/templating.ts +3 -1
- package/src/types.ts +15 -1
- package/dist/chunk-c06zjbcj.js.map +0 -14
- package/dist/chunk-cpsnmzrf.js.map +0 -10
- package/dist/chunk-garmxqte.js.map +0 -16
- package/dist/chunk-jnmd6w7f.js.map +0 -10
- package/dist/chunk-kb3rsr7n.js +0 -19
- package/dist/chunk-kb3rsr7n.js.map +0 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,mBAAmB,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,YAAY,EACV,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC5D,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC3G,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,sEAAsE;AACtE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,CAEnD"}
|
package/dist/protocol/index.js
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
import {
|
|
3
3
|
Modes2,
|
|
4
4
|
Parser2
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-rqykg4gj.js";
|
|
6
6
|
import {
|
|
7
|
-
exports_messages,
|
|
8
7
|
serialize2,
|
|
9
8
|
protocolAccessOf
|
|
10
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-cgt5pdan.js";
|
|
10
|
+
import {
|
|
11
|
+
exports_messages
|
|
12
|
+
} from "../chunk-ryjxx1c8.js";
|
|
11
13
|
// packages/pgwasm/src/protocol/index.ts
|
|
12
14
|
function protocol(pg) {
|
|
13
15
|
return protocolAccessOf(pg);
|
|
@@ -20,4 +22,4 @@ export {
|
|
|
20
22
|
serialize2 as serialize
|
|
21
23
|
};
|
|
22
24
|
|
|
23
|
-
//# debugId=
|
|
25
|
+
//# debugId=D26D28AA4E01519D64756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/protocol/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Wire-level access to a pgwasm instance, for tools that speak the Postgres protocol themselves\n * (pg_dump, a REPL, a benchmark). Everyday code uses `query`, `exec` and `transaction` instead: the\n * `execProtocol*` calls bypass pgwasm's query locks. A tool whose exchanges must not interleave with\n * anything else runs them inside `runExclusiveSession`, which holds those locks.\n */\n\nimport {
|
|
5
|
+
"/**\n * Wire-level access to a pgwasm instance, for tools that speak the Postgres protocol themselves\n * (pg_dump, a REPL, a benchmark). Everyday code uses `query`, `exec` and `transaction` instead: the\n * `execProtocol*` calls bypass pgwasm's query locks. A tool whose exchanges must not interleave with\n * anything else runs them inside `runExclusiveSession`, which holds those locks.\n */\n\nimport { type PgwasmProtocol, protocolAccessOf } from \"../core/internals\";\nimport type { Pgwasm } from \"../interface\";\n\nexport type {\n ExecProtocolOptions,\n ExecProtocolResult,\n ExecProtocolStreamOptions,\n PgwasmProtocol,\n} from \"../core/internals\";\nexport { Parser, serialize, messages, Modes } from \"./wire\";\nexport type { BindOpts, ExecOpts, LegalValue, MessageCallback, Mode, ParseOpts, PortalOpts } from \"./wire\";\nexport type { BackendMessage } from \"./wire/messages\";\n\n/** The wire-level methods of a database created by `createPgwasm`. */\nexport function protocol(pg: Pgwasm): PgwasmProtocol {\n return protocolAccessOf(pg);\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": "
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;;;;;;;;;;;;AAqBO,SAAS,QAAQ,CAAC,IAA4B;AAAA,EACnD,OAAO,iBAAiB,EAAE;AAAA;",
|
|
8
|
+
"debugId": "D26D28AA4E01519D64756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sources":["../../../src/protocol/wire/parser.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sources":["../../../src/protocol/wire/parser.ts"],"names":[],"mappings":"AAKA,OAAO,EASL,KAAK,cAAc,EAsBpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,eAAe,EAAS,MAAM,SAAS,CAAC;AAkCtD,MAAM,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,cAAc,KAAK,IAAI,CAAC;AAE5D;;;GAGG;AACH,qBAAa,MAAM;;IAMjB,KAAK,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,GAAG,IAAI,CAgC9D;CAiQF"}
|
package/dist/templating.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templating.d.ts","sources":["../src/templating.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templating.d.ts","sources":["../src/templating.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,YAAY;aAChB,IAAI,EAAE,MAAM;aACZ,SAAS,EAAE,WAAW;CACd,CAAC;AAEX,sGAAsG;AACtG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,OAAO,YAAY,CAAC,IAAI,CAAC;IACjD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,+DAA+D;AAC/D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,aAAa,EAAE,OAAO,YAAY,CAAC,SAAS,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAED,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;CAC5B;AAoBD;;;;;;GAMG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAyB1F;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAE5F;AAED,kFAAkF;AAClF,wBAAgB,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,YAAY,CAErF;AAED,wEAAwE;AACxE,wBAAgB,KAAK,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,cAAc,CAMzF"}
|
package/dist/types.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type Serializer = (value: unknown) => string;
|
|
|
8
8
|
declare function serializeString(value: unknown): string;
|
|
9
9
|
declare function serializeBoolean(value: unknown): string;
|
|
10
10
|
declare function serializeDate(value: unknown): string;
|
|
11
|
+
declare function parseDate(value: string): Date | number;
|
|
11
12
|
declare function serializeBytea(value: unknown): string;
|
|
12
13
|
declare function parseBytea(value: string): Uint8Array;
|
|
13
14
|
declare function parseBigint(value: string): number | bigint;
|
|
@@ -48,7 +49,7 @@ export declare const types: {
|
|
|
48
49
|
to: number;
|
|
49
50
|
from: number[];
|
|
50
51
|
serialize: typeof serializeDate;
|
|
51
|
-
parse:
|
|
52
|
+
parse: typeof parseDate;
|
|
52
53
|
};
|
|
53
54
|
bytea: {
|
|
54
55
|
to: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sources":["../src/types.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAKjD,0BAA0B;AAC1B,eAAO,MAAM,IAAI,KAAK,EACpB,KAAK,KAAK,EACV,IAAI,KAAK,EACT,IAAI,KAAK,EACT,IAAI,KAAK,EACT,IAAI,KAAK,EACT,OAAO,KAAK,EACZ,IAAI,KAAK,EACT,GAAG,KAAK,EACR,GAAG,KAAK,EACR,GAAG,KAAK,EACR,G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AmG;AACnG,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAgBzG;AAWD,yEAAyE;AACzE,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAG5F"}
|
package/package.json
CHANGED
package/skills/opfs/SKILL.md
CHANGED
|
@@ -11,7 +11,7 @@ import type { DataDirEntry } from "../build/seam";
|
|
|
11
11
|
import { BackupFormatError } from "../errors";
|
|
12
12
|
import type { DumpCompression } from "../interface";
|
|
13
13
|
import { gunzipIfCompressed, gzip } from "../tar/gzip";
|
|
14
|
-
import { readTar, TarFormatError, writeTar
|
|
14
|
+
import { readTar, type TarEntry, TarFormatError, writeTar } from "../tar/tar";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Normalize a backup member's name to a data-directory path: a leading `/`, no trailing `/`, no empty,
|
package/src/core/parse.ts
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import type { QueryOptions, Results, Row } from "../interface";
|
|
5
5
|
import {
|
|
6
|
+
type BackendMessage,
|
|
6
7
|
CommandCompleteMessage,
|
|
7
8
|
DataRowMessage,
|
|
8
9
|
ParameterDescriptionMessage,
|
|
9
10
|
RowDescriptionMessage,
|
|
10
|
-
type BackendMessage,
|
|
11
11
|
} from "../protocol/wire/messages";
|
|
12
|
-
import {
|
|
12
|
+
import { type Parser, parseType } from "../types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Turn the backend messages of a simple or extended query into result sets, one per statement
|
package/src/core/pgwasm.ts
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
PgwasmClosedError,
|
|
19
19
|
PgwasmError,
|
|
20
20
|
PgwasmFailedError,
|
|
21
|
+
TransactionAbortedError,
|
|
21
22
|
UnsupportedFeatureError,
|
|
22
23
|
} from "../errors";
|
|
23
24
|
import type {
|
|
@@ -32,10 +33,11 @@ import type {
|
|
|
32
33
|
Transaction,
|
|
33
34
|
} from "../interface";
|
|
34
35
|
import {
|
|
36
|
+
type BackendMessage,
|
|
35
37
|
DatabaseError,
|
|
38
|
+
DataRowMessage,
|
|
36
39
|
NoticeMessage,
|
|
37
40
|
NotificationResponseMessage,
|
|
38
|
-
type BackendMessage,
|
|
39
41
|
} from "../protocol/wire/messages";
|
|
40
42
|
import { Parser as WireParser } from "../protocol/wire/parser";
|
|
41
43
|
import { serialize } from "../protocol/wire/serializer";
|
|
@@ -43,11 +45,11 @@ import { query as queryTemplate } from "../templating";
|
|
|
43
45
|
import {
|
|
44
46
|
arrayParser,
|
|
45
47
|
arraySerializer,
|
|
48
|
+
type Parser,
|
|
46
49
|
parsers as defaultParsers,
|
|
50
|
+
type Serializer,
|
|
47
51
|
serializers as defaultSerializers,
|
|
48
52
|
toText,
|
|
49
|
-
type Parser,
|
|
50
|
-
type Serializer,
|
|
51
53
|
} from "../types";
|
|
52
54
|
import { writeDataDirArchive } from "./data-dir-archive";
|
|
53
55
|
import {
|
|
@@ -58,7 +60,7 @@ import {
|
|
|
58
60
|
} from "./internals";
|
|
59
61
|
import { BUILD_MARKER_PATH, checkBuildMarker, encodeBuildMarker, PG_VERSION_PATH } from "./marker";
|
|
60
62
|
import { Mutex } from "./mutex";
|
|
61
|
-
import { quoteIdentifier, toPostgresName } from "./names";
|
|
63
|
+
import { quoteIdentifier, randomId, toPostgresName } from "./names";
|
|
62
64
|
import { parseDescribeStatementResults, parseResults } from "./parse";
|
|
63
65
|
import { backupBaseName, describeStorage } from "./storage";
|
|
64
66
|
|
|
@@ -154,6 +156,8 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
154
156
|
|
|
155
157
|
readonly #parsers: Record<number | string, Parser>;
|
|
156
158
|
readonly #serializers: Record<number | string, Serializer>;
|
|
159
|
+
readonly #domainArrays = new Set<number>();
|
|
160
|
+
#paramTypesStatement: string | undefined;
|
|
157
161
|
#arrayTypesInitialized = false;
|
|
158
162
|
#inTransaction = false;
|
|
159
163
|
|
|
@@ -510,15 +514,93 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
510
514
|
return chunks === undefined ? undefined : new Blob(chunks);
|
|
511
515
|
}
|
|
512
516
|
|
|
513
|
-
#serializeParams(
|
|
517
|
+
async #serializeParams(
|
|
514
518
|
params: readonly unknown[],
|
|
515
519
|
dataTypeIDs: readonly number[],
|
|
516
520
|
options?: QueryOptions,
|
|
517
|
-
): (string | null)[] {
|
|
521
|
+
): Promise<(string | null)[]> {
|
|
522
|
+
if (params.length === 0) return [];
|
|
523
|
+
let unresolved: Set<number> | undefined;
|
|
524
|
+
params.forEach((param, index) => {
|
|
525
|
+
const oid = dataTypeIDs[index] ?? 0;
|
|
526
|
+
if (
|
|
527
|
+
param !== null &&
|
|
528
|
+
param !== undefined &&
|
|
529
|
+
typeof param !== "string" &&
|
|
530
|
+
!options?.serializers?.[oid] &&
|
|
531
|
+
(!this.#serializers[oid] || this.#domainArrays.has(oid))
|
|
532
|
+
) {
|
|
533
|
+
(unresolved ??= new Set()).add(oid);
|
|
534
|
+
}
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
if (unresolved === undefined) {
|
|
538
|
+
return params.map((param, index) => {
|
|
539
|
+
if (param === null || param === undefined) return null;
|
|
540
|
+
const oid = dataTypeIDs[index] ?? 0;
|
|
541
|
+
const serializer = options?.serializers?.[oid] ?? this.#serializers[oid];
|
|
542
|
+
return serializer ? serializer(param) : toText(param);
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// Resolve against this transaction's catalog. Caching domain OIDs across a rollback or a
|
|
547
|
+
// dropped/recreated type can retain the wrong base serializer when PostgreSQL reuses an OID.
|
|
548
|
+
const types = new Map<number, { base: number; element: number; domain: boolean; array: boolean }>();
|
|
549
|
+
const name = (this.#paramTypesStatement ??= `pgwasm_param_types_${randomId()}`);
|
|
550
|
+
const text = `
|
|
551
|
+
WITH RECURSIVE types AS (
|
|
552
|
+
SELECT oid, typbasetype, typelem, typtype, typcategory FROM pg_catalog.pg_type
|
|
553
|
+
WHERE oid IN (${[...unresolved].join(",")})
|
|
554
|
+
UNION
|
|
555
|
+
SELECT t.oid, t.typbasetype, t.typelem, t.typtype, t.typcategory
|
|
556
|
+
FROM pg_catalog.pg_type t JOIN types p
|
|
557
|
+
ON t.oid = CASE WHEN p.typtype = 'd' THEN p.typbasetype ELSE p.typelem END
|
|
558
|
+
WHERE p.typtype = 'd' OR p.typcategory = 'A'
|
|
559
|
+
) SELECT oid, typbasetype, typelem, typtype, typcategory FROM types
|
|
560
|
+
`;
|
|
561
|
+
// The caller has parsed its unnamed statement already. Catalog work uses a named
|
|
562
|
+
// statement and portal so its Parse/Bind cannot replace the caller's prepared state.
|
|
563
|
+
for (const message of [
|
|
564
|
+
serialize.close({ type: "S", name }),
|
|
565
|
+
serialize.parse({ name, text }),
|
|
566
|
+
serialize.bind({ statement: name, portal: name }),
|
|
567
|
+
serialize.execute({ portal: name }),
|
|
568
|
+
serialize.close({ type: "P", name }),
|
|
569
|
+
serialize.close({ type: "S", name }),
|
|
570
|
+
]) {
|
|
571
|
+
for (const result of await this.#execNoPersist(message, options)) {
|
|
572
|
+
if (result instanceof DataRowMessage) {
|
|
573
|
+
types.set(Number(result.fields[0]), {
|
|
574
|
+
base: Number(result.fields[1]),
|
|
575
|
+
element: Number(result.fields[2]),
|
|
576
|
+
domain: result.fields[3] === "d",
|
|
577
|
+
array: result.fields[4] === "A",
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
const serializerFor = (oid: number, domainBase = false): Serializer | undefined => {
|
|
583
|
+
const override = options?.serializers?.[oid];
|
|
584
|
+
if (override) return override;
|
|
585
|
+
const type = types.get(oid);
|
|
586
|
+
const serializer = this.#serializers[oid];
|
|
587
|
+
if (serializer && !this.#domainArrays.has(oid)) return serializer;
|
|
588
|
+
if (type?.domain) {
|
|
589
|
+
const baseSerializer = serializerFor(type.base, true);
|
|
590
|
+
return baseSerializer ? (value) => (typeof value === "string" ? value : baseSerializer(value)) : undefined;
|
|
591
|
+
}
|
|
592
|
+
// Ordinary arrays created after boot still require refreshArrayTypes().
|
|
593
|
+
if (type?.array && (domainBase || types.get(type.element)?.domain)) {
|
|
594
|
+
const elementSerializer = serializerFor(type.element);
|
|
595
|
+
return (value) => arraySerializer(value, elementSerializer, oid);
|
|
596
|
+
}
|
|
597
|
+
return serializer;
|
|
598
|
+
};
|
|
599
|
+
|
|
518
600
|
return params.map((param, index) => {
|
|
519
601
|
if (param === null || param === undefined) return null;
|
|
520
602
|
const oid = dataTypeIDs[index] ?? 0;
|
|
521
|
-
const serializer =
|
|
603
|
+
const serializer = serializerFor(oid);
|
|
522
604
|
return serializer ? serializer(param) : toText(param);
|
|
523
605
|
});
|
|
524
606
|
}
|
|
@@ -536,7 +618,7 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
536
618
|
const dataTypeIDs = parseDescribeStatementResults(
|
|
537
619
|
await this.#execNoPersist(serialize.describe({ type: "S" }), options),
|
|
538
620
|
);
|
|
539
|
-
const values = this.#serializeParams(params, dataTypeIDs, options);
|
|
621
|
+
const values = await this.#serializeParams(params, dataTypeIDs, options);
|
|
540
622
|
results = [
|
|
541
623
|
...parsed,
|
|
542
624
|
...(await this.#execNoPersist(serialize.bind({ values }), options)),
|
|
@@ -648,7 +730,15 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
648
730
|
this.#inTransaction = false;
|
|
649
731
|
if (!closed) {
|
|
650
732
|
closed = true;
|
|
651
|
-
await this.#runExec("COMMIT");
|
|
733
|
+
const [commit] = await this.#runExec("COMMIT");
|
|
734
|
+
if (commit?.command === "ROLLBACK") {
|
|
735
|
+
throw makeQueryError({
|
|
736
|
+
error: new TransactionAbortedError(),
|
|
737
|
+
query: "COMMIT",
|
|
738
|
+
params: undefined,
|
|
739
|
+
options: undefined,
|
|
740
|
+
});
|
|
741
|
+
}
|
|
652
742
|
} else {
|
|
653
743
|
// An explicit tx.rollback() ran inside the transaction; persist its outcome now.
|
|
654
744
|
await this.#persistAfterStatement();
|
|
@@ -695,16 +785,13 @@ export class PgwasmInstance implements Pgwasm {
|
|
|
695
785
|
async #initArrayTypes({ force = false } = {}): Promise<void> {
|
|
696
786
|
if (this.#arrayTypesInitialized && !force) return;
|
|
697
787
|
this.#arrayTypesInitialized = true;
|
|
698
|
-
const types = await this.query<{ oid: number; typarray: number }>(`
|
|
699
|
-
SELECT
|
|
700
|
-
FROM pg_catalog.pg_type a
|
|
701
|
-
LEFT JOIN pg_catalog.pg_type b ON b.oid = a.typelem
|
|
702
|
-
WHERE a.typcategory = 'A'
|
|
703
|
-
GROUP BY b.oid, b.typarray
|
|
704
|
-
ORDER BY b.oid
|
|
788
|
+
const types = await this.query<{ oid: number; typarray: number; typtype: string }>(`
|
|
789
|
+
SELECT oid, typarray, typtype FROM pg_catalog.pg_type WHERE typarray <> 0 ORDER BY oid
|
|
705
790
|
`);
|
|
706
791
|
for (const type of types.rows) {
|
|
707
|
-
this.#serializers[type.typarray]
|
|
792
|
+
if (!this.#serializers[type.typarray] && type.typtype === "d") this.#domainArrays.add(type.typarray);
|
|
793
|
+
this.#serializers[type.typarray] ??= (value) =>
|
|
794
|
+
arraySerializer(value, this.#serializers[type.oid], type.typarray);
|
|
708
795
|
this.#parsers[type.typarray] = (value) => arrayParser(value, this.#parsers[type.oid], type.typarray);
|
|
709
796
|
}
|
|
710
797
|
}
|
package/src/drizzle/codecs.ts
CHANGED
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
parseGeometryArrayAndNormalize,
|
|
12
12
|
parseGeometryTuple,
|
|
13
13
|
parseGeometryXY,
|
|
14
|
+
type PgCodecs,
|
|
14
15
|
refineGenericPgCodecs,
|
|
15
16
|
textToDate,
|
|
16
17
|
textToDateWithTz,
|
|
17
|
-
type PgCodecs,
|
|
18
18
|
} from "drizzle-orm/pg-core/codecs";
|
|
19
19
|
import { pgHexToUint8Array } from "drizzle-orm/utils";
|
|
20
20
|
|
|
21
|
-
import { arrayParser, DATE, INTERVAL, TIMESTAMP, TIMESTAMPTZ
|
|
21
|
+
import { arrayParser, DATE, INTERVAL, type Parser, TIMESTAMP, TIMESTAMPTZ } from "../types";
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* The identity parsers the driver passes with every query: these types reach drizzle as Postgres'
|
package/src/drizzle/driver.ts
CHANGED
|
@@ -12,7 +12,7 @@ import type { AnyRelations, EmptyRelations } from "drizzle-orm/relations";
|
|
|
12
12
|
import { PgwasmError } from "../errors";
|
|
13
13
|
import type { Pgwasm } from "../interface";
|
|
14
14
|
import { pgwasmCodecs } from "./codecs";
|
|
15
|
-
import {
|
|
15
|
+
import { type PgwasmQueryResultHKT, PgwasmSession, type PgwasmSessionClient } from "./session";
|
|
16
16
|
|
|
17
17
|
export class PgwasmDatabase<TRelations extends AnyRelations = EmptyRelations> extends PgAsyncDatabase<
|
|
18
18
|
PgwasmQueryResultHKT,
|
package/src/drizzle/session.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// own database. Owned outright (ADR-0062).
|
|
4
4
|
|
|
5
5
|
import { entityKind } from "drizzle-orm/entity";
|
|
6
|
-
import {
|
|
6
|
+
import { type Logger, NoopLogger } from "drizzle-orm/logger";
|
|
7
7
|
import { PgAsyncPreparedQuery, PgAsyncSession, PgAsyncTransaction } from "drizzle-orm/pg-core/async/session";
|
|
8
8
|
import type { PgDialect } from "drizzle-orm/pg-core/dialect";
|
|
9
9
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "drizzle-orm/pg-core/session";
|
|
10
10
|
import type { AnyRelations } from "drizzle-orm/relations";
|
|
11
|
-
import {
|
|
11
|
+
import { type Query, sql } from "drizzle-orm/sql/sql";
|
|
12
12
|
import type { Assume } from "drizzle-orm/utils";
|
|
13
13
|
|
|
14
14
|
import type { Pgwasm, Results, Row, Transaction } from "../interface";
|
package/src/errors.ts
CHANGED
|
@@ -4,7 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
import type { BuildIdentity, FilesystemKind } from "./build/seam";
|
|
6
6
|
import type { QueryOptions } from "./interface";
|
|
7
|
-
import
|
|
7
|
+
import { DatabaseError } from "./protocol/wire/messages";
|
|
8
|
+
|
|
9
|
+
/** COMMIT ended an aborted transaction with ROLLBACK instead of committing its writes. */
|
|
10
|
+
export class TransactionAbortedError extends DatabaseError {
|
|
11
|
+
constructor() {
|
|
12
|
+
super("Transaction was rolled back instead of committed", 0, "error");
|
|
13
|
+
this.severity = "ERROR";
|
|
14
|
+
this.code = "25P02";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
8
17
|
|
|
9
18
|
/** The base of every error pgwasm itself raises (SQL errors are {@link DatabaseError}). */
|
|
10
19
|
export class PgwasmError extends Error {
|
package/src/index.ts
CHANGED
package/src/interface.ts
CHANGED
|
@@ -159,7 +159,10 @@ export interface Pgwasm extends AsyncDisposable {
|
|
|
159
159
|
sql<T = Row>(sqlStrings: TemplateStringsArray, ...params: unknown[]): Promise<Results<T>>;
|
|
160
160
|
/** Any number of statements, through the simple protocol, without parameters. */
|
|
161
161
|
exec(sql: string, options?: QueryOptions): Promise<Results[]>;
|
|
162
|
-
/**
|
|
162
|
+
/**
|
|
163
|
+
* Run `callback` in a transaction: COMMIT when it resolves, ROLLBACK when it throws.
|
|
164
|
+
* Rejects with TransactionAbortedError if COMMIT rolls back an aborted transaction.
|
|
165
|
+
*/
|
|
163
166
|
transaction<T>(callback: (tx: Transaction) => Promise<T>): Promise<T>;
|
|
164
167
|
/** Run `fn` while no query or transaction runs. */
|
|
165
168
|
runExclusive<T>(fn: () => Promise<T>): Promise<T>;
|
package/src/live/format-query.ts
CHANGED
|
@@ -34,7 +34,8 @@ export async function formatQuery(
|
|
|
34
34
|
|
|
35
35
|
// $1, $2… become %1$L, %2$L…: the `$` makes format() positional; a bare `%1L` would mean "width 1"
|
|
36
36
|
// and consume arguments in order, binding the wrong value to a repeated or reordered placeholder.
|
|
37
|
-
|
|
37
|
+
// Escape the query's own percent signs before introducing format() placeholders.
|
|
38
|
+
const subbedQuery = query.replaceAll("%", "%%").replace(/\$([0-9]+)/g, (_, num: string) => `%${num}$L`);
|
|
38
39
|
const runner = tx ?? pg;
|
|
39
40
|
const result = await runner.query<{ query: string }>(
|
|
40
41
|
`SELECT format($1, ${params.map((_, i) => `$${i + 2}`).join(", ")}) as query`,
|
|
@@ -46,9 +46,11 @@
|
|
|
46
46
|
|
|
47
47
|
import { FsError } from "../core/errors";
|
|
48
48
|
import {
|
|
49
|
+
errnoName,
|
|
49
50
|
FAULT_NONE,
|
|
50
51
|
FAULT_PROTOCOL,
|
|
51
52
|
FAULT_STORE,
|
|
53
|
+
fsErrorNameOf,
|
|
52
54
|
HEADER_ERRNO,
|
|
53
55
|
HEADER_FAULT,
|
|
54
56
|
HEADER_OPCODE,
|
|
@@ -58,6 +60,7 @@ import {
|
|
|
58
60
|
HEADER_RESULT_LO,
|
|
59
61
|
HEADER_SEQUENCE,
|
|
60
62
|
HEADER_STATE,
|
|
63
|
+
joinResult,
|
|
61
64
|
OPCODE_CLOSE,
|
|
62
65
|
OPCODE_FSTAT,
|
|
63
66
|
OPCODE_FSYNC,
|
|
@@ -78,14 +81,11 @@ import {
|
|
|
78
81
|
PayloadReader,
|
|
79
82
|
PayloadWriter,
|
|
80
83
|
READDIR_DONE,
|
|
84
|
+
readStat,
|
|
81
85
|
STATE_DETACHED,
|
|
82
86
|
STATE_IDLE,
|
|
83
87
|
STATE_REQUEST,
|
|
84
88
|
STATE_RESPONSE,
|
|
85
|
-
errnoName,
|
|
86
|
-
fsErrorNameOf,
|
|
87
|
-
joinResult,
|
|
88
|
-
readStat,
|
|
89
89
|
} from "./protocol";
|
|
90
90
|
import type { BrokerStat, RepackedChannel } from "./protocol";
|
|
91
91
|
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
HEADER_RESULT_HI,
|
|
40
40
|
HEADER_RESULT_LO,
|
|
41
41
|
HEADER_STATE,
|
|
42
|
+
isKnownOpcode,
|
|
42
43
|
OPCODE_CLOSE,
|
|
43
44
|
OPCODE_FSTAT,
|
|
44
45
|
OPCODE_FSYNC,
|
|
@@ -60,13 +61,12 @@ import {
|
|
|
60
61
|
PayloadOverflowError,
|
|
61
62
|
PayloadReader,
|
|
62
63
|
PayloadWriter,
|
|
64
|
+
planOpen,
|
|
63
65
|
READDIR_DONE,
|
|
66
|
+
splitResult,
|
|
64
67
|
STATE_DETACHED,
|
|
65
68
|
STATE_REQUEST,
|
|
66
69
|
STATE_RESPONSE,
|
|
67
|
-
isKnownOpcode,
|
|
68
|
-
planOpen,
|
|
69
|
-
splitResult,
|
|
70
70
|
writeStat,
|
|
71
71
|
} from "./protocol";
|
|
72
72
|
import type { RepackedChannel, RepackedDoorbell } from "./protocol";
|
package/src/opfs/core/codec.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { crc32, crc32WithZeroedRange } from "./checksum";
|
|
|
2
2
|
import { CorruptStoreError, ExtentSizeMismatchError, StoreLimitError, StoreRecreationRequiredError } from "./errors";
|
|
3
3
|
import {
|
|
4
4
|
ARENA_HEADER_BYTES,
|
|
5
|
+
checkedU64,
|
|
5
6
|
FORMAT_VERSION,
|
|
6
7
|
LIMITS_PROFILE_VERSION,
|
|
7
8
|
MAX_COMPONENT_BYTES,
|
|
@@ -12,11 +13,10 @@ import {
|
|
|
12
13
|
MAX_METADATA_BASE_WRITER_BYTES,
|
|
13
14
|
MAX_PATH_BYTES,
|
|
14
15
|
MAX_TOTAL_EXTENTS,
|
|
15
|
-
checkedU64,
|
|
16
16
|
validateExtentSize,
|
|
17
17
|
} from "./limits";
|
|
18
18
|
import { validatePathComponent, validateSymlinkTarget } from "./path";
|
|
19
|
-
import {
|
|
19
|
+
import { estimateTxnPayloadBytes, IndexedExtentSet, validateState } from "./state-machine";
|
|
20
20
|
import type {
|
|
21
21
|
DirectoryInode,
|
|
22
22
|
ExtentRun,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ACTIVATION_SLOT_BYTES,
|
|
3
|
-
METADATA_HEADER_BYTES,
|
|
4
|
-
TXN_FRAME_HEADER_BYTES,
|
|
5
3
|
decodeArenaHeader,
|
|
6
4
|
decodeMetadataBase,
|
|
7
5
|
decodeTxnFrame,
|
|
@@ -10,9 +8,11 @@ import {
|
|
|
10
8
|
encodeMetadataBase,
|
|
11
9
|
inspectMetadataBaseHeader,
|
|
12
10
|
inspectTxnFrameHeader,
|
|
11
|
+
METADATA_HEADER_BYTES,
|
|
13
12
|
metadataBaseDigest,
|
|
14
13
|
selectActivationPair,
|
|
15
14
|
tryDecodeActivationSlot,
|
|
15
|
+
TXN_FRAME_HEADER_BYTES,
|
|
16
16
|
} from "./codec";
|
|
17
17
|
import type { ActivationRecord } from "./codec";
|
|
18
18
|
import {
|
|
@@ -25,18 +25,18 @@ import {
|
|
|
25
25
|
} from "./errors";
|
|
26
26
|
import {
|
|
27
27
|
ARENA_HEADER_BYTES,
|
|
28
|
+
checkedAdd,
|
|
29
|
+
checkedMultiply,
|
|
30
|
+
checkedSafeNumber,
|
|
28
31
|
DEFAULT_EXTENT_BYTES,
|
|
29
32
|
MAX_ACTIVE_LOG_BYTES,
|
|
30
33
|
MAX_ACTIVE_LOG_FRAMES,
|
|
31
34
|
MAX_EXTENT_BYTES,
|
|
32
35
|
MAX_METADATA_BASE_READER_BYTES,
|
|
33
36
|
MIN_EXTENT_BYTES,
|
|
34
|
-
checkedAdd,
|
|
35
|
-
checkedMultiply,
|
|
36
|
-
checkedSafeNumber,
|
|
37
37
|
validateExtentSize,
|
|
38
38
|
} from "./limits";
|
|
39
|
-
import {
|
|
39
|
+
import { metadataFileName, OWNED_FILE_NAMES, readExact, truncateChecked, writeExact } from "./port";
|
|
40
40
|
import type { OwnedFileName, RepackedFileHandle, RepackedPort, RepackedPortEntry } from "./port";
|
|
41
41
|
import { applyTxn, createInitialState, otherMetadataFile, validateState } from "./state-machine";
|
|
42
42
|
import type { MetadataFile, VfsState } from "./state-machine";
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
import { FS_ERRNO, FsError } from "./errors";
|
|
46
46
|
import { MAX_SYMLINK_HOPS } from "./limits";
|
|
47
47
|
import { parsePath } from "./path";
|
|
48
|
-
import type {
|
|
48
|
+
import type { RepackedFileSystem, RepackedStat, RepackedVfsMetrics, RepackReason } from "./repacked-vfs";
|
|
49
49
|
|
|
50
50
|
/** One store served at one path prefix. */
|
|
51
51
|
export interface RepackedMount {
|
package/src/opfs/core/port.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CorruptStoreError, StoreLimitError } from "./errors";
|
|
2
2
|
import {
|
|
3
3
|
ARENA_HEADER_BYTES,
|
|
4
|
-
MAX_TOTAL_EXTENTS,
|
|
5
4
|
checkedAdd,
|
|
6
5
|
checkedMultiply,
|
|
7
6
|
checkedSafeNumber,
|
|
8
7
|
checkedU64,
|
|
8
|
+
MAX_TOTAL_EXTENTS,
|
|
9
9
|
validateExtentSize,
|
|
10
10
|
} from "./limits";
|
|
11
11
|
import type { MetadataFile } from "./state-machine";
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ACTIVATION_SLOT_BYTES,
|
|
3
3
|
encodeActivationSlot,
|
|
4
|
-
encodeValidatedMetadataBase,
|
|
5
4
|
encodeTxnFrame,
|
|
5
|
+
encodeValidatedMetadataBase,
|
|
6
6
|
metadataBaseDigest,
|
|
7
7
|
txnFrameBytes,
|
|
8
8
|
} from "./codec";
|
|
9
9
|
import { CorruptStoreError, FS_ERRNO, FsError, StoreClosedError, StoreFailedError, StoreLimitError } from "./errors";
|
|
10
10
|
import {
|
|
11
11
|
ARENA_HEADER_BYTES,
|
|
12
|
+
checkedAdd,
|
|
13
|
+
checkedMultiply,
|
|
14
|
+
checkedSafeNumber,
|
|
15
|
+
checkedU64,
|
|
12
16
|
MAX_ACTIVE_LOG_BYTES,
|
|
13
17
|
MAX_ACTIVE_LOG_FRAMES,
|
|
14
18
|
MAX_EXTENTS_PER_INODE,
|
|
15
19
|
MAX_METADATA_BASE_WRITER_BYTES,
|
|
16
20
|
SOFT_ACTIVE_LOG_BYTES,
|
|
17
21
|
SOFT_ACTIVE_LOG_FRAMES,
|
|
18
|
-
checkedAdd,
|
|
19
|
-
checkedMultiply,
|
|
20
|
-
checkedSafeNumber,
|
|
21
|
-
checkedU64,
|
|
22
22
|
} from "./limits";
|
|
23
23
|
import { openMetadataStore } from "./metadata-store";
|
|
24
24
|
import type { OpenedMetadataStore } from "./metadata-store";
|
|
25
25
|
import { encodedUtf8Length } from "./path";
|
|
26
|
-
import {
|
|
26
|
+
import { arenaByteOffset, metadataFileName, PortWriteError, truncateChecked, writeExact } from "./port";
|
|
27
27
|
import type { RepackedFileHandle, RepackedPort } from "./port";
|
|
28
28
|
import {
|
|
29
29
|
applyTxn,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { FsError, StoreLimitError } from "./errors";
|
|
2
2
|
import {
|
|
3
|
+
checkedAdd,
|
|
4
|
+
checkedU64,
|
|
3
5
|
MAX_EXTENTS_PER_INODE,
|
|
4
|
-
MAX_INODES,
|
|
5
6
|
MAX_FRAME_PAYLOAD_BYTES,
|
|
7
|
+
MAX_INODES,
|
|
6
8
|
MAX_METADATA_BASE_WRITER_BYTES,
|
|
7
9
|
MAX_PATH_BYTES,
|
|
8
10
|
MAX_PATH_DEPTH,
|
|
9
11
|
MAX_SYMLINK_HOPS,
|
|
10
12
|
MAX_TOTAL_EXTENTS,
|
|
11
13
|
MAX_U64,
|
|
12
|
-
checkedAdd,
|
|
13
|
-
checkedU64,
|
|
14
14
|
validateExtentSize,
|
|
15
15
|
} from "./limits";
|
|
16
16
|
import { encodedUtf8Length, parsePath, validatePathComponent, validateSymlinkTarget } from "./path";
|
package/src/protocol/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* anything else runs them inside `runExclusiveSession`, which holds those locks.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { type PgwasmProtocol, protocolAccessOf } from "../core/internals";
|
|
9
9
|
import type { Pgwasm } from "../interface";
|
|
10
10
|
|
|
11
11
|
export type {
|