@crvouga/mockingbird-service-postgres 3.5.0 → 3.7.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/CHANGELOG.md +12 -0
- package/COMPATIBILITY.md +34 -0
- package/README.md +5 -0
- package/compat/sections/trg.ts +2 -0
- package/dist/admin.js +1114 -735
- package/dist/admin.js.map +4 -4
- package/dist/api/schema-report.d.ts +32 -0
- package/dist/ast/nodes.d.ts +11 -1
- package/dist/executor/relation.d.ts +1 -0
- package/dist/executor/triggers-scope.d.ts +4 -0
- package/dist/executor/triggers.d.ts +4 -0
- package/dist/expressions/context.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1266 -699
- package/dist/index.js.map +4 -4
- package/dist/server.js +1144 -736
- package/dist/server.js.map +4 -4
- package/dist/storage/database-state.d.ts +20 -0
- package/dist/storage/guc.d.ts +2 -0
- package/dist/storage/indexable-relation.d.ts +3 -0
- package/dist/types/regnamespace.d.ts +5 -0
- package/dist/types/value.d.ts +2 -0
- package/dist/unstable.js +17231 -16852
- package/dist/unstable.js.map +4 -4
- package/dist/wire/cli.js +1330 -749
- package/dist/wire/cli.js.map +4 -4
- package/dist/wire/index.js +1144 -736
- package/dist/wire/index.js.map +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface SchemaReportOptions {
|
|
2
|
+
/** Hard upper bounds are 4 MiB, 10,000 statements and 1,000 diagnostics. */
|
|
3
|
+
maxInputBytes?: number;
|
|
4
|
+
maxStatements?: number;
|
|
5
|
+
maxDiagnostics?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface SchemaDiagnostic {
|
|
8
|
+
statement: number;
|
|
9
|
+
offset: number;
|
|
10
|
+
line: number;
|
|
11
|
+
column: number;
|
|
12
|
+
object?: string;
|
|
13
|
+
sqlstate: string | null;
|
|
14
|
+
category: "unsupported" | "syntax" | "prerequisite" | "execution" | "unknown" | "limit";
|
|
15
|
+
message: string;
|
|
16
|
+
prerequisiteStatement?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface SchemaReport {
|
|
19
|
+
/** Identifies the local implementation; this is not a live PostgreSQL compatibility assertion. */
|
|
20
|
+
engine: "mockingbird-postgres";
|
|
21
|
+
version: string;
|
|
22
|
+
statements: number;
|
|
23
|
+
accepted: number;
|
|
24
|
+
/** false means a detected gap; null means semantics still require oracle verification. */
|
|
25
|
+
compatible: false | null;
|
|
26
|
+
truncated: boolean;
|
|
27
|
+
diagnostics: SchemaDiagnostic[];
|
|
28
|
+
}
|
|
29
|
+
/** Analyze plain schema SQL in a discarded in-memory database, without network or filesystem access.
|
|
30
|
+
* Successful execution is explicitly unverified: function bodies and dynamic SQL are not proved.
|
|
31
|
+
*/
|
|
32
|
+
export declare function analyzeSchema(sql: string, options?: SchemaReportOptions): SchemaReport;
|
package/dist/ast/nodes.d.ts
CHANGED
|
@@ -555,6 +555,7 @@ export interface CreateSequenceStmt {
|
|
|
555
555
|
readonly options: SequenceOptions;
|
|
556
556
|
}
|
|
557
557
|
export interface AlterSequenceStmt {
|
|
558
|
+
readonly renameTo?: string;
|
|
558
559
|
readonly type: "alter_sequence";
|
|
559
560
|
readonly name: string[];
|
|
560
561
|
readonly ifExists: boolean;
|
|
@@ -623,11 +624,15 @@ export interface CreateFunctionStmt {
|
|
|
623
624
|
readonly language: string;
|
|
624
625
|
readonly body: string | null;
|
|
625
626
|
readonly sqlBody: Statement[] | null;
|
|
627
|
+
readonly settings?: Record<string, string>;
|
|
626
628
|
readonly volatility: "immutable" | "stable" | "volatile" | null;
|
|
627
629
|
readonly strict: boolean;
|
|
628
630
|
}
|
|
629
631
|
export interface CreateTriggerStmt {
|
|
630
632
|
readonly type: "create_trigger";
|
|
633
|
+
readonly constraint: boolean;
|
|
634
|
+
readonly deferrable: boolean;
|
|
635
|
+
readonly initiallyDeferred: boolean;
|
|
631
636
|
readonly orReplace: boolean;
|
|
632
637
|
readonly name: string;
|
|
633
638
|
readonly timing: "before" | "after" | "instead_of";
|
|
@@ -787,6 +792,11 @@ export interface TransactionStmt {
|
|
|
787
792
|
/** COMMIT/ROLLBACK AND CHAIN */
|
|
788
793
|
readonly chain?: boolean;
|
|
789
794
|
}
|
|
795
|
+
export interface SetConstraintsStmt {
|
|
796
|
+
readonly type: "set_constraints";
|
|
797
|
+
readonly names: string[][] | null;
|
|
798
|
+
readonly deferred: boolean;
|
|
799
|
+
}
|
|
790
800
|
export interface SetStmt {
|
|
791
801
|
readonly type: "set";
|
|
792
802
|
readonly name: string;
|
|
@@ -861,4 +871,4 @@ export interface DoStmt {
|
|
|
861
871
|
readonly language: string;
|
|
862
872
|
readonly body: string;
|
|
863
873
|
}
|
|
864
|
-
export type Statement = SelectStmt | InsertStmt | UpdateStmt | DeleteStmt | CreateTableStmt | CreateTableAsStmt | CreateIndexStmt | CreateViewStmt | CreateSequenceStmt | AlterSequenceStmt | CreateSchemaStmt | CreateExtensionStmt | CreateEnumStmt | AlterEnumStmt | CreateDomainStmt | CreateFunctionStmt | CreateTriggerStmt | AlterTableStmt | AlterViewStmt | AlterIndexStmt | AlterSchemaStmt | DropStmt | TruncateStmt | RefreshMaterializedViewStmt | TransactionStmt | SetStmt | ShowStmt | ResetStmt | PrepareStmt | ExecuteStmt | DeallocateStmt | ExplainStmt | CopyStmt | CommentStmt | AnalyzeStmt | ReindexStmt | NoOpStmt | DoStmt;
|
|
874
|
+
export type Statement = SelectStmt | InsertStmt | UpdateStmt | DeleteStmt | CreateTableStmt | CreateTableAsStmt | CreateIndexStmt | CreateViewStmt | CreateSequenceStmt | AlterSequenceStmt | CreateSchemaStmt | CreateExtensionStmt | CreateEnumStmt | AlterEnumStmt | CreateDomainStmt | CreateFunctionStmt | CreateTriggerStmt | AlterTableStmt | AlterViewStmt | AlterIndexStmt | AlterSchemaStmt | DropStmt | TruncateStmt | RefreshMaterializedViewStmt | TransactionStmt | SetConstraintsStmt | SetStmt | ShowStmt | ResetStmt | PrepareStmt | ExecuteStmt | DeallocateStmt | ExplainStmt | CopyStmt | CommentStmt | AnalyzeStmt | ReindexStmt | NoOpStmt | DoStmt;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SetConstraintsStmt } from "../ast/nodes.js";
|
|
2
|
+
import type { DatabaseState } from "../storage/database-state.js";
|
|
1
3
|
import type { TableData, TriggerMeta } from "../storage/database-state.js";
|
|
2
4
|
import type { Datum } from "../types/value.js";
|
|
3
5
|
import type { ExecEnv } from "./relation.js";
|
|
@@ -14,3 +16,5 @@ export type TriggerExecutor = (env: ExecEnv, table: TableData, trigger: TriggerM
|
|
|
14
16
|
export declare function setTriggerExecutor(e: TriggerExecutor): void;
|
|
15
17
|
export declare function fireRowTriggers(env: ExecEnv, table: TableData, timing: "before" | "after" | "instead_of", event: TriggerEvent, oldRow: Datum[] | null, newRow: Datum[] | null): TriggerFireResult;
|
|
16
18
|
export declare function hasRowTriggers(table: TableData, timing: "before" | "after" | "instead_of", event: TriggerEvent): boolean;
|
|
19
|
+
export declare function flushConstraintTriggers(state: DatabaseState, all?: boolean): void;
|
|
20
|
+
export declare function setConstraints(state: DatabaseState, stmt: SetConstraintsStmt): void;
|
|
@@ -8,12 +8,16 @@ import { type TypeId } from "../types/value.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class EngineCtx implements CastEnv, CompareCtx {
|
|
10
10
|
readonly state: DatabaseState;
|
|
11
|
+
private writeXid;
|
|
12
|
+
rowVersionXid(): number;
|
|
11
13
|
/** transaction timestamp (now(), current_timestamp) — UTC micros since PG epoch */
|
|
12
14
|
readonly txNow: bigint;
|
|
13
15
|
/** statement timestamp */
|
|
14
16
|
readonly stmtNow: bigint;
|
|
15
17
|
constructor(state: DatabaseState, txNow?: bigint);
|
|
16
18
|
timezone(): string;
|
|
19
|
+
relationOid(parts: string[]): number;
|
|
20
|
+
relationName(oid: number): string | null;
|
|
17
21
|
namespaceOid(name: string): number;
|
|
18
22
|
namespaceName(oid: number): string | null;
|
|
19
23
|
zoneOffsetAt(utcMicros: bigint): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -26,3 +26,4 @@ export type { BindValue, JsValue, QueryRow } from "./api/bind.js";
|
|
|
26
26
|
export { Database, type DatabaseFaults, type DatabaseHistory, type DatabaseOptions, type HistoryCheckpoint, type QueryOptions, type RegisterFunctionOptions, Snapshot, } from "./api/database.js";
|
|
27
27
|
export { type ResultSet, type RunResult, Statement } from "./api/statement.js";
|
|
28
28
|
export { type ErrorCategory, PostgresError } from "./errors/error.js";
|
|
29
|
+
export { analyzeSchema, type SchemaReport, type SchemaReportOptions, type SchemaDiagnostic, } from "./api/schema-report.js";
|