@dbsp/adapter-pgsql 4.0.0 → 6.0.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 +2 -2
- package/dist/chunk-NXGMFZ4E.js +57170 -0
- package/dist/chunk-NXGMFZ4E.js.map +1 -0
- package/dist/index.d.ts +183 -1245
- package/dist/index.js +791 -36999
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +144 -5
- package/dist/internal.js +37 -1
- package/dist/outcome-protocol-Dw5DYhnA.d.ts +2727 -0
- package/package.json +8 -8
- package/dist/chunk-KZ3NLIZ5.js +0 -13043
- package/dist/chunk-KZ3NLIZ5.js.map +0 -1
- package/dist/outcome-protocol-CACJDzli.d.ts +0 -1088
package/dist/index.d.ts
CHANGED
|
@@ -1,97 +1,14 @@
|
|
|
1
|
+
import { N as NamingPlugin, F as FkColumnDerivation, C as ChangeKind, G as GeneratedPostconditionSession, T as TransitionJournalQueryable, P as PgLockedRun, a as PgOutcomeCheckpointObserver, b as ConvergePgOptions$1, c as PgPhysicalModel, d as PgConvergeResult, e as PgConvergeCheckResult, f as PgLedgerScopeCurrency, r as readTransitionJournal } from './outcome-protocol-Dw5DYhnA.js';
|
|
2
|
+
export { A as AddedEnumValue, g as AutoIncrementTransitionUnsupportedError, h as CamelCaseNamingPlugin, i as CanonicalizeCheckConstraintsOptions, j as CheckConstraintCanonicalizationError, k as CheckConstraintCanonicalizationWarning, l as CheckConstraintNewEnumValueError, m as ColumnDefaultCanonicalizationError, n as ColumnDefaultCanonicalizationWarning, o as ComparePgsqlDatabaseSchemaOptions, p as CompareSchemataOptions, D as DEFAULT_PK_COLUMN, q as DetectedHierarchy, s as DiffSummary, E as ExpressionCanonicalizationUnavailableError, t as ExpressionCanonicalizationWarning, u as ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError, v as GenerateDDLOptions, w as GeneratedPostcondition, x as GeneratedPostconditionBindingAddress, y as GeneratedPostconditionBindingResolutionError, z as GeneratedPostconditionProofInFlightError, B as GeneratedPostconditionReplanRequiredError, H as GeneratedPostconditionSessionDeactivatedError, I as GeneratedPostconditionWorkInFlightError, J as IdentityNamingPlugin, K as IndexCapabilityContext, L as IndexFeatureUnsupportedError, M as IndexPredicateCanonicalizationError, O as IndexRenderSpec, Q as IntrospectedModelIR, R as IntrospectionOptions, S as MigrationSQLOptions, U as NonConvergentSchemaDiffError, V as NonConvergentSchemaDiffSurface, W as PG_LEDGER_SHAPE_VERSION, X as PartialIndexPredicateNewEnumValueError, Y as PgAdmittedOperation, Z as PgAdmittedOperationResult, _ as PgAdvisoryLockKey, $ as PgAdvisoryLockResult, a0 as PgApplicationStepOwnedState, a1 as PgApplicationStepTx, a2 as PgCatalogueIdentityQueryable, a3 as PgConvergeApplicationStep, a4 as PgConvergeAssertStep, a5 as PgConvergeInitializationFailure, a6 as PgConvergeOnceStep, a7 as PgConvergePlannedStep, a8 as PgConvergeRefusal, a9 as PgConvergeRefusalChange, aa as PgConvergeRefusalError, ab as PgLedgerLockResult, ac as PgLedgerStorageUnsupportedError, ad as PgLedgerTarget, ae as PgOutcomeCheckpoint, af as PgOutcomeClaimRequest, ag as PgOutcomeExecutionRequest, ah as PgOutcomeNonTransactionalRequest, ai as PgOutcomeReadBackFactory, aj as PgOutcomeRecoveryRequest, ak as PgOutcomeRecoveryResult, al as PgOutcomeResolution, am as PgOutcomeResolutionAppendResult, an as PgOutcomeResult, ao as PgOutcomeTransactionalRequest, ap as PgOwnedCheckState, aq as PgPhysicalModelInput, ar as PgPhysicalModelInputError, as as PgPhysicalNameClaim, at as PgPhysicalNameCollision, au as PgPhysicalNameCollisionError, av as PgPhysicalNamespace, aw as PgReinitializePreflightOptions, ax as PgReinitializePreflightPool, ay as PgSchemaDiff, az as PgsqlAdapter, aA as PgsqlAdapterOptions, aB as PgsqlAdvisoryLockOptionsError, aC as PgsqlBorrowedClientAdapterOptions, aD as PgsqlCompileOnlyAdapterOptions, aE as PgsqlPinnedConnectionAbortSignalError, aF as PgsqlPoolAdapterOptions, aG as PgsqlPreparedStatementReplayError, aH as PgsqlPreparedStatementsOptions, aI as PgsqlRawSqlTransactionControlError, aJ as PgsqlTransactionAbortSignalError, aK as PgsqlTransactionAbortedCommitError, aL as PgsqlTransactionAbortedError, aM as PgsqlTransactionOptionsError, aN as PgsqlTransactionTimeoutError, aO as RawIndexPredicateFallbackError, aP as ReferencedKeyKind, aQ as ReferencedKeyRemovalConflict, aR as ReferencedKeyRemovalError, aS as RollbackOnlyPgsqlScope, aT as SchemaChange, aU as SchemaDiff, aV as SchemaScopeOptions, aW as TransitionRunIdentityMismatchError, aX as acquirePgLedgerLocks, aY as appendIntentJournal, aZ as appendTransitionAuthorization, a_ as assertCreateIndexSupported, a$ as assertCreateIndexesSupported, b0 as assertDeclarableChangeKind, b1 as assertGeneratedPostconditionSession, b2 as assertNoRepeatedExpressionSurfaceDrift, b3 as camelCaseNaming, b4 as canGenerateCreateIndex, b5 as canonicalizeCheckConstraints, b6 as comparePgsqlDatabaseSchema, b7 as compareSchemata, b8 as createPgPhysicalModel, b9 as createPgTransitionRunPersister, ba as createPgsqlAdapter, bb as createPgsqlCompileOnlyAdapter, bc as createPgsqlGeneratedManagedStep, bd as decodeGeneratedPostcondition, be as decodeGeneratedPostconditionPayload, bf as defaultFkDerivation, bg as ensureDbspMetaLedger, bh as ensurePgLedger, bi as ensurePgLedgerStorageVersion, bj as ensureTransitionJournal, bk as executePgAdmittedOperation, bl as generateCreateIndex, bm as generateDDL, bn as generateDownSQL, bo as generateMigrationSQL, bp as generatedPostconditionDigest, bq as generatedPostconditionForChange, br as getNamingPluginForDbCasing, bs as identityNaming, bt as introspect, bu as readPgCatalogueIdentity, bv as readPgLedgerMarker, bw as readPgLedgerReservationsForExecution, bx as readPgLedgerScopeCurrency, by as readPgOutcomeRecoveryReadBack, bz as readVerifiedPgLedgerReservationsForPair, bA as recordPgLedgerIdentity, bB as renderCreateDbspMetaSchemaSql, bC as renderCreateIndex, bD as renderCreateLedgerEventTableSql, bE as renderCreateLedgerIdentityTableSql, bF as renderCreateLedgerImmutabilityFunctionSql, bG as renderCreateLedgerImmutabilityTriggerSql, bH as renderCreateLedgerMarkerTableSql, bI as renderCreateLedgerReservationTableSql, bJ as renderCreateLedgerTerminalMemberIndexSql, bK as renderCreateTransitionAuthorizationTableSql, bL as renderCreateTransitionJournalTableSql, bM as renderCreateTransitionRunPlanTableSql, bN as renderCreateTransitionRunTableSql, bO as runPgReinitializePreflight, bP as toGeneratedPostconditionBindingAddress, bQ as validatePgLedgerRuntimeIntegrity, bR as verifyGeneratedCheckPostcondition, bS as verifyGeneratedColumnPostcondition, bT as verifyGeneratedIdentityPostcondition, bU as verifyGeneratedIndexPostcondition, bV as verifyGeneratedTablePostcondition, bW as withGeneratedPostconditionSession } from './outcome-protocol-Dw5DYhnA.js';
|
|
1
3
|
import * as _dbsp_core from '@dbsp/core';
|
|
2
|
-
import {
|
|
4
|
+
import { ExpressionRef, ModelIR as ModelIR$1, ValidatedManagedStepManifest, ExecutionCoordinator, CapabilityDescriptor } from '@dbsp/core';
|
|
3
5
|
export { normalizeSQL } from '@dbsp/core';
|
|
4
6
|
import * as _dbsp_types from '@dbsp/types';
|
|
5
|
-
import { DialectCapabilities, ModelIR, ColumnListInput, ParamIntent, JsonAggOrderByEntry,
|
|
7
|
+
import { OutputDescriptor, PlanReport, DialectCapabilities, ModelIR, ColumnListInput, ParamIntent, JsonAggOrderByEntry, LedgerPayload, LedgerAddress, NormalizedManagedStep, ColumnIR, MutationReturningItem, WhereIntent, DbCasing, QueryIntent, CompiledQuery, SetOperationIntent, CompileOptions, LedgerHome, ScopedApprovalSet, LedgerChainMember, OperationKindRef, SemanticArtifactRef, ProvenPlanShape, PostgreSqlObservationTargetIdentity, ExecutionContract, TransitionSessionClient, TransitionLessor, ExclusiveTransitionTarget, ObservationIssuer, ObservationRequest, ObservationContext, EvidenceObservation, TypeRef, ExpressionValue, CollationRef, LogicalIdentity, PhysicalOperation, OperationEffectAssessment, FingerprintManifest, DurableIntentRecord, IssuedObservation, ApplyGuard, AdvisoryObservation, TransactionalCompletionRecord, StepJournal, UnsafeNativeFragment, ResourceAddress, ExecutableAssertion, Assumption, TransitionRule, TransitionCompositionFact, TrustRoot, RequiredEnumLabelIR, TableReaddressDeclaration, LedgerReservationRow, LedgerRefusal, ContainmentClosureDestructiveOutcome, LedgerClaimKind } from '@dbsp/types';
|
|
6
8
|
import * as _pgsql_types from '@pgsql/types';
|
|
7
9
|
import { Node, OnConflictClause, ParamRef } from '@pgsql/types';
|
|
8
|
-
import {
|
|
9
|
-
export {
|
|
10
|
-
import { Pool, PoolClient } from 'pg';
|
|
11
|
-
import '@dbsp/core/internal';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Default primary key column name used as convention fallback
|
|
15
|
-
* when schema metadata doesn't provide an explicit PK.
|
|
16
|
-
*
|
|
17
|
-
* Consumers (handlers, compiler) must NOT use this directly —
|
|
18
|
-
* they use `requiredColumn()` to throw on missing data.
|
|
19
|
-
* Only convention mappers (extractors, introspection) should reference this.
|
|
20
|
-
*/
|
|
21
|
-
declare const DEFAULT_PK_COLUMN = "id";
|
|
22
|
-
/**
|
|
23
|
-
* Derive a foreign key column name from a table name and the PK column it references.
|
|
24
|
-
*
|
|
25
|
-
* Convention: `${singularTableName}_${pkColumnName}`
|
|
26
|
-
* e.g. (authors, id) → author_id, (categories, id) → category_id
|
|
27
|
-
*
|
|
28
|
-
* Consumers should use `deriveFkColumnName` from CompilerContext or options
|
|
29
|
-
* for configurable behavior.
|
|
30
|
-
*/
|
|
31
|
-
type FkColumnDerivation = (tableName: string, pkColumnName: string) => string;
|
|
32
|
-
declare const defaultFkDerivation: FkColumnDerivation;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* NamingPlugin - Identifier transformation between model and database naming conventions
|
|
36
|
-
*
|
|
37
|
-
* Inspired by Kysely's CamelCasePlugin architecture.
|
|
38
|
-
* The plugin transforms identifiers bidirectionally:
|
|
39
|
-
* - toDatabase: model name (camelCase) → database name (snake_case)
|
|
40
|
-
* - toModel: database name (snake_case) → model name (camelCase)
|
|
41
|
-
*/
|
|
42
|
-
/**
|
|
43
|
-
* Interface for naming convention transformation plugins
|
|
44
|
-
*/
|
|
45
|
-
interface NamingPlugin {
|
|
46
|
-
/**
|
|
47
|
-
* Transform a model identifier to database format
|
|
48
|
-
* Example: "createdAt" → "created_at"
|
|
49
|
-
*/
|
|
50
|
-
toDatabase(identifier: string): string;
|
|
51
|
-
/**
|
|
52
|
-
* Transform a database identifier to model format
|
|
53
|
-
* Example: "created_at" → "createdAt"
|
|
54
|
-
*/
|
|
55
|
-
toModel(identifier: string): string;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Identity plugin - no transformation
|
|
59
|
-
* Use this when model and database naming conventions match
|
|
60
|
-
*/
|
|
61
|
-
declare class IdentityNamingPlugin implements NamingPlugin {
|
|
62
|
-
toDatabase(identifier: string): string;
|
|
63
|
-
toModel(identifier: string): string;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* CamelCase ↔ snake_case transformation plugin
|
|
67
|
-
*
|
|
68
|
-
* Follows the same logic as Kysely's CamelCasePlugin:
|
|
69
|
-
* - Handles consecutive uppercase letters (e.g., "parseJSON" → "parse_json")
|
|
70
|
-
* - Handles numbers (e.g., "field1Name" → "field1_name")
|
|
71
|
-
* - Preserves leading underscores
|
|
72
|
-
*/
|
|
73
|
-
declare class CamelCaseNamingPlugin implements NamingPlugin {
|
|
74
|
-
/**
|
|
75
|
-
* camelCase → snake_case
|
|
76
|
-
*/
|
|
77
|
-
toDatabase(identifier: string): string;
|
|
78
|
-
/**
|
|
79
|
-
* snake_case → camelCase
|
|
80
|
-
*/
|
|
81
|
-
toModel(identifier: string): string;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Singleton instances for convenience
|
|
85
|
-
*/
|
|
86
|
-
declare const identityNaming: IdentityNamingPlugin;
|
|
87
|
-
declare const camelCaseNaming: CamelCaseNamingPlugin;
|
|
88
|
-
/**
|
|
89
|
-
* Get a naming plugin by DbCasing (intuitive semantics).
|
|
90
|
-
* - `'snake_case'`: DB uses snake_case → CamelCaseNamingPlugin (transforms to camelCase)
|
|
91
|
-
* - `'camelCase'`: DB uses camelCase → IdentityNamingPlugin (no transform)
|
|
92
|
-
* - `'preserve'`: No transformation → IdentityNamingPlugin
|
|
93
|
-
*/
|
|
94
|
-
declare function getNamingPluginForDbCasing(casing: 'snake_case' | 'camelCase' | 'preserve'): NamingPlugin;
|
|
10
|
+
import { PoolClient, Pool } from 'pg';
|
|
11
|
+
export { escapeDiagnosticText } from '@dbsp/core/internal';
|
|
95
12
|
|
|
96
13
|
/**
|
|
97
14
|
* Internal registry of NQL `| bind name` CTE names visible to a compile pass.
|
|
@@ -103,6 +20,47 @@ declare function getNamingPluginForDbCasing(casing: 'snake_case' | 'camelCase' |
|
|
|
103
20
|
|
|
104
21
|
type BindingNameRegistry = ReadonlySet<string>;
|
|
105
22
|
|
|
23
|
+
declare const projectionEnvelopeBrand: unique symbol;
|
|
24
|
+
type ProjectionEnvelope<T = unknown> = {
|
|
25
|
+
readonly [projectionEnvelopeBrand]: true;
|
|
26
|
+
readonly sql: string;
|
|
27
|
+
readonly parameters: readonly unknown[];
|
|
28
|
+
readonly ast?: Node;
|
|
29
|
+
readonly projection: ProjectionState;
|
|
30
|
+
readonly hydrationPlan?: PlanReport;
|
|
31
|
+
readonly __resultType?: T;
|
|
32
|
+
};
|
|
33
|
+
type ProjectionState = {
|
|
34
|
+
readonly kind: 'known';
|
|
35
|
+
readonly outputs: ReadonlyMap<string, OutputProjection>;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'dropped';
|
|
38
|
+
readonly reason: ProjectionDropReason;
|
|
39
|
+
readonly hadConvertibleSource: boolean;
|
|
40
|
+
};
|
|
41
|
+
type OutputProjection = OutputDescriptor;
|
|
42
|
+
|
|
43
|
+
type ProjectionDropReason = 'set-operation-positional-merge' | 'raw-recursive-cte-positional-merge' | 'unknown-raw-sql' | 'unsupported-source';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Resolves the columns available through a relation target. A query-local
|
|
47
|
+
* binding shadows a physical relation, so its (when known) projection is the
|
|
48
|
+
* authority for every column emitted against that target.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
type RelationTargetProjectionRegistry = ReadonlyMap<string, ProjectionEnvelope>;
|
|
52
|
+
/** A query-scope binding from an emitted SQL alias to the relation it exposes. */
|
|
53
|
+
type AliasColumnAuthority = ReadonlyMap<string, ResolvedRelationTarget>;
|
|
54
|
+
type ResolvedRelationTarget = {
|
|
55
|
+
readonly target: string;
|
|
56
|
+
readonly cteName?: string;
|
|
57
|
+
readonly outputs?: ReadonlyMap<string, OutputDescriptor>;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Built-in include strategies, shared by the runtime registry and public types. */
|
|
61
|
+
declare const INCLUDE_STRATEGIES: readonly ["join", "lateral", "json_agg", "cte"];
|
|
62
|
+
/** The four strategies this adapter implements handlers for, distinct from @dbsp/types' six-member IncludeStrategy, which includes the planner's subquery and auto. */
|
|
63
|
+
type IncludeHandlerStrategy = (typeof INCLUDE_STRATEGIES)[number];
|
|
106
64
|
/**
|
|
107
65
|
* Immutable context passed to all handlers during compilation.
|
|
108
66
|
*/
|
|
@@ -131,6 +89,10 @@ interface CompilerContext {
|
|
|
131
89
|
readonly outerAlias?: string;
|
|
132
90
|
/** Query-local CTE/binding names that must not be schema-qualified. */
|
|
133
91
|
readonly bindingNames?: BindingNameRegistry;
|
|
92
|
+
/** Known projections for visible CTE/binding relation targets. */
|
|
93
|
+
readonly relationTargetProjections?: RelationTargetProjectionRegistry;
|
|
94
|
+
/** Lexically visible SQL aliases that expose a known CTE projection. */
|
|
95
|
+
readonly aliasColumnAuthorities?: AliasColumnAuthority;
|
|
134
96
|
/**
|
|
135
97
|
* Optional callback to compile a QueryIntent into an AST Node (SubLink subselect).
|
|
136
98
|
* Set by PlanCompiler when compiling selectCustomExpression — enables SubqueryExpressionIntent
|
|
@@ -213,7 +175,7 @@ interface Decision {
|
|
|
213
175
|
readonly offset?: number | ParamIntent | {
|
|
214
176
|
paramIndex: number;
|
|
215
177
|
};
|
|
216
|
-
readonly strategy?:
|
|
178
|
+
readonly strategy?: IncludeHandlerStrategy;
|
|
217
179
|
readonly relation?: string;
|
|
218
180
|
readonly relationName?: string;
|
|
219
181
|
readonly relationPath?: string;
|
|
@@ -293,6 +255,8 @@ interface WhereHandler {
|
|
|
293
255
|
}
|
|
294
256
|
/**
|
|
295
257
|
* Dispatcher for recursive WHERE compilation.
|
|
258
|
+
* The same function object may be passed to every level of a recursive compilation, so it is an opaque callback.
|
|
259
|
+
* Handlers must not use its identity to distinguish frames or carry frame-local state.
|
|
296
260
|
*/
|
|
297
261
|
type WhereDispatcher = (decision: Decision, ctx: CompilerContext, state: CompilerState) => Node;
|
|
298
262
|
/**
|
|
@@ -324,7 +288,7 @@ interface ExpressionHandler {
|
|
|
324
288
|
*/
|
|
325
289
|
interface IncludeHandler {
|
|
326
290
|
/** Strategy this handler implements */
|
|
327
|
-
readonly strategy:
|
|
291
|
+
readonly strategy: IncludeHandlerStrategy;
|
|
328
292
|
/**
|
|
329
293
|
* Compile an include to AST.
|
|
330
294
|
* @param decision The include decision
|
|
@@ -532,6 +496,7 @@ interface CompilerOptions {
|
|
|
532
496
|
readonly model?: _dbsp_types.ModelIR;
|
|
533
497
|
/** Query-local CTE/binding names that must not be schema-qualified. */
|
|
534
498
|
readonly bindingNames?: BindingNameRegistry;
|
|
499
|
+
readonly relationTargetProjections?: RelationTargetProjectionRegistry;
|
|
535
500
|
}
|
|
536
501
|
declare class PlanCompiler {
|
|
537
502
|
private readonly naming;
|
|
@@ -541,6 +506,7 @@ declare class PlanCompiler {
|
|
|
541
506
|
private readonly model;
|
|
542
507
|
private readonly dialectCapabilities;
|
|
543
508
|
private readonly bindingNames;
|
|
509
|
+
private readonly relationTargetProjections;
|
|
544
510
|
/** Mutable state shared with extracted condition/value compilation functions */
|
|
545
511
|
private state;
|
|
546
512
|
/** Track root table for EXISTS FK correlation */
|
|
@@ -559,19 +525,35 @@ declare class PlanCompiler {
|
|
|
559
525
|
* correct source alias (e.g., 'callee.file' reads parent path 'callee').
|
|
560
526
|
*/
|
|
561
527
|
private joinAliasMap;
|
|
528
|
+
/**
|
|
529
|
+
* Immutable-before-emission mapping from a public relation qualifier to the
|
|
530
|
+
* SQL alias that is actually emitted for that relation.
|
|
531
|
+
*/
|
|
532
|
+
private visibleSqlQualifiers;
|
|
562
533
|
/**
|
|
563
534
|
* Tracks all join aliases in use for the current query.
|
|
564
535
|
* Entries are stored in emitted database-alias space, after naming.toDatabase().
|
|
565
536
|
* Ensures no two JOINs share the same alias (DOUBLE-ALIAS prevention).
|
|
566
537
|
*/
|
|
567
538
|
private usedJoinAliases;
|
|
539
|
+
/**
|
|
540
|
+
* Query-local authority for every emitted non-root alias. Root bindings are
|
|
541
|
+
* deliberately absent: an unqualified root reference retains its historical
|
|
542
|
+
* SQL semantics, even when the root happens to be a reduced CTE.
|
|
543
|
+
*/
|
|
544
|
+
private aliasColumnAuthorities;
|
|
568
545
|
constructor(options?: CompilerOptions);
|
|
569
546
|
private childCompilerOptions;
|
|
570
547
|
/** Build immutable context for handler-based WHERE compilation */
|
|
571
548
|
private handlerCtx;
|
|
549
|
+
private relationTargetContext;
|
|
550
|
+
/** Register an emitted alias before any column-reference path can use it. */
|
|
551
|
+
private registerAliasAuthority;
|
|
572
552
|
private findAliasForLegacySourceTable;
|
|
573
553
|
private emittedJoinAlias;
|
|
574
554
|
private resolvedJoinAliases;
|
|
555
|
+
private resolveVisibleSqlQualifier;
|
|
556
|
+
private filterJoinAlias;
|
|
575
557
|
/**
|
|
576
558
|
* Dispatch a PlanDecision through the unified WHERE handler system.
|
|
577
559
|
* Bridges PlanCompiler's state to handler types, calls dispatcher, syncs back.
|
|
@@ -635,6 +617,12 @@ declare class PlanCompiler {
|
|
|
635
617
|
private registerIncludeCompilationResult;
|
|
636
618
|
private compileIncludeDecision;
|
|
637
619
|
private compileJoinIncludeAllocationPass;
|
|
620
|
+
/**
|
|
621
|
+
* Allocate visible SQL qualifiers before compiling a target. Only emitted
|
|
622
|
+
* joins register their public qualifier; strategies without an outer source
|
|
623
|
+
* deliberately leave their relation unavailable to qualified references.
|
|
624
|
+
*/
|
|
625
|
+
private allocateVisibleSqlQualifiers;
|
|
638
626
|
/**
|
|
639
627
|
* Fold a WHERE-family decision into an existing where expression.
|
|
640
628
|
* Returns the updated (or new) where node.
|
|
@@ -733,93 +721,6 @@ declare function compilePlan(plan: SimplifiedPlanReport, options?: CompilerOptio
|
|
|
733
721
|
|
|
734
722
|
declare function dbTypesEqual(a: string, b: string): boolean;
|
|
735
723
|
|
|
736
|
-
type IndexRenderKey = {
|
|
737
|
-
readonly column?: string | undefined;
|
|
738
|
-
readonly expression?: string | undefined;
|
|
739
|
-
readonly opclass?: string | undefined;
|
|
740
|
-
};
|
|
741
|
-
type IndexRenderSpec = {
|
|
742
|
-
readonly name: string;
|
|
743
|
-
readonly table: string;
|
|
744
|
-
readonly schema?: string | undefined;
|
|
745
|
-
readonly unique: boolean;
|
|
746
|
-
readonly method?: string | undefined;
|
|
747
|
-
readonly keys: readonly IndexRenderKey[];
|
|
748
|
-
readonly include?: readonly string[] | undefined;
|
|
749
|
-
readonly nullsNotDistinct?: boolean | undefined;
|
|
750
|
-
readonly with?: Readonly<Record<string, unknown>> | undefined;
|
|
751
|
-
readonly where?: string | undefined;
|
|
752
|
-
/** The in-process index value that owns a deparsed `where` predicate. */
|
|
753
|
-
readonly whereSource?: IndexIR | undefined;
|
|
754
|
-
readonly concurrently?: boolean | undefined;
|
|
755
|
-
readonly ifNotExists?: boolean | undefined;
|
|
756
|
-
};
|
|
757
|
-
type IndexCapabilityContext = {
|
|
758
|
-
readonly caps: DialectCapabilities;
|
|
759
|
-
readonly targetVersion?: string | undefined;
|
|
760
|
-
};
|
|
761
|
-
type IndexFeature = 'INCLUDE' | 'PARTIAL INDEX' | 'EXPRESSION INDEX' | 'INDEX METHOD' | 'OPCLASS' | 'NULLS NOT DISTINCT';
|
|
762
|
-
declare class IndexFeatureUnsupportedError extends Error {
|
|
763
|
-
readonly indexName: string;
|
|
764
|
-
readonly unsupportedFeatures: readonly IndexFeature[];
|
|
765
|
-
constructor(indexName: string, unsupportedFeatures: readonly IndexFeature[], message: string);
|
|
766
|
-
}
|
|
767
|
-
declare function assertCreateIndexSupported(spec: IndexRenderSpec, ctx?: IndexCapabilityContext): void;
|
|
768
|
-
declare function assertCreateIndexesSupported(specs: readonly IndexRenderSpec[], ctx?: IndexCapabilityContext): void;
|
|
769
|
-
declare function renderCreateIndex(spec: IndexRenderSpec, ctx?: IndexCapabilityContext): string;
|
|
770
|
-
|
|
771
|
-
/**
|
|
772
|
-
* DDL Generator - Generates PostgreSQL DDL statements from ModelIR
|
|
773
|
-
*
|
|
774
|
-
* Generates SQL strings directly for better compatibility and control.
|
|
775
|
-
* Two-pass strategy handles circular FK dependencies.
|
|
776
|
-
*
|
|
777
|
-
* @module ddl/ddl-generator
|
|
778
|
-
*/
|
|
779
|
-
|
|
780
|
-
interface GenerateDDLOptions {
|
|
781
|
-
/** Include DROP TABLE IF EXISTS statements before CREATE TABLE */
|
|
782
|
-
readonly includeDropStatements?: boolean;
|
|
783
|
-
/**
|
|
784
|
-
* Database schema name (e.g., 'public', 'tenant_123').
|
|
785
|
-
* Required when emitted DDL would otherwise mix non-default target-scoped
|
|
786
|
-
* custom types/enums with unqualified table SQL.
|
|
787
|
-
*/
|
|
788
|
-
readonly schemaName?: string;
|
|
789
|
-
/**
|
|
790
|
-
* Automatically create indexes on foreign key columns.
|
|
791
|
-
* FK columns are frequently used in JOINs, so indexing is a best practice.
|
|
792
|
-
* @default true
|
|
793
|
-
*/
|
|
794
|
-
readonly fkAutoIndex?: boolean;
|
|
795
|
-
/** Naming plugin for identifier transformation */
|
|
796
|
-
readonly naming?: NamingPlugin;
|
|
797
|
-
/** Dialect capabilities — unsupported index features throw during DDL generation */
|
|
798
|
-
readonly dialectCapabilities?: DialectCapabilities;
|
|
799
|
-
}
|
|
800
|
-
/**
|
|
801
|
-
* Generate DDL statements from a ModelIR schema.
|
|
802
|
-
*
|
|
803
|
-
* Uses a two-pass approach to handle circular FK dependencies:
|
|
804
|
-
* 1. CREATE TABLE (without FK constraints)
|
|
805
|
-
* 2. ALTER TABLE ADD CONSTRAINT for foreign keys
|
|
806
|
-
* 3. CREATE INDEX (explicit + auto-generated for FKs)
|
|
807
|
-
*
|
|
808
|
-
* @param schema - The ModelIR schema to generate DDL from
|
|
809
|
-
* @param options - Optional configuration
|
|
810
|
-
* @returns Array of DDL statements in dependency order
|
|
811
|
-
*/
|
|
812
|
-
declare function generateDDL(schema: ModelIR, options?: GenerateDDLOptions): string[];
|
|
813
|
-
declare function generateCreateIndex(tableName: string, idx: IndexIR, schemaName: string | undefined, naming: NamingPlugin, context?: IndexCapabilityContext, ifNotExists?: boolean): string;
|
|
814
|
-
/**
|
|
815
|
-
* Returns whether the PostgreSQL DDL generator can emit this IndexIR.
|
|
816
|
-
*
|
|
817
|
-
* Keep this as the single representability predicate for generated schema
|
|
818
|
-
* omission and destructive-drop classification: both sides must agree on the
|
|
819
|
-
* exact validation surface used by generateCreateIndex().
|
|
820
|
-
*/
|
|
821
|
-
declare function canGenerateCreateIndex(tableName: string, idx: IndexIR, schemaName?: string | undefined, naming?: NamingPlugin): boolean;
|
|
822
|
-
|
|
823
724
|
/** EFF-04's closed generated-mutation result domain. */
|
|
824
725
|
type GeneratedMutationClassification = 'non-destructive' | 'removal' | 'data-destructive'
|
|
825
726
|
/** A table rename is executed only by the paired re-address protocol. */
|
|
@@ -839,1045 +740,31 @@ declare function refusesRecordedPlanRemoval(kind: ChangeKind | string, change?:
|
|
|
839
740
|
readonly destructive?: boolean;
|
|
840
741
|
}): boolean;
|
|
841
742
|
|
|
842
|
-
/**
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
* Queries information_schema/pg_catalog to build ModelIR
|
|
846
|
-
* from an existing database. Supports:
|
|
847
|
-
* - Table/column/PK discovery
|
|
848
|
-
* - FK → bidirectional relation inference
|
|
849
|
-
* - Hierarchy detection (adjacency + edge-table)
|
|
850
|
-
* - Include/exclude filtering
|
|
851
|
-
*
|
|
852
|
-
* @module introspection
|
|
853
|
-
*/
|
|
854
|
-
|
|
855
|
-
/** The minimum every schema-level operation needs: which schema. */
|
|
856
|
-
interface SchemaScopeOptions {
|
|
857
|
-
/** Schema name to operate on (default: 'public') */
|
|
858
|
-
readonly schema?: string;
|
|
859
|
-
}
|
|
860
|
-
/**
|
|
861
|
-
* Introspection additionally chooses WHICH TABLES to read. It is a read-only
|
|
862
|
-
* path, so narrowing it is safe — that is why the table filters live here and
|
|
863
|
-
* nowhere else.
|
|
864
|
-
*/
|
|
865
|
-
interface IntrospectionOptions extends SchemaScopeOptions {
|
|
866
|
-
/** Tables to exclude (glob patterns: * matches any chars) */
|
|
867
|
-
readonly exclude?: readonly string[];
|
|
868
|
-
/** Tables to include (default: all). Applied before exclude. */
|
|
869
|
-
readonly include?: readonly string[];
|
|
870
|
-
}
|
|
871
|
-
/** Hierarchy pattern detected during introspection */
|
|
872
|
-
/**
|
|
873
|
-
* Hierarchy pattern detected during introspection.
|
|
874
|
-
* Alias of {@link HierarchyIR} from \@dbsp/types — kept here for
|
|
875
|
-
* public-API backwards compatibility (re-exported from \@dbsp/adapter-pgsql).
|
|
876
|
-
*/
|
|
877
|
-
type DetectedHierarchy = HierarchyIR;
|
|
878
|
-
/** Extended ModelIR with hierarchy metadata */
|
|
879
|
-
interface IntrospectedModelIR extends ModelIR {
|
|
880
|
-
readonly hierarchies: readonly DetectedHierarchy[];
|
|
881
|
-
readonly introspectedAt: Date;
|
|
882
|
-
readonly warnings: readonly string[];
|
|
883
|
-
}
|
|
884
|
-
/**
|
|
885
|
-
* Introspect a database through a pool.
|
|
886
|
-
*
|
|
887
|
-
* This does NOT accept a checked-out `PoolClient`, and that is deliberate. A
|
|
888
|
-
* client may be sitting inside a transaction that belongs to its owner, and a
|
|
889
|
-
* catalog query that fails there aborts *their* transaction. Protecting that
|
|
890
|
-
* needs a savepoint, and knowing whether to take one needs the caller to say
|
|
891
|
-
* whose transaction it is — which is what `PgsqlAdapter`'s `borrowedClient`
|
|
892
|
-
* declaration is for. Guessing it from the object's shape is the exact defect
|
|
893
|
-
* this adapter was rewritten to remove.
|
|
894
|
-
*
|
|
895
|
-
* Saying so in a comment is not enough: `CatalogQueryExecutor` is structural, so
|
|
896
|
-
* a `PoolClient` — which has a `query()` — satisfies it, and the prose would have
|
|
897
|
-
* been the only thing standing in the way. It is branded instead, and only the
|
|
898
|
-
* adapter's own protected executor carries the brand. A client cannot be passed
|
|
899
|
-
* here at all.
|
|
900
|
-
*
|
|
901
|
-
* So: hold a client, use `new PgsqlAdapter(client, { borrowedClient: true })`
|
|
902
|
-
* and call `.introspect()` on it.
|
|
903
|
-
*/
|
|
904
|
-
declare function introspect(pool: Pool, options?: IntrospectionOptions): Promise<IntrospectedModelIR>;
|
|
905
|
-
|
|
906
|
-
type PgsqlTransactionTimeoutParameter = 'lock_timeout' | 'statement_timeout';
|
|
907
|
-
|
|
908
|
-
/**
|
|
909
|
-
* PgsqlAdapter - Implements the Adapter interface for PostgreSQL using native pg driver.
|
|
910
|
-
*
|
|
911
|
-
* This adapter wraps a pg Pool instance and provides the unified
|
|
912
|
-
* adapter interface for the db-semantic-planner ORM.
|
|
913
|
-
*
|
|
914
|
-
* @module pgsql-adapter
|
|
915
|
-
*/
|
|
916
|
-
|
|
917
|
-
declare const rollbackOnlyPgsqlScopeBrand: unique symbol;
|
|
918
|
-
/** A scope minted by withScratchScope and guaranteed to roll back on success. */
|
|
919
|
-
type RollbackOnlyPgsqlScope<DB = unknown> = PgsqlAdapter<DB> & {
|
|
920
|
-
readonly [rollbackOnlyPgsqlScopeBrand]: typeof rollbackOnlyPgsqlScopeBrand;
|
|
743
|
+
/** Durable payload roles are disjoint before the outcome protocol serializes them. */
|
|
744
|
+
type GeneratedIdentityObservation = LedgerPayload & {
|
|
745
|
+
readonly payloadKind: 'generated-identity-observation';
|
|
921
746
|
};
|
|
922
|
-
type
|
|
923
|
-
readonly
|
|
924
|
-
readonly objId: number;
|
|
747
|
+
type GeneratedStructuralObservation = LedgerPayload & {
|
|
748
|
+
readonly payloadKind: 'generated-structural-observation';
|
|
925
749
|
};
|
|
926
|
-
type
|
|
927
|
-
|
|
928
|
-
readonly
|
|
929
|
-
|
|
930
|
-
readonly acquired: false;
|
|
750
|
+
type GeneratedPostconditionObservation = GeneratedIdentityObservation | GeneratedStructuralObservation;
|
|
751
|
+
type GeneratedPostconditionReadBack = {
|
|
752
|
+
readonly observed: GeneratedPostconditionObservation;
|
|
753
|
+
readonly catalogueIdentity?: NonNullable<LedgerAddress['catalogueIdentity']>;
|
|
931
754
|
};
|
|
932
|
-
declare class PgsqlRawSqlTransactionControlError extends Error {
|
|
933
|
-
readonly dbspRawSqlTransactionControl = true;
|
|
934
|
-
constructor(cause: unknown);
|
|
935
|
-
}
|
|
936
|
-
declare class PgsqlTransactionAbortedCommitError extends Error {
|
|
937
|
-
readonly dbspTransactionAbortedCommit = true;
|
|
938
|
-
constructor(cause: unknown);
|
|
939
|
-
}
|
|
940
|
-
declare class PgsqlTransactionAbortedError extends Error {
|
|
941
|
-
readonly dbspTransactionAborted = true;
|
|
942
|
-
constructor(cause: unknown);
|
|
943
|
-
}
|
|
944
755
|
/**
|
|
945
|
-
*
|
|
946
|
-
*
|
|
947
|
-
*
|
|
756
|
+
* Reads a generated declaration's terminal observation and catalogue identity.
|
|
757
|
+
* The decoded declaration remains module-private so every public path enters
|
|
758
|
+
* through the versioned decoder before it can dispatch on a declaration kind.
|
|
948
759
|
*/
|
|
949
|
-
declare
|
|
950
|
-
readonly dbspTransactionAbortSignal = true;
|
|
951
|
-
constructor();
|
|
952
|
-
}
|
|
953
|
-
declare class PgsqlPinnedConnectionAbortSignalError extends Error {
|
|
954
|
-
readonly dbspPinnedConnectionAbortSignal = true;
|
|
955
|
-
constructor();
|
|
956
|
-
}
|
|
957
|
-
declare class PgsqlTransactionOptionsError extends Error {
|
|
958
|
-
readonly dbspTransactionOptions = true;
|
|
959
|
-
constructor(message: string);
|
|
960
|
-
}
|
|
961
|
-
declare class PgsqlAdvisoryLockOptionsError extends Error {
|
|
962
|
-
readonly dbspAdvisoryLockOptions = true;
|
|
963
|
-
constructor(message: string);
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Raised when a statement inside a dbsp-managed transaction fails with a SQLSTATE
|
|
967
|
-
* that matches a timeout the caller configured for that transaction: `55P03`
|
|
968
|
-
* (`lock_not_available`) when `lockTimeoutMs` was set, or `57014` (`query_canceled`)
|
|
969
|
-
* when `statementTimeoutMs` was set. The original PostgreSQL error is preserved as
|
|
970
|
-
* `cause`.
|
|
971
|
-
*
|
|
972
|
-
* Classification is by SQLSTATE only. PostgreSQL assigns these codes to the OUTCOME,
|
|
973
|
-
* not the cause: `55P03` is also raised by `FOR UPDATE NOWAIT`, and `57014` is also
|
|
974
|
-
* raised by an external cancel (e.g. `pg_cancel_backend`). There is no locale-stable
|
|
975
|
-
* structured field that separates the timeout from the other cause, so the message
|
|
976
|
-
* text is deliberately NOT parsed. dbsp never emits `NOWAIT` itself, so a `55P03`
|
|
977
|
-
* here is the configured `lock_timeout` unless the caller's own raw SQL used
|
|
978
|
-
* `NOWAIT`; a `57014` is the configured `statement_timeout` unless the backend was
|
|
979
|
-
* cancelled from outside. Inspect `cause` when that distinction matters.
|
|
980
|
-
*/
|
|
981
|
-
declare class PgsqlTransactionTimeoutError extends Error {
|
|
982
|
-
readonly timeout: PgsqlTransactionTimeoutParameter;
|
|
983
|
-
readonly dbspTransactionTimeout = true;
|
|
984
|
-
constructor(cause: unknown, timeout: PgsqlTransactionTimeoutParameter);
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Raised when the single safe unnamed replay after a prepared-statement
|
|
988
|
-
* infrastructure failure also fails. `message` is always the safe constant
|
|
989
|
-
* `Prepared statement recovery replay failed.`; `cause` is the replay error;
|
|
990
|
-
* `infrastructureError` is the original infrastructure error; and
|
|
991
|
-
* `admissionFingerprint` identifies the admitted statement. DBSP-authored
|
|
992
|
-
* messages carry no parameter values; preserved upstream errors, including the
|
|
993
|
-
* standard Error `cause`, are unsanitized.
|
|
994
|
-
*/
|
|
995
|
-
declare class PgsqlPreparedStatementReplayError extends Error {
|
|
996
|
-
readonly admissionFingerprint: string;
|
|
997
|
-
readonly infrastructureError: unknown;
|
|
998
|
-
readonly dbspPreparedStatementReplay = true;
|
|
999
|
-
readonly originalInfrastructureError: unknown;
|
|
1000
|
-
readonly originalError: unknown;
|
|
1001
|
-
constructor(admissionFingerprint: string, infrastructureError: unknown, cause: unknown);
|
|
1002
|
-
}
|
|
760
|
+
declare function readGeneratedPostconditionReadBack(executor: GeneratedPostconditionSession, step: NormalizedManagedStep, address: LedgerAddress): Promise<GeneratedPostconditionReadBack>;
|
|
1003
761
|
/**
|
|
1004
|
-
*
|
|
762
|
+
* Generated DDL has no operation runtime to supply an observation. Structural
|
|
763
|
+
* declarations read the precise catalogue fields they change; the four #597
|
|
764
|
+
* identity-only declarations prove existence and catalogue identity, not shape.
|
|
765
|
+
* A same-named object is never enough to write an `observed` terminal.
|
|
1005
766
|
*/
|
|
1006
|
-
|
|
1007
|
-
/** Maximum distinct compiled statements admitted per executor (default: 500). */
|
|
1008
|
-
readonly maxStatements?: number;
|
|
1009
|
-
}
|
|
1010
|
-
interface PgsqlAdapterOptions {
|
|
1011
|
-
/** Schema name for multi-tenant queries */
|
|
1012
|
-
readonly schemaName?: string;
|
|
1013
|
-
/**
|
|
1014
|
-
* DB column casing convention (intuitive semantics).
|
|
1015
|
-
* - `'snake_case'`: DB columns are snake_case → transform to camelCase for JS
|
|
1016
|
-
* - `'camelCase'`: DB columns are camelCase → no transformation
|
|
1017
|
-
* - `'preserve'`: No transformation
|
|
1018
|
-
*/
|
|
1019
|
-
readonly dbCasing?: DbCasing;
|
|
1020
|
-
/** Optional model for WHERE compilation */
|
|
1021
|
-
readonly model?: ModelIR;
|
|
1022
|
-
/** Optional logger for debug/error messages */
|
|
1023
|
-
readonly logger?: AdapterLogger;
|
|
1024
|
-
/** Default primary key column name for convention fallbacks (default: 'id') */
|
|
1025
|
-
readonly defaultPkColumnName?: string;
|
|
1026
|
-
/** Convention for deriving FK column names: (tableName, pkName) => fkColumnName */
|
|
1027
|
-
readonly deriveFkColumnName?: FkColumnDerivation;
|
|
1028
|
-
/**
|
|
1029
|
-
* Opt in to node-postgres named prepared statements for compiled queries with
|
|
1030
|
-
* parameters. `true` uses the default statement cap; an object overrides it.
|
|
1031
|
-
*/
|
|
1032
|
-
readonly preparedStatements?: boolean | PgsqlPreparedStatementsOptions;
|
|
1033
|
-
}
|
|
1034
|
-
interface PgsqlPoolAdapterOptionsBase extends PgsqlAdapterOptions {
|
|
1035
|
-
readonly borrowedClient?: false;
|
|
1036
|
-
}
|
|
1037
|
-
type PgsqlPoolAdapterOptions = (PgsqlPoolAdapterOptionsBase & {
|
|
1038
|
-
readonly replayInvalidatedPlans?: false | undefined;
|
|
1039
|
-
}) | (Omit<PgsqlPoolAdapterOptionsBase, 'preparedStatements'> & {
|
|
1040
|
-
readonly preparedStatements: true | PgsqlPreparedStatementsOptions;
|
|
1041
|
-
/**
|
|
1042
|
-
* Enable one unnamed replay after `0A000`/`RevalidateCachedQuery` only when
|
|
1043
|
-
* you assert that your statements do not invoke functions performing
|
|
1044
|
-
* effectful work before nested prepared-statement operations. This requires
|
|
1045
|
-
* `preparedStatements: true` (or a prepared-statements options object).
|
|
1046
|
-
*
|
|
1047
|
-
* Replay snapshots JSON-like values (finite numbers, strings, booleans,
|
|
1048
|
-
* `null`, arrays, plain or null-prototype objects) and clean `Date`/`Buffer`
|
|
1049
|
-
* instances. It excludes non-finite numbers, `undefined`, `bigint`, functions,
|
|
1050
|
-
* proxies, cycles, sparse arrays, accessors, symbol-valued
|
|
1051
|
-
* parameters, symbol keys on plain objects, exotic prototypes, custom built-ins,
|
|
1052
|
-
* and values with their own node-postgres
|
|
1053
|
-
* `toPostgres` behavior.
|
|
1054
|
-
* Serialization-irrelevant symbol metadata on arrays and Buffers is ignored.
|
|
1055
|
-
* The detached snapshot covers later mutations to the supplied value graph,
|
|
1056
|
-
* not built-in prototypes, timezone state, or node-postgres serialization
|
|
1057
|
-
* configuration; a process-global `toPostgres` or `toJSON` installed while
|
|
1058
|
-
* the call is in flight is outside the guarantee. Each capture or replay copy
|
|
1059
|
-
* is independently limited to 64 Ki visited values, 16 MiB of UTF-8 strings,
|
|
1060
|
-
* and 16 MiB of Buffer data. An ineligible or over-budget value still receives
|
|
1061
|
-
* the initial named submission, but disables transparent replay.
|
|
1062
|
-
* These budgets bound copied nodes and payload bytes; enumerating a plain
|
|
1063
|
-
* object's existing property table is proportional to the caller's own object.
|
|
1064
|
-
*
|
|
1065
|
-
* Replay needs the adapter-owned serialized physical client available from a
|
|
1066
|
-
* pool; it is therefore not supported by borrowed or compile-only adapters.
|
|
1067
|
-
*/
|
|
1068
|
-
readonly replayInvalidatedPlans: true;
|
|
1069
|
-
});
|
|
1070
|
-
interface PgsqlBorrowedClientAdapterOptions extends PgsqlAdapterOptions {
|
|
1071
|
-
/** Replay is only available to a pool-owned pinned scope. */
|
|
1072
|
-
readonly replayInvalidatedPlans?: never;
|
|
1073
|
-
/** This connection belongs to the caller. dbsp never releases it. */
|
|
1074
|
-
readonly borrowedClient: true;
|
|
1075
|
-
/**
|
|
1076
|
-
* Let dbsp run transactions on your connection, through a savepoint.
|
|
1077
|
-
*
|
|
1078
|
-
* When your connection is already inside a transaction, dbsp creates a
|
|
1079
|
-
* savepoint and rolls back dbsp's changes after that savepoint if the callback
|
|
1080
|
-
* fails. `RELEASE SAVEPOINT` does not commit; it merges the work into your
|
|
1081
|
-
* surrounding transaction, so a callback that succeeded is still undone if you
|
|
1082
|
-
* later roll back. Deferred constraints or triggers can still make your outer
|
|
1083
|
-
* `COMMIT` fail after dbsp has returned. `SET LOCAL` changes inside the callback
|
|
1084
|
-
* remain in effect for the rest of your transaction after the savepoint is
|
|
1085
|
-
* released. `ON COMMIT DROP` and `ON COMMIT DELETE ROWS` fire at your transaction
|
|
1086
|
-
* boundary, not at the savepoint. Sequences are not transactional:
|
|
1087
|
-
* `nextval`/`setval` are not reclaimed by a savepoint rollback. Session-level
|
|
1088
|
-
* advisory locks ignore rollback; transaction-level advisory locks taken by a
|
|
1089
|
-
* successful callback last until your transaction ends.
|
|
1090
|
-
*
|
|
1091
|
-
* Transaction control through raw SQL inside a scope dbsp is managing is
|
|
1092
|
-
* unsupported. `COMMIT`, `ROLLBACK`, and `PREPARE TRANSACTION` end the
|
|
1093
|
-
* transaction dbsp is working inside; dbsp detects that and fails loudly, but
|
|
1094
|
-
* the data is already whatever your statement made it. Raw savepoint control
|
|
1095
|
-
* (`SAVEPOINT`, `RELEASE SAVEPOINT`, `ROLLBACK TO SAVEPOINT`) can alter the
|
|
1096
|
-
* savepoint stack before dbsp sees the command tag; dbsp poisons the scope, but
|
|
1097
|
-
* it cannot make that command un-run. Manage your transaction outside dbsp's
|
|
1098
|
-
* calls.
|
|
1099
|
-
*/
|
|
1100
|
-
readonly managedTransactions?: true;
|
|
1101
|
-
}
|
|
1102
|
-
/** Options for a connectionless adapter, which cannot own replay serialization. */
|
|
1103
|
-
interface PgsqlCompileOnlyAdapterOptions extends PgsqlAdapterOptions {
|
|
1104
|
-
readonly replayInvalidatedPlans?: never;
|
|
1105
|
-
}
|
|
1106
|
-
/**
|
|
1107
|
-
* Adapter implementation for PostgreSQL using native pg driver.
|
|
1108
|
-
*
|
|
1109
|
-
* @typeParam DB - Database schema type
|
|
1110
|
-
*
|
|
1111
|
-
* @example
|
|
1112
|
-
* ```typescript
|
|
1113
|
-
* import { Pool } from 'pg';
|
|
1114
|
-
* import { createPgsqlAdapter } from '@dbsp/adapter-pgsql';
|
|
1115
|
-
*
|
|
1116
|
-
* const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
1117
|
-
* const adapter = createPgsqlAdapter(pool);
|
|
1118
|
-
* const orm = createOrm({ model, adapter });
|
|
1119
|
-
* ```
|
|
1120
|
-
*/
|
|
1121
|
-
declare class PgsqlAdapter<DB = unknown> implements Adapter<DB> {
|
|
1122
|
-
private readonly pool;
|
|
1123
|
-
private readonly client;
|
|
1124
|
-
private readonly borrowedClient;
|
|
1125
|
-
private readonly managedTransactions;
|
|
1126
|
-
private readonly adapterManagedTransaction;
|
|
1127
|
-
private readonly adapterManagedPinnedConnection;
|
|
1128
|
-
private readonly rollbackOnlyScope;
|
|
1129
|
-
private readonly scopeToken;
|
|
1130
|
-
private readonly scopeState;
|
|
1131
|
-
private readonly schemaName;
|
|
1132
|
-
private readonly _dbCasing;
|
|
1133
|
-
private readonly naming;
|
|
1134
|
-
private readonly model;
|
|
1135
|
-
private readonly logger;
|
|
1136
|
-
private readonly replayInvalidatedPlans;
|
|
1137
|
-
private readonly preparedStatements;
|
|
1138
|
-
private readonly preparedStatementRegistry;
|
|
1139
|
-
private readonly _capabilities;
|
|
1140
|
-
private readonly defaultPk;
|
|
1141
|
-
private readonly deriveFk;
|
|
1142
|
-
/**
|
|
1143
|
-
* Create a new PgsqlAdapter.
|
|
1144
|
-
*
|
|
1145
|
-
* Ownership of the connection is **declared**, never inferred. Handing over a
|
|
1146
|
-
* `PoolClient` means nothing on its own — it says the object has a `release()`
|
|
1147
|
-
* method, not that a transaction is open or that the caller owns the lifecycle.
|
|
1148
|
-
* Pass `borrowedClient: true` to say so.
|
|
1149
|
-
*
|
|
1150
|
-
* @param pool - a pg.Pool, a caller-owned pg.PoolClient (with `borrowedClient: true`),
|
|
1151
|
-
* or nothing at all for compile-only mode
|
|
1152
|
-
* @param options - configuration; declares connection ownership
|
|
1153
|
-
*/
|
|
1154
|
-
constructor(pool: Pool, options?: PgsqlPoolAdapterOptions);
|
|
1155
|
-
constructor(client: PoolClient, options: PgsqlBorrowedClientAdapterOptions);
|
|
1156
|
-
constructor(pool?: undefined, options?: PgsqlCompileOnlyAdapterOptions);
|
|
1157
|
-
/**
|
|
1158
|
-
* Shared compilation dependencies — built lazily from adapter fields.
|
|
1159
|
-
* Passed to compiler sub-modules instead of `this`.
|
|
1160
|
-
*/
|
|
1161
|
-
/**
|
|
1162
|
-
* Return a new PgsqlAdapterOptions that merges current config with overrides.
|
|
1163
|
-
* Ensures that all configuration fields (logger, defaultPkColumnName,
|
|
1164
|
-
* deriveFkColumnName, etc.) are propagated to scoped/transactional adapters.
|
|
1165
|
-
*/
|
|
1166
|
-
private cloneOptions;
|
|
1167
|
-
private buildCompileDeps;
|
|
1168
|
-
private requireNqlCompileModel;
|
|
1169
|
-
private assertNqlBindingNamesDisjointFromTables;
|
|
1170
|
-
private compileNqlMutation;
|
|
1171
|
-
private compileNqlBundleLeafEnvelope;
|
|
1172
|
-
private compileNqlBundle;
|
|
1173
|
-
/**
|
|
1174
|
-
* Returns the pool/client executor, or refuses a connectionless adapter.
|
|
1175
|
-
*/
|
|
1176
|
-
private requireConnection;
|
|
1177
|
-
/** Adapter capabilities for feature detection */
|
|
1178
|
-
get capabilities(): AdapterCapabilities;
|
|
1179
|
-
/** Per-instance connection state, distinct from PostgreSQL capabilities. */
|
|
1180
|
-
get connectionAvailability(): ConnectionAvailability;
|
|
1181
|
-
/** Side-effect-free execution availability for core feature detection. */
|
|
1182
|
-
executionAvailable(): boolean;
|
|
1183
|
-
/** PostgreSQL dialect capabilities for planner strategy selection */
|
|
1184
|
-
get dialectCapabilities(): DialectCapabilities;
|
|
1185
|
-
/**
|
|
1186
|
-
* DB column casing convention used by this adapter.
|
|
1187
|
-
*/
|
|
1188
|
-
get dbCasing(): DbCasing;
|
|
1189
|
-
/**
|
|
1190
|
-
* Get the underlying pg Pool or borrowed PoolClient instance.
|
|
1191
|
-
*
|
|
1192
|
-
* Exposing raw access from a pool-owned dbsp-managed scope permanently taints that
|
|
1193
|
-
* physical client: external callers can queue commands outside dbsp's statement
|
|
1194
|
-
* lock, so replay is disabled and dbsp destroys the client at scope release.
|
|
1195
|
-
* Expect pool churn; session state on that exposed connection does not survive the
|
|
1196
|
-
* release. A borrowed client remains caller-owned: dbsp never releases it, and the
|
|
1197
|
-
* caller decides its fate after raw exposure.
|
|
1198
|
-
*/
|
|
1199
|
-
getPoolInstance(): Pool | PoolClient;
|
|
1200
|
-
/**
|
|
1201
|
-
* Compile a plan to executable SQL.
|
|
1202
|
-
*
|
|
1203
|
-
* When passed a direct `CompiledNqlQuery`, the adapter trusts that the bundle
|
|
1204
|
-
* has already been semantically validated by the NQL compiler. This method
|
|
1205
|
-
* still performs adapter-owned SQL safety checks for emitted binding names
|
|
1206
|
-
* before CTE emission.
|
|
1207
|
-
*/
|
|
1208
|
-
compile<T = unknown>(plan: PlanReport | CompiledNqlQuery, options?: CompileOptions): CompiledQuery<T>;
|
|
1209
|
-
/**
|
|
1210
|
-
* Compile a plan with includes, returning subquery include metadata (DX-033).
|
|
1211
|
-
*/
|
|
1212
|
-
compileWithIncludes<T = unknown>(plan: PlanReport, options?: CompileOptions): CompileResultWithIncludes<T>;
|
|
1213
|
-
/**
|
|
1214
|
-
* Compile a subquery include query for given parent IDs (DX-033).
|
|
1215
|
-
* Generates: SELECT * FROM targetTable WHERE foreignKey IN ($1, $2, ...)
|
|
1216
|
-
*
|
|
1217
|
-
* @param info - Subquery include metadata
|
|
1218
|
-
* @param parentIds - Parent record IDs to fetch related records for
|
|
1219
|
-
* @param options - Compile options
|
|
1220
|
-
* @returns Compiled query for fetching related records
|
|
1221
|
-
*/
|
|
1222
|
-
compileSubqueryInclude(info: SubqueryIncludeInfo, parentIds: readonly unknown[], options?: CompileOptions): CompiledQuery;
|
|
1223
|
-
/**
|
|
1224
|
-
* Compile a FROM-less SELECT expression to SQL.
|
|
1225
|
-
*
|
|
1226
|
-
* Produces: SELECT <expr>
|
|
1227
|
-
* Example: SELECT nextval('my_seq')
|
|
1228
|
-
*
|
|
1229
|
-
* @param expr - ExpressionIntent to evaluate
|
|
1230
|
-
* @returns Compiled SQL and parameters
|
|
1231
|
-
*/
|
|
1232
|
-
compileSelectExpression<T = unknown>(expr: ExpressionIntent): CompiledQuery<T>;
|
|
1233
|
-
/**
|
|
1234
|
-
* Compile an insert intent to executable SQL.
|
|
1235
|
-
*
|
|
1236
|
-
* Strategy switch (per CompileOptions):
|
|
1237
|
-
* - rows <= batchThreshold (default 50): VALUES ($1,$2),($3,$4),...
|
|
1238
|
-
* - rows > batchThreshold OR batchThreshold === 0: SELECT unnest($1::type[]),...
|
|
1239
|
-
*/
|
|
1240
|
-
compileInsert(intent: InsertIntent, options?: CompileOptions): CompiledQuery;
|
|
1241
|
-
/**
|
|
1242
|
-
* Compile an insert-from intent to executable SQL (NQL-ALIGN).
|
|
1243
|
-
* INSERT INTO target (cols) SELECT cols FROM source WHERE ... LIMIT ... RETURNING ...
|
|
1244
|
-
*/
|
|
1245
|
-
compileInsertFrom(intent: InsertFromIntent, options?: CompileOptions): CompiledQuery;
|
|
1246
|
-
/**
|
|
1247
|
-
* Compile an update intent to executable SQL.
|
|
1248
|
-
*/
|
|
1249
|
-
compileUpdate(intent: UpdateIntent, options?: CompileOptions): CompiledQuery;
|
|
1250
|
-
/**
|
|
1251
|
-
* Compile a batch update intent to executable SQL using unnest FROM strategy (BATCH-001).
|
|
1252
|
-
*
|
|
1253
|
-
* Generates:
|
|
1254
|
-
* UPDATE "table" SET "update_col" = t."update_col" [, "scalar_col" = $N]
|
|
1255
|
-
* FROM unnest(CAST($1 AS type[]), CAST($2 AS type[])) AS t("match_col", "update_col")
|
|
1256
|
-
* WHERE "table"."match_col" = t."match_col"
|
|
1257
|
-
* [RETURNING ...]
|
|
1258
|
-
*/
|
|
1259
|
-
compileBatchUpdate(intent: BatchUpdateIntent, options?: CompileOptions): CompiledQuery;
|
|
1260
|
-
/**
|
|
1261
|
-
* Compile a delete intent to executable SQL.
|
|
1262
|
-
*/
|
|
1263
|
-
compileDelete(intent: DeleteIntent, options?: CompileOptions): CompiledQuery;
|
|
1264
|
-
/**
|
|
1265
|
-
* Compile an upsert intent to executable SQL (DX-026).
|
|
1266
|
-
*/
|
|
1267
|
-
compileUpsert(intent: UpsertIntent, options?: CompileOptions): CompiledQuery;
|
|
1268
|
-
/**
|
|
1269
|
-
* Compile an upsert-from intent to executable SQL (NQL-BIND).
|
|
1270
|
-
* INSERT INTO target SELECT ... FROM source ON CONFLICT (cols) DO UPDATE SET ...
|
|
1271
|
-
*/
|
|
1272
|
-
compileUpsertFrom(intent: UpsertFromIntent, options?: CompileOptions): CompiledQuery;
|
|
1273
|
-
/**
|
|
1274
|
-
* Compile a recursive CTE plan to executable SQL.
|
|
1275
|
-
* Supports adjacency-list and edge-table traversal modes.
|
|
1276
|
-
*/
|
|
1277
|
-
compileRecursive<T = unknown>(report: RecursivePlanReport, model: ModelIR, options?: CompileOptions): CompiledQuery<T>;
|
|
1278
|
-
/**
|
|
1279
|
-
* Compile a CTE query backed by unnest() arrays (BATCH-001 Block 5).
|
|
1280
|
-
*
|
|
1281
|
-
* Strategy: compile CTE nodes to SQL fragments, compile outer query
|
|
1282
|
-
* independently (parameters starting at $1), then renumber outer params
|
|
1283
|
-
* to start after CTE params and prepend WITH clause.
|
|
1284
|
-
*/
|
|
1285
|
-
compileCteQuery<T = unknown>(intent: CteQueryIntent, options?: CompileOptions): CompiledQuery<T>;
|
|
1286
|
-
/**
|
|
1287
|
-
* Compile a set operation (UNION / INTERSECT / EXCEPT) to SQL.
|
|
1288
|
-
*/
|
|
1289
|
-
compileSetOperation<T = unknown>(intent: SetOperationIntent, model: ModelIR, options?: CompileOptions): CompiledQuery<T>;
|
|
1290
|
-
private compileSetOperationWithBindings;
|
|
1291
|
-
/**
|
|
1292
|
-
* Create a dump for observability.
|
|
1293
|
-
*/
|
|
1294
|
-
createDump(plan: PlanReport, query: CompiledQuery, meta?: DumpMeta): Dump;
|
|
1295
|
-
/**
|
|
1296
|
-
* Execute a query and return all results.
|
|
1297
|
-
* Results are transformed to use model naming convention (e.g., snake_case → camelCase)
|
|
1298
|
-
*/
|
|
1299
|
-
execute<T>(query: CompiledQuery<T>): Promise<T[]>;
|
|
1300
|
-
/**
|
|
1301
|
-
* Execute a query and return rows plus PostgreSQL result metadata.
|
|
1302
|
-
* Results are transformed to use model naming convention (e.g., snake_case → camelCase)
|
|
1303
|
-
*/
|
|
1304
|
-
executeWithMeta(query: CompiledQuery): Promise<{
|
|
1305
|
-
readonly rows: readonly unknown[];
|
|
1306
|
-
readonly rowCount: number;
|
|
1307
|
-
readonly command?: string;
|
|
1308
|
-
}>;
|
|
1309
|
-
/**
|
|
1310
|
-
* Transform result rows from database naming to model naming convention.
|
|
1311
|
-
* For CamelCaseNamingPlugin: price_cents → priceCents
|
|
1312
|
-
*/
|
|
1313
|
-
private transformResultRows;
|
|
1314
|
-
/**
|
|
1315
|
-
* Execute a query and return the first result or null.
|
|
1316
|
-
*/
|
|
1317
|
-
executeOne<T>(query: CompiledQuery<T>): Promise<T | null>;
|
|
1318
|
-
/**
|
|
1319
|
-
* Execute a query and return the first result or throw.
|
|
1320
|
-
*/
|
|
1321
|
-
executeOneOrThrow<T>(query: CompiledQuery<T>): Promise<T>;
|
|
1322
|
-
/**
|
|
1323
|
-
* Stream query results as an async iterable iterator.
|
|
1324
|
-
* Uses PostgreSQL cursors for efficient streaming.
|
|
1325
|
-
*
|
|
1326
|
-
* Note: The cursor must be used within a transaction. If not already
|
|
1327
|
-
* in a transaction, this method wraps the streaming in one.
|
|
1328
|
-
*
|
|
1329
|
-
* @param query - Compiled query to stream
|
|
1330
|
-
* @param options - Stream options (chunkSize)
|
|
1331
|
-
* @returns AsyncIterableIterator that yields rows one by one
|
|
1332
|
-
*/
|
|
1333
|
-
stream<T>(query: CompiledQuery<T>, options?: AdapterStreamOptions): AsyncIterableIterator<T>;
|
|
1334
|
-
/** Stream raw SQL directly using the same cursor machinery as stream(). */
|
|
1335
|
-
streamRaw<T = unknown>(sql: string, parameters?: readonly unknown[], options?: AdapterStreamOptions): AsyncIterableIterator<T>;
|
|
1336
|
-
private streamCursor;
|
|
1337
|
-
/**
|
|
1338
|
-
* Internal: Stream with an existing client using cursors.
|
|
1339
|
-
*/
|
|
1340
|
-
private streamWithClient;
|
|
1341
|
-
private streamWithManagedClient;
|
|
1342
|
-
private streamWithManagedClientSavepointScope;
|
|
1343
|
-
private streamWithClientTransaction;
|
|
1344
|
-
/**
|
|
1345
|
-
* Introspect the database schema and return a ModelIR.
|
|
1346
|
-
*
|
|
1347
|
-
* @param options - Optional introspection options (schema, include/exclude filters)
|
|
1348
|
-
* @returns IntrospectedModelIR with tables, relations, and hierarchy metadata
|
|
1349
|
-
*
|
|
1350
|
-
* @example
|
|
1351
|
-
* ```typescript
|
|
1352
|
-
* const model = await adapter.introspect();
|
|
1353
|
-
* const model = await adapter.introspect({ schema: 'tenant_1' });
|
|
1354
|
-
* const model = await adapter.introspect({ exclude: ['_prisma*'] });
|
|
1355
|
-
* ```
|
|
1356
|
-
*/
|
|
1357
|
-
introspect(options?: IntrospectionOptions): Promise<IntrospectedModelIR>;
|
|
1358
|
-
/**
|
|
1359
|
-
* Acquire an exclusive session-level PostgreSQL advisory lock for the callback.
|
|
1360
|
-
*
|
|
1361
|
-
* The lock, callback, and unlock run on one `withPinnedConnection()` adapter.
|
|
1362
|
-
* dbsp performs one PostgreSQL acquire and one matching unlock per call. It
|
|
1363
|
-
* does not track reentrant depth in v1; PostgreSQL's session-level stacking
|
|
1364
|
-
* still applies when callers deliberately nest on the same pinned adapter.
|
|
1365
|
-
*/
|
|
1366
|
-
withAdvisoryLock<T>(key: PgAdvisoryLockKey, fn: (locked: Adapter<DB>) => Promise<T>): Promise<T>;
|
|
1367
|
-
withAdvisoryLock<T>(key: PgAdvisoryLockKey, fn: (locked: Adapter<DB>) => Promise<T>, options: {
|
|
1368
|
-
readonly wait?: 'block';
|
|
1369
|
-
readonly signal?: AbortSignal;
|
|
1370
|
-
}): Promise<T>;
|
|
1371
|
-
withAdvisoryLock<T>(key: PgAdvisoryLockKey, fn: (locked: Adapter<DB>) => Promise<T>, options: {
|
|
1372
|
-
readonly wait: 'try';
|
|
1373
|
-
readonly signal?: AbortSignal;
|
|
1374
|
-
}): Promise<PgAdvisoryLockResult<T>>;
|
|
1375
|
-
withAdvisoryLock<T>(key: PgAdvisoryLockKey, fn: (locked: Adapter<DB>) => Promise<T>, options?: {
|
|
1376
|
-
readonly wait?: 'block' | 'try';
|
|
1377
|
-
readonly signal?: AbortSignal;
|
|
1378
|
-
}): Promise<T | PgAdvisoryLockResult<T>>;
|
|
1379
|
-
private unlockAdvisoryLock;
|
|
1380
|
-
withPinnedConnection<T>(fn: (adapter: Adapter<DB>) => Promise<T>, options?: PinnedConnectionOptions): Promise<T>;
|
|
1381
|
-
private pinnedConnectionReleaseReason;
|
|
1382
|
-
private pinnedConnectionWithClient;
|
|
1383
|
-
/**
|
|
1384
|
-
* Execute a callback within a database transaction.
|
|
1385
|
-
*
|
|
1386
|
-
* ## What this guarantees
|
|
1387
|
-
*
|
|
1388
|
-
* The callback's work commits together or not at all; a statement issued inside
|
|
1389
|
-
* the transaction never executes after its boundary, even if you forget to
|
|
1390
|
-
* `await` it; a nested `transaction()` is a real savepoint; and the connection
|
|
1391
|
-
* never goes back to the pool with a transaction still open on it.
|
|
1392
|
-
*
|
|
1393
|
-
* ## What it cannot guarantee, and you should know before you reach for raw SQL
|
|
1394
|
-
*
|
|
1395
|
-
* **Raw SQL that ends the transaction ends it.** `COMMIT`, `ROLLBACK` and
|
|
1396
|
-
* `PREPARE TRANSACTION` issued through `executeRaw` — or through several commands
|
|
1397
|
-
* in one call — reach PostgreSQL and take effect *before* dbsp is told what they
|
|
1398
|
-
* were: the command tag arrives after the statement has run. dbsp detects it, kills
|
|
1399
|
-
* the scope so nothing else escapes, and throws — but **it cannot un-run what your
|
|
1400
|
-
* statement already did**, and `transaction()` rejecting does not mean nothing was
|
|
1401
|
-
* committed.
|
|
1402
|
-
*
|
|
1403
|
-
* The same holds for session state raw SQL creates: a sequence that advanced stays
|
|
1404
|
-
* advanced, an advisory lock stays held, a `PREPARE` or a `SET` you issued survives
|
|
1405
|
-
* on a pooled connection. dbsp cleans up only what dbsp created.
|
|
1406
|
-
*
|
|
1407
|
-
* This is the contract of an escape hatch, not an oversight — see #327. If you need
|
|
1408
|
-
* transaction control, own the transaction: take a client, `BEGIN` on it yourself,
|
|
1409
|
-
* and hand dbsp a `borrowedClient` **without** `managedTransactions`. dbsp will then
|
|
1410
|
-
* contain its own statements inside *your* transaction instead of the other way round.
|
|
1411
|
-
*/
|
|
1412
|
-
transaction<T>(fn: (adapter: Adapter<DB>) => Promise<T>, options?: TransactionOptions): Promise<T>;
|
|
1413
|
-
/**
|
|
1414
|
-
* Execute scratch PostgreSQL work in a scope that always rolls back on success.
|
|
1415
|
-
*
|
|
1416
|
-
* This is intentionally PostgreSQL-adapter-specific. It is used for catalog
|
|
1417
|
-
* shaped scratch DDL such as expression canonicalisation, where the caller
|
|
1418
|
-
* needs PostgreSQL's rendering but must not keep the scratch objects. This
|
|
1419
|
-
* scope has exactly one successful exit: rollback. In a caller transaction,
|
|
1420
|
-
* only this outer savepoint is retained after rollback; nested work releases
|
|
1421
|
-
* normally, so a large canonicalisation run cannot retain one subtransaction
|
|
1422
|
-
* per expression.
|
|
1423
|
-
* Rollback here is cleanup of dbsp-created work, not a sandbox for arbitrary
|
|
1424
|
-
* session effects.
|
|
1425
|
-
*/
|
|
1426
|
-
withScratchScope<T>(fn: (adapter: RollbackOnlyPgsqlScope<DB>) => Promise<T>): Promise<T>;
|
|
1427
|
-
private createManagedClientAdapter;
|
|
1428
|
-
private createPinnedConnectionAdapter;
|
|
1429
|
-
private createChildTransactionObserver;
|
|
1430
|
-
private observeChildTransaction;
|
|
1431
|
-
private markChildTransactionObserved;
|
|
1432
|
-
private refreshScopeChildrenFailure;
|
|
1433
|
-
private transactionWithManagedClient;
|
|
1434
|
-
private transactionWithManagedClientSavepointScope;
|
|
1435
|
-
private applyTransactionTimeouts;
|
|
1436
|
-
private captureAndApplySavepointTimeouts;
|
|
1437
|
-
private restoreSavepointTimeouts;
|
|
1438
|
-
private transactionWithClientTransaction;
|
|
1439
|
-
private releaseClient;
|
|
1440
|
-
private rollbackAndReleaseSavepoint;
|
|
1441
|
-
private rollbackSavepoint;
|
|
1442
|
-
private releaseSavepoint;
|
|
1443
|
-
private rollbackTransactionIfOpen;
|
|
1444
|
-
private classifyTransactionStateError;
|
|
1445
|
-
private probeTransactionState;
|
|
1446
|
-
private classifySavepointReleaseFailure;
|
|
1447
|
-
private rollbackSavepointAfterReleaseFailure;
|
|
1448
|
-
private enterTransactionScope;
|
|
1449
|
-
private enterPinnedConnectionScope;
|
|
1450
|
-
private enterSavepointScope;
|
|
1451
|
-
private pushClientScope;
|
|
1452
|
-
private currentClientScope;
|
|
1453
|
-
private managedScopeEndedMessage;
|
|
1454
|
-
private assertCanUseClient;
|
|
1455
|
-
private assertUsableScopeAncestors;
|
|
1456
|
-
private findClientScope;
|
|
1457
|
-
private assertScopeNotPoisoned;
|
|
1458
|
-
private throwIfScopePoisoned;
|
|
1459
|
-
private scopePoisonOutranksError;
|
|
1460
|
-
private poisonScopeState;
|
|
1461
|
-
private poisonClientScope;
|
|
1462
|
-
private poisonClientScopeStack;
|
|
1463
|
-
private runWithScopeStatementLock;
|
|
1464
|
-
private closeScope;
|
|
1465
|
-
private closeScopeAndAssertChildren;
|
|
1466
|
-
private drainScopeStatements;
|
|
1467
|
-
private drainScopeChildren;
|
|
1468
|
-
private assertScopeChildrenSettled;
|
|
1469
|
-
private drainScopeWork;
|
|
1470
|
-
private executeScopeBoundaryStatement;
|
|
1471
|
-
private assertCommitSucceeded;
|
|
1472
|
-
/**
|
|
1473
|
-
* Create a schema-scoped adapter for multi-tenant queries.
|
|
1474
|
-
*/
|
|
1475
|
-
withSchema(schemaName: string): Adapter<DB>;
|
|
1476
|
-
/**
|
|
1477
|
-
* Execute raw SQL directly.
|
|
1478
|
-
*
|
|
1479
|
-
* ⚠️ WARNING: Use parameter placeholders ($1, $2, etc.) for all values.
|
|
1480
|
-
*
|
|
1481
|
-
* Transaction control through raw SQL inside a scope dbsp is managing is
|
|
1482
|
-
* unsupported. `COMMIT`, `ROLLBACK`, and `PREPARE TRANSACTION` end the
|
|
1483
|
-
* transaction dbsp is working inside; dbsp detects that and fails loudly, but
|
|
1484
|
-
* the data is already whatever your statement made it. Raw savepoint control
|
|
1485
|
-
* (`SAVEPOINT`, `RELEASE SAVEPOINT`, `ROLLBACK TO SAVEPOINT`) can alter the
|
|
1486
|
-
* savepoint stack before dbsp sees the command tag; dbsp poisons the scope, but
|
|
1487
|
-
* it cannot make that command un-run. Manage your transaction outside dbsp's
|
|
1488
|
-
* calls.
|
|
1489
|
-
*/
|
|
1490
|
-
executeRaw<T = unknown>(sql: string, parameters?: readonly unknown[]): Promise<T[]>;
|
|
1491
|
-
/**
|
|
1492
|
-
* Generate DDL statements from a ModelIR schema.
|
|
1493
|
-
*
|
|
1494
|
-
* Uses PostgreSQL AST nodes and pgsql-deparser for consistent SQL generation.
|
|
1495
|
-
* Applies the naming plugin for identifier transformation.
|
|
1496
|
-
*
|
|
1497
|
-
* @param schema - The ModelIR schema to generate DDL from
|
|
1498
|
-
* @param overrideOptions - Optional overrides for DDL generation (e.g., includeDropStatements)
|
|
1499
|
-
* @returns Array of DDL statements in dependency order
|
|
1500
|
-
*/
|
|
1501
|
-
generateDDL(schema: ModelIR, overrideOptions?: Partial<GenerateDDLOptions>): string[];
|
|
1502
|
-
/**
|
|
1503
|
-
* Execute a DDL statement directly (e.g. TRUNCATE, VACUUM, ALTER TABLE, CREATE INDEX).
|
|
1504
|
-
*
|
|
1505
|
-
* @throws Error if called on a compile-only adapter (no pool)
|
|
1506
|
-
* @since DDL-TABLE-001
|
|
1507
|
-
*/
|
|
1508
|
-
executeDDL(sql: string): Promise<void>;
|
|
1509
|
-
/**
|
|
1510
|
-
* Whether a transaction is open on this adapter's connection.
|
|
1511
|
-
* This is true for dbsp-managed scopes and for borrowed pg clients whose
|
|
1512
|
-
* ReadyForQuery status says the caller has an open transaction.
|
|
1513
|
-
*
|
|
1514
|
-
* @since DDL-TABLE-001
|
|
1515
|
-
*/
|
|
1516
|
-
get inTransaction(): boolean;
|
|
1517
|
-
private adapterManagedScopeIsLive;
|
|
1518
|
-
private shouldProtectBorrowedClientTransaction;
|
|
1519
|
-
/**
|
|
1520
|
-
* An idle ReadyForQuery status says nothing about commands another owner has
|
|
1521
|
-
* already queued on a PoolClient. Only a dbsp-created pinned scope both owns
|
|
1522
|
-
* the checked-out physical client and holds its statement lock across the
|
|
1523
|
-
* failed named execution and any unnamed replay.
|
|
1524
|
-
*/
|
|
1525
|
-
private ownsSerializedClientForPreparedStatementReplay;
|
|
1526
|
-
private executeQueryProtectingOpenTransaction;
|
|
1527
|
-
private executeConnectionStatement;
|
|
1528
|
-
private executeConnectionStatementUnlocked;
|
|
1529
|
-
private executeConnectionStatementInSavepoint;
|
|
1530
|
-
private issueConnectionQuery;
|
|
1531
|
-
private assertNoMultiCommandRawCall;
|
|
1532
|
-
private assertNoTransactionControlCommand;
|
|
1533
|
-
private assertPrepareDidNotEndTransaction;
|
|
1534
|
-
/**
|
|
1535
|
-
* Resolve the explicit schema for a catalog read: an explicit argument, else
|
|
1536
|
-
* the adapter's configured schema, else `undefined` (resolve in-query). NOT a
|
|
1537
|
-
* hard-coded 'public' — an unresolved schema is handled by the SQL, which
|
|
1538
|
-
* finds the table's schema search_path-aware, in the SAME session, so a
|
|
1539
|
-
* non-public search_path and a pooled connection both stay correct.
|
|
1540
|
-
*/
|
|
1541
|
-
private explicitSchema;
|
|
1542
|
-
/**
|
|
1543
|
-
* List all indexes on a table by querying pg_indexes.
|
|
1544
|
-
*
|
|
1545
|
-
* @param table - Table name
|
|
1546
|
-
* @param schema - Schema name (defaults to the search_path-resolved schema)
|
|
1547
|
-
*/
|
|
1548
|
-
listIndexes(table: string, schema?: string, options?: {
|
|
1549
|
-
namePattern?: string;
|
|
1550
|
-
}): Promise<IndexInfo[]>;
|
|
1551
|
-
/**
|
|
1552
|
-
* Check whether an index with the given name exists on a table.
|
|
1553
|
-
*
|
|
1554
|
-
* @param name - Index name
|
|
1555
|
-
* @param table - Table name
|
|
1556
|
-
* @param schema - Schema name (defaults to the search_path-resolved schema)
|
|
1557
|
-
*/
|
|
1558
|
-
indexExists(name: string, table: string, schema?: string): Promise<boolean>;
|
|
1559
|
-
/**
|
|
1560
|
-
* Return the total storage size of a table in bytes (includes indexes and TOAST).
|
|
1561
|
-
*
|
|
1562
|
-
* The table name is a SQL identifier — it is double-quoted, not parameterized,
|
|
1563
|
-
* because PostgreSQL does not allow parameterized table names in FROM clauses.
|
|
1564
|
-
* With no known schema the table is left unqualified so ::regclass resolves it
|
|
1565
|
-
* through search_path (the same table an unqualified reference would hit).
|
|
1566
|
-
*
|
|
1567
|
-
* @param table - Table name
|
|
1568
|
-
* @param schema - Schema name (defaults to the search_path-resolved schema)
|
|
1569
|
-
*/
|
|
1570
|
-
storageSize(table: string, schema?: string): Promise<number>;
|
|
1571
|
-
/**
|
|
1572
|
-
* Generate SQL for TRUNCATE TABLE.
|
|
1573
|
-
* Implements TableDDLGeneratorAdapter.generateTruncate.
|
|
1574
|
-
*/
|
|
1575
|
-
generateTruncate(table: string, schemaName: string, options?: TruncateOptions): string;
|
|
1576
|
-
/**
|
|
1577
|
-
* Generate SQL for VACUUM.
|
|
1578
|
-
* Implements TableDDLGeneratorAdapter.generateVacuum.
|
|
1579
|
-
*/
|
|
1580
|
-
generateVacuum(table: string, schemaName: string, options?: VacuumOptions): string;
|
|
1581
|
-
/**
|
|
1582
|
-
* Generate SQL for ALTER TABLE ... ALTER COLUMN.
|
|
1583
|
-
* Implements TableDDLGeneratorAdapter.generateAlterColumn.
|
|
1584
|
-
*/
|
|
1585
|
-
generateAlterColumn(table: string, schemaName: string, column: string, options: AlterColumnOptions): string;
|
|
1586
|
-
/**
|
|
1587
|
-
* Generate SQL for CREATE INDEX.
|
|
1588
|
-
* Implements TableDDLGeneratorAdapter.generateCreateIndex.
|
|
1589
|
-
*/
|
|
1590
|
-
generateCreateIndex(table: string, schemaName: string, options: CreateIndexOptions): string;
|
|
1591
|
-
/**
|
|
1592
|
-
* Generate SQL for DROP INDEX.
|
|
1593
|
-
* Implements TableDDLGeneratorAdapter.generateDropIndex.
|
|
1594
|
-
*/
|
|
1595
|
-
generateDropIndex(name: string, schemaName: string, options?: DropIndexOptions): string;
|
|
1596
|
-
/**
|
|
1597
|
-
* Validate an identifier (table name, column name, schema name).
|
|
1598
|
-
*/
|
|
1599
|
-
validateIdentifier(value: string, type: string): void;
|
|
1600
|
-
}
|
|
1601
|
-
/**
|
|
1602
|
-
* Create a PgsqlAdapter from a pg Pool instance.
|
|
1603
|
-
*
|
|
1604
|
-
* @param pool - pg Pool instance
|
|
1605
|
-
* @param options - Optional configuration
|
|
1606
|
-
* @returns A new PgsqlAdapter instance
|
|
1607
|
-
*
|
|
1608
|
-
* @example
|
|
1609
|
-
* ```typescript
|
|
1610
|
-
* import { Pool } from 'pg';
|
|
1611
|
-
* import { createPgsqlAdapter } from '@dbsp/adapter-pgsql';
|
|
1612
|
-
*
|
|
1613
|
-
* const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
|
1614
|
-
* const adapter = createPgsqlAdapter(pool);
|
|
1615
|
-
*
|
|
1616
|
-
* // With naming convention
|
|
1617
|
-
* const adapter = createPgsqlAdapter(pool, { dbCasing: 'snake_case' });
|
|
1618
|
-
* ```
|
|
1619
|
-
*/
|
|
1620
|
-
declare function createPgsqlAdapter<DB = unknown>(pool: Pool, options?: PgsqlPoolAdapterOptions): PgsqlAdapter<DB>;
|
|
1621
|
-
declare function createPgsqlAdapter<DB = unknown>(client: PoolClient, options: PgsqlBorrowedClientAdapterOptions): PgsqlAdapter<DB>;
|
|
1622
|
-
/**
|
|
1623
|
-
* Creates a connectionless PgsqlAdapter for SQL generation without a database connection.
|
|
1624
|
-
*
|
|
1625
|
-
* All compilation methods (compile, compileInsert, etc.), createDump(), and generateDDL()
|
|
1626
|
-
* work normally. The adapter has the full PgsqlAdapter surface; database operations refuse
|
|
1627
|
-
* at runtime until it is constructed with a connection via createPgsqlAdapter(pool).
|
|
1628
|
-
*
|
|
1629
|
-
* @example
|
|
1630
|
-
* ```typescript
|
|
1631
|
-
* import { createPgsqlCompileOnlyAdapter } from '@dbsp/adapter-pgsql';
|
|
1632
|
-
* import { createOrm } from '@dbsp/core';
|
|
1633
|
-
*
|
|
1634
|
-
* const adapter = createPgsqlCompileOnlyAdapter();
|
|
1635
|
-
* const orm = createOrm({ model, adapter });
|
|
1636
|
-
* const dump = await orm.select('users').dump();
|
|
1637
|
-
* console.log(dump.sql);
|
|
1638
|
-
* ```
|
|
1639
|
-
*/
|
|
1640
|
-
declare function createPgsqlCompileOnlyAdapter<DB = unknown>(options?: PgsqlCompileOnlyAdapterOptions): PgsqlAdapter<DB>;
|
|
1641
|
-
|
|
1642
|
-
interface CheckConstraintCanonicalizationWarning {
|
|
1643
|
-
readonly table: string;
|
|
1644
|
-
readonly kind: 'check_constraint';
|
|
1645
|
-
readonly name: string;
|
|
1646
|
-
readonly constraint: string;
|
|
1647
|
-
readonly message: string;
|
|
1648
|
-
readonly cause: unknown;
|
|
1649
|
-
}
|
|
1650
|
-
interface ColumnDefaultCanonicalizationWarning {
|
|
1651
|
-
readonly table: string;
|
|
1652
|
-
readonly kind: 'column_default';
|
|
1653
|
-
readonly name: string;
|
|
1654
|
-
readonly message: string;
|
|
1655
|
-
readonly cause: unknown;
|
|
1656
|
-
readonly outcome?: 'unavailable' | 'rejected' | 'refused';
|
|
1657
|
-
/** Whether this warning represents a raw fallback or absent counterpart. */
|
|
1658
|
-
readonly comparison: 'raw' | 'unpaired';
|
|
1659
|
-
/** Present when the default could not be paired with the opposite model side. */
|
|
1660
|
-
readonly side?: 'desired' | 'database';
|
|
1661
|
-
}
|
|
1662
|
-
interface IndexPredicateCanonicalizationWarning {
|
|
1663
|
-
readonly table: string;
|
|
1664
|
-
readonly kind: 'index_predicate';
|
|
1665
|
-
readonly name: string;
|
|
1666
|
-
readonly message: string;
|
|
1667
|
-
readonly cause: unknown;
|
|
1668
|
-
readonly outcome: 'unavailable' | 'rejected' | 'refused';
|
|
1669
|
-
/** Predicate fallback always compares both complete models raw. */
|
|
1670
|
-
readonly comparison: 'raw';
|
|
1671
|
-
readonly side?: 'desired' | 'database';
|
|
1672
|
-
}
|
|
1673
|
-
type ExpressionCanonicalizationWarning = CheckConstraintCanonicalizationWarning | ColumnDefaultCanonicalizationWarning | IndexPredicateCanonicalizationWarning;
|
|
1674
|
-
interface CanonicalizeCheckConstraintsOptions {
|
|
1675
|
-
/** Database schema that owns the target tables and target-scoped enum types. */
|
|
1676
|
-
readonly schemaName?: string;
|
|
1677
|
-
/** Naming convention used when matching desired table names to DB table names. */
|
|
1678
|
-
readonly dbCasing?: DbCasing;
|
|
1679
|
-
/** Called when PostgreSQL CHECK canonicalisation fails and raw comparison is used. */
|
|
1680
|
-
readonly onWarning?: (warning: CheckConstraintCanonicalizationWarning) => void;
|
|
1681
|
-
/** Throw instead of falling back to raw comparison when canonicalisation fails. */
|
|
1682
|
-
readonly requireCanonicalization?: boolean;
|
|
1683
|
-
/** Skip CHECK scratch work when the caller's dialect does not support CHECK DDL. */
|
|
1684
|
-
readonly canonicalizeCheckConstraints?: boolean;
|
|
1685
|
-
/** Capabilities used to generate the migration this scope is staging for. */
|
|
1686
|
-
readonly dialectCapabilities?: DialectCapabilities;
|
|
1687
|
-
}
|
|
1688
|
-
declare class CheckConstraintCanonicalizationError extends Error {
|
|
1689
|
-
readonly table: string;
|
|
1690
|
-
readonly constraints: readonly string[];
|
|
1691
|
-
readonly cause: unknown;
|
|
1692
|
-
constructor(table: string, constraints: readonly string[], cause: unknown);
|
|
1693
|
-
}
|
|
1694
|
-
declare class ColumnDefaultCanonicalizationError extends Error {
|
|
1695
|
-
readonly table: string;
|
|
1696
|
-
readonly column: string;
|
|
1697
|
-
readonly cause: unknown;
|
|
1698
|
-
constructor(table: string, column: string, cause: unknown);
|
|
1699
|
-
}
|
|
1700
|
-
/**
|
|
1701
|
-
* Canonicalise PostgreSQL CHECK constraint expressions in a desired model.
|
|
1702
|
-
*/
|
|
1703
|
-
declare function canonicalizeCheckConstraints(adapter: RollbackOnlyPgsqlScope, desired: ModelIR, dbModel: ModelIR, options?: CanonicalizeCheckConstraintsOptions): Promise<ModelIR>;
|
|
1704
|
-
|
|
1705
|
-
interface ComparePgsqlDatabaseSchemaOptions extends CompareSchemataOptions, SchemaScopeOptions {
|
|
1706
|
-
/**
|
|
1707
|
-
* Whether to canonicalise PostgreSQL CHECK constraint expressions, column defaults, and predicates on column-keyed
|
|
1708
|
-
* partial indexes before comparing. Defaults to `true`. Expression-keyed
|
|
1709
|
-
* partial-index predicates are reported as unavailable. Set to `false` only for compatibility with
|
|
1710
|
-
* legacy raw-string live diffs.
|
|
1711
|
-
*
|
|
1712
|
-
* Live canonicalisation creates temporary scratch tables inside an adapter
|
|
1713
|
-
* scratch scope whose successful cleanup is rollback. The database role needs
|
|
1714
|
-
* permission to create temporary tables and use the scratch column types. If
|
|
1715
|
-
* PostgreSQL refuses that scratch DDL, non-strict mode warns and falls back to
|
|
1716
|
-
* best-effort raw string comparison for the affected expression surfaces.
|
|
1717
|
-
*/
|
|
1718
|
-
readonly canonicalizeExpressions?: boolean;
|
|
1719
|
-
/**
|
|
1720
|
-
* Receives live expression canonicalisation warnings. Defaults to console.warn.
|
|
1721
|
-
*/
|
|
1722
|
-
readonly onWarning?: (message: string) => void;
|
|
1723
|
-
/** Receives the identity-bearing canonicalisation warning before its string form. */
|
|
1724
|
-
readonly onExpressionCanonicalizationWarning?: (warning: ExpressionCanonicalizationWarning) => void;
|
|
1725
|
-
/**
|
|
1726
|
-
* Diff that the caller just applied before this live re-diff. Used only when
|
|
1727
|
-
* expression surfaces are compared by raw text to fail loudly if the exact same
|
|
1728
|
-
* expression-surface drift appears again after re-introspection.
|
|
1729
|
-
*/
|
|
1730
|
-
readonly previouslyAppliedDiff?: SchemaDiff;
|
|
1731
|
-
}
|
|
1732
|
-
type NonConvergentSchemaDiffSurface = {
|
|
1733
|
-
readonly kind: 'check_constraint';
|
|
1734
|
-
readonly table: string;
|
|
1735
|
-
readonly constraint: string;
|
|
1736
|
-
} | {
|
|
1737
|
-
readonly kind: 'column_default';
|
|
1738
|
-
readonly table: string;
|
|
1739
|
-
readonly column: string;
|
|
1740
|
-
};
|
|
1741
|
-
declare class NonConvergentSchemaDiffError extends Error {
|
|
1742
|
-
readonly surface: NonConvergentSchemaDiffSurface;
|
|
1743
|
-
readonly desiredExpressionHash: string;
|
|
1744
|
-
readonly databaseExpressionHash: string;
|
|
1745
|
-
constructor(surface: NonConvergentSchemaDiffSurface, desiredExpressionHash: string, databaseExpressionHash: string);
|
|
1746
|
-
}
|
|
1747
|
-
/** An enum value this diff adds, reported as a candidate cause — never asserted. */
|
|
1748
|
-
interface AddedEnumValue {
|
|
1749
|
-
readonly enumName: string;
|
|
1750
|
-
readonly value: string;
|
|
1751
|
-
}
|
|
1752
|
-
declare class CheckConstraintNewEnumValueError extends Error {
|
|
1753
|
-
readonly table: string;
|
|
1754
|
-
readonly constraint: string;
|
|
1755
|
-
readonly addedEnumValues: readonly AddedEnumValue[];
|
|
1756
|
-
constructor(table: string, constraint: string, addedEnumValues: readonly AddedEnumValue[]);
|
|
1757
|
-
}
|
|
1758
|
-
/** A raw partial-index predicate and added enum values cannot share one migration. */
|
|
1759
|
-
declare class PartialIndexPredicateNewEnumValueError extends Error {
|
|
1760
|
-
readonly addedEnumValues: readonly AddedEnumValue[];
|
|
1761
|
-
constructor(addedEnumValues: readonly AddedEnumValue[]);
|
|
1762
|
-
}
|
|
1763
|
-
/** #454: Predicate canonicalization is not implemented for indexes with expression keys. */
|
|
1764
|
-
declare class ExpressionKeyedIndexPredicateCanonicalizationUnsupportedError extends Error {
|
|
1765
|
-
readonly predicates: readonly {
|
|
1766
|
-
readonly side: 'desired' | 'database';
|
|
1767
|
-
readonly table: string;
|
|
1768
|
-
readonly index: string;
|
|
1769
|
-
}[];
|
|
1770
|
-
constructor(predicates: readonly {
|
|
1771
|
-
readonly side: 'desired' | 'database';
|
|
1772
|
-
readonly table: string;
|
|
1773
|
-
readonly index: string;
|
|
1774
|
-
}[]);
|
|
1775
|
-
}
|
|
1776
|
-
/**
|
|
1777
|
-
* A raw partial-index predicate cannot be proven to converge after PostgreSQL
|
|
1778
|
-
* deparses it, so emitting its CREATE statement is unsafe.
|
|
1779
|
-
*/
|
|
1780
|
-
declare class RawIndexPredicateFallbackError extends Error {
|
|
1781
|
-
constructor(cause?: unknown);
|
|
1782
|
-
}
|
|
1783
|
-
declare class IndexPredicateCanonicalizationError extends Error {
|
|
1784
|
-
readonly rejectedPredicates: readonly {
|
|
1785
|
-
readonly side: 'desired' | 'database';
|
|
1786
|
-
readonly table: string;
|
|
1787
|
-
readonly index: string;
|
|
1788
|
-
readonly reason?: unknown;
|
|
1789
|
-
}[];
|
|
1790
|
-
/**
|
|
1791
|
-
* Enum values added by this migration are diagnostic candidates only. They
|
|
1792
|
-
* are collected from the schema diff, never matched to a rejected index.
|
|
1793
|
-
*/
|
|
1794
|
-
readonly addedEnumValues: readonly AddedEnumValue[];
|
|
1795
|
-
constructor(rejectedPredicates: readonly {
|
|
1796
|
-
readonly side: 'desired' | 'database';
|
|
1797
|
-
readonly table: string;
|
|
1798
|
-
readonly index: string;
|
|
1799
|
-
readonly reason?: unknown;
|
|
1800
|
-
}[],
|
|
1801
|
-
/**
|
|
1802
|
-
* Enum values added by this migration are diagnostic candidates only. They
|
|
1803
|
-
* are collected from the schema diff, never matched to a rejected index.
|
|
1804
|
-
*/
|
|
1805
|
-
addedEnumValues?: readonly AddedEnumValue[]);
|
|
1806
|
-
}
|
|
1807
|
-
/**
|
|
1808
|
-
* Live PostgreSQL schema diff: introspect, canonicalise desired CHECK
|
|
1809
|
-
* constraint expressions, column defaults, and predicates on column-keyed
|
|
1810
|
-
* partial indexes through PostgreSQL, then call the pure synchronous
|
|
1811
|
-
* schema comparator.
|
|
1812
|
-
*
|
|
1813
|
-
* If CHECK canonicalisation falls back while the same diff adds a plausibly
|
|
1814
|
-
* referenced enum value, the diff is refused. dbsp currently applies each
|
|
1815
|
-
* migration in one transaction, and PostgreSQL forbids using a newly added enum
|
|
1816
|
-
* value in that same transaction; emitting the CHECK would produce a migration
|
|
1817
|
-
* that cannot run. Apply the enum addition by itself first, then add or update
|
|
1818
|
-
* the CHECK constraint in a later migration.
|
|
1819
|
-
*
|
|
1820
|
-
* Index expressions are intentionally not canonicalised here; partial-index
|
|
1821
|
-
* predicates on expression-keyed indexes are reported as unavailable and are
|
|
1822
|
-
* therefore rejected by strict mode. They need their own key-shape substrate.
|
|
1823
|
-
*/
|
|
1824
|
-
declare function comparePgsqlDatabaseSchema(adapter: PgsqlAdapter, desired: ModelIR, options?: ComparePgsqlDatabaseSchemaOptions): Promise<SchemaDiff>;
|
|
1825
|
-
declare function assertNoRepeatedExpressionSurfaceDrift(previouslyAppliedDiff: SchemaDiff, currentDiff: SchemaDiff, rawExpressionSurfaces?: ReadonlySet<string>): void;
|
|
1826
|
-
|
|
1827
|
-
/**
|
|
1828
|
-
* Migration SQL Generator (DDL-PROV Block 1)
|
|
1829
|
-
*
|
|
1830
|
-
* Generates ordered SQL statements from a SchemaDiff.
|
|
1831
|
-
* Statements are topologically sorted: DROP constraints → DROP objects → CREATE objects → ADD constraints.
|
|
1832
|
-
*
|
|
1833
|
-
* @module migration-sql
|
|
1834
|
-
*/
|
|
1835
|
-
|
|
1836
|
-
interface MigrationSQLOptions {
|
|
1837
|
-
/**
|
|
1838
|
-
* Schema namespace (default: none — unqualified).
|
|
1839
|
-
* Required when emitted migration SQL would otherwise mix non-default
|
|
1840
|
-
* target-scoped custom types/enums with unqualified table SQL.
|
|
1841
|
-
*/
|
|
1842
|
-
readonly schemaName?: string;
|
|
1843
|
-
/** Whether to include destructive changes (drops) */
|
|
1844
|
-
readonly includeDestructive?: boolean;
|
|
1845
|
-
/** Automatically create indexes on FK columns for new tables (default: true) */
|
|
1846
|
-
readonly fkAutoIndex?: boolean;
|
|
1847
|
-
/** Dialect capabilities — unsupported index features throw during migration SQL generation */
|
|
1848
|
-
readonly dialectCapabilities?: DialectCapabilities;
|
|
1849
|
-
}
|
|
1850
|
-
/**
|
|
1851
|
-
* Generate ordered SQL statements from a SchemaDiff.
|
|
1852
|
-
*
|
|
1853
|
-
* Topological order:
|
|
1854
|
-
* 0. DROP FK/CHECK constraints (must drop before referenced tables)
|
|
1855
|
-
* 1. DROP indexes
|
|
1856
|
-
* 2. DROP columns
|
|
1857
|
-
* 3. DROP primary keys
|
|
1858
|
-
* 4. DROP tables, DROP ENUMs
|
|
1859
|
-
* 5. CREATE ENUMs (must exist before tables that use them)
|
|
1860
|
-
* 6. CREATE tables
|
|
1861
|
-
* 7. ADD columns
|
|
1862
|
-
* 8. ALTER columns (type, nullable, default)
|
|
1863
|
-
* 9. ADD primary keys / column UNIQUE constraints
|
|
1864
|
-
* 10. ADD FK constraints (must add after referenced tables exist)
|
|
1865
|
-
* 11. ALTER FK (drop + re-add)
|
|
1866
|
-
* 12. CREATE indexes
|
|
1867
|
-
* 13. ADD CHECK constraints
|
|
1868
|
-
* 14. ALTER ENUM ADD VALUE (must be last — has transaction visibility caveats in PG)
|
|
1869
|
-
* 15. COMMENT ON TABLE / COLUMN (very last)
|
|
1870
|
-
*/
|
|
1871
|
-
declare function generateMigrationSQL(diff: SchemaDiff, options?: MigrationSQLOptions): readonly string[];
|
|
1872
|
-
/**
|
|
1873
|
-
* Generate ordered DOWN SQL statements from a SchemaDiff.
|
|
1874
|
-
*
|
|
1875
|
-
* Reverses the topological order used in UP migrations:
|
|
1876
|
-
* phases run in descending order (11, 10, 9, ..., 0).
|
|
1877
|
-
*
|
|
1878
|
-
* Irreversible changes (drops that lose data) produce SQL WARNING comments.
|
|
1879
|
-
*/
|
|
1880
|
-
declare function generateDownSQL(diff: SchemaDiff, options?: MigrationSQLOptions): readonly string[];
|
|
767
|
+
declare function readGeneratedPostcondition(executor: GeneratedPostconditionSession, step: NormalizedManagedStep, address: LedgerAddress): Promise<GeneratedPostconditionObservation>;
|
|
1881
768
|
|
|
1882
769
|
/**
|
|
1883
770
|
* Type Mapping - Maps ModelIR ColumnType to PostgreSQL data types
|
|
@@ -2510,28 +1397,6 @@ declare const DEFAULT_REDACTION_PATTERNS: ReadonlyArray<RegExp>;
|
|
|
2510
1397
|
*/
|
|
2511
1398
|
declare function redactParams(params: readonly unknown[], config: RedactionConfig): readonly unknown[];
|
|
2512
1399
|
|
|
2513
|
-
declare const projectionEnvelopeBrand: unique symbol;
|
|
2514
|
-
type ProjectionEnvelope<T = unknown> = {
|
|
2515
|
-
readonly [projectionEnvelopeBrand]: true;
|
|
2516
|
-
readonly sql: string;
|
|
2517
|
-
readonly parameters: readonly unknown[];
|
|
2518
|
-
readonly ast?: Node;
|
|
2519
|
-
readonly projection: ProjectionState;
|
|
2520
|
-
readonly hydrationPlan?: PlanReport;
|
|
2521
|
-
readonly __resultType?: T;
|
|
2522
|
-
};
|
|
2523
|
-
type ProjectionState = {
|
|
2524
|
-
readonly kind: 'known';
|
|
2525
|
-
readonly outputs: ReadonlyMap<string, OutputProjection>;
|
|
2526
|
-
} | {
|
|
2527
|
-
readonly kind: 'dropped';
|
|
2528
|
-
readonly reason: ProjectionDropReason;
|
|
2529
|
-
readonly hadConvertibleSource: boolean;
|
|
2530
|
-
};
|
|
2531
|
-
type OutputProjection = OutputDescriptor;
|
|
2532
|
-
|
|
2533
|
-
type ProjectionDropReason = 'set-operation-positional-merge' | 'raw-recursive-cte-positional-merge' | 'unknown-raw-sql' | 'unsupported-source';
|
|
2534
|
-
|
|
2535
1400
|
/**
|
|
2536
1401
|
* Set operation compiler (UNION / INTERSECT / EXCEPT)
|
|
2537
1402
|
*
|
|
@@ -3292,10 +2157,7 @@ interface SetNotNullMatch {
|
|
|
3292
2157
|
readonly expectedColumnShape: SetNotNullColumnShapeExpectation;
|
|
3293
2158
|
readonly assumptions?: readonly Assumption[];
|
|
3294
2159
|
}
|
|
3295
|
-
|
|
3296
|
-
readonly naming?: NamingPlugin;
|
|
3297
|
-
}
|
|
3298
|
-
declare function createSetNotNullRule(options?: SetNotNullRuleOptions): TransitionRule<SetNotNullMatch>;
|
|
2160
|
+
declare function createSetNotNullRule(): TransitionRule<SetNotNullMatch>;
|
|
3299
2161
|
|
|
3300
2162
|
interface EnumAddValueMatch {
|
|
3301
2163
|
readonly schema?: string;
|
|
@@ -3308,6 +2170,9 @@ interface EnumAddValueMatch {
|
|
|
3308
2170
|
readonly assumptions?: readonly Assumption[];
|
|
3309
2171
|
}
|
|
3310
2172
|
interface EnumAddValueRuleOptions {
|
|
2173
|
+
/**
|
|
2174
|
+
* @deprecated Ignored because declared enum names are physical identifiers (#825).
|
|
2175
|
+
*/
|
|
3311
2176
|
readonly naming?: NamingPlugin;
|
|
3312
2177
|
}
|
|
3313
2178
|
declare function satisfiesPgEnumLabelVisibleCompositionFact(fact: TransitionCompositionFact, current: ModelIR, _context: ObservationContext): boolean;
|
|
@@ -3336,7 +2201,6 @@ interface LogicalIdentityAdoptionMatch {
|
|
|
3336
2201
|
readonly selectionBasis: string;
|
|
3337
2202
|
}
|
|
3338
2203
|
interface LogicalIdentityAdoptionRuleOptions {
|
|
3339
|
-
readonly naming?: NamingPlugin;
|
|
3340
2204
|
readonly asserter?: IdentityAdoptionAsserter;
|
|
3341
2205
|
readonly selectionBasis?: string;
|
|
3342
2206
|
}
|
|
@@ -3353,8 +2217,6 @@ interface AddCheckMatch {
|
|
|
3353
2217
|
}
|
|
3354
2218
|
|
|
3355
2219
|
interface PgTransitionPackOptions {
|
|
3356
|
-
readonly dbCasing?: DbCasing;
|
|
3357
|
-
readonly naming?: NamingPlugin;
|
|
3358
2220
|
readonly identityAdoptionAsserter?: IdentityAdoptionAsserter;
|
|
3359
2221
|
readonly identityAdoptionSelectionBasis?: string;
|
|
3360
2222
|
}
|
|
@@ -3868,12 +2730,93 @@ declare function readPgRemovalEffectsClosure(input: {
|
|
|
3868
2730
|
readonly isManaged: (address: LedgerAddress) => Promise<boolean>;
|
|
3869
2731
|
}): Promise<PgRemovalEffectsClosure>;
|
|
3870
2732
|
|
|
2733
|
+
interface ConvergePgBaseOptions extends Omit<ConvergePgOptions$1, 'schema' | 'dbCasing' | 'mode' | 'declaredSequenceNames' | 'fkAutoIndex'> {
|
|
2734
|
+
}
|
|
2735
|
+
interface ConvergePgOptions extends ConvergePgBaseOptions {
|
|
2736
|
+
readonly mode?: 'apply';
|
|
2737
|
+
}
|
|
2738
|
+
interface ConvergePgCheckOptions extends ConvergePgBaseOptions {
|
|
2739
|
+
readonly mode: 'check';
|
|
2740
|
+
}
|
|
2741
|
+
declare function convergePg(pool: Pool, physical: PgPhysicalModel, options?: ConvergePgOptions): Promise<PgConvergeResult>;
|
|
2742
|
+
declare function convergePg(pool: Pool, physical: PgPhysicalModel, options: ConvergePgCheckOptions): Promise<PgConvergeCheckResult>;
|
|
2743
|
+
|
|
2744
|
+
type PgReconcileRecoveryOutcome = 'appended' | 'already-appended' | 'indeterminate-appended' | 'no-open-claim' | 'pending' | 'blocked' | 'malformed-chain' | 'protocol-refused' | 'transport-ambiguous' | 'refused-pair' | 'indeterminate-pair';
|
|
2745
|
+
type PgReconcileRecoveryFailureCause = 'catalogue' | 'malformed-journal' | 'transport';
|
|
2746
|
+
/** One ordered recovery attempt; diagnostics are raw and presentation-free. */
|
|
2747
|
+
interface PgReconcileRecoveryReport {
|
|
2748
|
+
readonly address: LedgerAddress;
|
|
2749
|
+
readonly outcome: PgReconcileRecoveryOutcome;
|
|
2750
|
+
readonly reason?: string;
|
|
2751
|
+
readonly pairId?: string;
|
|
2752
|
+
readonly failureCause?: PgReconcileRecoveryFailureCause;
|
|
2753
|
+
}
|
|
2754
|
+
/** The selected semantic refusal condition, never a CLI refusal document. */
|
|
2755
|
+
type PgReconcileSelectedIssue = {
|
|
2756
|
+
readonly kind: 'ledger-not-current';
|
|
2757
|
+
readonly currency: Exclude<PgLedgerScopeCurrency, {
|
|
2758
|
+
readonly kind: 'current';
|
|
2759
|
+
}>;
|
|
2760
|
+
readonly affectedAddresses: readonly LedgerAddress[];
|
|
2761
|
+
} | {
|
|
2762
|
+
readonly kind: 'database-read-only';
|
|
2763
|
+
readonly reason: string;
|
|
2764
|
+
readonly affectedAddresses: readonly LedgerAddress[];
|
|
2765
|
+
} | {
|
|
2766
|
+
readonly kind: 'catalogue-unavailable';
|
|
2767
|
+
readonly address: LedgerAddress;
|
|
2768
|
+
} | {
|
|
2769
|
+
readonly kind: 'malformed-chain';
|
|
2770
|
+
readonly address: LedgerAddress;
|
|
2771
|
+
};
|
|
2772
|
+
interface PgReconcileBaseResult {
|
|
2773
|
+
readonly runId: string;
|
|
2774
|
+
readonly addresses: readonly ResourceAddress[];
|
|
2775
|
+
readonly recovery?: readonly PgReconcileRecoveryReport[];
|
|
2776
|
+
readonly selectedIssue?: PgReconcileSelectedIssue;
|
|
2777
|
+
}
|
|
2778
|
+
type PgReconcileTransitionRunResult = (PgReconcileBaseResult & {
|
|
2779
|
+
readonly kind: 'completed';
|
|
2780
|
+
}) | (PgReconcileBaseResult & {
|
|
2781
|
+
readonly kind: 'unresolved';
|
|
2782
|
+
}) | (PgReconcileBaseResult & {
|
|
2783
|
+
readonly kind: 'selection-unavailable';
|
|
2784
|
+
readonly detail?: string;
|
|
2785
|
+
}) | (PgReconcileBaseResult & {
|
|
2786
|
+
readonly kind: 'database-read-only';
|
|
2787
|
+
readonly selectedIssue: Extract<PgReconcileSelectedIssue, {
|
|
2788
|
+
readonly kind: 'database-read-only';
|
|
2789
|
+
}>;
|
|
2790
|
+
}) | {
|
|
2791
|
+
readonly kind: 'busy';
|
|
2792
|
+
readonly runId: string;
|
|
2793
|
+
readonly addresses: readonly ResourceAddress[];
|
|
2794
|
+
};
|
|
2795
|
+
type PgReconcileFailureStage = 'reconcile' | 'journal' | 'catalogue';
|
|
2796
|
+
/** A read/recovery failure whose original cause remains available to callers. */
|
|
2797
|
+
declare class PgReconcileTransitionRunError extends Error {
|
|
2798
|
+
readonly stage: PgReconcileFailureStage;
|
|
2799
|
+
readonly originalCause: unknown;
|
|
2800
|
+
constructor(stage: PgReconcileFailureStage, originalCause: unknown);
|
|
2801
|
+
}
|
|
2802
|
+
/**
|
|
2803
|
+
* Returns recovery decisions for one durable run without reissuing DDL.
|
|
2804
|
+
*
|
|
2805
|
+
* Reconciliation keeps the run-lock session while `recoverPgOutcomeClaim`
|
|
2806
|
+
* acquires its own outcome session. The supplied pool must allow at least two
|
|
2807
|
+
* concurrent connections: a pool with `max: 1` waits forever under the lock.
|
|
2808
|
+
*/
|
|
2809
|
+
declare function reconcilePgTransitionRun(pool: Pool, runId: string): Promise<PgReconcileTransitionRunResult>;
|
|
2810
|
+
/** Finds every execution id durably attributable to one transition run. */
|
|
2811
|
+
declare function executionIdsForRun(journal: Awaited<ReturnType<typeof readTransitionJournal>>): readonly string[];
|
|
2812
|
+
|
|
3871
2813
|
/**
|
|
3872
2814
|
* Identifier Validation for adapter-pgsql
|
|
3873
2815
|
*
|
|
3874
2816
|
* Security layer to prevent SQL injection via identifiers.
|
|
3875
2817
|
* All table names, column names, schema names, and aliases MUST pass validation.
|
|
3876
2818
|
*/
|
|
2819
|
+
|
|
3877
2820
|
/**
|
|
3878
2821
|
* Error thrown when an identifier fails validation.
|
|
3879
2822
|
*/
|
|
@@ -3926,11 +2869,6 @@ declare function validateIdentifiers(identifiers: Record<string, 'table' | 'colu
|
|
|
3926
2869
|
* NOT for use in SQL - use validateIdentifier + AST helpers for that.
|
|
3927
2870
|
*/
|
|
3928
2871
|
declare function sanitizeForDisplay(value: string): string;
|
|
3929
|
-
/**
|
|
3930
|
-
* Preserve hostile diagnostic text as one printable line without losing which
|
|
3931
|
-
* control character was supplied. This is for diagnostics only, never SQL.
|
|
3932
|
-
*/
|
|
3933
|
-
declare function escapeDiagnosticText(value: string): string;
|
|
3934
2872
|
/**
|
|
3935
2873
|
* Validate a raw SQL expression used in DDL contexts (defaults, policy USING/CHECK).
|
|
3936
2874
|
* Rejects injection vectors: semicolons, line-comment markers, block-comment markers.
|
|
@@ -3942,4 +2880,4 @@ declare function escapeDiagnosticText(value: string): string;
|
|
|
3942
2880
|
*/
|
|
3943
2881
|
declare function validateSqlExpression(sql: string, context: string): void;
|
|
3944
2882
|
|
|
3945
|
-
export { ADD_CHECK_RULE_ID, ALTER_AUTHORITY_OBSERVATION, ALTER_COLUMN_SET_NOT_NULL_OPERATION_KIND, ALTER_TYPE_ADD_VALUE_OPERATION_KIND, ATTACH_LOGICAL_IDENTITY_OPERATION_KIND, type
|
|
2883
|
+
export { ADD_CHECK_RULE_ID, ALTER_AUTHORITY_OBSERVATION, ALTER_COLUMN_SET_NOT_NULL_OPERATION_KIND, ALTER_TYPE_ADD_VALUE_OPERATION_KIND, ATTACH_LOGICAL_IDENTITY_OPERATION_KIND, type AlterColumnSetNotNullPayload, type AlterTypeAddValuePayload, type AttachLogicalIdentityPayload, type BatchValuesJoinDecision, COLUMN_EXISTS_OBSERVATION, ChangeKind, type CompiledResult, type CompilerContext, type CompilerOptions, type CompilerState, type ConflictAction, type ConflictTarget, type ConvergePgBaseOptions, type ConvergePgCheckOptions, type ConvergePgOptions, type CursorHoldOption, type CursorOptions, type CursorScrollOption, DATABASE_READ_ONLY_OUTCOME, DBSP_LEDGER_EVENT_TABLE, DBSP_LEDGER_IDENTITY_TABLE, DBSP_LEDGER_MARKER_TABLE, DBSP_LEDGER_RESERVATION_TABLE, DBSP_LOGICAL_IDENTITY_TABLE, DBSP_META_SCHEMA, DBSP_TRANSITION_AUTHORIZATION_TABLE, DBSP_TRANSITION_JOURNAL_TABLE, DBSP_TRANSITION_RUN_PLAN_TABLE, DBSP_TRANSITION_RUN_TABLE, DEFAULT_REDACTION_PATTERNS, type Decision, type DeleteConfig, ENGINE_VERSION_OBSERVATION, ENUM_ADD_VALUE_RULE_ID, ENUM_LABEL_VISIBLE_OBSERVATION, ENUM_TYPE_EXISTS_OBSERVATION, type EnumAddValueMatch, type EnumAddValueRuleOptions, type ExplainFormat, type ExplainOptions, type ExplainPlan, type ExpressionHandler, type FetchDirection, type FetchOptions, FkColumnDerivation, type GeneratedIdentityObservation, type GeneratedMutationClassification, type GeneratedPostconditionObservation, type GeneratedPostconditionReadBack, GeneratedPostconditionSession, type GeneratedStructuralObservation, type IdentityAdoptionAsserter, type IncludeHandler, type IncludeResult, type InsertConfig, InvalidIdentifierError, type JoinDecision, LOGICAL_IDENTITY_ADOPTION_RULE_ID, LOGICAL_IDENTITY_CARRIER_OBSERVATION, type LeafCompileFn, type LogicalIdentityAdoptionMatch, type LogicalIdentityAdoptionRuleOptions, MANUAL_SQL_OPERATION_KIND, type ManualSqlPayload, NO_NULLS_GUARD, NamingPlugin, PG_INTROSPECTION_ARTIFACT, PG_OPERATION_PACK_ARTIFACT, PG_RULE_PACK_ARTIFACT, type ParamRefValidationResult, type PgAdoptionPreflightResult, type PgAdoptionResult, PgConvergeCheckResult, PgConvergeResult, PgDatabaseReadOnlyError, type PgDatabaseWritability, type PgDeclaredAdoptionInput, PgExecutionContractDerivationError, type PgLedgerAddressChain, PgLedgerScopeCurrency, PgLockedRun, PgOutcomeCheckpointObserver, type PgPersistedDeclaredAdoptionInput, type PgPersistedReaddressInput, PgPhysicalModel, type PgReaddressPairRecoveryResult, type PgReconcileFailureStage, type PgReconcileRecoveryFailureCause, type PgReconcileRecoveryOutcome, type PgReconcileRecoveryReport, type PgReconcileSelectedIssue, PgReconcileTransitionRunError, type PgReconcileTransitionRunResult, type PgReleaseResult, type PgRemovalEffectAddress, type PgRemovalEffectsClosure, type PgTransitionClientLease, type PgTransitionPackOptions, PlanCompiler, type PlanDecision, type PrecompiledJoinDecision, type RedactionConfig, type RedactionPattern, SET_NOT_NULL_RULE_ID, type SetNotNullMatch, type SetOperationResult, type SimplifiedPlanReport, type StreamConfig, type UpdateConfig, type UpsertConfig, type WhereDispatcher, type WhereHandler, acquirePgTransitionClient, assertCreateUniqueIndexConcurrentlyRecoveryNotInvalid, assertPgDatabaseWritable, bm25Search, booleanSearch, boost, buildCloseCursor, buildDeclareCursor, buildExplain, buildExplainAnalyzeJson, buildExplainPlan, buildExplainVerbose, buildFetch, buildFetchAll, buildFetchFirst, buildFetchForward, buildFetchNext, buildOnConflictClause, buildStreamingStatements, classifyGeneratedMutation, classifyPgDatabaseWritability, classifyPgReaddressRecovery, classifyPgReaddressSupport, classifyPgWrite, classifyRemovalEffectsClosure, collectAndValidateParamRefs, compileDelete, compileInsert, compileMutation, compilePlan, compileSetOperation, compileUpdate, compileUpsert, conditionalUpdate, containmentAuthorityOutcome, convergePg, cosineDistance, createAlterColumnSetNotNullOperationRuntime, createAlterTypeAddValueOperationRuntime, createAnyExpr, createAttachLogicalIdentityOperationRuntime, createEnumAddValueRule, createEqualityExpr, createLeafCompileFn, createLogicalIdentityAdoptionRule, createManualSqlOperationRuntime, createParamRef, createPgExecutionContract, createPgObservationIssuer, createPgTransitionLessor, createPgTransitionPack, createSetNotNullRule, createTypeCastParamRef, dbTypesEqual, derivePostgresqlCapabilitiesForVersion, evaluatePgExecutionContract, excludedRef, executePgDeclaredAdoption, executePgObservationFromLessor, executePgPersistedTableReaddress, executionIdsForRun, findPgLedgerTerminalMember, generateCursorName, generateSeries, getRowEstimates, getTotalExecutionTime, innerProduct, isBatchValuesJoinDecision, isGeneratedMutationDestructive, isJoinDecision, isPgDatabaseReadOnlyError, isPrecompiledJoinDecision, isReservedKeyword, l2Distance, mapColumnType, mapOnDeleteAction, nextval, normalizeManualSqlPayload, parse, parseExplainJson, pgTargetIdentityMismatch, preflightPgDeclaredAdoption, preparePgExecutionSession, preparePgRecoveryAdmission, rawDistance, readGeneratedPostcondition, readGeneratedPostconditionReadBack, readPgExecutionTargetFromClient, readPgLedgerAddressChain, readPgLedgerControllerOid, readPgObservationContextFromClient, readPgObservationContextFromLessor, readPgRemovalEffectsClosure, readTransitionJournal, reconcilePgTransitionRun, recoverPgReaddressPair, redactParams, refusesRecordedPlanRemoval, releasePgManagedAddress, renderAlterColumnSetNotNullSql, renderAlterTypeAddValueSql, renderAttachLogicalIdentityLockSql, renderCreateLogicalIdentityIndexesSql, renderCreateLogicalIdentitySideTableSql, renderInsertLogicalIdentitySql, renderNoNullsCheckSql, renderPgTableReaddressStatements, renderSetNotNullLockSql, reservationsForRemovalClosure, resolveLogicalName, sanitizeForDisplay, score, validateIdentifier, validateIdentifiers, validateParamRef, validatePgManagedLedgerCurrency, validateQualifiedIdentifier, validateSqlExpression, vectorDims, withPgTransitionRunLock };
|