@dbsp/adapter-pgsql 3.2.1 → 3.3.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/dist/index.d.ts +66 -68
- package/dist/index.js +181 -230
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -27306,7 +27306,69 @@ async function readTransitionJournal(executor, runId) {
|
|
|
27306
27306
|
};
|
|
27307
27307
|
}
|
|
27308
27308
|
|
|
27309
|
+
// src/transition/lessor.ts
|
|
27310
|
+
import { createTransitionLessor } from "@dbsp/core";
|
|
27311
|
+
function createPgTransitionLessor(pool) {
|
|
27312
|
+
if (pool != null && (typeof pool === "object" || typeof pool === "function") && typeof pool.release === "function") {
|
|
27313
|
+
throw new Error(
|
|
27314
|
+
"createPgTransitionLessor received a checked-out pg PoolClient. A transition owns its lease from acquisition to release, so it needs a pool to lease from; there is no borrowed-client mode here. Pass the pg Pool the client was checked out of."
|
|
27315
|
+
);
|
|
27316
|
+
}
|
|
27317
|
+
return createTransitionLessor(async () => {
|
|
27318
|
+
const client = await pool.connect();
|
|
27319
|
+
const end = readMember(client, "end");
|
|
27320
|
+
const release = readMember(client, "release");
|
|
27321
|
+
const query = readMember(client, "query");
|
|
27322
|
+
if (typeof release !== "function" || typeof query !== "function") {
|
|
27323
|
+
if (typeof release === "function") {
|
|
27324
|
+
const rejection = new Error(
|
|
27325
|
+
"createPgTransitionLessor acquired a malformed pg lease without query(); it was returned through its captured release()."
|
|
27326
|
+
);
|
|
27327
|
+
try {
|
|
27328
|
+
void Promise.resolve(release.call(client, rejection)).catch(
|
|
27329
|
+
() => void 0
|
|
27330
|
+
);
|
|
27331
|
+
} catch {
|
|
27332
|
+
}
|
|
27333
|
+
throw rejection;
|
|
27334
|
+
}
|
|
27335
|
+
endLeakedConnection(client, end);
|
|
27336
|
+
throw new Error(
|
|
27337
|
+
"createPgTransitionLessor was given a pg Client rather than a pg Pool: connect() returned the connection itself without release(), so no acquired lease could be returned. Pass a pg Pool."
|
|
27338
|
+
);
|
|
27339
|
+
}
|
|
27340
|
+
return Object.freeze({
|
|
27341
|
+
query: (sql, params) => query.call(client, sql, params),
|
|
27342
|
+
release: (error) => release.call(client, error)
|
|
27343
|
+
});
|
|
27344
|
+
});
|
|
27345
|
+
}
|
|
27346
|
+
function endLeakedConnection(client, end) {
|
|
27347
|
+
if (typeof end !== "function") {
|
|
27348
|
+
return;
|
|
27349
|
+
}
|
|
27350
|
+
try {
|
|
27351
|
+
void Promise.resolve(end.call(client)).catch(() => void 0);
|
|
27352
|
+
} catch {
|
|
27353
|
+
}
|
|
27354
|
+
}
|
|
27355
|
+
function readMember(value, member) {
|
|
27356
|
+
if (value == null || typeof value !== "object" && typeof value !== "function") {
|
|
27357
|
+
return void 0;
|
|
27358
|
+
}
|
|
27359
|
+
try {
|
|
27360
|
+
return value[member];
|
|
27361
|
+
} catch {
|
|
27362
|
+
return void 0;
|
|
27363
|
+
}
|
|
27364
|
+
}
|
|
27365
|
+
|
|
27309
27366
|
// src/transition/observation-issuer.ts
|
|
27367
|
+
import {
|
|
27368
|
+
acquireTransitionLease,
|
|
27369
|
+
isTransitionLessor,
|
|
27370
|
+
TRANSITION_LESSOR_REJECTION
|
|
27371
|
+
} from "@dbsp/core";
|
|
27310
27372
|
init_validate();
|
|
27311
27373
|
|
|
27312
27374
|
// src/transition/claim-stamping.ts
|
|
@@ -27429,9 +27491,6 @@ function queryable(target) {
|
|
|
27429
27491
|
"PostgreSQL observation target must expose query(sql, params)"
|
|
27430
27492
|
);
|
|
27431
27493
|
}
|
|
27432
|
-
function poolLike(target) {
|
|
27433
|
-
return isRecord4(target) && typeof target.connect === "function" && typeof target.release !== "function" ? target : void 0;
|
|
27434
|
-
}
|
|
27435
27494
|
function nextEvidenceId(kind) {
|
|
27436
27495
|
observationSequence += 1;
|
|
27437
27496
|
return evidenceId(
|
|
@@ -28874,75 +28933,78 @@ async function observeEngineVersion(executor, request, context) {
|
|
|
28874
28933
|
value
|
|
28875
28934
|
});
|
|
28876
28935
|
}
|
|
28877
|
-
function
|
|
28878
|
-
|
|
28879
|
-
|
|
28880
|
-
|
|
28881
|
-
|
|
28882
|
-
|
|
28883
|
-
|
|
28884
|
-
|
|
28885
|
-
|
|
28886
|
-
|
|
28887
|
-
|
|
28888
|
-
|
|
28889
|
-
|
|
28890
|
-
|
|
28891
|
-
|
|
28892
|
-
|
|
28893
|
-
|
|
28894
|
-
|
|
28895
|
-
|
|
28896
|
-
|
|
28897
|
-
|
|
28898
|
-
|
|
28899
|
-
|
|
28900
|
-
|
|
28901
|
-
return observeEnumLabels(executor, request, context);
|
|
28902
|
-
case ALTER_AUTHORITY_OBSERVATION:
|
|
28903
|
-
case ALTER_TYPE_AUTHORITY_OBSERVATION:
|
|
28904
|
-
return observeAlterAuthority(executor, request, context);
|
|
28905
|
-
case ENGINE_VERSION_OBSERVATION:
|
|
28906
|
-
return observeEngineVersion(executor, request, context);
|
|
28907
|
-
case EXPRESSION_DEPARSE_OBSERVATION: {
|
|
28908
|
-
const deparsePool = poolLike(target);
|
|
28909
|
-
if (deparsePool) {
|
|
28910
|
-
const client = await deparsePool.connect();
|
|
28911
|
-
try {
|
|
28912
|
-
return await observeExpressionDeparse(client, request, context);
|
|
28913
|
-
} finally {
|
|
28914
|
-
client.release();
|
|
28915
|
-
}
|
|
28916
|
-
}
|
|
28917
|
-
return observeExpressionDeparse(executor, request, context);
|
|
28918
|
-
}
|
|
28919
|
-
default:
|
|
28920
|
-
throw new Error(`unsupported PostgreSQL observation ${request.kind}`);
|
|
28921
|
-
}
|
|
28922
|
-
}
|
|
28923
|
-
};
|
|
28936
|
+
async function executePgObservationFromClient(request, target, context) {
|
|
28937
|
+
const executor = queryable(target);
|
|
28938
|
+
switch (request.kind) {
|
|
28939
|
+
case COLUMN_EXISTS_OBSERVATION:
|
|
28940
|
+
return observeColumn(executor, request, context);
|
|
28941
|
+
case TABLE_CHECK_CONSTRAINTS_OBSERVATION:
|
|
28942
|
+
return observeTableChecks(executor, request, context);
|
|
28943
|
+
case TABLE_INDEXES_OBSERVATION:
|
|
28944
|
+
return observeTableIndexes(executor, request, context);
|
|
28945
|
+
case LOGICAL_IDENTITY_CARRIER_OBSERVATION:
|
|
28946
|
+
return observeLogicalIdentityCarrier(executor, request, context);
|
|
28947
|
+
case ENUM_TYPE_EXISTS_OBSERVATION:
|
|
28948
|
+
case ENUM_LABEL_VISIBLE_OBSERVATION:
|
|
28949
|
+
return observeEnumLabels(executor, request, context);
|
|
28950
|
+
case ALTER_AUTHORITY_OBSERVATION:
|
|
28951
|
+
case ALTER_TYPE_AUTHORITY_OBSERVATION:
|
|
28952
|
+
return observeAlterAuthority(executor, request, context);
|
|
28953
|
+
case ENGINE_VERSION_OBSERVATION:
|
|
28954
|
+
return observeEngineVersion(executor, request, context);
|
|
28955
|
+
case EXPRESSION_DEPARSE_OBSERVATION:
|
|
28956
|
+
return observeExpressionDeparse(executor, request, context);
|
|
28957
|
+
default:
|
|
28958
|
+
throw new Error(`unsupported PostgreSQL observation ${request.kind}`);
|
|
28959
|
+
}
|
|
28924
28960
|
}
|
|
28925
|
-
|
|
28926
|
-
|
|
28927
|
-
|
|
28928
|
-
const client = await pool.connect();
|
|
28929
|
-
try {
|
|
28930
|
-
return await readPgObservationContextFromClient(
|
|
28931
|
-
client,
|
|
28932
|
-
schema,
|
|
28933
|
-
observationTarget
|
|
28934
|
-
);
|
|
28935
|
-
} finally {
|
|
28936
|
-
client.release();
|
|
28937
|
-
}
|
|
28961
|
+
function assertTransitionLessor(value) {
|
|
28962
|
+
if (!isTransitionLessor(value)) {
|
|
28963
|
+
throw new Error(TRANSITION_LESSOR_REJECTION);
|
|
28938
28964
|
}
|
|
28939
|
-
|
|
28965
|
+
}
|
|
28966
|
+
async function executePgObservationFromLessor(lessor, request, context) {
|
|
28967
|
+
assertTransitionLessor(lessor);
|
|
28968
|
+
const lease = await acquireTransitionLease(lessor);
|
|
28969
|
+
let releaseFailure;
|
|
28970
|
+
try {
|
|
28971
|
+
return await executePgObservationFromClient(
|
|
28972
|
+
request,
|
|
28973
|
+
lease.session,
|
|
28974
|
+
context
|
|
28975
|
+
);
|
|
28976
|
+
} catch (error) {
|
|
28977
|
+
releaseFailure = { error };
|
|
28978
|
+
throw error;
|
|
28979
|
+
} finally {
|
|
28980
|
+
await lease.release(releaseFailure);
|
|
28981
|
+
}
|
|
28982
|
+
}
|
|
28983
|
+
async function readPgObservationContextFromClient(target, schema, observationTarget) {
|
|
28984
|
+
return readPgObservationContextFromQueryable(
|
|
28940
28985
|
queryable(target),
|
|
28941
28986
|
schema,
|
|
28942
28987
|
observationTarget
|
|
28943
28988
|
);
|
|
28944
28989
|
}
|
|
28945
|
-
async function
|
|
28990
|
+
async function readPgObservationContextFromLessor(lessor, schema, observationTarget) {
|
|
28991
|
+
assertTransitionLessor(lessor);
|
|
28992
|
+
const lease = await acquireTransitionLease(lessor);
|
|
28993
|
+
let releaseFailure;
|
|
28994
|
+
try {
|
|
28995
|
+
return await readPgObservationContextFromClient(
|
|
28996
|
+
lease.session,
|
|
28997
|
+
schema,
|
|
28998
|
+
observationTarget
|
|
28999
|
+
);
|
|
29000
|
+
} catch (error) {
|
|
29001
|
+
releaseFailure = { error };
|
|
29002
|
+
throw error;
|
|
29003
|
+
} finally {
|
|
29004
|
+
await lease.release(releaseFailure);
|
|
29005
|
+
}
|
|
29006
|
+
}
|
|
29007
|
+
async function readPgObservationContextFromQueryable(executor, schema, observationTarget) {
|
|
28946
29008
|
const version = await executor.query("SHOW server_version_num");
|
|
28947
29009
|
const database = await executor.query(
|
|
28948
29010
|
"SELECT current_database() AS database_id"
|
|
@@ -29010,6 +29072,20 @@ async function readPgObservationContextFromClient(executor, schema, observationT
|
|
|
29010
29072
|
...collationVersion ? { collationVersion } : {}
|
|
29011
29073
|
};
|
|
29012
29074
|
}
|
|
29075
|
+
function createPgObservationIssuer() {
|
|
29076
|
+
return {
|
|
29077
|
+
artifact: PG_INTROSPECTION_ARTIFACT,
|
|
29078
|
+
mergeObservationPrivileges: mergePgObservationPrivileges,
|
|
29079
|
+
async readContext(target, context, requests) {
|
|
29080
|
+
return readPgObservationContextFromClient(
|
|
29081
|
+
target,
|
|
29082
|
+
explicitSchemaFromContext(context),
|
|
29083
|
+
targetFromRequests(requests, context)
|
|
29084
|
+
);
|
|
29085
|
+
},
|
|
29086
|
+
execute: executePgObservationFromClient
|
|
29087
|
+
};
|
|
29088
|
+
}
|
|
29013
29089
|
|
|
29014
29090
|
// src/transition/operations/alter-column-set-not-null.ts
|
|
29015
29091
|
import { createHash } from "crypto";
|
|
@@ -31136,12 +31212,6 @@ function queryable2(target) {
|
|
|
31136
31212
|
"PostgreSQL transition target must expose query(sql, params)"
|
|
31137
31213
|
);
|
|
31138
31214
|
}
|
|
31139
|
-
function releasable(target) {
|
|
31140
|
-
return isRecord8(target) && typeof target.release === "function";
|
|
31141
|
-
}
|
|
31142
|
-
function poolLike2(target) {
|
|
31143
|
-
return isRecord8(target) && typeof target.connect === "function" && !releasable(target) ? target : void 0;
|
|
31144
|
-
}
|
|
31145
31215
|
function clientQuery(client) {
|
|
31146
31216
|
return queryable2(client.opaqueClient);
|
|
31147
31217
|
}
|
|
@@ -31241,20 +31311,6 @@ function createAlterColumnSetNotNullOperationRuntime() {
|
|
|
31241
31311
|
};
|
|
31242
31312
|
},
|
|
31243
31313
|
buildFingerprints: beforeAfterFingerprints,
|
|
31244
|
-
async checkout(target) {
|
|
31245
|
-
const pool = poolLike2(target);
|
|
31246
|
-
if (!pool) {
|
|
31247
|
-
throw new Error(
|
|
31248
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
31249
|
-
);
|
|
31250
|
-
}
|
|
31251
|
-
return { opaqueClient: await pool.connect() };
|
|
31252
|
-
},
|
|
31253
|
-
release(client, error) {
|
|
31254
|
-
if (releasable(client.opaqueClient)) {
|
|
31255
|
-
client.opaqueClient.release(error);
|
|
31256
|
-
}
|
|
31257
|
-
},
|
|
31258
31314
|
async writeIntentJournal(client, record) {
|
|
31259
31315
|
await appendIntentJournal(clientQuery(client), record);
|
|
31260
31316
|
},
|
|
@@ -31276,7 +31332,7 @@ function createAlterColumnSetNotNullOperationRuntime() {
|
|
|
31276
31332
|
},
|
|
31277
31333
|
async observeContext(client, operation, _proofContext) {
|
|
31278
31334
|
const payload = payloadOf(operation);
|
|
31279
|
-
return
|
|
31335
|
+
return readPgObservationContextFromClient(
|
|
31280
31336
|
client.opaqueClient,
|
|
31281
31337
|
explicitSchema(payload),
|
|
31282
31338
|
payload
|
|
@@ -31834,12 +31890,6 @@ function queryable3(target) {
|
|
|
31834
31890
|
"PostgreSQL transition target must expose query(sql, params)"
|
|
31835
31891
|
);
|
|
31836
31892
|
}
|
|
31837
|
-
function releasable2(target) {
|
|
31838
|
-
return isRecord9(target) && typeof target.release === "function";
|
|
31839
|
-
}
|
|
31840
|
-
function poolLike3(target) {
|
|
31841
|
-
return isRecord9(target) && typeof target.connect === "function" && !releasable2(target) ? target : void 0;
|
|
31842
|
-
}
|
|
31843
31893
|
function clientQuery2(client) {
|
|
31844
31894
|
return queryable3(client.opaqueClient);
|
|
31845
31895
|
}
|
|
@@ -31949,20 +31999,6 @@ function createAlterTableAddCheckOperationRuntime() {
|
|
|
31949
31999
|
};
|
|
31950
32000
|
},
|
|
31951
32001
|
buildFingerprints: beforeAfterFingerprints2,
|
|
31952
|
-
async checkout(target) {
|
|
31953
|
-
const pool = poolLike3(target);
|
|
31954
|
-
if (!pool) {
|
|
31955
|
-
throw new Error(
|
|
31956
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
31957
|
-
);
|
|
31958
|
-
}
|
|
31959
|
-
return { opaqueClient: await pool.connect() };
|
|
31960
|
-
},
|
|
31961
|
-
release(client, error) {
|
|
31962
|
-
if (releasable2(client.opaqueClient)) {
|
|
31963
|
-
client.opaqueClient.release(error);
|
|
31964
|
-
}
|
|
31965
|
-
},
|
|
31966
32002
|
async writeIntentJournal(client, record) {
|
|
31967
32003
|
await appendIntentJournal(clientQuery2(client), record);
|
|
31968
32004
|
},
|
|
@@ -31984,11 +32020,15 @@ function createAlterTableAddCheckOperationRuntime() {
|
|
|
31984
32020
|
},
|
|
31985
32021
|
async observeContext(client, operation, _proofContext) {
|
|
31986
32022
|
const payload = payloadOf2(operation);
|
|
31987
|
-
return
|
|
31988
|
-
|
|
31989
|
-
|
|
31990
|
-
|
|
31991
|
-
|
|
32023
|
+
return readPgObservationContextFromClient(
|
|
32024
|
+
client.opaqueClient,
|
|
32025
|
+
payload.schema,
|
|
32026
|
+
{
|
|
32027
|
+
schema: payload.schema,
|
|
32028
|
+
table: payload.table,
|
|
32029
|
+
constraint: payload.constraint
|
|
32030
|
+
}
|
|
32031
|
+
);
|
|
31992
32032
|
},
|
|
31993
32033
|
async observeOperation(client, operation, context, phase, issuer) {
|
|
31994
32034
|
const payload = payloadOf2(operation);
|
|
@@ -32480,12 +32520,6 @@ function queryable4(target) {
|
|
|
32480
32520
|
"PostgreSQL transition target must expose query(sql, params)"
|
|
32481
32521
|
);
|
|
32482
32522
|
}
|
|
32483
|
-
function releasable3(target) {
|
|
32484
|
-
return isRecord10(target) && typeof target.release === "function";
|
|
32485
|
-
}
|
|
32486
|
-
function poolLike4(target) {
|
|
32487
|
-
return isRecord10(target) && typeof target.connect === "function" && !releasable3(target) ? target : void 0;
|
|
32488
|
-
}
|
|
32489
32523
|
function clientQuery3(client) {
|
|
32490
32524
|
return queryable4(client.opaqueClient);
|
|
32491
32525
|
}
|
|
@@ -32546,20 +32580,6 @@ function createAlterTypeAddValueOperationRuntime() {
|
|
|
32546
32580
|
};
|
|
32547
32581
|
},
|
|
32548
32582
|
buildFingerprints: beforeAfterFingerprints3,
|
|
32549
|
-
async checkout(target) {
|
|
32550
|
-
const pool = poolLike4(target);
|
|
32551
|
-
if (!pool) {
|
|
32552
|
-
throw new Error(
|
|
32553
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
32554
|
-
);
|
|
32555
|
-
}
|
|
32556
|
-
return { opaqueClient: await pool.connect() };
|
|
32557
|
-
},
|
|
32558
|
-
release(client, error) {
|
|
32559
|
-
if (releasable3(client.opaqueClient)) {
|
|
32560
|
-
client.opaqueClient.release(error);
|
|
32561
|
-
}
|
|
32562
|
-
},
|
|
32563
32583
|
async writeIntentJournal(client, record) {
|
|
32564
32584
|
await appendIntentJournal(clientQuery3(client), record);
|
|
32565
32585
|
},
|
|
@@ -32582,10 +32602,14 @@ function createAlterTypeAddValueOperationRuntime() {
|
|
|
32582
32602
|
},
|
|
32583
32603
|
async observeContext(client, operation, _proofContext) {
|
|
32584
32604
|
const payload = payloadOf3(operation);
|
|
32585
|
-
return
|
|
32586
|
-
|
|
32587
|
-
|
|
32588
|
-
|
|
32605
|
+
return readPgObservationContextFromClient(
|
|
32606
|
+
client.opaqueClient,
|
|
32607
|
+
payload.schema,
|
|
32608
|
+
{
|
|
32609
|
+
schema: payload.schema,
|
|
32610
|
+
type: payload.type
|
|
32611
|
+
}
|
|
32612
|
+
);
|
|
32589
32613
|
},
|
|
32590
32614
|
async observeOperation(client, operation, context, _phase, issuer) {
|
|
32591
32615
|
const payload = payloadOf3(operation);
|
|
@@ -32990,12 +33014,6 @@ function queryable5(target) {
|
|
|
32990
33014
|
"PostgreSQL transition target must expose query(sql, params)"
|
|
32991
33015
|
);
|
|
32992
33016
|
}
|
|
32993
|
-
function releasable4(target) {
|
|
32994
|
-
return isRecord11(target) && typeof target.release === "function";
|
|
32995
|
-
}
|
|
32996
|
-
function poolLike5(target) {
|
|
32997
|
-
return isRecord11(target) && typeof target.connect === "function" && !releasable4(target) ? target : void 0;
|
|
32998
|
-
}
|
|
32999
33017
|
function clientQuery4(client) {
|
|
33000
33018
|
return queryable5(client.opaqueClient);
|
|
33001
33019
|
}
|
|
@@ -33089,20 +33107,6 @@ function createAttachLogicalIdentityOperationRuntime() {
|
|
|
33089
33107
|
};
|
|
33090
33108
|
},
|
|
33091
33109
|
buildFingerprints: beforeAfterFingerprints4,
|
|
33092
|
-
async checkout(target) {
|
|
33093
|
-
const pool = poolLike5(target);
|
|
33094
|
-
if (!pool) {
|
|
33095
|
-
throw new Error(
|
|
33096
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
33097
|
-
);
|
|
33098
|
-
}
|
|
33099
|
-
return { opaqueClient: await pool.connect() };
|
|
33100
|
-
},
|
|
33101
|
-
release(client, error) {
|
|
33102
|
-
if (releasable4(client.opaqueClient)) {
|
|
33103
|
-
client.opaqueClient.release(error);
|
|
33104
|
-
}
|
|
33105
|
-
},
|
|
33106
33110
|
async writeIntentJournal(client, record) {
|
|
33107
33111
|
await appendIntentJournal(clientQuery4(client), record);
|
|
33108
33112
|
},
|
|
@@ -33124,11 +33128,15 @@ function createAttachLogicalIdentityOperationRuntime() {
|
|
|
33124
33128
|
},
|
|
33125
33129
|
async observeContext(client, operation, _proofContext) {
|
|
33126
33130
|
const payload = payloadOf4(operation);
|
|
33127
|
-
return
|
|
33128
|
-
|
|
33129
|
-
|
|
33130
|
-
|
|
33131
|
-
|
|
33131
|
+
return readPgObservationContextFromClient(
|
|
33132
|
+
client.opaqueClient,
|
|
33133
|
+
payload.schema,
|
|
33134
|
+
{
|
|
33135
|
+
table: payload.table,
|
|
33136
|
+
...payload.column ? { column: payload.column } : {},
|
|
33137
|
+
schema: payload.schema
|
|
33138
|
+
}
|
|
33139
|
+
);
|
|
33132
33140
|
},
|
|
33133
33141
|
async observeOperation(client, operation, context, phase, issuer) {
|
|
33134
33142
|
const payload = payloadOf4(operation);
|
|
@@ -33594,12 +33602,6 @@ function queryable6(target) {
|
|
|
33594
33602
|
"PostgreSQL transition target must expose query(sql, params)"
|
|
33595
33603
|
);
|
|
33596
33604
|
}
|
|
33597
|
-
function releasable5(target) {
|
|
33598
|
-
return isRecord12(target) && typeof target.release === "function";
|
|
33599
|
-
}
|
|
33600
|
-
function poolLike6(target) {
|
|
33601
|
-
return isRecord12(target) && typeof target.connect === "function" && !releasable5(target) ? target : void 0;
|
|
33602
|
-
}
|
|
33603
33605
|
function clientQuery5(client) {
|
|
33604
33606
|
return queryable6(client.opaqueClient);
|
|
33605
33607
|
}
|
|
@@ -33865,20 +33867,6 @@ function createCreateUniqueIndexConcurrentlyOperationRuntime() {
|
|
|
33865
33867
|
};
|
|
33866
33868
|
},
|
|
33867
33869
|
buildFingerprints: beforeAfterFingerprints5,
|
|
33868
|
-
async checkout(target) {
|
|
33869
|
-
const pool = poolLike6(target);
|
|
33870
|
-
if (!pool) {
|
|
33871
|
-
throw new Error(
|
|
33872
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
33873
|
-
);
|
|
33874
|
-
}
|
|
33875
|
-
return { opaqueClient: await pool.connect() };
|
|
33876
|
-
},
|
|
33877
|
-
release(client, error) {
|
|
33878
|
-
if (releasable5(client.opaqueClient)) {
|
|
33879
|
-
client.opaqueClient.release(error);
|
|
33880
|
-
}
|
|
33881
|
-
},
|
|
33882
33870
|
async writeIntentJournal(client, record) {
|
|
33883
33871
|
await appendIntentJournal(clientQuery5(client), record);
|
|
33884
33872
|
},
|
|
@@ -33893,11 +33881,15 @@ function createCreateUniqueIndexConcurrentlyOperationRuntime() {
|
|
|
33893
33881
|
},
|
|
33894
33882
|
async observeContext(client, operation, _proofContext) {
|
|
33895
33883
|
const payload = payloadOf5(operation);
|
|
33896
|
-
return
|
|
33897
|
-
|
|
33898
|
-
|
|
33899
|
-
|
|
33900
|
-
|
|
33884
|
+
return readPgObservationContextFromClient(
|
|
33885
|
+
client.opaqueClient,
|
|
33886
|
+
payload.schema,
|
|
33887
|
+
{
|
|
33888
|
+
schema: payload.schema,
|
|
33889
|
+
table: payload.table,
|
|
33890
|
+
index: payload.index
|
|
33891
|
+
}
|
|
33892
|
+
);
|
|
33901
33893
|
},
|
|
33902
33894
|
async observeOperation(client, operation, context, phase, issuer) {
|
|
33903
33895
|
const payload = payloadOf5(operation);
|
|
@@ -34013,12 +34005,6 @@ function queryable7(target) {
|
|
|
34013
34005
|
"PostgreSQL transition target must expose query(sql, params)"
|
|
34014
34006
|
);
|
|
34015
34007
|
}
|
|
34016
|
-
function releasable6(target) {
|
|
34017
|
-
return isRecord13(target) && typeof target.release === "function";
|
|
34018
|
-
}
|
|
34019
|
-
function poolLike7(target) {
|
|
34020
|
-
return isRecord13(target) && typeof target.connect === "function" && !releasable6(target) ? target : void 0;
|
|
34021
|
-
}
|
|
34022
34008
|
function clientQuery6(client) {
|
|
34023
34009
|
return queryable7(client.opaqueClient);
|
|
34024
34010
|
}
|
|
@@ -34600,20 +34586,6 @@ function createManualSqlOperationRuntime() {
|
|
|
34600
34586
|
};
|
|
34601
34587
|
},
|
|
34602
34588
|
buildFingerprints: beforeAfterFingerprints6,
|
|
34603
|
-
async checkout(target) {
|
|
34604
|
-
const pool = poolLike7(target);
|
|
34605
|
-
if (!pool) {
|
|
34606
|
-
throw new Error(
|
|
34607
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
34608
|
-
);
|
|
34609
|
-
}
|
|
34610
|
-
return { opaqueClient: await pool.connect() };
|
|
34611
|
-
},
|
|
34612
|
-
release(client, error) {
|
|
34613
|
-
if (releasable6(client.opaqueClient)) {
|
|
34614
|
-
client.opaqueClient.release(error);
|
|
34615
|
-
}
|
|
34616
|
-
},
|
|
34617
34589
|
async writeIntentJournal(client, record) {
|
|
34618
34590
|
await appendIntentJournal(clientQuery6(client), record);
|
|
34619
34591
|
},
|
|
@@ -34625,7 +34597,7 @@ function createManualSqlOperationRuntime() {
|
|
|
34625
34597
|
async acquireLocks() {
|
|
34626
34598
|
},
|
|
34627
34599
|
async observeContext(client, _operation, proofContext) {
|
|
34628
|
-
return
|
|
34600
|
+
return readPgObservationContextFromClient(
|
|
34629
34601
|
client.opaqueClient,
|
|
34630
34602
|
proofContext.targetSchema ?? proofContext.searchPath?.[0] ?? "public"
|
|
34631
34603
|
);
|
|
@@ -36909,15 +36881,6 @@ var PG_TRANSACTION_DOMAIN = "postgresql.transition.connection";
|
|
|
36909
36881
|
function isRecord19(value) {
|
|
36910
36882
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
36911
36883
|
}
|
|
36912
|
-
function poolLike8(value) {
|
|
36913
|
-
if (isRecord19(value) && typeof value.connect === "function") {
|
|
36914
|
-
return value;
|
|
36915
|
-
}
|
|
36916
|
-
return void 0;
|
|
36917
|
-
}
|
|
36918
|
-
function releasable7(value) {
|
|
36919
|
-
return isRecord19(value) && typeof value.query === "function" && typeof value.release === "function";
|
|
36920
|
-
}
|
|
36921
36884
|
function clientQuery7(client) {
|
|
36922
36885
|
if (isRecord19(client.opaqueClient) && typeof client.opaqueClient.query === "function") {
|
|
36923
36886
|
return client.opaqueClient;
|
|
@@ -36933,20 +36896,6 @@ function boundedLockTimeout(maxWaitMs) {
|
|
|
36933
36896
|
function createPgExecutionCoordinator() {
|
|
36934
36897
|
return {
|
|
36935
36898
|
transactionDomain: PG_TRANSACTION_DOMAIN,
|
|
36936
|
-
async checkout(target) {
|
|
36937
|
-
const pool = poolLike8(target);
|
|
36938
|
-
if (!pool) {
|
|
36939
|
-
throw new Error(
|
|
36940
|
-
"PostgreSQL transition target must be a Pool-like object with connect(); checked-out clients are not accepted"
|
|
36941
|
-
);
|
|
36942
|
-
}
|
|
36943
|
-
return { opaqueClient: await pool.connect() };
|
|
36944
|
-
},
|
|
36945
|
-
release(client, error) {
|
|
36946
|
-
if (releasable7(client.opaqueClient)) {
|
|
36947
|
-
client.opaqueClient.release(error);
|
|
36948
|
-
}
|
|
36949
|
-
},
|
|
36950
36899
|
async begin(client) {
|
|
36951
36900
|
await clientQuery7(client).query("BEGIN");
|
|
36952
36901
|
},
|
|
@@ -37122,6 +37071,7 @@ export {
|
|
|
37122
37071
|
createManualSqlOperationRuntime,
|
|
37123
37072
|
createParamRef,
|
|
37124
37073
|
createPgObservationIssuer,
|
|
37074
|
+
createPgTransitionLessor,
|
|
37125
37075
|
createPgTransitionPack,
|
|
37126
37076
|
createPgsqlAdapter,
|
|
37127
37077
|
createPgsqlCompileOnlyAdapter,
|
|
@@ -37132,6 +37082,7 @@ export {
|
|
|
37132
37082
|
ensureMigrationsTable,
|
|
37133
37083
|
ensureTransitionJournal,
|
|
37134
37084
|
excludedRef,
|
|
37085
|
+
executePgObservationFromLessor,
|
|
37135
37086
|
generateCreateIndex,
|
|
37136
37087
|
generateCursorName,
|
|
37137
37088
|
generateDDL,
|
|
@@ -37163,7 +37114,7 @@ export {
|
|
|
37163
37114
|
parseExplainJson,
|
|
37164
37115
|
parseMigrationFile,
|
|
37165
37116
|
rawDistance,
|
|
37166
|
-
|
|
37117
|
+
readPgObservationContextFromLessor,
|
|
37167
37118
|
readTransitionJournal,
|
|
37168
37119
|
recordMigration,
|
|
37169
37120
|
redactParams,
|