@crvouga/postgres-mem 0.1.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/AGENTS.md +159 -0
- package/COMPATIBILITY-AUDIT.md +155 -0
- package/COMPATIBILITY.md +87 -0
- package/LICENSE +21 -0
- package/README.md +325 -0
- package/compat/coverage.json +1081 -0
- package/compat/divergences.json +191 -0
- package/compat/gate-report.json +80 -0
- package/compat/requirements.json +1105 -0
- package/compat/requirements.raw.html +484 -0
- package/compat/scenario-types.ts +98 -0
- package/compat/scenarios.ts +98 -0
- package/compat/sections/agg.ts +45 -0
- package/compat/sections/api.ts +28 -0
- package/compat/sections/arr.ts +45 -0
- package/compat/sections/cat.ts +47 -0
- package/compat/sections/con.ts +32 -0
- package/compat/sections/cpy.ts +24 -0
- package/compat/sections/cte.ts +29 -0
- package/compat/sections/dat.ts +60 -0
- package/compat/sections/ddl.ts +55 -0
- package/compat/sections/det.ts +20 -0
- package/compat/sections/dml.ts +37 -0
- package/compat/sections/eco.ts +16 -0
- package/compat/sections/err.ts +16 -0
- package/compat/sections/exp.ts +53 -0
- package/compat/sections/fun.ts +58 -0
- package/compat/sections/fzz.ts +36 -0
- package/compat/sections/guc.ts +27 -0
- package/compat/sections/joi.ts +33 -0
- package/compat/sections/jsn.ts +46 -0
- package/compat/sections/lim.ts +13 -0
- package/compat/sections/par.ts +61 -0
- package/compat/sections/pre.ts +26 -0
- package/compat/sections/sch.ts +31 -0
- package/compat/sections/sel.ts +43 -0
- package/compat/sections/seq.ts +31 -0
- package/compat/sections/snp.ts +21 -0
- package/compat/sections/tok.ts +53 -0
- package/compat/sections/trg.ts +57 -0
- package/compat/sections/tsr.ts +37 -0
- package/compat/sections/txn.ts +39 -0
- package/compat/sections/typ.ts +55 -0
- package/compat/sections/uni.ts +13 -0
- package/compat/sections/win.ts +43 -0
- package/compat/smoke-baseline.json +3 -0
- package/compat/unsupported-register.json +2526 -0
- package/dist/api/bind.d.ts +10 -0
- package/dist/api/database.d.ts +69 -0
- package/dist/api/statement.d.ts +51 -0
- package/dist/ast/nodes.d.ts +810 -0
- package/dist/constraints/enforce.d.ts +39 -0
- package/dist/errors/error.d.ts +24 -0
- package/dist/executor/ddl.d.ts +23 -0
- package/dist/executor/dml.d.ts +10 -0
- package/dist/executor/execute.d.ts +11 -0
- package/dist/executor/relation.d.ts +60 -0
- package/dist/executor/select.d.ts +41 -0
- package/dist/executor/session.d.ts +21 -0
- package/dist/executor/triggers-exec.d.ts +1 -0
- package/dist/executor/triggers.d.ts +16 -0
- package/dist/executor/window.d.ts +13 -0
- package/dist/expressions/context.d.ts +23 -0
- package/dist/expressions/eval.d.ts +38 -0
- package/dist/expressions/operators.d.ts +8 -0
- package/dist/expressions/pattern.d.ts +20 -0
- package/dist/functions/aggregates.d.ts +17 -0
- package/dist/functions/array-fns.d.ts +2 -0
- package/dist/functions/datetime-fns.d.ts +26 -0
- package/dist/functions/datetime-registry.d.ts +2 -0
- package/dist/functions/json-fns.d.ts +7 -0
- package/dist/functions/math-fns.d.ts +2 -0
- package/dist/functions/misc-fns.d.ts +8 -0
- package/dist/functions/scalar.d.ts +10 -0
- package/dist/functions/srf.d.ts +12 -0
- package/dist/functions/string-fns.d.ts +4 -0
- package/dist/functions/tsearch-fns.d.ts +2 -0
- package/dist/functions/util.d.ts +14 -0
- package/dist/functions/window.d.ts +7 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +19591 -0
- package/dist/index.js.map +7 -0
- package/dist/lexer/tokenize.d.ts +8 -0
- package/dist/parser/index.d.ts +1 -0
- package/dist/parser/parser.d.ts +96 -0
- package/dist/runtime/clock.d.ts +14 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/options.d.ts +25 -0
- package/dist/runtime/prng.d.ts +48 -0
- package/dist/schema/catalog-tables.d.ts +1 -0
- package/dist/schema/catalog.d.ts +12 -0
- package/dist/serialization/codec.d.ts +29 -0
- package/dist/serialization/index.d.ts +1 -0
- package/dist/storage/database-state.d.ts +216 -0
- package/dist/transactions/manager.d.ts +25 -0
- package/dist/tsearch/stem.d.ts +5 -0
- package/dist/tsearch/tsearch.d.ts +59 -0
- package/dist/types/cast.d.ts +26 -0
- package/dist/types/compare.d.ts +18 -0
- package/dist/types/datetime.d.ts +68 -0
- package/dist/types/jsonb.d.ts +45 -0
- package/dist/types/numeric.d.ts +69 -0
- package/dist/types/resolve.d.ts +15 -0
- package/dist/types/timezone.d.ts +9 -0
- package/dist/types/value.d.ts +99 -0
- package/dist/unstable.d.ts +15 -0
- package/dist/unstable.js +19153 -0
- package/dist/unstable.js.map +7 -0
- package/package.json +120 -0
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated-union AST. `type` tags are snake_case; interfaces PascalCase.
|
|
3
|
+
* Identifier parts are stored case-folded (unquoted → lowercase) by the parser.
|
|
4
|
+
*/
|
|
5
|
+
export interface TypeName {
|
|
6
|
+
/** qualified name parts, already case-folded */
|
|
7
|
+
readonly parts: string[];
|
|
8
|
+
/** typmod arguments, e.g. varchar(10) → [10]; numeric(10,2) → [10,2] */
|
|
9
|
+
readonly mods: number[];
|
|
10
|
+
/** number of array bracket pairs (0 = scalar) */
|
|
11
|
+
readonly arrayDims: number;
|
|
12
|
+
readonly setof?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export type Expr = NullLit | StringLit | NumberLit | BoolLit | BitStringLit | ParamRef | ColumnRef | StarExpr | BinaryOp | UnaryOp | CastExpr | CollateExpr | FuncCall | CaseExpr | SubqueryExpr | InExpr | BetweenExpr | IsNullExpr | BoolTest | IsDistinctExpr | RowExpr | ArrayCtor | ArrayQueryCtor | SubscriptExpr | FieldSelect | AtTimeZone | LikeExpr | PositionExpr | SubstringExpr | OverlayExpr | TrimExpr | ExtractExpr | GroupingFunc | DefaultExpr;
|
|
15
|
+
export interface NullLit {
|
|
16
|
+
readonly type: "null_lit";
|
|
17
|
+
}
|
|
18
|
+
export interface StringLit {
|
|
19
|
+
readonly type: "string_lit";
|
|
20
|
+
readonly value: string;
|
|
21
|
+
}
|
|
22
|
+
export interface NumberLit {
|
|
23
|
+
readonly type: "number_lit";
|
|
24
|
+
/** raw literal text (underscores stripped) */
|
|
25
|
+
readonly raw: string;
|
|
26
|
+
}
|
|
27
|
+
export interface BoolLit {
|
|
28
|
+
readonly type: "bool_lit";
|
|
29
|
+
readonly value: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface BitStringLit {
|
|
32
|
+
readonly type: "bitstring_lit";
|
|
33
|
+
/** leading 'b' or 'x' + digits */
|
|
34
|
+
readonly value: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ParamRef {
|
|
37
|
+
readonly type: "param";
|
|
38
|
+
readonly index: number;
|
|
39
|
+
}
|
|
40
|
+
export interface ColumnRef {
|
|
41
|
+
readonly type: "colref";
|
|
42
|
+
/** [col] | [table, col] | [schema, table, col] */
|
|
43
|
+
readonly parts: string[];
|
|
44
|
+
}
|
|
45
|
+
export interface StarExpr {
|
|
46
|
+
readonly type: "star";
|
|
47
|
+
/** qualified prefix for t.* */
|
|
48
|
+
readonly table?: string[];
|
|
49
|
+
}
|
|
50
|
+
export interface BinaryOp {
|
|
51
|
+
readonly type: "binop";
|
|
52
|
+
readonly op: string;
|
|
53
|
+
readonly left: Expr;
|
|
54
|
+
readonly right: Expr;
|
|
55
|
+
}
|
|
56
|
+
export interface UnaryOp {
|
|
57
|
+
readonly type: "unop";
|
|
58
|
+
readonly op: string;
|
|
59
|
+
readonly operand: Expr;
|
|
60
|
+
}
|
|
61
|
+
export interface CastExpr {
|
|
62
|
+
readonly type: "cast";
|
|
63
|
+
readonly expr: Expr;
|
|
64
|
+
readonly target: TypeName;
|
|
65
|
+
}
|
|
66
|
+
export interface CollateExpr {
|
|
67
|
+
readonly type: "collate";
|
|
68
|
+
readonly expr: Expr;
|
|
69
|
+
readonly collation: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface OrderByItem {
|
|
72
|
+
readonly expr: Expr;
|
|
73
|
+
readonly dir: "asc" | "desc" | null;
|
|
74
|
+
readonly nulls: "first" | "last" | null;
|
|
75
|
+
readonly using?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface WindowSpec {
|
|
78
|
+
readonly name?: string;
|
|
79
|
+
readonly partitionBy: Expr[];
|
|
80
|
+
readonly orderBy: OrderByItem[];
|
|
81
|
+
readonly frame: FrameSpec | null;
|
|
82
|
+
}
|
|
83
|
+
export interface FrameSpec {
|
|
84
|
+
readonly mode: "range" | "rows" | "groups";
|
|
85
|
+
readonly start: FrameBound;
|
|
86
|
+
readonly end: FrameBound | null;
|
|
87
|
+
readonly exclusion: "current_row" | "group" | "ties" | "no_others" | null;
|
|
88
|
+
}
|
|
89
|
+
export interface FrameBound {
|
|
90
|
+
readonly kind: "unbounded_preceding" | "preceding" | "current_row" | "following" | "unbounded_following";
|
|
91
|
+
readonly offset?: Expr;
|
|
92
|
+
}
|
|
93
|
+
export interface FuncCall {
|
|
94
|
+
readonly type: "func";
|
|
95
|
+
readonly name: string[];
|
|
96
|
+
readonly args: Expr[];
|
|
97
|
+
readonly star?: boolean;
|
|
98
|
+
readonly distinct?: boolean;
|
|
99
|
+
readonly orderBy?: OrderByItem[];
|
|
100
|
+
readonly filter?: Expr;
|
|
101
|
+
readonly withinGroupOrderBy?: OrderByItem[];
|
|
102
|
+
readonly over?: WindowSpec | null;
|
|
103
|
+
readonly variadic?: boolean;
|
|
104
|
+
/** parallel to args; non-null entries are named-notation argument names (f(a => 1)) */
|
|
105
|
+
readonly argNames?: (string | null)[];
|
|
106
|
+
}
|
|
107
|
+
export interface CaseExpr {
|
|
108
|
+
readonly type: "case";
|
|
109
|
+
readonly operand: Expr | null;
|
|
110
|
+
readonly whens: ReadonlyArray<{
|
|
111
|
+
when: Expr;
|
|
112
|
+
then: Expr;
|
|
113
|
+
}>;
|
|
114
|
+
readonly elseExpr: Expr | null;
|
|
115
|
+
}
|
|
116
|
+
export interface SubqueryExpr {
|
|
117
|
+
readonly type: "subquery_expr";
|
|
118
|
+
readonly kind: "scalar" | "exists" | "any" | "all";
|
|
119
|
+
/** comparison operator for ANY/ALL */
|
|
120
|
+
readonly op?: string;
|
|
121
|
+
readonly left?: Expr;
|
|
122
|
+
readonly query: SelectStmt;
|
|
123
|
+
readonly not?: boolean;
|
|
124
|
+
}
|
|
125
|
+
export interface InExpr {
|
|
126
|
+
readonly type: "in_expr";
|
|
127
|
+
readonly left: Expr;
|
|
128
|
+
readonly not: boolean;
|
|
129
|
+
readonly list?: Expr[];
|
|
130
|
+
readonly query?: SelectStmt;
|
|
131
|
+
}
|
|
132
|
+
export interface BetweenExpr {
|
|
133
|
+
readonly type: "between";
|
|
134
|
+
readonly left: Expr;
|
|
135
|
+
readonly low: Expr;
|
|
136
|
+
readonly high: Expr;
|
|
137
|
+
readonly not: boolean;
|
|
138
|
+
readonly symmetric: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface IsNullExpr {
|
|
141
|
+
readonly type: "is_null";
|
|
142
|
+
readonly expr: Expr;
|
|
143
|
+
readonly not: boolean;
|
|
144
|
+
}
|
|
145
|
+
export interface BoolTest {
|
|
146
|
+
readonly type: "bool_test";
|
|
147
|
+
readonly expr: Expr;
|
|
148
|
+
readonly test: "true" | "false" | "unknown";
|
|
149
|
+
readonly not: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface IsDistinctExpr {
|
|
152
|
+
readonly type: "is_distinct";
|
|
153
|
+
readonly left: Expr;
|
|
154
|
+
readonly right: Expr;
|
|
155
|
+
readonly not: boolean;
|
|
156
|
+
}
|
|
157
|
+
export interface RowExpr {
|
|
158
|
+
readonly type: "row";
|
|
159
|
+
readonly items: Expr[];
|
|
160
|
+
readonly explicit: boolean;
|
|
161
|
+
}
|
|
162
|
+
export interface ArrayCtor {
|
|
163
|
+
readonly type: "array_ctor";
|
|
164
|
+
readonly items: Expr[];
|
|
165
|
+
}
|
|
166
|
+
export interface ArrayQueryCtor {
|
|
167
|
+
readonly type: "array_query";
|
|
168
|
+
readonly query: SelectStmt;
|
|
169
|
+
}
|
|
170
|
+
export interface SubscriptExpr {
|
|
171
|
+
readonly type: "subscript";
|
|
172
|
+
readonly base: Expr;
|
|
173
|
+
readonly indexes: ReadonlyArray<{
|
|
174
|
+
lower: Expr | null;
|
|
175
|
+
upper: Expr | null;
|
|
176
|
+
slice: boolean;
|
|
177
|
+
}>;
|
|
178
|
+
}
|
|
179
|
+
export interface FieldSelect {
|
|
180
|
+
readonly type: "field_select";
|
|
181
|
+
readonly base: Expr;
|
|
182
|
+
readonly field: string | "*";
|
|
183
|
+
}
|
|
184
|
+
export interface AtTimeZone {
|
|
185
|
+
readonly type: "at_time_zone";
|
|
186
|
+
readonly expr: Expr;
|
|
187
|
+
readonly zone: Expr;
|
|
188
|
+
}
|
|
189
|
+
export interface LikeExpr {
|
|
190
|
+
readonly type: "like";
|
|
191
|
+
readonly kind: "like" | "ilike" | "similar";
|
|
192
|
+
readonly left: Expr;
|
|
193
|
+
readonly pattern: Expr;
|
|
194
|
+
readonly escape: Expr | null;
|
|
195
|
+
readonly not: boolean;
|
|
196
|
+
}
|
|
197
|
+
export interface PositionExpr {
|
|
198
|
+
readonly type: "position";
|
|
199
|
+
readonly needle: Expr;
|
|
200
|
+
readonly haystack: Expr;
|
|
201
|
+
}
|
|
202
|
+
export interface SubstringExpr {
|
|
203
|
+
readonly type: "substring_sql";
|
|
204
|
+
readonly source: Expr;
|
|
205
|
+
readonly from: Expr | null;
|
|
206
|
+
readonly forLen: Expr | null;
|
|
207
|
+
readonly similar: Expr | null;
|
|
208
|
+
readonly escape: Expr | null;
|
|
209
|
+
}
|
|
210
|
+
export interface OverlayExpr {
|
|
211
|
+
readonly type: "overlay";
|
|
212
|
+
readonly source: Expr;
|
|
213
|
+
readonly placing: Expr;
|
|
214
|
+
readonly from: Expr;
|
|
215
|
+
readonly forLen: Expr | null;
|
|
216
|
+
}
|
|
217
|
+
export interface TrimExpr {
|
|
218
|
+
readonly type: "trim";
|
|
219
|
+
readonly side: "both" | "leading" | "trailing";
|
|
220
|
+
readonly chars: Expr | null;
|
|
221
|
+
readonly source: Expr;
|
|
222
|
+
}
|
|
223
|
+
export interface ExtractExpr {
|
|
224
|
+
readonly type: "extract";
|
|
225
|
+
readonly field: string;
|
|
226
|
+
readonly source: Expr;
|
|
227
|
+
}
|
|
228
|
+
export interface GroupingFunc {
|
|
229
|
+
readonly type: "grouping_func";
|
|
230
|
+
readonly args: Expr[];
|
|
231
|
+
}
|
|
232
|
+
export interface DefaultExpr {
|
|
233
|
+
readonly type: "default_expr";
|
|
234
|
+
}
|
|
235
|
+
export interface WithClause {
|
|
236
|
+
readonly recursive: boolean;
|
|
237
|
+
readonly ctes: CommonTableExpr[];
|
|
238
|
+
}
|
|
239
|
+
export interface CommonTableExpr {
|
|
240
|
+
readonly name: string;
|
|
241
|
+
readonly columns: string[] | null;
|
|
242
|
+
readonly query: Statement;
|
|
243
|
+
readonly materialized: boolean | null;
|
|
244
|
+
}
|
|
245
|
+
export type SelectBody = SelectCore | SetOp | ValuesBody;
|
|
246
|
+
export interface SetOp {
|
|
247
|
+
readonly type: "setop";
|
|
248
|
+
readonly op: "union" | "intersect" | "except";
|
|
249
|
+
readonly all: boolean;
|
|
250
|
+
readonly left: SelectBody;
|
|
251
|
+
readonly right: SelectBody;
|
|
252
|
+
}
|
|
253
|
+
export interface ValuesBody {
|
|
254
|
+
readonly type: "values";
|
|
255
|
+
readonly rows: Expr[][];
|
|
256
|
+
}
|
|
257
|
+
export interface SelectTarget {
|
|
258
|
+
readonly expr: Expr;
|
|
259
|
+
readonly alias: string | null;
|
|
260
|
+
}
|
|
261
|
+
export type GroupItem = {
|
|
262
|
+
kind: "expr";
|
|
263
|
+
expr: Expr;
|
|
264
|
+
} | {
|
|
265
|
+
kind: "rollup" | "cube";
|
|
266
|
+
items: Expr[][];
|
|
267
|
+
} | {
|
|
268
|
+
kind: "grouping_sets";
|
|
269
|
+
sets: GroupItem[][];
|
|
270
|
+
} | {
|
|
271
|
+
kind: "empty";
|
|
272
|
+
};
|
|
273
|
+
export interface SelectCore {
|
|
274
|
+
readonly type: "select_core";
|
|
275
|
+
readonly distinct: {
|
|
276
|
+
on: Expr[] | null;
|
|
277
|
+
} | null;
|
|
278
|
+
readonly targets: SelectTarget[];
|
|
279
|
+
readonly from: FromItem[];
|
|
280
|
+
readonly where: Expr | null;
|
|
281
|
+
readonly groupBy: GroupItem[] | null;
|
|
282
|
+
readonly groupDistinct: boolean;
|
|
283
|
+
readonly having: Expr | null;
|
|
284
|
+
readonly windows: ReadonlyArray<{
|
|
285
|
+
name: string;
|
|
286
|
+
spec: WindowSpec;
|
|
287
|
+
}>;
|
|
288
|
+
}
|
|
289
|
+
export type FromItem = FromTable | FromSubquery | FromFunc | FromJoin;
|
|
290
|
+
export interface FromTable {
|
|
291
|
+
readonly type: "from_table";
|
|
292
|
+
readonly name: string[];
|
|
293
|
+
readonly only: boolean;
|
|
294
|
+
readonly alias: string | null;
|
|
295
|
+
readonly colAliases: string[] | null;
|
|
296
|
+
}
|
|
297
|
+
export interface FromSubquery {
|
|
298
|
+
readonly type: "from_subquery";
|
|
299
|
+
readonly query: SelectStmt;
|
|
300
|
+
readonly lateral: boolean;
|
|
301
|
+
readonly alias: string | null;
|
|
302
|
+
readonly colAliases: string[] | null;
|
|
303
|
+
}
|
|
304
|
+
export interface FromFunc {
|
|
305
|
+
readonly type: "from_func";
|
|
306
|
+
readonly call: Expr;
|
|
307
|
+
readonly lateral: boolean;
|
|
308
|
+
readonly withOrdinality: boolean;
|
|
309
|
+
readonly alias: string | null;
|
|
310
|
+
readonly colAliases: string[] | null;
|
|
311
|
+
/** ROWS FROM (f1(), f2()) */
|
|
312
|
+
readonly rowsFrom: Expr[] | null;
|
|
313
|
+
}
|
|
314
|
+
export interface FromJoin {
|
|
315
|
+
readonly type: "from_join";
|
|
316
|
+
readonly kind: "inner" | "left" | "right" | "full" | "cross";
|
|
317
|
+
readonly left: FromItem;
|
|
318
|
+
readonly right: FromItem;
|
|
319
|
+
readonly on: Expr | null;
|
|
320
|
+
readonly using: string[] | null;
|
|
321
|
+
readonly usingAlias: string | null;
|
|
322
|
+
readonly natural: boolean;
|
|
323
|
+
}
|
|
324
|
+
export interface SelectStmt {
|
|
325
|
+
readonly type: "select";
|
|
326
|
+
readonly with: WithClause | null;
|
|
327
|
+
readonly body: SelectBody;
|
|
328
|
+
readonly orderBy: OrderByItem[];
|
|
329
|
+
readonly limit: Expr | null;
|
|
330
|
+
/** FETCH FIRST n ROWS WITH TIES */
|
|
331
|
+
readonly limitWithTies: boolean;
|
|
332
|
+
readonly offset: Expr | null;
|
|
333
|
+
readonly lockingClause: string | null;
|
|
334
|
+
}
|
|
335
|
+
export interface InsertStmt {
|
|
336
|
+
readonly type: "insert";
|
|
337
|
+
readonly with: WithClause | null;
|
|
338
|
+
readonly table: string[];
|
|
339
|
+
readonly alias: string | null;
|
|
340
|
+
readonly columns: string[] | null;
|
|
341
|
+
readonly overriding: "system" | "user" | null;
|
|
342
|
+
readonly source: SelectStmt | "default_values";
|
|
343
|
+
readonly onConflict: OnConflictClause | null;
|
|
344
|
+
readonly returning: SelectTarget[] | null;
|
|
345
|
+
}
|
|
346
|
+
export interface OnConflictClause {
|
|
347
|
+
readonly target: {
|
|
348
|
+
columns: Expr[];
|
|
349
|
+
where: Expr | null;
|
|
350
|
+
} | {
|
|
351
|
+
constraint: string;
|
|
352
|
+
} | null;
|
|
353
|
+
readonly action: "nothing" | {
|
|
354
|
+
sets: UpdateSet[];
|
|
355
|
+
where: Expr | null;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
export interface UpdateSet {
|
|
359
|
+
readonly columns: ReadonlyArray<{
|
|
360
|
+
name: string;
|
|
361
|
+
subscripts: SubscriptExpr["indexes"] | null;
|
|
362
|
+
fields: string[];
|
|
363
|
+
}>;
|
|
364
|
+
readonly value: Expr | {
|
|
365
|
+
kind: "row_subquery";
|
|
366
|
+
query: SelectStmt;
|
|
367
|
+
} | {
|
|
368
|
+
kind: "row_values";
|
|
369
|
+
items: Expr[];
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
export interface UpdateStmt {
|
|
373
|
+
readonly type: "update";
|
|
374
|
+
readonly with: WithClause | null;
|
|
375
|
+
readonly table: string[];
|
|
376
|
+
readonly only: boolean;
|
|
377
|
+
readonly alias: string | null;
|
|
378
|
+
readonly sets: UpdateSet[];
|
|
379
|
+
readonly from: FromItem[];
|
|
380
|
+
readonly where: Expr | null;
|
|
381
|
+
readonly whereCurrentOf: string | null;
|
|
382
|
+
readonly returning: SelectTarget[] | null;
|
|
383
|
+
}
|
|
384
|
+
export interface DeleteStmt {
|
|
385
|
+
readonly type: "delete";
|
|
386
|
+
readonly with: WithClause | null;
|
|
387
|
+
readonly table: string[];
|
|
388
|
+
readonly only: boolean;
|
|
389
|
+
readonly alias: string | null;
|
|
390
|
+
readonly using: FromItem[];
|
|
391
|
+
readonly where: Expr | null;
|
|
392
|
+
readonly returning: SelectTarget[] | null;
|
|
393
|
+
}
|
|
394
|
+
export type ColumnConstraint = {
|
|
395
|
+
kind: "not_null";
|
|
396
|
+
name: string | null;
|
|
397
|
+
} | {
|
|
398
|
+
kind: "null";
|
|
399
|
+
name: string | null;
|
|
400
|
+
} | {
|
|
401
|
+
kind: "default";
|
|
402
|
+
expr: Expr;
|
|
403
|
+
name: string | null;
|
|
404
|
+
} | {
|
|
405
|
+
kind: "primary_key";
|
|
406
|
+
name: string | null;
|
|
407
|
+
} | {
|
|
408
|
+
kind: "unique";
|
|
409
|
+
name: string | null;
|
|
410
|
+
nullsNotDistinct: boolean;
|
|
411
|
+
} | {
|
|
412
|
+
kind: "check";
|
|
413
|
+
expr: Expr;
|
|
414
|
+
name: string | null;
|
|
415
|
+
noInherit: boolean;
|
|
416
|
+
} | {
|
|
417
|
+
kind: "references";
|
|
418
|
+
name: string | null;
|
|
419
|
+
table: string[];
|
|
420
|
+
columns: string[] | null;
|
|
421
|
+
onDelete: RefAction;
|
|
422
|
+
onUpdate: RefAction;
|
|
423
|
+
match: "full" | "partial" | "simple" | null;
|
|
424
|
+
} | {
|
|
425
|
+
kind: "generated_identity";
|
|
426
|
+
always: boolean;
|
|
427
|
+
name: string | null;
|
|
428
|
+
options: SequenceOptions;
|
|
429
|
+
} | {
|
|
430
|
+
kind: "generated_stored";
|
|
431
|
+
expr: Expr;
|
|
432
|
+
name: string | null;
|
|
433
|
+
} | {
|
|
434
|
+
kind: "collate";
|
|
435
|
+
collation: string[];
|
|
436
|
+
};
|
|
437
|
+
export type RefAction = "no_action" | "restrict" | "cascade" | "set_null" | "set_default" | null;
|
|
438
|
+
export interface ColumnDef {
|
|
439
|
+
readonly name: string;
|
|
440
|
+
readonly typeName: TypeName;
|
|
441
|
+
readonly constraints: ColumnConstraint[];
|
|
442
|
+
}
|
|
443
|
+
export type TableConstraint = {
|
|
444
|
+
kind: "primary_key";
|
|
445
|
+
name: string | null;
|
|
446
|
+
columns: string[];
|
|
447
|
+
} | {
|
|
448
|
+
kind: "unique";
|
|
449
|
+
name: string | null;
|
|
450
|
+
columns: string[];
|
|
451
|
+
nullsNotDistinct: boolean;
|
|
452
|
+
} | {
|
|
453
|
+
kind: "check";
|
|
454
|
+
name: string | null;
|
|
455
|
+
expr: Expr;
|
|
456
|
+
noInherit: boolean;
|
|
457
|
+
} | {
|
|
458
|
+
kind: "foreign_key";
|
|
459
|
+
name: string | null;
|
|
460
|
+
columns: string[];
|
|
461
|
+
refTable: string[];
|
|
462
|
+
refColumns: string[] | null;
|
|
463
|
+
onDelete: RefAction;
|
|
464
|
+
onUpdate: RefAction;
|
|
465
|
+
match: "full" | "partial" | "simple" | null;
|
|
466
|
+
} | {
|
|
467
|
+
kind: "exclude";
|
|
468
|
+
name: string | null;
|
|
469
|
+
};
|
|
470
|
+
export interface CreateTableStmt {
|
|
471
|
+
readonly type: "create_table";
|
|
472
|
+
readonly name: string[];
|
|
473
|
+
readonly ifNotExists: boolean;
|
|
474
|
+
readonly temp: boolean;
|
|
475
|
+
readonly unlogged: boolean;
|
|
476
|
+
readonly columns: ColumnDef[];
|
|
477
|
+
readonly constraints: TableConstraint[];
|
|
478
|
+
readonly likeClauses: ReadonlyArray<{
|
|
479
|
+
table: string[];
|
|
480
|
+
options: string[];
|
|
481
|
+
}>;
|
|
482
|
+
}
|
|
483
|
+
export interface CreateTableAsStmt {
|
|
484
|
+
readonly type: "create_table_as";
|
|
485
|
+
readonly name: string[];
|
|
486
|
+
readonly ifNotExists: boolean;
|
|
487
|
+
readonly temp: boolean;
|
|
488
|
+
readonly columns: string[] | null;
|
|
489
|
+
readonly query: SelectStmt;
|
|
490
|
+
readonly withData: boolean;
|
|
491
|
+
readonly materialized: boolean;
|
|
492
|
+
}
|
|
493
|
+
export interface CreateIndexStmt {
|
|
494
|
+
readonly type: "create_index";
|
|
495
|
+
readonly unique: boolean;
|
|
496
|
+
readonly name: string | null;
|
|
497
|
+
readonly ifNotExists: boolean;
|
|
498
|
+
readonly table: string[];
|
|
499
|
+
readonly using: string | null;
|
|
500
|
+
readonly columns: ReadonlyArray<{
|
|
501
|
+
expr: Expr;
|
|
502
|
+
dir: "asc" | "desc" | null;
|
|
503
|
+
nulls: "first" | "last" | null;
|
|
504
|
+
opclass: string | null;
|
|
505
|
+
}>;
|
|
506
|
+
readonly include: string[];
|
|
507
|
+
readonly where: Expr | null;
|
|
508
|
+
readonly nullsNotDistinct: boolean;
|
|
509
|
+
readonly concurrently: boolean;
|
|
510
|
+
}
|
|
511
|
+
export interface CreateViewStmt {
|
|
512
|
+
readonly type: "create_view";
|
|
513
|
+
readonly name: string[];
|
|
514
|
+
readonly orReplace: boolean;
|
|
515
|
+
readonly temp: boolean;
|
|
516
|
+
readonly columns: string[] | null;
|
|
517
|
+
readonly query: SelectStmt;
|
|
518
|
+
readonly materialized: boolean;
|
|
519
|
+
readonly withData: boolean;
|
|
520
|
+
}
|
|
521
|
+
export interface SequenceOptions {
|
|
522
|
+
increment?: bigint;
|
|
523
|
+
minValue?: bigint | "no";
|
|
524
|
+
maxValue?: bigint | "no";
|
|
525
|
+
start?: bigint;
|
|
526
|
+
cache?: bigint;
|
|
527
|
+
cycle?: boolean;
|
|
528
|
+
ownedBy?: string[] | "none";
|
|
529
|
+
as?: TypeName;
|
|
530
|
+
restart?: bigint | "default";
|
|
531
|
+
}
|
|
532
|
+
export interface CreateSequenceStmt {
|
|
533
|
+
readonly type: "create_sequence";
|
|
534
|
+
readonly name: string[];
|
|
535
|
+
readonly ifNotExists: boolean;
|
|
536
|
+
readonly temp: boolean;
|
|
537
|
+
readonly options: SequenceOptions;
|
|
538
|
+
}
|
|
539
|
+
export interface AlterSequenceStmt {
|
|
540
|
+
readonly type: "alter_sequence";
|
|
541
|
+
readonly name: string[];
|
|
542
|
+
readonly ifExists: boolean;
|
|
543
|
+
readonly options: SequenceOptions;
|
|
544
|
+
}
|
|
545
|
+
export interface CreateSchemaStmt {
|
|
546
|
+
readonly type: "create_schema";
|
|
547
|
+
readonly name: string;
|
|
548
|
+
readonly ifNotExists: boolean;
|
|
549
|
+
}
|
|
550
|
+
export interface CreateEnumStmt {
|
|
551
|
+
readonly type: "create_enum";
|
|
552
|
+
readonly name: string[];
|
|
553
|
+
readonly labels: string[];
|
|
554
|
+
}
|
|
555
|
+
export interface AlterEnumStmt {
|
|
556
|
+
readonly type: "alter_enum";
|
|
557
|
+
readonly name: string[];
|
|
558
|
+
readonly action: {
|
|
559
|
+
kind: "add_value";
|
|
560
|
+
label: string;
|
|
561
|
+
ifNotExists: boolean;
|
|
562
|
+
before: string | null;
|
|
563
|
+
after: string | null;
|
|
564
|
+
} | {
|
|
565
|
+
kind: "rename_value";
|
|
566
|
+
from: string;
|
|
567
|
+
to: string;
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
export interface CreateDomainStmt {
|
|
571
|
+
readonly type: "create_domain";
|
|
572
|
+
readonly name: string[];
|
|
573
|
+
readonly baseType: TypeName;
|
|
574
|
+
readonly notNull: boolean;
|
|
575
|
+
readonly defaultExpr: Expr | null;
|
|
576
|
+
readonly checks: ReadonlyArray<{
|
|
577
|
+
name: string | null;
|
|
578
|
+
expr: Expr;
|
|
579
|
+
}>;
|
|
580
|
+
readonly collate: string[] | null;
|
|
581
|
+
}
|
|
582
|
+
export interface CreateFunctionStmt {
|
|
583
|
+
readonly type: "create_function";
|
|
584
|
+
readonly orReplace: boolean;
|
|
585
|
+
readonly name: string[];
|
|
586
|
+
readonly args: ReadonlyArray<{
|
|
587
|
+
name: string | null;
|
|
588
|
+
typeName: TypeName;
|
|
589
|
+
mode: "in" | "out" | "inout" | "variadic";
|
|
590
|
+
defaultExpr: Expr | null;
|
|
591
|
+
}>;
|
|
592
|
+
readonly returns: TypeName | null;
|
|
593
|
+
readonly returnsTable: ReadonlyArray<{
|
|
594
|
+
name: string;
|
|
595
|
+
typeName: TypeName;
|
|
596
|
+
}> | null;
|
|
597
|
+
readonly language: string;
|
|
598
|
+
readonly body: string | null;
|
|
599
|
+
readonly sqlBody: Statement[] | null;
|
|
600
|
+
readonly volatility: "immutable" | "stable" | "volatile" | null;
|
|
601
|
+
readonly strict: boolean;
|
|
602
|
+
}
|
|
603
|
+
export interface CreateTriggerStmt {
|
|
604
|
+
readonly type: "create_trigger";
|
|
605
|
+
readonly orReplace: boolean;
|
|
606
|
+
readonly name: string;
|
|
607
|
+
readonly timing: "before" | "after" | "instead_of";
|
|
608
|
+
readonly events: ReadonlyArray<{
|
|
609
|
+
event: "insert" | "update" | "delete" | "truncate";
|
|
610
|
+
columns: string[] | null;
|
|
611
|
+
}>;
|
|
612
|
+
readonly table: string[];
|
|
613
|
+
readonly forEachRow: boolean;
|
|
614
|
+
readonly when: Expr | null;
|
|
615
|
+
readonly funcName: string[];
|
|
616
|
+
readonly funcArgs: string[];
|
|
617
|
+
}
|
|
618
|
+
export type AlterTableAction = {
|
|
619
|
+
kind: "add_column";
|
|
620
|
+
column: ColumnDef;
|
|
621
|
+
ifNotExists: boolean;
|
|
622
|
+
} | {
|
|
623
|
+
kind: "drop_column";
|
|
624
|
+
name: string;
|
|
625
|
+
ifExists: boolean;
|
|
626
|
+
cascade: boolean;
|
|
627
|
+
} | {
|
|
628
|
+
kind: "alter_type";
|
|
629
|
+
column: string;
|
|
630
|
+
typeName: TypeName;
|
|
631
|
+
using: Expr | null;
|
|
632
|
+
} | {
|
|
633
|
+
kind: "set_default";
|
|
634
|
+
column: string;
|
|
635
|
+
expr: Expr;
|
|
636
|
+
} | {
|
|
637
|
+
kind: "drop_default";
|
|
638
|
+
column: string;
|
|
639
|
+
} | {
|
|
640
|
+
kind: "set_not_null";
|
|
641
|
+
column: string;
|
|
642
|
+
} | {
|
|
643
|
+
kind: "drop_not_null";
|
|
644
|
+
column: string;
|
|
645
|
+
} | {
|
|
646
|
+
kind: "add_constraint";
|
|
647
|
+
constraint: TableConstraint;
|
|
648
|
+
skipValidation: boolean;
|
|
649
|
+
} | {
|
|
650
|
+
kind: "drop_constraint";
|
|
651
|
+
name: string;
|
|
652
|
+
ifExists: boolean;
|
|
653
|
+
cascade: boolean;
|
|
654
|
+
} | {
|
|
655
|
+
kind: "rename_column";
|
|
656
|
+
from: string;
|
|
657
|
+
to: string;
|
|
658
|
+
} | {
|
|
659
|
+
kind: "rename_constraint";
|
|
660
|
+
from: string;
|
|
661
|
+
to: string;
|
|
662
|
+
} | {
|
|
663
|
+
kind: "rename_table";
|
|
664
|
+
to: string;
|
|
665
|
+
} | {
|
|
666
|
+
kind: "set_schema";
|
|
667
|
+
to: string;
|
|
668
|
+
} | {
|
|
669
|
+
kind: "owner_to";
|
|
670
|
+
role: string;
|
|
671
|
+
} | {
|
|
672
|
+
kind: "add_identity";
|
|
673
|
+
column: string;
|
|
674
|
+
always: boolean;
|
|
675
|
+
options: SequenceOptions;
|
|
676
|
+
} | {
|
|
677
|
+
kind: "drop_identity";
|
|
678
|
+
column: string;
|
|
679
|
+
ifExists: boolean;
|
|
680
|
+
} | {
|
|
681
|
+
kind: "validate_constraint";
|
|
682
|
+
name: string;
|
|
683
|
+
};
|
|
684
|
+
export interface AlterTableStmt {
|
|
685
|
+
readonly type: "alter_table";
|
|
686
|
+
readonly table: string[];
|
|
687
|
+
readonly ifExists: boolean;
|
|
688
|
+
readonly only: boolean;
|
|
689
|
+
readonly actions: AlterTableAction[];
|
|
690
|
+
}
|
|
691
|
+
export interface AlterViewStmt {
|
|
692
|
+
readonly type: "alter_view";
|
|
693
|
+
readonly name: string[];
|
|
694
|
+
readonly ifExists: boolean;
|
|
695
|
+
readonly action: {
|
|
696
|
+
kind: "rename_table";
|
|
697
|
+
to: string;
|
|
698
|
+
} | {
|
|
699
|
+
kind: "set_schema";
|
|
700
|
+
to: string;
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
export interface AlterIndexStmt {
|
|
704
|
+
readonly type: "alter_index";
|
|
705
|
+
readonly name: string[];
|
|
706
|
+
readonly ifExists: boolean;
|
|
707
|
+
readonly action: {
|
|
708
|
+
kind: "rename_table";
|
|
709
|
+
to: string;
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
export interface AlterSchemaStmt {
|
|
713
|
+
readonly type: "alter_schema";
|
|
714
|
+
readonly name: string;
|
|
715
|
+
readonly action: {
|
|
716
|
+
kind: "rename";
|
|
717
|
+
to: string;
|
|
718
|
+
};
|
|
719
|
+
}
|
|
720
|
+
export interface DropStmt {
|
|
721
|
+
readonly type: "drop";
|
|
722
|
+
readonly kind: "table" | "view" | "materialized_view" | "index" | "sequence" | "schema" | "type" | "domain" | "function" | "trigger" | "extension";
|
|
723
|
+
readonly names: string[][];
|
|
724
|
+
/** for DROP TRIGGER name ON table */
|
|
725
|
+
readonly onTable: string[] | null;
|
|
726
|
+
/** for DROP FUNCTION name(argtypes) */
|
|
727
|
+
readonly funcArgs: TypeName[][] | null;
|
|
728
|
+
readonly ifExists: boolean;
|
|
729
|
+
readonly cascade: boolean;
|
|
730
|
+
}
|
|
731
|
+
export interface TruncateStmt {
|
|
732
|
+
readonly type: "truncate";
|
|
733
|
+
readonly tables: string[][];
|
|
734
|
+
readonly restartIdentity: boolean;
|
|
735
|
+
readonly cascade: boolean;
|
|
736
|
+
}
|
|
737
|
+
export interface RefreshMaterializedViewStmt {
|
|
738
|
+
readonly type: "refresh_materialized_view";
|
|
739
|
+
readonly name: string[];
|
|
740
|
+
readonly withData: boolean;
|
|
741
|
+
}
|
|
742
|
+
export interface TransactionStmt {
|
|
743
|
+
readonly type: "transaction";
|
|
744
|
+
readonly action: "begin" | "commit" | "rollback" | "savepoint" | "release" | "rollback_to";
|
|
745
|
+
readonly savepointName?: string;
|
|
746
|
+
/** BEGIN ISOLATION LEVEL ... (accepted, single-session engine) */
|
|
747
|
+
readonly modes?: string[];
|
|
748
|
+
/** COMMIT/ROLLBACK AND CHAIN */
|
|
749
|
+
readonly chain?: boolean;
|
|
750
|
+
}
|
|
751
|
+
export interface SetStmt {
|
|
752
|
+
readonly type: "set";
|
|
753
|
+
readonly name: string;
|
|
754
|
+
readonly value: string | null;
|
|
755
|
+
readonly local: boolean;
|
|
756
|
+
}
|
|
757
|
+
export interface ShowStmt {
|
|
758
|
+
readonly type: "show";
|
|
759
|
+
readonly name: string;
|
|
760
|
+
}
|
|
761
|
+
export interface ResetStmt {
|
|
762
|
+
readonly type: "reset";
|
|
763
|
+
readonly name: string;
|
|
764
|
+
}
|
|
765
|
+
export interface PrepareStmt {
|
|
766
|
+
readonly type: "prepare";
|
|
767
|
+
readonly name: string;
|
|
768
|
+
readonly argTypes: TypeName[] | null;
|
|
769
|
+
readonly query: Statement;
|
|
770
|
+
}
|
|
771
|
+
export interface ExecuteStmt {
|
|
772
|
+
readonly type: "execute";
|
|
773
|
+
readonly name: string;
|
|
774
|
+
readonly params: Expr[];
|
|
775
|
+
}
|
|
776
|
+
export interface DeallocateStmt {
|
|
777
|
+
readonly type: "deallocate";
|
|
778
|
+
readonly name: string | null;
|
|
779
|
+
}
|
|
780
|
+
export interface ExplainStmt {
|
|
781
|
+
readonly type: "explain";
|
|
782
|
+
readonly analyze: boolean;
|
|
783
|
+
readonly verbose: boolean;
|
|
784
|
+
readonly query: Statement;
|
|
785
|
+
}
|
|
786
|
+
export interface CopyStmt {
|
|
787
|
+
readonly type: "copy";
|
|
788
|
+
readonly table: string[] | null;
|
|
789
|
+
readonly columns: string[] | null;
|
|
790
|
+
readonly query: Statement | null;
|
|
791
|
+
readonly direction: "from" | "to";
|
|
792
|
+
readonly target: "stdin" | "stdout";
|
|
793
|
+
readonly options: Record<string, string | boolean>;
|
|
794
|
+
}
|
|
795
|
+
export interface CommentStmt {
|
|
796
|
+
readonly type: "comment";
|
|
797
|
+
readonly objectKind: string;
|
|
798
|
+
readonly objectName: string[];
|
|
799
|
+
readonly comment: string | null;
|
|
800
|
+
}
|
|
801
|
+
export interface NoOpStmt {
|
|
802
|
+
readonly type: "no_op";
|
|
803
|
+
readonly what: string;
|
|
804
|
+
}
|
|
805
|
+
export interface DoStmt {
|
|
806
|
+
readonly type: "do";
|
|
807
|
+
readonly language: string;
|
|
808
|
+
readonly body: string;
|
|
809
|
+
}
|
|
810
|
+
export type Statement = SelectStmt | InsertStmt | UpdateStmt | DeleteStmt | CreateTableStmt | CreateTableAsStmt | CreateIndexStmt | CreateViewStmt | CreateSequenceStmt | AlterSequenceStmt | CreateSchemaStmt | CreateEnumStmt | AlterEnumStmt | CreateDomainStmt | CreateFunctionStmt | CreateTriggerStmt | AlterTableStmt | AlterViewStmt | AlterIndexStmt | AlterSchemaStmt | DropStmt | TruncateStmt | RefreshMaterializedViewStmt | TransactionStmt | SetStmt | ShowStmt | ResetStmt | PrepareStmt | ExecuteStmt | DeallocateStmt | ExplainStmt | CopyStmt | CommentStmt | NoOpStmt | DoStmt;
|