@jaepil/usqldb 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +225 -0
- package/dist/types/cli/command-handler.d.ts +52 -0
- package/dist/types/cli/command-handler.d.ts.map +1 -0
- package/dist/types/cli/completer.d.ts +23 -0
- package/dist/types/cli/completer.d.ts.map +1 -0
- package/dist/types/cli/formatter.d.ts +39 -0
- package/dist/types/cli/formatter.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +4 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/cli/shell-cli.d.ts +5 -0
- package/dist/types/cli/shell-cli.d.ts.map +1 -0
- package/dist/types/cli/shell.d.ts +41 -0
- package/dist/types/cli/shell.d.ts.map +1 -0
- package/dist/types/core/compiler.d.ts +4 -0
- package/dist/types/core/compiler.d.ts.map +1 -0
- package/dist/types/core/engine.d.ts +14 -0
- package/dist/types/core/engine.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/net/pgwire/auth.d.ts +46 -0
- package/dist/types/net/pgwire/auth.d.ts.map +1 -0
- package/dist/types/net/pgwire/config.d.ts +24 -0
- package/dist/types/net/pgwire/config.d.ts.map +1 -0
- package/dist/types/net/pgwire/connection.d.ts +84 -0
- package/dist/types/net/pgwire/connection.d.ts.map +1 -0
- package/dist/types/net/pgwire/constants.d.ts +73 -0
- package/dist/types/net/pgwire/constants.d.ts.map +1 -0
- package/dist/types/net/pgwire/errors.d.ts +210 -0
- package/dist/types/net/pgwire/errors.d.ts.map +1 -0
- package/dist/types/net/pgwire/index.d.ts +5 -0
- package/dist/types/net/pgwire/index.d.ts.map +1 -0
- package/dist/types/net/pgwire/message-codec.d.ts +65 -0
- package/dist/types/net/pgwire/message-codec.d.ts.map +1 -0
- package/dist/types/net/pgwire/messages.d.ts +126 -0
- package/dist/types/net/pgwire/messages.d.ts.map +1 -0
- package/dist/types/net/pgwire/query-executor.d.ts +34 -0
- package/dist/types/net/pgwire/query-executor.d.ts.map +1 -0
- package/dist/types/net/pgwire/read-buffer.d.ts +24 -0
- package/dist/types/net/pgwire/read-buffer.d.ts.map +1 -0
- package/dist/types/net/pgwire/server-cli.d.ts +2 -0
- package/dist/types/net/pgwire/server-cli.d.ts.map +1 -0
- package/dist/types/net/pgwire/server.d.ts +23 -0
- package/dist/types/net/pgwire/server.d.ts.map +1 -0
- package/dist/types/net/pgwire/type-codec.d.ts +9 -0
- package/dist/types/net/pgwire/type-codec.d.ts.map +1 -0
- package/dist/types/net/pgwire/write-buffer.d.ts +34 -0
- package/dist/types/net/pgwire/write-buffer.d.ts.map +1 -0
- package/dist/types/pg-compat/connection-registry.d.ts +19 -0
- package/dist/types/pg-compat/connection-registry.d.ts.map +1 -0
- package/dist/types/pg-compat/information-schema.d.ts +34 -0
- package/dist/types/pg-compat/information-schema.d.ts.map +1 -0
- package/dist/types/pg-compat/oid.d.ts +48 -0
- package/dist/types/pg-compat/oid.d.ts.map +1 -0
- package/dist/types/pg-compat/pg-catalog.d.ts +45 -0
- package/dist/types/pg-compat/pg-catalog.d.ts.map +1 -0
- package/dist/usqldb.es.js +3598 -0
- package/dist/usqldb.es.js.map +1 -0
- package/dist/usqldb.umd.js +2 -0
- package/dist/usqldb.umd.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,3598 @@
|
|
|
1
|
+
var ue = Object.defineProperty;
|
|
2
|
+
var _e = (u, e, l) => e in u ? ue(u, e, { enumerable: !0, configurable: !0, writable: !0, value: l }) : u[e] = l;
|
|
3
|
+
var A = (u, e, l) => _e(u, typeof e != "symbol" ? e + "" : e, l);
|
|
4
|
+
import { Engine as de } from "@jaepil/uqa";
|
|
5
|
+
function me(u) {
|
|
6
|
+
if (u.length === 0) return u;
|
|
7
|
+
const e = [];
|
|
8
|
+
for (const l of u) {
|
|
9
|
+
const o = {};
|
|
10
|
+
for (const [t, n] of Object.entries(l))
|
|
11
|
+
typeof n == "boolean" ? o[t] = n ? 1 : 0 : typeof n == "number" && (Number.isNaN(n) || !Number.isFinite(n)) ? o[t] = null : o[t] = n;
|
|
12
|
+
e.push(o);
|
|
13
|
+
}
|
|
14
|
+
return e;
|
|
15
|
+
}
|
|
16
|
+
const ee = {
|
|
17
|
+
boolean: 16,
|
|
18
|
+
bool: 16,
|
|
19
|
+
bytea: 17,
|
|
20
|
+
name: 19,
|
|
21
|
+
bigint: 20,
|
|
22
|
+
int8: 20,
|
|
23
|
+
smallint: 21,
|
|
24
|
+
int2: 21,
|
|
25
|
+
integer: 23,
|
|
26
|
+
int: 23,
|
|
27
|
+
int4: 23,
|
|
28
|
+
oid: 26,
|
|
29
|
+
text: 25,
|
|
30
|
+
json: 114,
|
|
31
|
+
xml: 142,
|
|
32
|
+
point: 600,
|
|
33
|
+
real: 700,
|
|
34
|
+
float: 700,
|
|
35
|
+
float4: 700,
|
|
36
|
+
"double precision": 701,
|
|
37
|
+
float8: 701,
|
|
38
|
+
character: 1042,
|
|
39
|
+
char: 1042,
|
|
40
|
+
"character varying": 1043,
|
|
41
|
+
varchar: 1043,
|
|
42
|
+
date: 1082,
|
|
43
|
+
time: 1083,
|
|
44
|
+
timestamp: 1114,
|
|
45
|
+
"timestamp without time zone": 1114,
|
|
46
|
+
timestamptz: 1184,
|
|
47
|
+
"timestamp with time zone": 1184,
|
|
48
|
+
interval: 1186,
|
|
49
|
+
numeric: 1700,
|
|
50
|
+
decimal: 1700,
|
|
51
|
+
uuid: 2950,
|
|
52
|
+
jsonb: 3802,
|
|
53
|
+
serial: 23,
|
|
54
|
+
bigserial: 20,
|
|
55
|
+
vector: 16385
|
|
56
|
+
}, Z = {
|
|
57
|
+
16: 1e3,
|
|
58
|
+
// bool[]
|
|
59
|
+
17: 1001,
|
|
60
|
+
// bytea[]
|
|
61
|
+
20: 1016,
|
|
62
|
+
// int8[]
|
|
63
|
+
21: 1005,
|
|
64
|
+
// int2[]
|
|
65
|
+
23: 1007,
|
|
66
|
+
// int4[]
|
|
67
|
+
25: 1009,
|
|
68
|
+
// text[]
|
|
69
|
+
26: 1028,
|
|
70
|
+
// oid[]
|
|
71
|
+
114: 199,
|
|
72
|
+
// json[]
|
|
73
|
+
700: 1021,
|
|
74
|
+
// float4[]
|
|
75
|
+
701: 1022,
|
|
76
|
+
// float8[]
|
|
77
|
+
1042: 1014,
|
|
78
|
+
// bpchar[]
|
|
79
|
+
1043: 1015,
|
|
80
|
+
// varchar[]
|
|
81
|
+
1082: 1182,
|
|
82
|
+
// date[]
|
|
83
|
+
1083: 1183,
|
|
84
|
+
// time[]
|
|
85
|
+
1114: 1115,
|
|
86
|
+
// timestamp[]
|
|
87
|
+
1184: 1185,
|
|
88
|
+
// timestamptz[]
|
|
89
|
+
1700: 1231,
|
|
90
|
+
// numeric[]
|
|
91
|
+
2950: 2951,
|
|
92
|
+
// uuid[]
|
|
93
|
+
3802: 3807
|
|
94
|
+
// jsonb[]
|
|
95
|
+
}, J = {
|
|
96
|
+
pg_catalog: 11,
|
|
97
|
+
public: 2200,
|
|
98
|
+
information_schema: 13182
|
|
99
|
+
}, R = 1, T = 10, z = 403, pe = 405, te = 2, fe = 16386, ge = 16387, ne = {
|
|
100
|
+
int: "integer",
|
|
101
|
+
int2: "smallint",
|
|
102
|
+
int4: "integer",
|
|
103
|
+
int8: "bigint",
|
|
104
|
+
float: "real",
|
|
105
|
+
float4: "real",
|
|
106
|
+
float8: "double precision",
|
|
107
|
+
bool: "boolean",
|
|
108
|
+
serial: "integer",
|
|
109
|
+
bigserial: "bigint",
|
|
110
|
+
decimal: "numeric",
|
|
111
|
+
char: "character",
|
|
112
|
+
"character varying": "character varying",
|
|
113
|
+
varchar: "character varying",
|
|
114
|
+
name: "name",
|
|
115
|
+
"timestamp without time zone": "timestamp without time zone",
|
|
116
|
+
"timestamp with time zone": "timestamp with time zone"
|
|
117
|
+
}, ae = {
|
|
118
|
+
16: 1,
|
|
119
|
+
// bool
|
|
120
|
+
17: -1,
|
|
121
|
+
// bytea
|
|
122
|
+
19: 64,
|
|
123
|
+
// name
|
|
124
|
+
20: 8,
|
|
125
|
+
// int8
|
|
126
|
+
21: 2,
|
|
127
|
+
// int2
|
|
128
|
+
23: 4,
|
|
129
|
+
// int4
|
|
130
|
+
25: -1,
|
|
131
|
+
// text
|
|
132
|
+
26: 4,
|
|
133
|
+
// oid
|
|
134
|
+
114: -1,
|
|
135
|
+
// json
|
|
136
|
+
142: -1,
|
|
137
|
+
// xml
|
|
138
|
+
600: 16,
|
|
139
|
+
// point
|
|
140
|
+
700: 4,
|
|
141
|
+
// float4
|
|
142
|
+
701: 8,
|
|
143
|
+
// float8
|
|
144
|
+
1042: -1,
|
|
145
|
+
// bpchar
|
|
146
|
+
1043: -1,
|
|
147
|
+
// varchar
|
|
148
|
+
1082: 4,
|
|
149
|
+
// date
|
|
150
|
+
1083: 8,
|
|
151
|
+
// time
|
|
152
|
+
1114: 8,
|
|
153
|
+
// timestamp
|
|
154
|
+
1184: 8,
|
|
155
|
+
// timestamptz
|
|
156
|
+
1186: 16,
|
|
157
|
+
// interval
|
|
158
|
+
1700: -1,
|
|
159
|
+
// numeric
|
|
160
|
+
2950: 16,
|
|
161
|
+
// uuid
|
|
162
|
+
3802: -1,
|
|
163
|
+
// jsonb
|
|
164
|
+
16385: -1
|
|
165
|
+
// vector
|
|
166
|
+
}, le = {
|
|
167
|
+
16: !0,
|
|
168
|
+
// bool
|
|
169
|
+
21: !0,
|
|
170
|
+
// int2
|
|
171
|
+
23: !0,
|
|
172
|
+
// int4
|
|
173
|
+
26: !0,
|
|
174
|
+
// oid
|
|
175
|
+
700: !0
|
|
176
|
+
// float4
|
|
177
|
+
}, K = {
|
|
178
|
+
16: "c",
|
|
179
|
+
// char alignment
|
|
180
|
+
17: "i",
|
|
181
|
+
// int alignment
|
|
182
|
+
19: "c",
|
|
183
|
+
// char
|
|
184
|
+
20: "d",
|
|
185
|
+
// double
|
|
186
|
+
21: "s",
|
|
187
|
+
// short
|
|
188
|
+
23: "i",
|
|
189
|
+
// int
|
|
190
|
+
25: "i",
|
|
191
|
+
// int
|
|
192
|
+
26: "i",
|
|
193
|
+
// int
|
|
194
|
+
700: "i",
|
|
195
|
+
// int
|
|
196
|
+
701: "d",
|
|
197
|
+
// double
|
|
198
|
+
1042: "i",
|
|
199
|
+
// int
|
|
200
|
+
1043: "i",
|
|
201
|
+
// int
|
|
202
|
+
1082: "i",
|
|
203
|
+
// int
|
|
204
|
+
1083: "d",
|
|
205
|
+
// double
|
|
206
|
+
1114: "d",
|
|
207
|
+
// double
|
|
208
|
+
1184: "d",
|
|
209
|
+
// double
|
|
210
|
+
1186: "d",
|
|
211
|
+
// double
|
|
212
|
+
1700: "i",
|
|
213
|
+
// int
|
|
214
|
+
2950: "c",
|
|
215
|
+
// char
|
|
216
|
+
3802: "i"
|
|
217
|
+
// int
|
|
218
|
+
}, V = {
|
|
219
|
+
16: "p",
|
|
220
|
+
// plain
|
|
221
|
+
17: "x",
|
|
222
|
+
// extended
|
|
223
|
+
19: "p",
|
|
224
|
+
// plain
|
|
225
|
+
20: "p",
|
|
226
|
+
// plain
|
|
227
|
+
21: "p",
|
|
228
|
+
// plain
|
|
229
|
+
23: "p",
|
|
230
|
+
// plain
|
|
231
|
+
25: "x",
|
|
232
|
+
// extended
|
|
233
|
+
26: "p",
|
|
234
|
+
// plain
|
|
235
|
+
114: "x",
|
|
236
|
+
// extended
|
|
237
|
+
700: "p",
|
|
238
|
+
// plain
|
|
239
|
+
701: "p",
|
|
240
|
+
// plain
|
|
241
|
+
1042: "x",
|
|
242
|
+
// extended
|
|
243
|
+
1043: "x",
|
|
244
|
+
// extended
|
|
245
|
+
1082: "p",
|
|
246
|
+
// plain
|
|
247
|
+
1114: "p",
|
|
248
|
+
// plain
|
|
249
|
+
1184: "p",
|
|
250
|
+
// plain
|
|
251
|
+
1700: "m",
|
|
252
|
+
// main
|
|
253
|
+
2950: "p",
|
|
254
|
+
// plain
|
|
255
|
+
3802: "x"
|
|
256
|
+
// extended
|
|
257
|
+
};
|
|
258
|
+
function I(u) {
|
|
259
|
+
if (u.endsWith("[]")) {
|
|
260
|
+
const e = u.slice(0, -2), l = ee[e] ?? 25;
|
|
261
|
+
return Z[l] ?? 1009;
|
|
262
|
+
}
|
|
263
|
+
return ee[u] ?? 25;
|
|
264
|
+
}
|
|
265
|
+
function Y(u) {
|
|
266
|
+
if (u.endsWith("[]")) {
|
|
267
|
+
const e = u.slice(0, -2);
|
|
268
|
+
return `${ne[e] ?? e}[]`;
|
|
269
|
+
}
|
|
270
|
+
return ne[u] ?? u;
|
|
271
|
+
}
|
|
272
|
+
function L(u) {
|
|
273
|
+
const e = I(u);
|
|
274
|
+
return {
|
|
275
|
+
21: 16,
|
|
276
|
+
// int2
|
|
277
|
+
23: 32,
|
|
278
|
+
// int4
|
|
279
|
+
20: 64,
|
|
280
|
+
// int8
|
|
281
|
+
700: 24,
|
|
282
|
+
// float4
|
|
283
|
+
701: 53
|
|
284
|
+
// float8
|
|
285
|
+
}[e] ?? null;
|
|
286
|
+
}
|
|
287
|
+
function W(u) {
|
|
288
|
+
const e = I(u);
|
|
289
|
+
return e === 21 || e === 23 || e === 20 ? 0 : null;
|
|
290
|
+
}
|
|
291
|
+
function B(u) {
|
|
292
|
+
const e = I(u);
|
|
293
|
+
return e === 21 || e === 23 || e === 20 || e === 1700 ? 10 : e === 700 || e === 701 ? 2 : null;
|
|
294
|
+
}
|
|
295
|
+
function be(u) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
function ye(u) {
|
|
299
|
+
const e = I(u);
|
|
300
|
+
return e === 25 || e === 1042 || e === 1043 ? 1073741824 : null;
|
|
301
|
+
}
|
|
302
|
+
class he {
|
|
303
|
+
constructor(e) {
|
|
304
|
+
A(this, "_map");
|
|
305
|
+
A(this, "_next");
|
|
306
|
+
this._map = /* @__PURE__ */ new Map(), this._next = 16384, this._build(e);
|
|
307
|
+
}
|
|
308
|
+
_alloc() {
|
|
309
|
+
const e = this._next;
|
|
310
|
+
return this._next += 1, e;
|
|
311
|
+
}
|
|
312
|
+
_build(e) {
|
|
313
|
+
for (const t of [...e._tables.keys()].sort())
|
|
314
|
+
this._map.set(`table:${t}`, this._alloc()), this._map.set(`table_type:${t}`, this._alloc()), this._map.set(`toast:${t}`, this._alloc());
|
|
315
|
+
for (const t of [...e._views.keys()].sort())
|
|
316
|
+
this._map.set(`view:${t}`, this._alloc());
|
|
317
|
+
for (const t of [...e._sequences.keys()].sort())
|
|
318
|
+
this._map.set(`sequence:${t}`, this._alloc());
|
|
319
|
+
for (const t of [...e._foreignTables.keys()].sort())
|
|
320
|
+
this._map.set(`foreign_table:${t}`, this._alloc());
|
|
321
|
+
for (const t of [...e._foreignServers.keys()].sort())
|
|
322
|
+
this._map.set(`foreign_server:${t}`, this._alloc());
|
|
323
|
+
const l = /* @__PURE__ */ new Set();
|
|
324
|
+
for (const t of e._foreignServers.values())
|
|
325
|
+
l.add(t.fdwType);
|
|
326
|
+
for (const t of [...l].sort())
|
|
327
|
+
this._map.set(`fdw:${t}`, this._alloc());
|
|
328
|
+
const o = e._indexManager;
|
|
329
|
+
if (o != null) {
|
|
330
|
+
const t = o._indexes;
|
|
331
|
+
if (t !== void 0)
|
|
332
|
+
for (const n of [...t.keys()].sort())
|
|
333
|
+
this._map.set(`index:${n}`, this._alloc());
|
|
334
|
+
}
|
|
335
|
+
for (const t of [...e._tables.keys()].sort()) {
|
|
336
|
+
const n = e._tables.get(t);
|
|
337
|
+
n.primaryKey && (this._map.set(`constraint:${t}_pkey`, this._alloc()), this._map.set(`index:${t}_pkey`, this._alloc()));
|
|
338
|
+
for (const [a, s] of n.columns)
|
|
339
|
+
s.unique && !s.primaryKey && (this._map.set(`constraint:${t}_${a}_key`, this._alloc()), this._map.set(`index:${t}_${a}_key`, this._alloc()));
|
|
340
|
+
for (const a of n.foreignKeys)
|
|
341
|
+
this._map.set(`constraint:${t}_${a.column}_fkey`, this._alloc());
|
|
342
|
+
for (const [a] of n.checkConstraints)
|
|
343
|
+
this._map.set(`constraint:${t}_${a}_check`, this._alloc());
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
get(e, l) {
|
|
347
|
+
return this._map.get(`${e}:${l}`) ?? null;
|
|
348
|
+
}
|
|
349
|
+
getOrAlloc(e, l) {
|
|
350
|
+
const o = `${e}:${l}`, t = this._map.get(o);
|
|
351
|
+
if (t !== void 0) return t;
|
|
352
|
+
const n = this._alloc();
|
|
353
|
+
return this._map.set(o, n), n;
|
|
354
|
+
}
|
|
355
|
+
relationOid(e, l) {
|
|
356
|
+
for (const o of ["table", "view", "foreign_table", "sequence"]) {
|
|
357
|
+
const t = this._map.get(`${o}:${e}`);
|
|
358
|
+
if (t !== void 0) return t;
|
|
359
|
+
}
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
allByCategory(e) {
|
|
363
|
+
const l = `${e}:`, o = /* @__PURE__ */ new Map();
|
|
364
|
+
for (const [t, n] of this._map)
|
|
365
|
+
t.startsWith(l) && o.set(t.slice(l.length), n);
|
|
366
|
+
return o;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
const m = "uqa", h = "public", q = "uqa";
|
|
370
|
+
function se(u) {
|
|
371
|
+
const e = {
|
|
372
|
+
integer: "int4",
|
|
373
|
+
int: "int4",
|
|
374
|
+
int4: "int4",
|
|
375
|
+
bigint: "int8",
|
|
376
|
+
int8: "int8",
|
|
377
|
+
smallint: "int2",
|
|
378
|
+
int2: "int2",
|
|
379
|
+
serial: "int4",
|
|
380
|
+
bigserial: "int8",
|
|
381
|
+
text: "text",
|
|
382
|
+
varchar: "varchar",
|
|
383
|
+
"character varying": "varchar",
|
|
384
|
+
character: "bpchar",
|
|
385
|
+
char: "bpchar",
|
|
386
|
+
name: "name",
|
|
387
|
+
boolean: "bool",
|
|
388
|
+
bool: "bool",
|
|
389
|
+
real: "float4",
|
|
390
|
+
float: "float4",
|
|
391
|
+
float4: "float4",
|
|
392
|
+
"double precision": "float8",
|
|
393
|
+
float8: "float8",
|
|
394
|
+
numeric: "numeric",
|
|
395
|
+
decimal: "numeric",
|
|
396
|
+
date: "date",
|
|
397
|
+
timestamp: "timestamp",
|
|
398
|
+
"timestamp without time zone": "timestamp",
|
|
399
|
+
timestamptz: "timestamptz",
|
|
400
|
+
"timestamp with time zone": "timestamptz",
|
|
401
|
+
json: "json",
|
|
402
|
+
jsonb: "jsonb",
|
|
403
|
+
uuid: "uuid",
|
|
404
|
+
bytea: "bytea",
|
|
405
|
+
point: "point",
|
|
406
|
+
vector: "vector"
|
|
407
|
+
};
|
|
408
|
+
if (u.endsWith("[]")) {
|
|
409
|
+
const l = u.slice(0, -2);
|
|
410
|
+
return `_${e[l] ?? l}`;
|
|
411
|
+
}
|
|
412
|
+
return e[u] ?? u;
|
|
413
|
+
}
|
|
414
|
+
function ve(u) {
|
|
415
|
+
return typeof u == "string" ? `'${u.replace(/'/g, "''")}'::text` : typeof u == "boolean" ? u ? "true" : "false" : String(u);
|
|
416
|
+
}
|
|
417
|
+
function oe(u) {
|
|
418
|
+
return u.typeName === "float" && u.numericScale !== null ? "numeric" : u.typeName;
|
|
419
|
+
}
|
|
420
|
+
const k = class k {
|
|
421
|
+
static supportedViews() {
|
|
422
|
+
return Object.keys(k._VIEWS);
|
|
423
|
+
}
|
|
424
|
+
static build(e, l, o) {
|
|
425
|
+
const t = k._VIEWS[e];
|
|
426
|
+
if (t === void 0)
|
|
427
|
+
throw new Error(`Unknown information_schema view: '${e}'`);
|
|
428
|
+
return t(l, o);
|
|
429
|
+
}
|
|
430
|
+
// ==================================================================
|
|
431
|
+
// information_schema.schemata
|
|
432
|
+
// ==================================================================
|
|
433
|
+
static _buildSchemata(e, l) {
|
|
434
|
+
return [[
|
|
435
|
+
"catalog_name",
|
|
436
|
+
"schema_name",
|
|
437
|
+
"schema_owner",
|
|
438
|
+
"default_character_set_catalog",
|
|
439
|
+
"default_character_set_schema",
|
|
440
|
+
"default_character_set_name",
|
|
441
|
+
"sql_path"
|
|
442
|
+
], [
|
|
443
|
+
{
|
|
444
|
+
catalog_name: m,
|
|
445
|
+
schema_name: "public",
|
|
446
|
+
schema_owner: q,
|
|
447
|
+
default_character_set_catalog: null,
|
|
448
|
+
default_character_set_schema: null,
|
|
449
|
+
default_character_set_name: null,
|
|
450
|
+
sql_path: null
|
|
451
|
+
},
|
|
452
|
+
{
|
|
453
|
+
catalog_name: m,
|
|
454
|
+
schema_name: "information_schema",
|
|
455
|
+
schema_owner: q,
|
|
456
|
+
default_character_set_catalog: null,
|
|
457
|
+
default_character_set_schema: null,
|
|
458
|
+
default_character_set_name: null,
|
|
459
|
+
sql_path: null
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
catalog_name: m,
|
|
463
|
+
schema_name: "pg_catalog",
|
|
464
|
+
schema_owner: q,
|
|
465
|
+
default_character_set_catalog: null,
|
|
466
|
+
default_character_set_schema: null,
|
|
467
|
+
default_character_set_name: null,
|
|
468
|
+
sql_path: null
|
|
469
|
+
}
|
|
470
|
+
]];
|
|
471
|
+
}
|
|
472
|
+
// ==================================================================
|
|
473
|
+
// information_schema.tables
|
|
474
|
+
// ==================================================================
|
|
475
|
+
static _buildTables(e, l) {
|
|
476
|
+
const o = [
|
|
477
|
+
"table_catalog",
|
|
478
|
+
"table_schema",
|
|
479
|
+
"table_name",
|
|
480
|
+
"table_type",
|
|
481
|
+
"self_referencing_column_name",
|
|
482
|
+
"reference_generation",
|
|
483
|
+
"user_defined_type_catalog",
|
|
484
|
+
"user_defined_type_schema",
|
|
485
|
+
"user_defined_type_name",
|
|
486
|
+
"is_insertable_into",
|
|
487
|
+
"is_typed",
|
|
488
|
+
"commit_action"
|
|
489
|
+
], t = [];
|
|
490
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
491
|
+
const a = e._tempTables.has(n);
|
|
492
|
+
t.push({
|
|
493
|
+
table_catalog: m,
|
|
494
|
+
table_schema: h,
|
|
495
|
+
table_name: n,
|
|
496
|
+
table_type: a ? "LOCAL TEMPORARY" : "BASE TABLE",
|
|
497
|
+
self_referencing_column_name: null,
|
|
498
|
+
reference_generation: null,
|
|
499
|
+
user_defined_type_catalog: null,
|
|
500
|
+
user_defined_type_schema: null,
|
|
501
|
+
user_defined_type_name: null,
|
|
502
|
+
is_insertable_into: "YES",
|
|
503
|
+
is_typed: "NO",
|
|
504
|
+
commit_action: null
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
for (const n of [...e._views.keys()].sort())
|
|
508
|
+
t.push({
|
|
509
|
+
table_catalog: m,
|
|
510
|
+
table_schema: h,
|
|
511
|
+
table_name: n,
|
|
512
|
+
table_type: "VIEW",
|
|
513
|
+
self_referencing_column_name: null,
|
|
514
|
+
reference_generation: null,
|
|
515
|
+
user_defined_type_catalog: null,
|
|
516
|
+
user_defined_type_schema: null,
|
|
517
|
+
user_defined_type_name: null,
|
|
518
|
+
is_insertable_into: "NO",
|
|
519
|
+
is_typed: "NO",
|
|
520
|
+
commit_action: null
|
|
521
|
+
});
|
|
522
|
+
for (const n of [...e._foreignTables.keys()].sort())
|
|
523
|
+
t.push({
|
|
524
|
+
table_catalog: m,
|
|
525
|
+
table_schema: h,
|
|
526
|
+
table_name: n,
|
|
527
|
+
table_type: "FOREIGN",
|
|
528
|
+
self_referencing_column_name: null,
|
|
529
|
+
reference_generation: null,
|
|
530
|
+
user_defined_type_catalog: null,
|
|
531
|
+
user_defined_type_schema: null,
|
|
532
|
+
user_defined_type_name: null,
|
|
533
|
+
is_insertable_into: "NO",
|
|
534
|
+
is_typed: "NO",
|
|
535
|
+
commit_action: null
|
|
536
|
+
});
|
|
537
|
+
return [o, t];
|
|
538
|
+
}
|
|
539
|
+
// ==================================================================
|
|
540
|
+
// information_schema.columns
|
|
541
|
+
// ==================================================================
|
|
542
|
+
static _buildColumns(e, l) {
|
|
543
|
+
const o = [
|
|
544
|
+
"table_catalog",
|
|
545
|
+
"table_schema",
|
|
546
|
+
"table_name",
|
|
547
|
+
"column_name",
|
|
548
|
+
"ordinal_position",
|
|
549
|
+
"column_default",
|
|
550
|
+
"is_nullable",
|
|
551
|
+
"data_type",
|
|
552
|
+
"character_maximum_length",
|
|
553
|
+
"character_octet_length",
|
|
554
|
+
"numeric_precision",
|
|
555
|
+
"numeric_precision_radix",
|
|
556
|
+
"numeric_scale",
|
|
557
|
+
"datetime_precision",
|
|
558
|
+
"interval_type",
|
|
559
|
+
"interval_precision",
|
|
560
|
+
"character_set_catalog",
|
|
561
|
+
"character_set_schema",
|
|
562
|
+
"character_set_name",
|
|
563
|
+
"collation_catalog",
|
|
564
|
+
"collation_schema",
|
|
565
|
+
"collation_name",
|
|
566
|
+
"domain_catalog",
|
|
567
|
+
"domain_schema",
|
|
568
|
+
"domain_name",
|
|
569
|
+
"udt_catalog",
|
|
570
|
+
"udt_schema",
|
|
571
|
+
"udt_name",
|
|
572
|
+
"scope_catalog",
|
|
573
|
+
"scope_schema",
|
|
574
|
+
"scope_name",
|
|
575
|
+
"maximum_cardinality",
|
|
576
|
+
"dtd_identifier",
|
|
577
|
+
"is_self_referencing",
|
|
578
|
+
"is_identity",
|
|
579
|
+
"identity_generation",
|
|
580
|
+
"identity_start",
|
|
581
|
+
"identity_increment",
|
|
582
|
+
"identity_maximum",
|
|
583
|
+
"identity_minimum",
|
|
584
|
+
"identity_cycle",
|
|
585
|
+
"is_generated",
|
|
586
|
+
"generation_expression",
|
|
587
|
+
"is_updatable"
|
|
588
|
+
], t = [];
|
|
589
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
590
|
+
const a = e._tables.get(n);
|
|
591
|
+
let s = 0;
|
|
592
|
+
for (const [i, r] of a.columns) {
|
|
593
|
+
s++;
|
|
594
|
+
const c = oe(r), _ = Y(c), d = se(c);
|
|
595
|
+
let v = null;
|
|
596
|
+
r.autoIncrement ? v = `nextval('${n}_${i}_seq'::regclass)` : r.defaultValue !== null && r.defaultValue !== void 0 && (v = ve(r.defaultValue));
|
|
597
|
+
const p = r.autoIncrement ? "YES" : "NO", f = r.autoIncrement ? "BY DEFAULT" : null;
|
|
598
|
+
let b = null;
|
|
599
|
+
[
|
|
600
|
+
"timestamp",
|
|
601
|
+
"timestamptz",
|
|
602
|
+
"timestamp without time zone",
|
|
603
|
+
"timestamp with time zone",
|
|
604
|
+
"date",
|
|
605
|
+
"time"
|
|
606
|
+
].includes(c) && (b = 6), t.push({
|
|
607
|
+
table_catalog: m,
|
|
608
|
+
table_schema: h,
|
|
609
|
+
table_name: n,
|
|
610
|
+
column_name: i,
|
|
611
|
+
ordinal_position: s,
|
|
612
|
+
column_default: v,
|
|
613
|
+
is_nullable: r.notNull ? "NO" : "YES",
|
|
614
|
+
data_type: _,
|
|
615
|
+
character_maximum_length: be(),
|
|
616
|
+
character_octet_length: ye(c),
|
|
617
|
+
numeric_precision: r.numericPrecision !== null ? r.numericPrecision : L(c),
|
|
618
|
+
numeric_precision_radix: B(c),
|
|
619
|
+
numeric_scale: r.numericScale !== null ? r.numericScale : W(c),
|
|
620
|
+
datetime_precision: b,
|
|
621
|
+
interval_type: null,
|
|
622
|
+
interval_precision: null,
|
|
623
|
+
character_set_catalog: null,
|
|
624
|
+
character_set_schema: null,
|
|
625
|
+
character_set_name: null,
|
|
626
|
+
collation_catalog: null,
|
|
627
|
+
collation_schema: null,
|
|
628
|
+
collation_name: null,
|
|
629
|
+
domain_catalog: null,
|
|
630
|
+
domain_schema: null,
|
|
631
|
+
domain_name: null,
|
|
632
|
+
udt_catalog: m,
|
|
633
|
+
udt_schema: "pg_catalog",
|
|
634
|
+
udt_name: d,
|
|
635
|
+
scope_catalog: null,
|
|
636
|
+
scope_schema: null,
|
|
637
|
+
scope_name: null,
|
|
638
|
+
maximum_cardinality: null,
|
|
639
|
+
dtd_identifier: String(s),
|
|
640
|
+
is_self_referencing: "NO",
|
|
641
|
+
is_identity: p,
|
|
642
|
+
identity_generation: f,
|
|
643
|
+
identity_start: r.autoIncrement ? "1" : null,
|
|
644
|
+
identity_increment: r.autoIncrement ? "1" : null,
|
|
645
|
+
identity_maximum: null,
|
|
646
|
+
identity_minimum: null,
|
|
647
|
+
identity_cycle: r.autoIncrement ? "NO" : null,
|
|
648
|
+
is_generated: "NEVER",
|
|
649
|
+
generation_expression: null,
|
|
650
|
+
is_updatable: "YES"
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
for (const n of [...e._foreignTables.keys()].sort()) {
|
|
655
|
+
const a = e._foreignTables.get(n);
|
|
656
|
+
let s = 0;
|
|
657
|
+
for (const [i, r] of a.columns) {
|
|
658
|
+
s++;
|
|
659
|
+
const c = oe(r), _ = Y(c), d = se(c);
|
|
660
|
+
t.push({
|
|
661
|
+
table_catalog: m,
|
|
662
|
+
table_schema: h,
|
|
663
|
+
table_name: n,
|
|
664
|
+
column_name: i,
|
|
665
|
+
ordinal_position: s,
|
|
666
|
+
column_default: null,
|
|
667
|
+
is_nullable: "YES",
|
|
668
|
+
data_type: _,
|
|
669
|
+
character_maximum_length: null,
|
|
670
|
+
character_octet_length: null,
|
|
671
|
+
numeric_precision: L(c),
|
|
672
|
+
numeric_precision_radix: B(c),
|
|
673
|
+
numeric_scale: W(c),
|
|
674
|
+
datetime_precision: null,
|
|
675
|
+
interval_type: null,
|
|
676
|
+
interval_precision: null,
|
|
677
|
+
character_set_catalog: null,
|
|
678
|
+
character_set_schema: null,
|
|
679
|
+
character_set_name: null,
|
|
680
|
+
collation_catalog: null,
|
|
681
|
+
collation_schema: null,
|
|
682
|
+
collation_name: null,
|
|
683
|
+
domain_catalog: null,
|
|
684
|
+
domain_schema: null,
|
|
685
|
+
domain_name: null,
|
|
686
|
+
udt_catalog: m,
|
|
687
|
+
udt_schema: "pg_catalog",
|
|
688
|
+
udt_name: d,
|
|
689
|
+
scope_catalog: null,
|
|
690
|
+
scope_schema: null,
|
|
691
|
+
scope_name: null,
|
|
692
|
+
maximum_cardinality: null,
|
|
693
|
+
dtd_identifier: String(s),
|
|
694
|
+
is_self_referencing: "NO",
|
|
695
|
+
is_identity: "NO",
|
|
696
|
+
identity_generation: null,
|
|
697
|
+
identity_start: null,
|
|
698
|
+
identity_increment: null,
|
|
699
|
+
identity_maximum: null,
|
|
700
|
+
identity_minimum: null,
|
|
701
|
+
identity_cycle: null,
|
|
702
|
+
is_generated: "NEVER",
|
|
703
|
+
generation_expression: null,
|
|
704
|
+
is_updatable: "NO"
|
|
705
|
+
});
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
return [o, t];
|
|
709
|
+
}
|
|
710
|
+
// ==================================================================
|
|
711
|
+
// information_schema.table_constraints
|
|
712
|
+
// ==================================================================
|
|
713
|
+
static _buildTableConstraints(e, l) {
|
|
714
|
+
const o = [
|
|
715
|
+
"constraint_catalog",
|
|
716
|
+
"constraint_schema",
|
|
717
|
+
"constraint_name",
|
|
718
|
+
"table_catalog",
|
|
719
|
+
"table_schema",
|
|
720
|
+
"table_name",
|
|
721
|
+
"constraint_type",
|
|
722
|
+
"is_deferrable",
|
|
723
|
+
"initially_deferred",
|
|
724
|
+
"enforced",
|
|
725
|
+
"nulls_distinct"
|
|
726
|
+
], t = [];
|
|
727
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
728
|
+
const a = e._tables.get(n);
|
|
729
|
+
a.primaryKey && t.push({
|
|
730
|
+
constraint_catalog: m,
|
|
731
|
+
constraint_schema: h,
|
|
732
|
+
constraint_name: `${n}_pkey`,
|
|
733
|
+
table_catalog: m,
|
|
734
|
+
table_schema: h,
|
|
735
|
+
table_name: n,
|
|
736
|
+
constraint_type: "PRIMARY KEY",
|
|
737
|
+
is_deferrable: "NO",
|
|
738
|
+
initially_deferred: "NO",
|
|
739
|
+
enforced: "YES",
|
|
740
|
+
nulls_distinct: null
|
|
741
|
+
});
|
|
742
|
+
for (const [s, i] of a.columns)
|
|
743
|
+
i.unique && !i.primaryKey && t.push({
|
|
744
|
+
constraint_catalog: m,
|
|
745
|
+
constraint_schema: h,
|
|
746
|
+
constraint_name: `${n}_${s}_key`,
|
|
747
|
+
table_catalog: m,
|
|
748
|
+
table_schema: h,
|
|
749
|
+
table_name: n,
|
|
750
|
+
constraint_type: "UNIQUE",
|
|
751
|
+
is_deferrable: "NO",
|
|
752
|
+
initially_deferred: "NO",
|
|
753
|
+
enforced: "YES",
|
|
754
|
+
nulls_distinct: "YES"
|
|
755
|
+
});
|
|
756
|
+
for (const s of a.foreignKeys)
|
|
757
|
+
t.push({
|
|
758
|
+
constraint_catalog: m,
|
|
759
|
+
constraint_schema: h,
|
|
760
|
+
constraint_name: `${n}_${s.column}_fkey`,
|
|
761
|
+
table_catalog: m,
|
|
762
|
+
table_schema: h,
|
|
763
|
+
table_name: n,
|
|
764
|
+
constraint_type: "FOREIGN KEY",
|
|
765
|
+
is_deferrable: "NO",
|
|
766
|
+
initially_deferred: "NO",
|
|
767
|
+
enforced: "YES",
|
|
768
|
+
nulls_distinct: null
|
|
769
|
+
});
|
|
770
|
+
for (const [s] of a.checkConstraints)
|
|
771
|
+
t.push({
|
|
772
|
+
constraint_catalog: m,
|
|
773
|
+
constraint_schema: h,
|
|
774
|
+
constraint_name: `${n}_${s}_check`,
|
|
775
|
+
table_catalog: m,
|
|
776
|
+
table_schema: h,
|
|
777
|
+
table_name: n,
|
|
778
|
+
constraint_type: "CHECK",
|
|
779
|
+
is_deferrable: "NO",
|
|
780
|
+
initially_deferred: "NO",
|
|
781
|
+
enforced: "YES",
|
|
782
|
+
nulls_distinct: null
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
return [o, t];
|
|
786
|
+
}
|
|
787
|
+
// ==================================================================
|
|
788
|
+
// information_schema.key_column_usage
|
|
789
|
+
// ==================================================================
|
|
790
|
+
static _buildKeyColumnUsage(e, l) {
|
|
791
|
+
const o = [
|
|
792
|
+
"constraint_catalog",
|
|
793
|
+
"constraint_schema",
|
|
794
|
+
"constraint_name",
|
|
795
|
+
"table_catalog",
|
|
796
|
+
"table_schema",
|
|
797
|
+
"table_name",
|
|
798
|
+
"column_name",
|
|
799
|
+
"ordinal_position",
|
|
800
|
+
"position_in_unique_constraint"
|
|
801
|
+
], t = [];
|
|
802
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
803
|
+
const a = e._tables.get(n);
|
|
804
|
+
a.primaryKey && t.push({
|
|
805
|
+
constraint_catalog: m,
|
|
806
|
+
constraint_schema: h,
|
|
807
|
+
constraint_name: `${n}_pkey`,
|
|
808
|
+
table_catalog: m,
|
|
809
|
+
table_schema: h,
|
|
810
|
+
table_name: n,
|
|
811
|
+
column_name: a.primaryKey,
|
|
812
|
+
ordinal_position: 1,
|
|
813
|
+
position_in_unique_constraint: null
|
|
814
|
+
});
|
|
815
|
+
for (const [s, i] of a.columns)
|
|
816
|
+
i.unique && !i.primaryKey && t.push({
|
|
817
|
+
constraint_catalog: m,
|
|
818
|
+
constraint_schema: h,
|
|
819
|
+
constraint_name: `${n}_${s}_key`,
|
|
820
|
+
table_catalog: m,
|
|
821
|
+
table_schema: h,
|
|
822
|
+
table_name: n,
|
|
823
|
+
column_name: s,
|
|
824
|
+
ordinal_position: 1,
|
|
825
|
+
position_in_unique_constraint: null
|
|
826
|
+
});
|
|
827
|
+
for (const s of a.foreignKeys) {
|
|
828
|
+
const i = e._tables.get(s.refTable);
|
|
829
|
+
let r = null;
|
|
830
|
+
i !== void 0 && [...i.columns.keys()].includes(s.refColumn) && (r = 1), t.push({
|
|
831
|
+
constraint_catalog: m,
|
|
832
|
+
constraint_schema: h,
|
|
833
|
+
constraint_name: `${n}_${s.column}_fkey`,
|
|
834
|
+
table_catalog: m,
|
|
835
|
+
table_schema: h,
|
|
836
|
+
table_name: n,
|
|
837
|
+
column_name: s.column,
|
|
838
|
+
ordinal_position: 1,
|
|
839
|
+
position_in_unique_constraint: r
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
return [o, t];
|
|
844
|
+
}
|
|
845
|
+
// ==================================================================
|
|
846
|
+
// information_schema.referential_constraints
|
|
847
|
+
// ==================================================================
|
|
848
|
+
static _buildReferentialConstraints(e, l) {
|
|
849
|
+
const o = [
|
|
850
|
+
"constraint_catalog",
|
|
851
|
+
"constraint_schema",
|
|
852
|
+
"constraint_name",
|
|
853
|
+
"unique_constraint_catalog",
|
|
854
|
+
"unique_constraint_schema",
|
|
855
|
+
"unique_constraint_name",
|
|
856
|
+
"match_option",
|
|
857
|
+
"update_rule",
|
|
858
|
+
"delete_rule"
|
|
859
|
+
], t = [];
|
|
860
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
861
|
+
const a = e._tables.get(n);
|
|
862
|
+
for (const s of a.foreignKeys) {
|
|
863
|
+
const i = e._tables.get(s.refTable);
|
|
864
|
+
let r = null;
|
|
865
|
+
i !== void 0 && (i.primaryKey === s.refColumn ? r = `${s.refTable}_pkey` : r = `${s.refTable}_${s.refColumn}_key`), t.push({
|
|
866
|
+
constraint_catalog: m,
|
|
867
|
+
constraint_schema: h,
|
|
868
|
+
constraint_name: `${n}_${s.column}_fkey`,
|
|
869
|
+
unique_constraint_catalog: m,
|
|
870
|
+
unique_constraint_schema: h,
|
|
871
|
+
unique_constraint_name: r,
|
|
872
|
+
match_option: "NONE",
|
|
873
|
+
update_rule: "NO ACTION",
|
|
874
|
+
delete_rule: "NO ACTION"
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return [o, t];
|
|
879
|
+
}
|
|
880
|
+
// ==================================================================
|
|
881
|
+
// information_schema.constraint_column_usage
|
|
882
|
+
// ==================================================================
|
|
883
|
+
static _buildConstraintColumnUsage(e, l) {
|
|
884
|
+
const o = [
|
|
885
|
+
"table_catalog",
|
|
886
|
+
"table_schema",
|
|
887
|
+
"table_name",
|
|
888
|
+
"column_name",
|
|
889
|
+
"constraint_catalog",
|
|
890
|
+
"constraint_schema",
|
|
891
|
+
"constraint_name"
|
|
892
|
+
], t = [];
|
|
893
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
894
|
+
const a = e._tables.get(n);
|
|
895
|
+
a.primaryKey && t.push({
|
|
896
|
+
table_catalog: m,
|
|
897
|
+
table_schema: h,
|
|
898
|
+
table_name: n,
|
|
899
|
+
column_name: a.primaryKey,
|
|
900
|
+
constraint_catalog: m,
|
|
901
|
+
constraint_schema: h,
|
|
902
|
+
constraint_name: `${n}_pkey`
|
|
903
|
+
});
|
|
904
|
+
for (const [s, i] of a.columns)
|
|
905
|
+
i.unique && !i.primaryKey && t.push({
|
|
906
|
+
table_catalog: m,
|
|
907
|
+
table_schema: h,
|
|
908
|
+
table_name: n,
|
|
909
|
+
column_name: s,
|
|
910
|
+
constraint_catalog: m,
|
|
911
|
+
constraint_schema: h,
|
|
912
|
+
constraint_name: `${n}_${s}_key`
|
|
913
|
+
});
|
|
914
|
+
for (const s of a.foreignKeys)
|
|
915
|
+
t.push({
|
|
916
|
+
table_catalog: m,
|
|
917
|
+
table_schema: h,
|
|
918
|
+
table_name: s.refTable,
|
|
919
|
+
column_name: s.refColumn,
|
|
920
|
+
constraint_catalog: m,
|
|
921
|
+
constraint_schema: h,
|
|
922
|
+
constraint_name: `${n}_${s.column}_fkey`
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
return [o, t];
|
|
926
|
+
}
|
|
927
|
+
// ==================================================================
|
|
928
|
+
// information_schema.check_constraints
|
|
929
|
+
// ==================================================================
|
|
930
|
+
static _buildCheckConstraints(e, l) {
|
|
931
|
+
const o = [
|
|
932
|
+
"constraint_catalog",
|
|
933
|
+
"constraint_schema",
|
|
934
|
+
"constraint_name",
|
|
935
|
+
"check_clause"
|
|
936
|
+
], t = [];
|
|
937
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
938
|
+
const a = e._tables.get(n);
|
|
939
|
+
for (const [s, i] of a.columns)
|
|
940
|
+
i.notNull && !i.primaryKey && t.push({
|
|
941
|
+
constraint_catalog: m,
|
|
942
|
+
constraint_schema: h,
|
|
943
|
+
constraint_name: `${n}_${s}_not_null`,
|
|
944
|
+
check_clause: `${s} IS NOT NULL`
|
|
945
|
+
});
|
|
946
|
+
for (const [s] of a.checkConstraints)
|
|
947
|
+
t.push({
|
|
948
|
+
constraint_catalog: m,
|
|
949
|
+
constraint_schema: h,
|
|
950
|
+
constraint_name: `${n}_${s}_check`,
|
|
951
|
+
check_clause: s
|
|
952
|
+
});
|
|
953
|
+
}
|
|
954
|
+
return [o, t];
|
|
955
|
+
}
|
|
956
|
+
// ==================================================================
|
|
957
|
+
// information_schema.views
|
|
958
|
+
// ==================================================================
|
|
959
|
+
static _buildViews(e, l) {
|
|
960
|
+
const o = [
|
|
961
|
+
"table_catalog",
|
|
962
|
+
"table_schema",
|
|
963
|
+
"table_name",
|
|
964
|
+
"view_definition",
|
|
965
|
+
"check_option",
|
|
966
|
+
"is_updatable",
|
|
967
|
+
"is_insertable_into",
|
|
968
|
+
"is_trigger_updatable",
|
|
969
|
+
"is_trigger_deletable",
|
|
970
|
+
"is_trigger_insertable_into"
|
|
971
|
+
], t = [];
|
|
972
|
+
for (const n of [...e._views.keys()].sort())
|
|
973
|
+
t.push({
|
|
974
|
+
table_catalog: m,
|
|
975
|
+
table_schema: h,
|
|
976
|
+
table_name: n,
|
|
977
|
+
view_definition: "",
|
|
978
|
+
check_option: "NONE",
|
|
979
|
+
is_updatable: "NO",
|
|
980
|
+
is_insertable_into: "NO",
|
|
981
|
+
is_trigger_updatable: "NO",
|
|
982
|
+
is_trigger_deletable: "NO",
|
|
983
|
+
is_trigger_insertable_into: "NO"
|
|
984
|
+
});
|
|
985
|
+
return [o, t];
|
|
986
|
+
}
|
|
987
|
+
// ==================================================================
|
|
988
|
+
// information_schema.sequences
|
|
989
|
+
// ==================================================================
|
|
990
|
+
static _buildSequences(e, l) {
|
|
991
|
+
const o = [
|
|
992
|
+
"sequence_catalog",
|
|
993
|
+
"sequence_schema",
|
|
994
|
+
"sequence_name",
|
|
995
|
+
"data_type",
|
|
996
|
+
"numeric_precision",
|
|
997
|
+
"numeric_precision_radix",
|
|
998
|
+
"numeric_scale",
|
|
999
|
+
"start_value",
|
|
1000
|
+
"minimum_value",
|
|
1001
|
+
"maximum_value",
|
|
1002
|
+
"increment",
|
|
1003
|
+
"cycle_option"
|
|
1004
|
+
], t = [];
|
|
1005
|
+
for (const n of [...e._sequences.keys()].sort()) {
|
|
1006
|
+
const a = e._sequences.get(n);
|
|
1007
|
+
t.push({
|
|
1008
|
+
sequence_catalog: m,
|
|
1009
|
+
sequence_schema: h,
|
|
1010
|
+
sequence_name: n,
|
|
1011
|
+
data_type: "bigint",
|
|
1012
|
+
numeric_precision: 64,
|
|
1013
|
+
numeric_precision_radix: 2,
|
|
1014
|
+
numeric_scale: 0,
|
|
1015
|
+
start_value: String(a.start ?? 1),
|
|
1016
|
+
minimum_value: "1",
|
|
1017
|
+
maximum_value: "9223372036854775807",
|
|
1018
|
+
increment: String(a.increment ?? 1),
|
|
1019
|
+
cycle_option: "NO"
|
|
1020
|
+
});
|
|
1021
|
+
}
|
|
1022
|
+
return [o, t];
|
|
1023
|
+
}
|
|
1024
|
+
// ==================================================================
|
|
1025
|
+
// information_schema.routines (empty)
|
|
1026
|
+
// ==================================================================
|
|
1027
|
+
static _buildRoutines(e, l) {
|
|
1028
|
+
return [[
|
|
1029
|
+
"specific_catalog",
|
|
1030
|
+
"specific_schema",
|
|
1031
|
+
"specific_name",
|
|
1032
|
+
"routine_catalog",
|
|
1033
|
+
"routine_schema",
|
|
1034
|
+
"routine_name",
|
|
1035
|
+
"routine_type",
|
|
1036
|
+
"data_type",
|
|
1037
|
+
"type_udt_catalog",
|
|
1038
|
+
"type_udt_schema",
|
|
1039
|
+
"type_udt_name",
|
|
1040
|
+
"routine_definition",
|
|
1041
|
+
"external_language",
|
|
1042
|
+
"is_deterministic",
|
|
1043
|
+
"security_type"
|
|
1044
|
+
], []];
|
|
1045
|
+
}
|
|
1046
|
+
// ==================================================================
|
|
1047
|
+
// information_schema.parameters (empty)
|
|
1048
|
+
// ==================================================================
|
|
1049
|
+
static _buildParameters(e, l) {
|
|
1050
|
+
return [[
|
|
1051
|
+
"specific_catalog",
|
|
1052
|
+
"specific_schema",
|
|
1053
|
+
"specific_name",
|
|
1054
|
+
"ordinal_position",
|
|
1055
|
+
"parameter_mode",
|
|
1056
|
+
"is_result",
|
|
1057
|
+
"as_locator",
|
|
1058
|
+
"parameter_name",
|
|
1059
|
+
"data_type",
|
|
1060
|
+
"parameter_default"
|
|
1061
|
+
], []];
|
|
1062
|
+
}
|
|
1063
|
+
// ==================================================================
|
|
1064
|
+
// information_schema.foreign_tables
|
|
1065
|
+
// ==================================================================
|
|
1066
|
+
static _buildForeignTables(e, l) {
|
|
1067
|
+
const o = [
|
|
1068
|
+
"foreign_table_catalog",
|
|
1069
|
+
"foreign_table_schema",
|
|
1070
|
+
"foreign_table_name",
|
|
1071
|
+
"foreign_server_catalog",
|
|
1072
|
+
"foreign_server_name"
|
|
1073
|
+
], t = [];
|
|
1074
|
+
for (const n of [...e._foreignTables.keys()].sort()) {
|
|
1075
|
+
const a = e._foreignTables.get(n);
|
|
1076
|
+
t.push({
|
|
1077
|
+
foreign_table_catalog: m,
|
|
1078
|
+
foreign_table_schema: h,
|
|
1079
|
+
foreign_table_name: n,
|
|
1080
|
+
foreign_server_catalog: m,
|
|
1081
|
+
foreign_server_name: a.serverName
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
return [o, t];
|
|
1085
|
+
}
|
|
1086
|
+
// ==================================================================
|
|
1087
|
+
// information_schema.foreign_servers
|
|
1088
|
+
// ==================================================================
|
|
1089
|
+
static _buildForeignServers(e, l) {
|
|
1090
|
+
const o = [
|
|
1091
|
+
"foreign_server_catalog",
|
|
1092
|
+
"foreign_server_name",
|
|
1093
|
+
"foreign_data_wrapper_catalog",
|
|
1094
|
+
"foreign_data_wrapper_name",
|
|
1095
|
+
"foreign_server_type",
|
|
1096
|
+
"foreign_server_version",
|
|
1097
|
+
"authorization_identifier"
|
|
1098
|
+
], t = [];
|
|
1099
|
+
for (const n of [...e._foreignServers.keys()].sort()) {
|
|
1100
|
+
const a = e._foreignServers.get(n);
|
|
1101
|
+
t.push({
|
|
1102
|
+
foreign_server_catalog: m,
|
|
1103
|
+
foreign_server_name: n,
|
|
1104
|
+
foreign_data_wrapper_catalog: m,
|
|
1105
|
+
foreign_data_wrapper_name: a.fdwType,
|
|
1106
|
+
foreign_server_type: null,
|
|
1107
|
+
foreign_server_version: null,
|
|
1108
|
+
authorization_identifier: q
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
return [o, t];
|
|
1112
|
+
}
|
|
1113
|
+
// ==================================================================
|
|
1114
|
+
// information_schema.foreign_server_options
|
|
1115
|
+
// ==================================================================
|
|
1116
|
+
static _buildForeignServerOptions(e, l) {
|
|
1117
|
+
const o = [
|
|
1118
|
+
"foreign_server_catalog",
|
|
1119
|
+
"foreign_server_name",
|
|
1120
|
+
"option_name",
|
|
1121
|
+
"option_value"
|
|
1122
|
+
], t = [];
|
|
1123
|
+
for (const n of [...e._foreignServers.keys()].sort()) {
|
|
1124
|
+
const a = e._foreignServers.get(n);
|
|
1125
|
+
for (const s of Object.keys(a.options).sort())
|
|
1126
|
+
t.push({
|
|
1127
|
+
foreign_server_catalog: m,
|
|
1128
|
+
foreign_server_name: n,
|
|
1129
|
+
option_name: s,
|
|
1130
|
+
option_value: a.options[s]
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
return [o, t];
|
|
1134
|
+
}
|
|
1135
|
+
// ==================================================================
|
|
1136
|
+
// information_schema.foreign_table_options
|
|
1137
|
+
// ==================================================================
|
|
1138
|
+
static _buildForeignTableOptions(e, l) {
|
|
1139
|
+
const o = [
|
|
1140
|
+
"foreign_table_catalog",
|
|
1141
|
+
"foreign_table_schema",
|
|
1142
|
+
"foreign_table_name",
|
|
1143
|
+
"option_name",
|
|
1144
|
+
"option_value"
|
|
1145
|
+
], t = [];
|
|
1146
|
+
for (const n of [...e._foreignTables.keys()].sort()) {
|
|
1147
|
+
const a = e._foreignTables.get(n);
|
|
1148
|
+
for (const s of Object.keys(a.options).sort())
|
|
1149
|
+
t.push({
|
|
1150
|
+
foreign_table_catalog: m,
|
|
1151
|
+
foreign_table_schema: h,
|
|
1152
|
+
foreign_table_name: n,
|
|
1153
|
+
option_name: s,
|
|
1154
|
+
option_value: a.options[s]
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
return [o, t];
|
|
1158
|
+
}
|
|
1159
|
+
// ==================================================================
|
|
1160
|
+
// information_schema.enabled_roles
|
|
1161
|
+
// ==================================================================
|
|
1162
|
+
static _buildEnabledRoles(e, l) {
|
|
1163
|
+
return [["role_name"], [{ role_name: q }]];
|
|
1164
|
+
}
|
|
1165
|
+
// ==================================================================
|
|
1166
|
+
// information_schema.applicable_roles
|
|
1167
|
+
// ==================================================================
|
|
1168
|
+
static _buildApplicableRoles(e, l) {
|
|
1169
|
+
return [
|
|
1170
|
+
["grantee", "role_name", "is_grantable"],
|
|
1171
|
+
[{ grantee: q, role_name: q, is_grantable: "YES" }]
|
|
1172
|
+
];
|
|
1173
|
+
}
|
|
1174
|
+
// ==================================================================
|
|
1175
|
+
// information_schema.character_sets
|
|
1176
|
+
// ==================================================================
|
|
1177
|
+
static _buildCharacterSets(e, l) {
|
|
1178
|
+
return [
|
|
1179
|
+
[
|
|
1180
|
+
"character_set_catalog",
|
|
1181
|
+
"character_set_schema",
|
|
1182
|
+
"character_set_name",
|
|
1183
|
+
"character_repertoire",
|
|
1184
|
+
"form_of_use",
|
|
1185
|
+
"default_collate_catalog",
|
|
1186
|
+
"default_collate_schema",
|
|
1187
|
+
"default_collate_name"
|
|
1188
|
+
],
|
|
1189
|
+
[
|
|
1190
|
+
{
|
|
1191
|
+
character_set_catalog: null,
|
|
1192
|
+
character_set_schema: null,
|
|
1193
|
+
character_set_name: "UTF8",
|
|
1194
|
+
character_repertoire: "UCS",
|
|
1195
|
+
form_of_use: "UTF8",
|
|
1196
|
+
default_collate_catalog: m,
|
|
1197
|
+
default_collate_schema: "pg_catalog",
|
|
1198
|
+
default_collate_name: "en_US.utf8"
|
|
1199
|
+
}
|
|
1200
|
+
]
|
|
1201
|
+
];
|
|
1202
|
+
}
|
|
1203
|
+
// ==================================================================
|
|
1204
|
+
// information_schema.collations
|
|
1205
|
+
// ==================================================================
|
|
1206
|
+
static _buildCollations(e, l) {
|
|
1207
|
+
return [
|
|
1208
|
+
[
|
|
1209
|
+
"collation_catalog",
|
|
1210
|
+
"collation_schema",
|
|
1211
|
+
"collation_name",
|
|
1212
|
+
"pad_attribute"
|
|
1213
|
+
],
|
|
1214
|
+
[
|
|
1215
|
+
{
|
|
1216
|
+
collation_catalog: m,
|
|
1217
|
+
collation_schema: "pg_catalog",
|
|
1218
|
+
collation_name: "en_US.utf8",
|
|
1219
|
+
pad_attribute: "NO PAD"
|
|
1220
|
+
}
|
|
1221
|
+
]
|
|
1222
|
+
];
|
|
1223
|
+
}
|
|
1224
|
+
// ==================================================================
|
|
1225
|
+
// information_schema.domains (empty)
|
|
1226
|
+
// ==================================================================
|
|
1227
|
+
static _buildDomains(e, l) {
|
|
1228
|
+
return [[
|
|
1229
|
+
"domain_catalog",
|
|
1230
|
+
"domain_schema",
|
|
1231
|
+
"domain_name",
|
|
1232
|
+
"data_type",
|
|
1233
|
+
"character_maximum_length",
|
|
1234
|
+
"numeric_precision",
|
|
1235
|
+
"domain_default"
|
|
1236
|
+
], []];
|
|
1237
|
+
}
|
|
1238
|
+
// ==================================================================
|
|
1239
|
+
// information_schema.element_types
|
|
1240
|
+
// ==================================================================
|
|
1241
|
+
static _buildElementTypes(e, l) {
|
|
1242
|
+
const o = [
|
|
1243
|
+
"object_catalog",
|
|
1244
|
+
"object_schema",
|
|
1245
|
+
"object_name",
|
|
1246
|
+
"object_type",
|
|
1247
|
+
"collection_type_identifier",
|
|
1248
|
+
"data_type",
|
|
1249
|
+
"character_maximum_length",
|
|
1250
|
+
"numeric_precision",
|
|
1251
|
+
"numeric_precision_radix",
|
|
1252
|
+
"numeric_scale",
|
|
1253
|
+
"dtd_identifier"
|
|
1254
|
+
], t = [];
|
|
1255
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
1256
|
+
const a = e._tables.get(n);
|
|
1257
|
+
let s = 0;
|
|
1258
|
+
for (const [, i] of a.columns)
|
|
1259
|
+
if (s++, i.typeName.endsWith("[]")) {
|
|
1260
|
+
const r = i.typeName.slice(0, -2), c = Y(r);
|
|
1261
|
+
t.push({
|
|
1262
|
+
object_catalog: m,
|
|
1263
|
+
object_schema: h,
|
|
1264
|
+
object_name: n,
|
|
1265
|
+
object_type: "TABLE",
|
|
1266
|
+
collection_type_identifier: String(s),
|
|
1267
|
+
data_type: c,
|
|
1268
|
+
character_maximum_length: null,
|
|
1269
|
+
numeric_precision: L(r),
|
|
1270
|
+
numeric_precision_radix: B(r),
|
|
1271
|
+
numeric_scale: W(r),
|
|
1272
|
+
dtd_identifier: String(s)
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
return [o, t];
|
|
1277
|
+
}
|
|
1278
|
+
// ==================================================================
|
|
1279
|
+
// information_schema.triggers (empty)
|
|
1280
|
+
// ==================================================================
|
|
1281
|
+
static _buildTriggers(e, l) {
|
|
1282
|
+
return [[
|
|
1283
|
+
"trigger_catalog",
|
|
1284
|
+
"trigger_schema",
|
|
1285
|
+
"trigger_name",
|
|
1286
|
+
"event_manipulation",
|
|
1287
|
+
"event_object_catalog",
|
|
1288
|
+
"event_object_schema",
|
|
1289
|
+
"event_object_table",
|
|
1290
|
+
"action_order",
|
|
1291
|
+
"action_condition",
|
|
1292
|
+
"action_statement",
|
|
1293
|
+
"action_orientation",
|
|
1294
|
+
"action_timing"
|
|
1295
|
+
], []];
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
A(k, "_VIEWS", {
|
|
1299
|
+
schemata: k._buildSchemata,
|
|
1300
|
+
tables: k._buildTables,
|
|
1301
|
+
columns: k._buildColumns,
|
|
1302
|
+
table_constraints: k._buildTableConstraints,
|
|
1303
|
+
key_column_usage: k._buildKeyColumnUsage,
|
|
1304
|
+
referential_constraints: k._buildReferentialConstraints,
|
|
1305
|
+
constraint_column_usage: k._buildConstraintColumnUsage,
|
|
1306
|
+
check_constraints: k._buildCheckConstraints,
|
|
1307
|
+
views: k._buildViews,
|
|
1308
|
+
sequences: k._buildSequences,
|
|
1309
|
+
routines: k._buildRoutines,
|
|
1310
|
+
parameters: k._buildParameters,
|
|
1311
|
+
foreign_tables: k._buildForeignTables,
|
|
1312
|
+
foreign_servers: k._buildForeignServers,
|
|
1313
|
+
foreign_server_options: k._buildForeignServerOptions,
|
|
1314
|
+
foreign_table_options: k._buildForeignTableOptions,
|
|
1315
|
+
enabled_roles: k._buildEnabledRoles,
|
|
1316
|
+
applicable_roles: k._buildApplicableRoles,
|
|
1317
|
+
character_sets: k._buildCharacterSets,
|
|
1318
|
+
collations: k._buildCollations,
|
|
1319
|
+
domains: k._buildDomains,
|
|
1320
|
+
element_types: k._buildElementTypes,
|
|
1321
|
+
triggers: k._buildTriggers
|
|
1322
|
+
});
|
|
1323
|
+
let D = k;
|
|
1324
|
+
const we = /* @__PURE__ */ new Map();
|
|
1325
|
+
function xe() {
|
|
1326
|
+
return Array.from(we.values());
|
|
1327
|
+
}
|
|
1328
|
+
function ie(u) {
|
|
1329
|
+
return u.typeName === "float" && u.numericScale !== null ? "numeric" : u.typeName;
|
|
1330
|
+
}
|
|
1331
|
+
const G = "uqa", N = "public", $ = "uqa", ke = 6, E = J.pg_catalog, U = J.public, Se = J.information_schema;
|
|
1332
|
+
function P(u) {
|
|
1333
|
+
const e = u.reltuples ?? -1;
|
|
1334
|
+
return {
|
|
1335
|
+
oid: u.oid,
|
|
1336
|
+
relname: u.relname,
|
|
1337
|
+
relnamespace: u.relnamespace,
|
|
1338
|
+
reltype: u.reltype ?? 0,
|
|
1339
|
+
reloftype: u.reloftype ?? 0,
|
|
1340
|
+
relowner: u.relowner ?? T,
|
|
1341
|
+
relam: u.relam ?? 0,
|
|
1342
|
+
relfilenode: u.oid,
|
|
1343
|
+
reltablespace: 0,
|
|
1344
|
+
relpages: e > 0 ? Math.max(1, Math.floor(e / 100)) : 0,
|
|
1345
|
+
reltuples: e,
|
|
1346
|
+
relallvisible: 0,
|
|
1347
|
+
reltoastrelid: 0,
|
|
1348
|
+
relhasindex: u.relhasindex ?? !1,
|
|
1349
|
+
relisshared: !1,
|
|
1350
|
+
relpersistence: "p",
|
|
1351
|
+
relkind: u.relkind ?? "r",
|
|
1352
|
+
relnatts: u.relnatts ?? 0,
|
|
1353
|
+
relchecks: u.relchecks ?? 0,
|
|
1354
|
+
relhasrules: u.relhasrules ?? !1,
|
|
1355
|
+
relhastriggers: !1,
|
|
1356
|
+
relhassubclass: !1,
|
|
1357
|
+
relrowsecurity: !1,
|
|
1358
|
+
relforcerowsecurity: !1,
|
|
1359
|
+
relispopulated: !0,
|
|
1360
|
+
relreplident: "d",
|
|
1361
|
+
relispartition: !1,
|
|
1362
|
+
relrewrite: 0,
|
|
1363
|
+
relfrozenxid: 0,
|
|
1364
|
+
relminmxid: 1,
|
|
1365
|
+
relacl: null,
|
|
1366
|
+
reloptions: null,
|
|
1367
|
+
relpartbound: null
|
|
1368
|
+
};
|
|
1369
|
+
}
|
|
1370
|
+
function H(u) {
|
|
1371
|
+
const e = u._indexManager;
|
|
1372
|
+
if (e == null) return null;
|
|
1373
|
+
const l = e._indexes;
|
|
1374
|
+
return l === void 0 ? null : l;
|
|
1375
|
+
}
|
|
1376
|
+
const g = class g {
|
|
1377
|
+
static supportedTables() {
|
|
1378
|
+
return Object.keys(g._TABLES);
|
|
1379
|
+
}
|
|
1380
|
+
static build(e, l, o) {
|
|
1381
|
+
const t = g._TABLES[e];
|
|
1382
|
+
if (t === void 0)
|
|
1383
|
+
throw new Error(`Unknown pg_catalog table: '${e}'`);
|
|
1384
|
+
return t(l, o);
|
|
1385
|
+
}
|
|
1386
|
+
// ==================================================================
|
|
1387
|
+
// pg_namespace -- schemas
|
|
1388
|
+
// ==================================================================
|
|
1389
|
+
static _buildPgNamespace(e, l) {
|
|
1390
|
+
return [["oid", "nspname", "nspowner", "nspacl"], [
|
|
1391
|
+
{
|
|
1392
|
+
oid: E,
|
|
1393
|
+
nspname: "pg_catalog",
|
|
1394
|
+
nspowner: T,
|
|
1395
|
+
nspacl: null
|
|
1396
|
+
},
|
|
1397
|
+
{
|
|
1398
|
+
oid: U,
|
|
1399
|
+
nspname: "public",
|
|
1400
|
+
nspowner: T,
|
|
1401
|
+
nspacl: null
|
|
1402
|
+
},
|
|
1403
|
+
{
|
|
1404
|
+
oid: Se,
|
|
1405
|
+
nspname: "information_schema",
|
|
1406
|
+
nspowner: T,
|
|
1407
|
+
nspacl: null
|
|
1408
|
+
}
|
|
1409
|
+
]];
|
|
1410
|
+
}
|
|
1411
|
+
// ==================================================================
|
|
1412
|
+
// pg_class -- all relations (tables, views, indexes, sequences, etc.)
|
|
1413
|
+
// ==================================================================
|
|
1414
|
+
static _buildPgClass(e, l) {
|
|
1415
|
+
const o = [
|
|
1416
|
+
"oid",
|
|
1417
|
+
"relname",
|
|
1418
|
+
"relnamespace",
|
|
1419
|
+
"reltype",
|
|
1420
|
+
"reloftype",
|
|
1421
|
+
"relowner",
|
|
1422
|
+
"relam",
|
|
1423
|
+
"relfilenode",
|
|
1424
|
+
"reltablespace",
|
|
1425
|
+
"relpages",
|
|
1426
|
+
"reltuples",
|
|
1427
|
+
"relallvisible",
|
|
1428
|
+
"reltoastrelid",
|
|
1429
|
+
"relhasindex",
|
|
1430
|
+
"relisshared",
|
|
1431
|
+
"relpersistence",
|
|
1432
|
+
"relkind",
|
|
1433
|
+
"relnatts",
|
|
1434
|
+
"relchecks",
|
|
1435
|
+
"relhasrules",
|
|
1436
|
+
"relhastriggers",
|
|
1437
|
+
"relhassubclass",
|
|
1438
|
+
"relrowsecurity",
|
|
1439
|
+
"relforcerowsecurity",
|
|
1440
|
+
"relispopulated",
|
|
1441
|
+
"relreplident",
|
|
1442
|
+
"relispartition",
|
|
1443
|
+
"relrewrite",
|
|
1444
|
+
"relfrozenxid",
|
|
1445
|
+
"relminmxid",
|
|
1446
|
+
"relacl",
|
|
1447
|
+
"reloptions",
|
|
1448
|
+
"relpartbound"
|
|
1449
|
+
], t = [], n = U;
|
|
1450
|
+
for (const s of [...e._tables.keys()].sort()) {
|
|
1451
|
+
const i = e._tables.get(s), r = l.get("table", s) ?? 0, c = l.get("table_type", s) ?? 0, _ = i.primaryKey !== null || [...i.columns.values()].some((p) => p.unique), d = i.checkConstraints.length, v = i.rowCount;
|
|
1452
|
+
t.push(
|
|
1453
|
+
P({
|
|
1454
|
+
oid: r,
|
|
1455
|
+
relname: s,
|
|
1456
|
+
relnamespace: n,
|
|
1457
|
+
reltype: c,
|
|
1458
|
+
relam: te,
|
|
1459
|
+
reltuples: v,
|
|
1460
|
+
relhasindex: _,
|
|
1461
|
+
relkind: "r",
|
|
1462
|
+
relnatts: i.columns.size,
|
|
1463
|
+
relchecks: d
|
|
1464
|
+
})
|
|
1465
|
+
);
|
|
1466
|
+
}
|
|
1467
|
+
for (const s of [...e._views.keys()].sort()) {
|
|
1468
|
+
const i = l.get("view", s) ?? 0;
|
|
1469
|
+
t.push(
|
|
1470
|
+
P({
|
|
1471
|
+
oid: i,
|
|
1472
|
+
relname: s,
|
|
1473
|
+
relnamespace: n,
|
|
1474
|
+
relkind: "v",
|
|
1475
|
+
relhasrules: !0
|
|
1476
|
+
})
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
for (const s of [...e._sequences.keys()].sort()) {
|
|
1480
|
+
const i = l.get("sequence", s) ?? 0;
|
|
1481
|
+
t.push(
|
|
1482
|
+
P({
|
|
1483
|
+
oid: i,
|
|
1484
|
+
relname: s,
|
|
1485
|
+
relnamespace: n,
|
|
1486
|
+
relkind: "S",
|
|
1487
|
+
relnatts: 3
|
|
1488
|
+
})
|
|
1489
|
+
);
|
|
1490
|
+
}
|
|
1491
|
+
for (const s of [...e._foreignTables.keys()].sort()) {
|
|
1492
|
+
const i = l.get("foreign_table", s) ?? 0, r = e._foreignTables.get(s);
|
|
1493
|
+
t.push(
|
|
1494
|
+
P({
|
|
1495
|
+
oid: i,
|
|
1496
|
+
relname: s,
|
|
1497
|
+
relnamespace: n,
|
|
1498
|
+
relkind: "f",
|
|
1499
|
+
relnatts: r.columns.size
|
|
1500
|
+
})
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
const a = H(e);
|
|
1504
|
+
if (a !== null)
|
|
1505
|
+
for (const s of [...a.keys()].sort()) {
|
|
1506
|
+
const i = a.get(s), r = l.get("index", s) ?? 0, c = i.indexDef;
|
|
1507
|
+
t.push(
|
|
1508
|
+
P({
|
|
1509
|
+
oid: r,
|
|
1510
|
+
relname: s,
|
|
1511
|
+
relnamespace: n,
|
|
1512
|
+
relam: z,
|
|
1513
|
+
relkind: "i",
|
|
1514
|
+
relnatts: c.columns.length
|
|
1515
|
+
})
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
for (const s of [...e._tables.keys()].sort()) {
|
|
1519
|
+
const i = e._tables.get(s);
|
|
1520
|
+
if (i.primaryKey) {
|
|
1521
|
+
const r = `${s}_pkey`, c = l.get("index", r) ?? 0;
|
|
1522
|
+
t.push(
|
|
1523
|
+
P({
|
|
1524
|
+
oid: c,
|
|
1525
|
+
relname: r,
|
|
1526
|
+
relnamespace: n,
|
|
1527
|
+
relam: z,
|
|
1528
|
+
relkind: "i",
|
|
1529
|
+
relnatts: 1
|
|
1530
|
+
})
|
|
1531
|
+
);
|
|
1532
|
+
}
|
|
1533
|
+
for (const [r, c] of i.columns)
|
|
1534
|
+
if (c.unique && !c.primaryKey) {
|
|
1535
|
+
const _ = `${s}_${r}_key`, d = l.get("index", _) ?? 0;
|
|
1536
|
+
t.push(
|
|
1537
|
+
P({
|
|
1538
|
+
oid: d,
|
|
1539
|
+
relname: _,
|
|
1540
|
+
relnamespace: n,
|
|
1541
|
+
relam: z,
|
|
1542
|
+
relkind: "i",
|
|
1543
|
+
relnatts: 1
|
|
1544
|
+
})
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
return [o, t];
|
|
1549
|
+
}
|
|
1550
|
+
// ==================================================================
|
|
1551
|
+
// pg_attribute -- columns of all relations
|
|
1552
|
+
// ==================================================================
|
|
1553
|
+
static _buildPgAttribute(e, l) {
|
|
1554
|
+
const o = [
|
|
1555
|
+
"attrelid",
|
|
1556
|
+
"attname",
|
|
1557
|
+
"atttypid",
|
|
1558
|
+
"attstattarget",
|
|
1559
|
+
"attlen",
|
|
1560
|
+
"attnum",
|
|
1561
|
+
"attndims",
|
|
1562
|
+
"attcacheoff",
|
|
1563
|
+
"atttypmod",
|
|
1564
|
+
"attbyval",
|
|
1565
|
+
"attalign",
|
|
1566
|
+
"attstorage",
|
|
1567
|
+
"attcompression",
|
|
1568
|
+
"attnotnull",
|
|
1569
|
+
"atthasdef",
|
|
1570
|
+
"atthasmissing",
|
|
1571
|
+
"attidentity",
|
|
1572
|
+
"attgenerated",
|
|
1573
|
+
"attisdropped",
|
|
1574
|
+
"attislocal",
|
|
1575
|
+
"attinhcount",
|
|
1576
|
+
"attcollation",
|
|
1577
|
+
"attacl",
|
|
1578
|
+
"attoptions",
|
|
1579
|
+
"attfdwoptions",
|
|
1580
|
+
"attmissingval"
|
|
1581
|
+
], t = [], n = [
|
|
1582
|
+
["tableoid", 26, 4, -6],
|
|
1583
|
+
["cmax", 29, 4, -5],
|
|
1584
|
+
["xmax", 28, 4, -4],
|
|
1585
|
+
["cmin", 29, 4, -3],
|
|
1586
|
+
["xmin", 28, 4, -2],
|
|
1587
|
+
["ctid", 27, 6, -1]
|
|
1588
|
+
];
|
|
1589
|
+
for (const a of [...e._tables.keys()].sort()) {
|
|
1590
|
+
const s = e._tables.get(a), i = l.get("table", a) ?? 0;
|
|
1591
|
+
let r = 0;
|
|
1592
|
+
for (const [c, _] of s.columns) {
|
|
1593
|
+
r++;
|
|
1594
|
+
const d = I(ie(_)), v = ae[d] ?? -1, p = le[d] ?? !1, f = K[d] ?? "i", b = V[d] ?? "p", x = _.typeName.endsWith("[]") ? 1 : 0, y = _.defaultValue !== null && _.defaultValue !== void 0 || _.autoIncrement, S = _.autoIncrement ? "d" : "", w = d === 25 || d === 1042 || d === 1043 ? 100 : 0;
|
|
1595
|
+
t.push({
|
|
1596
|
+
attrelid: i,
|
|
1597
|
+
attname: c,
|
|
1598
|
+
atttypid: d,
|
|
1599
|
+
attstattarget: -1,
|
|
1600
|
+
attlen: v,
|
|
1601
|
+
attnum: r,
|
|
1602
|
+
attndims: x,
|
|
1603
|
+
attcacheoff: -1,
|
|
1604
|
+
atttypmod: -1,
|
|
1605
|
+
attbyval: p,
|
|
1606
|
+
attalign: f,
|
|
1607
|
+
attstorage: b,
|
|
1608
|
+
attcompression: "",
|
|
1609
|
+
attnotnull: _.notNull || _.primaryKey,
|
|
1610
|
+
atthasdef: y,
|
|
1611
|
+
atthasmissing: !1,
|
|
1612
|
+
attidentity: S,
|
|
1613
|
+
attgenerated: "",
|
|
1614
|
+
attisdropped: !1,
|
|
1615
|
+
attislocal: !0,
|
|
1616
|
+
attinhcount: 0,
|
|
1617
|
+
attcollation: w,
|
|
1618
|
+
attacl: null,
|
|
1619
|
+
attoptions: null,
|
|
1620
|
+
attfdwoptions: null,
|
|
1621
|
+
attmissingval: null
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
for (const [c, _, d, v] of n)
|
|
1625
|
+
t.push({
|
|
1626
|
+
attrelid: i,
|
|
1627
|
+
attname: c,
|
|
1628
|
+
atttypid: _,
|
|
1629
|
+
attstattarget: 0,
|
|
1630
|
+
attlen: d,
|
|
1631
|
+
attnum: v,
|
|
1632
|
+
attndims: 0,
|
|
1633
|
+
attcacheoff: -1,
|
|
1634
|
+
atttypmod: -1,
|
|
1635
|
+
attbyval: !0,
|
|
1636
|
+
attalign: d === 4 ? "i" : "s",
|
|
1637
|
+
attstorage: "p",
|
|
1638
|
+
attcompression: "",
|
|
1639
|
+
attnotnull: !0,
|
|
1640
|
+
atthasdef: !1,
|
|
1641
|
+
atthasmissing: !1,
|
|
1642
|
+
attidentity: "",
|
|
1643
|
+
attgenerated: "",
|
|
1644
|
+
attisdropped: !1,
|
|
1645
|
+
attislocal: !0,
|
|
1646
|
+
attinhcount: 0,
|
|
1647
|
+
attcollation: 0,
|
|
1648
|
+
attacl: null,
|
|
1649
|
+
attoptions: null,
|
|
1650
|
+
attfdwoptions: null,
|
|
1651
|
+
attmissingval: null
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
for (const a of [...e._foreignTables.keys()].sort()) {
|
|
1655
|
+
const s = e._foreignTables.get(a), i = l.get("foreign_table", a) ?? 0;
|
|
1656
|
+
let r = 0;
|
|
1657
|
+
for (const [c, _] of s.columns) {
|
|
1658
|
+
r++;
|
|
1659
|
+
const d = I(ie(_)), v = ae[d] ?? -1;
|
|
1660
|
+
t.push({
|
|
1661
|
+
attrelid: i,
|
|
1662
|
+
attname: c,
|
|
1663
|
+
atttypid: d,
|
|
1664
|
+
attstattarget: -1,
|
|
1665
|
+
attlen: v,
|
|
1666
|
+
attnum: r,
|
|
1667
|
+
attndims: 0,
|
|
1668
|
+
attcacheoff: -1,
|
|
1669
|
+
atttypmod: -1,
|
|
1670
|
+
attbyval: le[d] ?? !1,
|
|
1671
|
+
attalign: K[d] ?? "i",
|
|
1672
|
+
attstorage: V[d] ?? "p",
|
|
1673
|
+
attcompression: "",
|
|
1674
|
+
attnotnull: !1,
|
|
1675
|
+
atthasdef: !1,
|
|
1676
|
+
atthasmissing: !1,
|
|
1677
|
+
attidentity: "",
|
|
1678
|
+
attgenerated: "",
|
|
1679
|
+
attisdropped: !1,
|
|
1680
|
+
attislocal: !0,
|
|
1681
|
+
attinhcount: 0,
|
|
1682
|
+
attcollation: d === 25 || d === 1042 || d === 1043 ? 100 : 0,
|
|
1683
|
+
attacl: null,
|
|
1684
|
+
attoptions: null,
|
|
1685
|
+
attfdwoptions: null,
|
|
1686
|
+
attmissingval: null
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
return [o, t];
|
|
1691
|
+
}
|
|
1692
|
+
// ==================================================================
|
|
1693
|
+
// pg_type -- data types
|
|
1694
|
+
// ==================================================================
|
|
1695
|
+
static _buildPgType(e, l) {
|
|
1696
|
+
const o = [
|
|
1697
|
+
"oid",
|
|
1698
|
+
"typname",
|
|
1699
|
+
"typnamespace",
|
|
1700
|
+
"typowner",
|
|
1701
|
+
"typlen",
|
|
1702
|
+
"typbyval",
|
|
1703
|
+
"typtype",
|
|
1704
|
+
"typcategory",
|
|
1705
|
+
"typispreferred",
|
|
1706
|
+
"typisdefined",
|
|
1707
|
+
"typdelim",
|
|
1708
|
+
"typrelid",
|
|
1709
|
+
"typsubscript",
|
|
1710
|
+
"typelem",
|
|
1711
|
+
"typarray",
|
|
1712
|
+
"typinput",
|
|
1713
|
+
"typoutput",
|
|
1714
|
+
"typreceive",
|
|
1715
|
+
"typsend",
|
|
1716
|
+
"typmodin",
|
|
1717
|
+
"typmodout",
|
|
1718
|
+
"typanalyze",
|
|
1719
|
+
"typalign",
|
|
1720
|
+
"typstorage",
|
|
1721
|
+
"typnotnull",
|
|
1722
|
+
"typbasetype",
|
|
1723
|
+
"typtypmod",
|
|
1724
|
+
"typndims",
|
|
1725
|
+
"typcollation",
|
|
1726
|
+
"typdefaultbin",
|
|
1727
|
+
"typdefault",
|
|
1728
|
+
"typacl"
|
|
1729
|
+
], t = E, n = [], a = [
|
|
1730
|
+
[16, "bool", 1, !0, "B", !0],
|
|
1731
|
+
[17, "bytea", -1, !1, "U", !1],
|
|
1732
|
+
[18, "char", 1, !0, "Z", !1],
|
|
1733
|
+
[19, "name", 64, !1, "S", !1],
|
|
1734
|
+
[20, "int8", 8, !0, "N", !1],
|
|
1735
|
+
[21, "int2", 2, !0, "N", !1],
|
|
1736
|
+
[23, "int4", 4, !0, "N", !1],
|
|
1737
|
+
[25, "text", -1, !1, "S", !0],
|
|
1738
|
+
[26, "oid", 4, !0, "N", !1],
|
|
1739
|
+
[27, "tid", 6, !1, "U", !1],
|
|
1740
|
+
[28, "xid", 4, !0, "U", !1],
|
|
1741
|
+
[29, "cid", 4, !0, "U", !1],
|
|
1742
|
+
[114, "json", -1, !1, "U", !1],
|
|
1743
|
+
[142, "xml", -1, !1, "U", !1],
|
|
1744
|
+
[600, "point", 16, !1, "G", !1],
|
|
1745
|
+
[700, "float4", 4, !0, "N", !1],
|
|
1746
|
+
[701, "float8", 8, !0, "N", !0],
|
|
1747
|
+
[1042, "bpchar", -1, !1, "S", !1],
|
|
1748
|
+
[1043, "varchar", -1, !1, "S", !1],
|
|
1749
|
+
[1082, "date", 4, !0, "D", !1],
|
|
1750
|
+
[1083, "time", 8, !0, "D", !1],
|
|
1751
|
+
[1114, "timestamp", 8, !0, "D", !1],
|
|
1752
|
+
[1184, "timestamptz", 8, !0, "D", !0],
|
|
1753
|
+
[1186, "interval", 16, !1, "T", !0],
|
|
1754
|
+
[1700, "numeric", -1, !1, "N", !1],
|
|
1755
|
+
[2205, "regclass", 4, !0, "N", !1],
|
|
1756
|
+
[2249, "record", -1, !1, "P", !1],
|
|
1757
|
+
[2278, "void", 4, !0, "P", !1],
|
|
1758
|
+
[2950, "uuid", 16, !1, "U", !1],
|
|
1759
|
+
[3802, "jsonb", -1, !1, "U", !1],
|
|
1760
|
+
[16385, "vector", -1, !1, "U", !1]
|
|
1761
|
+
];
|
|
1762
|
+
for (const [i, r, c, _, d, v] of a) {
|
|
1763
|
+
const p = Z[i] ?? 0, f = K[i] ?? "i", b = V[i] ?? "p", x = d === "S" ? 100 : 0;
|
|
1764
|
+
n.push({
|
|
1765
|
+
oid: i,
|
|
1766
|
+
typname: r,
|
|
1767
|
+
typnamespace: t,
|
|
1768
|
+
typowner: T,
|
|
1769
|
+
typlen: c,
|
|
1770
|
+
typbyval: _,
|
|
1771
|
+
typtype: "b",
|
|
1772
|
+
typcategory: d,
|
|
1773
|
+
typispreferred: v,
|
|
1774
|
+
typisdefined: !0,
|
|
1775
|
+
typdelim: ",",
|
|
1776
|
+
typrelid: 0,
|
|
1777
|
+
typsubscript: "",
|
|
1778
|
+
typelem: 0,
|
|
1779
|
+
typarray: p,
|
|
1780
|
+
typinput: `${r}in`,
|
|
1781
|
+
typoutput: `${r}out`,
|
|
1782
|
+
typreceive: `${r}recv`,
|
|
1783
|
+
typsend: `${r}send`,
|
|
1784
|
+
typmodin: "",
|
|
1785
|
+
typmodout: "",
|
|
1786
|
+
typanalyze: "",
|
|
1787
|
+
typalign: f,
|
|
1788
|
+
typstorage: b,
|
|
1789
|
+
typnotnull: !1,
|
|
1790
|
+
typbasetype: 0,
|
|
1791
|
+
typtypmod: -1,
|
|
1792
|
+
typndims: 0,
|
|
1793
|
+
typcollation: x,
|
|
1794
|
+
typdefaultbin: null,
|
|
1795
|
+
typdefault: null,
|
|
1796
|
+
typacl: null
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
const s = Object.entries(Z).map(([i, r]) => [Number(i), r]).sort((i, r) => i[0] - r[0]);
|
|
1800
|
+
for (const [i, r] of s) {
|
|
1801
|
+
let c = "";
|
|
1802
|
+
for (const [_, d] of a)
|
|
1803
|
+
if (_ === i) {
|
|
1804
|
+
c = d;
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
c && n.push({
|
|
1808
|
+
oid: r,
|
|
1809
|
+
typname: `_${c}`,
|
|
1810
|
+
typnamespace: t,
|
|
1811
|
+
typowner: T,
|
|
1812
|
+
typlen: -1,
|
|
1813
|
+
typbyval: !1,
|
|
1814
|
+
typtype: "b",
|
|
1815
|
+
typcategory: "A",
|
|
1816
|
+
typispreferred: !1,
|
|
1817
|
+
typisdefined: !0,
|
|
1818
|
+
typdelim: ",",
|
|
1819
|
+
typrelid: 0,
|
|
1820
|
+
typsubscript: "array_subscript_handler",
|
|
1821
|
+
typelem: i,
|
|
1822
|
+
typarray: 0,
|
|
1823
|
+
typinput: "array_in",
|
|
1824
|
+
typoutput: "array_out",
|
|
1825
|
+
typreceive: "array_recv",
|
|
1826
|
+
typsend: "array_send",
|
|
1827
|
+
typmodin: "",
|
|
1828
|
+
typmodout: "",
|
|
1829
|
+
typanalyze: "",
|
|
1830
|
+
typalign: "i",
|
|
1831
|
+
typstorage: "x",
|
|
1832
|
+
typnotnull: !1,
|
|
1833
|
+
typbasetype: 0,
|
|
1834
|
+
typtypmod: -1,
|
|
1835
|
+
typndims: 0,
|
|
1836
|
+
typcollation: 0,
|
|
1837
|
+
typdefaultbin: null,
|
|
1838
|
+
typdefault: null,
|
|
1839
|
+
typacl: null
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
for (const i of [...e._tables.keys()].sort()) {
|
|
1843
|
+
const r = l.get("table_type", i) ?? 0, c = l.get("table", i) ?? 0;
|
|
1844
|
+
n.push({
|
|
1845
|
+
oid: r,
|
|
1846
|
+
typname: i,
|
|
1847
|
+
typnamespace: U,
|
|
1848
|
+
typowner: T,
|
|
1849
|
+
typlen: -1,
|
|
1850
|
+
typbyval: !1,
|
|
1851
|
+
typtype: "c",
|
|
1852
|
+
typcategory: "C",
|
|
1853
|
+
typispreferred: !1,
|
|
1854
|
+
typisdefined: !0,
|
|
1855
|
+
typdelim: ",",
|
|
1856
|
+
typrelid: c,
|
|
1857
|
+
typsubscript: "",
|
|
1858
|
+
typelem: 0,
|
|
1859
|
+
typarray: 0,
|
|
1860
|
+
typinput: "record_in",
|
|
1861
|
+
typoutput: "record_out",
|
|
1862
|
+
typreceive: "record_recv",
|
|
1863
|
+
typsend: "record_send",
|
|
1864
|
+
typmodin: "",
|
|
1865
|
+
typmodout: "",
|
|
1866
|
+
typanalyze: "",
|
|
1867
|
+
typalign: "d",
|
|
1868
|
+
typstorage: "x",
|
|
1869
|
+
typnotnull: !1,
|
|
1870
|
+
typbasetype: 0,
|
|
1871
|
+
typtypmod: -1,
|
|
1872
|
+
typndims: 0,
|
|
1873
|
+
typcollation: 0,
|
|
1874
|
+
typdefaultbin: null,
|
|
1875
|
+
typdefault: null,
|
|
1876
|
+
typacl: null
|
|
1877
|
+
});
|
|
1878
|
+
}
|
|
1879
|
+
return [o, n];
|
|
1880
|
+
}
|
|
1881
|
+
// ==================================================================
|
|
1882
|
+
// pg_constraint
|
|
1883
|
+
// ==================================================================
|
|
1884
|
+
static _buildPgConstraint(e, l) {
|
|
1885
|
+
const o = [
|
|
1886
|
+
"oid",
|
|
1887
|
+
"conname",
|
|
1888
|
+
"connamespace",
|
|
1889
|
+
"contype",
|
|
1890
|
+
"condeferrable",
|
|
1891
|
+
"condeferred",
|
|
1892
|
+
"convalidated",
|
|
1893
|
+
"conrelid",
|
|
1894
|
+
"contypid",
|
|
1895
|
+
"conindid",
|
|
1896
|
+
"conparentid",
|
|
1897
|
+
"confrelid",
|
|
1898
|
+
"confupdtype",
|
|
1899
|
+
"confdeltype",
|
|
1900
|
+
"confmatchtype",
|
|
1901
|
+
"conislocal",
|
|
1902
|
+
"coninhcount",
|
|
1903
|
+
"connoinherit",
|
|
1904
|
+
"conkey",
|
|
1905
|
+
"confkey",
|
|
1906
|
+
"conpfeqop",
|
|
1907
|
+
"conppeqop",
|
|
1908
|
+
"conffeqop",
|
|
1909
|
+
"conexclop",
|
|
1910
|
+
"conbin"
|
|
1911
|
+
], t = [], n = U;
|
|
1912
|
+
for (const a of [...e._tables.keys()].sort()) {
|
|
1913
|
+
const s = e._tables.get(a), i = l.get("table", a) ?? 0, r = /* @__PURE__ */ new Map();
|
|
1914
|
+
let c = 0;
|
|
1915
|
+
for (const _ of s.columns.keys())
|
|
1916
|
+
c++, r.set(_, c);
|
|
1917
|
+
if (s.primaryKey) {
|
|
1918
|
+
const _ = `${a}_pkey`, d = l.get("constraint", _) ?? 0, v = l.get("index", _) ?? 0, p = r.get(s.primaryKey) ?? 1;
|
|
1919
|
+
t.push({
|
|
1920
|
+
oid: d,
|
|
1921
|
+
conname: _,
|
|
1922
|
+
connamespace: n,
|
|
1923
|
+
contype: "p",
|
|
1924
|
+
condeferrable: !1,
|
|
1925
|
+
condeferred: !1,
|
|
1926
|
+
convalidated: !0,
|
|
1927
|
+
conrelid: i,
|
|
1928
|
+
contypid: 0,
|
|
1929
|
+
conindid: v,
|
|
1930
|
+
conparentid: 0,
|
|
1931
|
+
confrelid: 0,
|
|
1932
|
+
confupdtype: " ",
|
|
1933
|
+
confdeltype: " ",
|
|
1934
|
+
confmatchtype: " ",
|
|
1935
|
+
conislocal: !0,
|
|
1936
|
+
coninhcount: 0,
|
|
1937
|
+
connoinherit: !0,
|
|
1938
|
+
conkey: `{${p}}`,
|
|
1939
|
+
confkey: null,
|
|
1940
|
+
conpfeqop: null,
|
|
1941
|
+
conppeqop: null,
|
|
1942
|
+
conffeqop: null,
|
|
1943
|
+
conexclop: null,
|
|
1944
|
+
conbin: null
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
for (const [_, d] of s.columns)
|
|
1948
|
+
if (d.unique && !d.primaryKey) {
|
|
1949
|
+
const v = `${a}_${_}_key`, p = l.get("constraint", v) ?? 0, f = l.get("index", v) ?? 0, b = r.get(_) ?? 1;
|
|
1950
|
+
t.push({
|
|
1951
|
+
oid: p,
|
|
1952
|
+
conname: v,
|
|
1953
|
+
connamespace: n,
|
|
1954
|
+
contype: "u",
|
|
1955
|
+
condeferrable: !1,
|
|
1956
|
+
condeferred: !1,
|
|
1957
|
+
convalidated: !0,
|
|
1958
|
+
conrelid: i,
|
|
1959
|
+
contypid: 0,
|
|
1960
|
+
conindid: f,
|
|
1961
|
+
conparentid: 0,
|
|
1962
|
+
confrelid: 0,
|
|
1963
|
+
confupdtype: " ",
|
|
1964
|
+
confdeltype: " ",
|
|
1965
|
+
confmatchtype: " ",
|
|
1966
|
+
conislocal: !0,
|
|
1967
|
+
coninhcount: 0,
|
|
1968
|
+
connoinherit: !0,
|
|
1969
|
+
conkey: `{${b}}`,
|
|
1970
|
+
confkey: null,
|
|
1971
|
+
conpfeqop: null,
|
|
1972
|
+
conppeqop: null,
|
|
1973
|
+
conffeqop: null,
|
|
1974
|
+
conexclop: null,
|
|
1975
|
+
conbin: null
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
for (const _ of s.foreignKeys) {
|
|
1979
|
+
const d = `${a}_${_.column}_fkey`, v = l.get("constraint", d) ?? 0, p = r.get(_.column) ?? 1, f = l.get("table", _.refTable) ?? 0, b = e._tables.get(_.refTable);
|
|
1980
|
+
let x = 1;
|
|
1981
|
+
if (b !== void 0) {
|
|
1982
|
+
const y = /* @__PURE__ */ new Map();
|
|
1983
|
+
let S = 0;
|
|
1984
|
+
for (const w of b.columns.keys())
|
|
1985
|
+
S++, y.set(w, S);
|
|
1986
|
+
x = y.get(_.refColumn) ?? 1;
|
|
1987
|
+
}
|
|
1988
|
+
t.push({
|
|
1989
|
+
oid: v,
|
|
1990
|
+
conname: d,
|
|
1991
|
+
connamespace: n,
|
|
1992
|
+
contype: "f",
|
|
1993
|
+
condeferrable: !1,
|
|
1994
|
+
condeferred: !1,
|
|
1995
|
+
convalidated: !0,
|
|
1996
|
+
conrelid: i,
|
|
1997
|
+
contypid: 0,
|
|
1998
|
+
conindid: 0,
|
|
1999
|
+
conparentid: 0,
|
|
2000
|
+
confrelid: f,
|
|
2001
|
+
confupdtype: "a",
|
|
2002
|
+
confdeltype: "a",
|
|
2003
|
+
confmatchtype: "s",
|
|
2004
|
+
conislocal: !0,
|
|
2005
|
+
coninhcount: 0,
|
|
2006
|
+
connoinherit: !0,
|
|
2007
|
+
conkey: `{${p}}`,
|
|
2008
|
+
confkey: `{${x}}`,
|
|
2009
|
+
conpfeqop: null,
|
|
2010
|
+
conppeqop: null,
|
|
2011
|
+
conffeqop: null,
|
|
2012
|
+
conexclop: null,
|
|
2013
|
+
conbin: null
|
|
2014
|
+
});
|
|
2015
|
+
}
|
|
2016
|
+
for (const [_] of s.checkConstraints) {
|
|
2017
|
+
const d = `${a}_${_}_check`, v = l.get("constraint", d) ?? 0;
|
|
2018
|
+
t.push({
|
|
2019
|
+
oid: v,
|
|
2020
|
+
conname: d,
|
|
2021
|
+
connamespace: n,
|
|
2022
|
+
contype: "c",
|
|
2023
|
+
condeferrable: !1,
|
|
2024
|
+
condeferred: !1,
|
|
2025
|
+
convalidated: !0,
|
|
2026
|
+
conrelid: i,
|
|
2027
|
+
contypid: 0,
|
|
2028
|
+
conindid: 0,
|
|
2029
|
+
conparentid: 0,
|
|
2030
|
+
confrelid: 0,
|
|
2031
|
+
confupdtype: " ",
|
|
2032
|
+
confdeltype: " ",
|
|
2033
|
+
confmatchtype: " ",
|
|
2034
|
+
conislocal: !0,
|
|
2035
|
+
coninhcount: 0,
|
|
2036
|
+
connoinherit: !0,
|
|
2037
|
+
conkey: null,
|
|
2038
|
+
confkey: null,
|
|
2039
|
+
conpfeqop: null,
|
|
2040
|
+
conppeqop: null,
|
|
2041
|
+
conffeqop: null,
|
|
2042
|
+
conexclop: null,
|
|
2043
|
+
conbin: null
|
|
2044
|
+
});
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
return [o, t];
|
|
2048
|
+
}
|
|
2049
|
+
// ==================================================================
|
|
2050
|
+
// pg_index
|
|
2051
|
+
// ==================================================================
|
|
2052
|
+
static _buildPgIndex(e, l) {
|
|
2053
|
+
const o = [
|
|
2054
|
+
"indexrelid",
|
|
2055
|
+
"indrelid",
|
|
2056
|
+
"indnatts",
|
|
2057
|
+
"indnkeyatts",
|
|
2058
|
+
"indisunique",
|
|
2059
|
+
"indisprimary",
|
|
2060
|
+
"indisexclusion",
|
|
2061
|
+
"indimmediate",
|
|
2062
|
+
"indisclustered",
|
|
2063
|
+
"indisvalid",
|
|
2064
|
+
"indcheckxmin",
|
|
2065
|
+
"indisready",
|
|
2066
|
+
"indislive",
|
|
2067
|
+
"indisreplident",
|
|
2068
|
+
"indkey",
|
|
2069
|
+
"indcollation",
|
|
2070
|
+
"indclass",
|
|
2071
|
+
"indoption",
|
|
2072
|
+
"indexprs",
|
|
2073
|
+
"indpred"
|
|
2074
|
+
], t = [], n = H(e);
|
|
2075
|
+
if (n !== null)
|
|
2076
|
+
for (const a of [...n.keys()].sort()) {
|
|
2077
|
+
const s = n.get(a), i = l.get("index", a) ?? 0, r = s.indexDef, c = l.get("table", r.tableName) ?? 0, _ = e._tables.get(r.tableName), d = r.columns.length, v = [];
|
|
2078
|
+
if (_ !== void 0) {
|
|
2079
|
+
const b = /* @__PURE__ */ new Map();
|
|
2080
|
+
let x = 0;
|
|
2081
|
+
for (const y of _.columns.keys())
|
|
2082
|
+
x++, b.set(y, x);
|
|
2083
|
+
for (const y of r.columns)
|
|
2084
|
+
v.push(String(b.get(y) ?? 0));
|
|
2085
|
+
}
|
|
2086
|
+
const p = v.length > 0 ? v.join(" ") : "0", f = r.unique ?? !1;
|
|
2087
|
+
t.push({
|
|
2088
|
+
indexrelid: i,
|
|
2089
|
+
indrelid: c,
|
|
2090
|
+
indnatts: d,
|
|
2091
|
+
indnkeyatts: d,
|
|
2092
|
+
indisunique: f,
|
|
2093
|
+
indisprimary: !1,
|
|
2094
|
+
indisexclusion: !1,
|
|
2095
|
+
indimmediate: !0,
|
|
2096
|
+
indisclustered: !1,
|
|
2097
|
+
indisvalid: !0,
|
|
2098
|
+
indcheckxmin: !1,
|
|
2099
|
+
indisready: !0,
|
|
2100
|
+
indislive: !0,
|
|
2101
|
+
indisreplident: !1,
|
|
2102
|
+
indkey: p,
|
|
2103
|
+
indcollation: "",
|
|
2104
|
+
indclass: "",
|
|
2105
|
+
indoption: "",
|
|
2106
|
+
indexprs: null,
|
|
2107
|
+
indpred: null
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
for (const a of [...e._tables.keys()].sort()) {
|
|
2111
|
+
const s = e._tables.get(a), i = l.get("table", a) ?? 0, r = /* @__PURE__ */ new Map();
|
|
2112
|
+
let c = 0;
|
|
2113
|
+
for (const _ of s.columns.keys())
|
|
2114
|
+
c++, r.set(_, c);
|
|
2115
|
+
if (s.primaryKey) {
|
|
2116
|
+
const _ = `${a}_pkey`, d = l.get("index", _) ?? 0, v = r.get(s.primaryKey) ?? 0;
|
|
2117
|
+
t.push({
|
|
2118
|
+
indexrelid: d,
|
|
2119
|
+
indrelid: i,
|
|
2120
|
+
indnatts: 1,
|
|
2121
|
+
indnkeyatts: 1,
|
|
2122
|
+
indisunique: !0,
|
|
2123
|
+
indisprimary: !0,
|
|
2124
|
+
indisexclusion: !1,
|
|
2125
|
+
indimmediate: !0,
|
|
2126
|
+
indisclustered: !1,
|
|
2127
|
+
indisvalid: !0,
|
|
2128
|
+
indcheckxmin: !1,
|
|
2129
|
+
indisready: !0,
|
|
2130
|
+
indislive: !0,
|
|
2131
|
+
indisreplident: !1,
|
|
2132
|
+
indkey: String(v),
|
|
2133
|
+
indcollation: "",
|
|
2134
|
+
indclass: "",
|
|
2135
|
+
indoption: "",
|
|
2136
|
+
indexprs: null,
|
|
2137
|
+
indpred: null
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
for (const [_, d] of s.columns)
|
|
2141
|
+
if (d.unique && !d.primaryKey) {
|
|
2142
|
+
const v = `${a}_${_}_key`, p = l.get("index", v) ?? 0, f = r.get(_) ?? 0;
|
|
2143
|
+
t.push({
|
|
2144
|
+
indexrelid: p,
|
|
2145
|
+
indrelid: i,
|
|
2146
|
+
indnatts: 1,
|
|
2147
|
+
indnkeyatts: 1,
|
|
2148
|
+
indisunique: !0,
|
|
2149
|
+
indisprimary: !1,
|
|
2150
|
+
indisexclusion: !1,
|
|
2151
|
+
indimmediate: !0,
|
|
2152
|
+
indisclustered: !1,
|
|
2153
|
+
indisvalid: !0,
|
|
2154
|
+
indcheckxmin: !1,
|
|
2155
|
+
indisready: !0,
|
|
2156
|
+
indislive: !0,
|
|
2157
|
+
indisreplident: !1,
|
|
2158
|
+
indkey: String(f),
|
|
2159
|
+
indcollation: "",
|
|
2160
|
+
indclass: "",
|
|
2161
|
+
indoption: "",
|
|
2162
|
+
indexprs: null,
|
|
2163
|
+
indpred: null
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
return [o, t];
|
|
2168
|
+
}
|
|
2169
|
+
// ==================================================================
|
|
2170
|
+
// pg_attrdef -- column defaults
|
|
2171
|
+
// ==================================================================
|
|
2172
|
+
static _buildPgAttrdef(e, l) {
|
|
2173
|
+
const o = ["oid", "adrelid", "adnum", "adbin"], t = [];
|
|
2174
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
2175
|
+
const a = e._tables.get(n), s = l.get("table", n) ?? 0;
|
|
2176
|
+
let i = 0;
|
|
2177
|
+
for (const [r, c] of a.columns)
|
|
2178
|
+
if (i++, c.defaultValue !== null && c.defaultValue !== void 0 || c.autoIncrement) {
|
|
2179
|
+
const _ = l.getOrAlloc("attrdef", `${n}.${r}`);
|
|
2180
|
+
let d;
|
|
2181
|
+
c.autoIncrement ? d = `nextval('${n}_${r}_seq'::regclass)` : d = String(c.defaultValue), t.push({
|
|
2182
|
+
oid: _,
|
|
2183
|
+
adrelid: s,
|
|
2184
|
+
adnum: i,
|
|
2185
|
+
adbin: d
|
|
2186
|
+
});
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
return [o, t];
|
|
2190
|
+
}
|
|
2191
|
+
// ==================================================================
|
|
2192
|
+
// pg_am -- access methods
|
|
2193
|
+
// ==================================================================
|
|
2194
|
+
static _buildPgAm(e, l) {
|
|
2195
|
+
return [["oid", "amname", "amhandler", "amtype"], [
|
|
2196
|
+
{
|
|
2197
|
+
oid: te,
|
|
2198
|
+
amname: "heap",
|
|
2199
|
+
amhandler: "heap_tableam_handler",
|
|
2200
|
+
amtype: "t"
|
|
2201
|
+
},
|
|
2202
|
+
{
|
|
2203
|
+
oid: z,
|
|
2204
|
+
amname: "btree",
|
|
2205
|
+
amhandler: "bthandler",
|
|
2206
|
+
amtype: "i"
|
|
2207
|
+
},
|
|
2208
|
+
{
|
|
2209
|
+
oid: pe,
|
|
2210
|
+
amname: "hash",
|
|
2211
|
+
amhandler: "hashhandler",
|
|
2212
|
+
amtype: "i"
|
|
2213
|
+
},
|
|
2214
|
+
{
|
|
2215
|
+
oid: fe,
|
|
2216
|
+
amname: "hnsw",
|
|
2217
|
+
amhandler: "hnsw_handler",
|
|
2218
|
+
amtype: "i"
|
|
2219
|
+
},
|
|
2220
|
+
{
|
|
2221
|
+
oid: ge,
|
|
2222
|
+
amname: "ivf",
|
|
2223
|
+
amhandler: "ivf_handler",
|
|
2224
|
+
amtype: "i"
|
|
2225
|
+
}
|
|
2226
|
+
]];
|
|
2227
|
+
}
|
|
2228
|
+
// ==================================================================
|
|
2229
|
+
// pg_database
|
|
2230
|
+
// ==================================================================
|
|
2231
|
+
static _buildPgDatabase(e, l) {
|
|
2232
|
+
return [[
|
|
2233
|
+
"oid",
|
|
2234
|
+
"datname",
|
|
2235
|
+
"datdba",
|
|
2236
|
+
"encoding",
|
|
2237
|
+
"datlocprovider",
|
|
2238
|
+
"datistemplate",
|
|
2239
|
+
"datallowconn",
|
|
2240
|
+
"datconnlimit",
|
|
2241
|
+
"datfrozenxid",
|
|
2242
|
+
"datminmxid",
|
|
2243
|
+
"dattablespace",
|
|
2244
|
+
"datcollate",
|
|
2245
|
+
"datctype",
|
|
2246
|
+
"datlocale",
|
|
2247
|
+
"datcollversion",
|
|
2248
|
+
"datacl"
|
|
2249
|
+
], [
|
|
2250
|
+
{
|
|
2251
|
+
oid: R,
|
|
2252
|
+
datname: G,
|
|
2253
|
+
datdba: T,
|
|
2254
|
+
encoding: ke,
|
|
2255
|
+
datlocprovider: "c",
|
|
2256
|
+
datistemplate: !1,
|
|
2257
|
+
datallowconn: !0,
|
|
2258
|
+
datconnlimit: -1,
|
|
2259
|
+
datfrozenxid: 0,
|
|
2260
|
+
datminmxid: 1,
|
|
2261
|
+
dattablespace: 1663,
|
|
2262
|
+
datcollate: "en_US.UTF-8",
|
|
2263
|
+
datctype: "en_US.UTF-8",
|
|
2264
|
+
datlocale: null,
|
|
2265
|
+
datcollversion: null,
|
|
2266
|
+
datacl: null
|
|
2267
|
+
}
|
|
2268
|
+
]];
|
|
2269
|
+
}
|
|
2270
|
+
// ==================================================================
|
|
2271
|
+
// pg_roles
|
|
2272
|
+
// ==================================================================
|
|
2273
|
+
static _buildPgRoles(e, l) {
|
|
2274
|
+
return [[
|
|
2275
|
+
"oid",
|
|
2276
|
+
"rolname",
|
|
2277
|
+
"rolsuper",
|
|
2278
|
+
"rolinherit",
|
|
2279
|
+
"rolcreaterole",
|
|
2280
|
+
"rolcreatedb",
|
|
2281
|
+
"rolcanlogin",
|
|
2282
|
+
"rolreplication",
|
|
2283
|
+
"rolconnlimit",
|
|
2284
|
+
"rolpassword",
|
|
2285
|
+
"rolvaliduntil",
|
|
2286
|
+
"rolbypassrls",
|
|
2287
|
+
"rolconfig"
|
|
2288
|
+
], [
|
|
2289
|
+
{
|
|
2290
|
+
oid: T,
|
|
2291
|
+
rolname: $,
|
|
2292
|
+
rolsuper: !0,
|
|
2293
|
+
rolinherit: !0,
|
|
2294
|
+
rolcreaterole: !0,
|
|
2295
|
+
rolcreatedb: !0,
|
|
2296
|
+
rolcanlogin: !0,
|
|
2297
|
+
rolreplication: !0,
|
|
2298
|
+
rolconnlimit: -1,
|
|
2299
|
+
rolpassword: null,
|
|
2300
|
+
rolvaliduntil: null,
|
|
2301
|
+
rolbypassrls: !0,
|
|
2302
|
+
rolconfig: null
|
|
2303
|
+
}
|
|
2304
|
+
]];
|
|
2305
|
+
}
|
|
2306
|
+
// ==================================================================
|
|
2307
|
+
// pg_user -- simplified view over pg_roles
|
|
2308
|
+
// ==================================================================
|
|
2309
|
+
static _buildPgUser(e, l) {
|
|
2310
|
+
return [[
|
|
2311
|
+
"usename",
|
|
2312
|
+
"usesysid",
|
|
2313
|
+
"usecreatedb",
|
|
2314
|
+
"usesuper",
|
|
2315
|
+
"userepl",
|
|
2316
|
+
"usebypassrls",
|
|
2317
|
+
"passwd",
|
|
2318
|
+
"valuntil",
|
|
2319
|
+
"useconfig"
|
|
2320
|
+
], [
|
|
2321
|
+
{
|
|
2322
|
+
usename: $,
|
|
2323
|
+
usesysid: T,
|
|
2324
|
+
usecreatedb: !0,
|
|
2325
|
+
usesuper: !0,
|
|
2326
|
+
userepl: !0,
|
|
2327
|
+
usebypassrls: !0,
|
|
2328
|
+
passwd: null,
|
|
2329
|
+
valuntil: null,
|
|
2330
|
+
useconfig: null
|
|
2331
|
+
}
|
|
2332
|
+
]];
|
|
2333
|
+
}
|
|
2334
|
+
// ==================================================================
|
|
2335
|
+
// pg_tables -- convenience view
|
|
2336
|
+
// ==================================================================
|
|
2337
|
+
static _buildPgTables(e, l) {
|
|
2338
|
+
const o = [
|
|
2339
|
+
"schemaname",
|
|
2340
|
+
"tablename",
|
|
2341
|
+
"tableowner",
|
|
2342
|
+
"tablespace",
|
|
2343
|
+
"hasindexes",
|
|
2344
|
+
"hasrules",
|
|
2345
|
+
"hastriggers",
|
|
2346
|
+
"rowsecurity"
|
|
2347
|
+
], t = [];
|
|
2348
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
2349
|
+
const a = e._tables.get(n), s = a.primaryKey !== null || [...a.columns.values()].some((i) => i.unique);
|
|
2350
|
+
t.push({
|
|
2351
|
+
schemaname: N,
|
|
2352
|
+
tablename: n,
|
|
2353
|
+
tableowner: $,
|
|
2354
|
+
tablespace: null,
|
|
2355
|
+
hasindexes: s,
|
|
2356
|
+
hasrules: !1,
|
|
2357
|
+
hastriggers: !1,
|
|
2358
|
+
rowsecurity: !1
|
|
2359
|
+
});
|
|
2360
|
+
}
|
|
2361
|
+
return [o, t];
|
|
2362
|
+
}
|
|
2363
|
+
// ==================================================================
|
|
2364
|
+
// pg_views -- convenience view
|
|
2365
|
+
// ==================================================================
|
|
2366
|
+
static _buildPgViews(e, l) {
|
|
2367
|
+
const o = ["schemaname", "viewname", "viewowner", "definition"], t = [];
|
|
2368
|
+
for (const n of [...e._views.keys()].sort())
|
|
2369
|
+
t.push({
|
|
2370
|
+
schemaname: N,
|
|
2371
|
+
viewname: n,
|
|
2372
|
+
viewowner: $,
|
|
2373
|
+
definition: ""
|
|
2374
|
+
});
|
|
2375
|
+
return [o, t];
|
|
2376
|
+
}
|
|
2377
|
+
// ==================================================================
|
|
2378
|
+
// pg_indexes -- convenience view
|
|
2379
|
+
// ==================================================================
|
|
2380
|
+
static _buildPgIndexes(e, l) {
|
|
2381
|
+
const o = ["schemaname", "tablename", "indexname", "tablespace", "indexdef"], t = [], n = H(e);
|
|
2382
|
+
if (n !== null)
|
|
2383
|
+
for (const a of [...n.keys()].sort()) {
|
|
2384
|
+
const i = n.get(a).indexDef, r = i.columns.join(", ");
|
|
2385
|
+
t.push({
|
|
2386
|
+
schemaname: N,
|
|
2387
|
+
tablename: i.tableName,
|
|
2388
|
+
indexname: a,
|
|
2389
|
+
tablespace: null,
|
|
2390
|
+
indexdef: `CREATE INDEX ${a} ON ${i.tableName} (${r})`
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
for (const a of [...e._tables.keys()].sort()) {
|
|
2394
|
+
const s = e._tables.get(a);
|
|
2395
|
+
if (s.primaryKey) {
|
|
2396
|
+
const i = `${a}_pkey`;
|
|
2397
|
+
t.push({
|
|
2398
|
+
schemaname: N,
|
|
2399
|
+
tablename: a,
|
|
2400
|
+
indexname: i,
|
|
2401
|
+
tablespace: null,
|
|
2402
|
+
indexdef: `CREATE UNIQUE INDEX ${i} ON ${a} (${s.primaryKey})`
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
for (const [i, r] of s.columns)
|
|
2406
|
+
if (r.unique && !r.primaryKey) {
|
|
2407
|
+
const c = `${a}_${i}_key`;
|
|
2408
|
+
t.push({
|
|
2409
|
+
schemaname: N,
|
|
2410
|
+
tablename: a,
|
|
2411
|
+
indexname: c,
|
|
2412
|
+
tablespace: null,
|
|
2413
|
+
indexdef: `CREATE UNIQUE INDEX ${c} ON ${a} (${i})`
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
return [o, t];
|
|
2418
|
+
}
|
|
2419
|
+
// ==================================================================
|
|
2420
|
+
// pg_matviews -- materialized views (empty, UQA has none)
|
|
2421
|
+
// ==================================================================
|
|
2422
|
+
static _buildPgMatviews(e, l) {
|
|
2423
|
+
return [[
|
|
2424
|
+
"schemaname",
|
|
2425
|
+
"matviewname",
|
|
2426
|
+
"matviewowner",
|
|
2427
|
+
"tablespace",
|
|
2428
|
+
"hasindexes",
|
|
2429
|
+
"ispopulated",
|
|
2430
|
+
"definition"
|
|
2431
|
+
], []];
|
|
2432
|
+
}
|
|
2433
|
+
// ==================================================================
|
|
2434
|
+
// pg_sequences
|
|
2435
|
+
// ==================================================================
|
|
2436
|
+
static _buildPgSequences(e, l) {
|
|
2437
|
+
const o = [
|
|
2438
|
+
"schemaname",
|
|
2439
|
+
"sequencename",
|
|
2440
|
+
"sequenceowner",
|
|
2441
|
+
"data_type",
|
|
2442
|
+
"start_value",
|
|
2443
|
+
"min_value",
|
|
2444
|
+
"max_value",
|
|
2445
|
+
"increment_by",
|
|
2446
|
+
"cycle",
|
|
2447
|
+
"cache_size",
|
|
2448
|
+
"last_value"
|
|
2449
|
+
], t = [];
|
|
2450
|
+
for (const n of [...e._sequences.keys()].sort()) {
|
|
2451
|
+
const a = e._sequences.get(n);
|
|
2452
|
+
t.push({
|
|
2453
|
+
schemaname: N,
|
|
2454
|
+
sequencename: n,
|
|
2455
|
+
sequenceowner: $,
|
|
2456
|
+
data_type: "bigint",
|
|
2457
|
+
start_value: a.start ?? 1,
|
|
2458
|
+
min_value: 1,
|
|
2459
|
+
max_value: 9223372036854776e3,
|
|
2460
|
+
increment_by: a.increment ?? 1,
|
|
2461
|
+
cycle: !1,
|
|
2462
|
+
cache_size: 1,
|
|
2463
|
+
last_value: a.current ?? a.start ?? 1
|
|
2464
|
+
});
|
|
2465
|
+
}
|
|
2466
|
+
return [o, t];
|
|
2467
|
+
}
|
|
2468
|
+
// ==================================================================
|
|
2469
|
+
// pg_settings -- runtime parameters (GUC)
|
|
2470
|
+
// ==================================================================
|
|
2471
|
+
static _buildPgSettings(e, l) {
|
|
2472
|
+
const o = [
|
|
2473
|
+
"name",
|
|
2474
|
+
"setting",
|
|
2475
|
+
"unit",
|
|
2476
|
+
"category",
|
|
2477
|
+
"short_desc",
|
|
2478
|
+
"extra_desc",
|
|
2479
|
+
"context",
|
|
2480
|
+
"vartype",
|
|
2481
|
+
"source",
|
|
2482
|
+
"min_val",
|
|
2483
|
+
"max_val",
|
|
2484
|
+
"enumvals",
|
|
2485
|
+
"boot_val",
|
|
2486
|
+
"reset_val",
|
|
2487
|
+
"sourcefile",
|
|
2488
|
+
"sourceline",
|
|
2489
|
+
"pending_restart"
|
|
2490
|
+
], t = [
|
|
2491
|
+
[
|
|
2492
|
+
"server_version",
|
|
2493
|
+
"17.0",
|
|
2494
|
+
null,
|
|
2495
|
+
"Preset Options",
|
|
2496
|
+
"Shows the server version.",
|
|
2497
|
+
null,
|
|
2498
|
+
"internal",
|
|
2499
|
+
"string",
|
|
2500
|
+
"default",
|
|
2501
|
+
null,
|
|
2502
|
+
null,
|
|
2503
|
+
null,
|
|
2504
|
+
"17.0",
|
|
2505
|
+
"17.0",
|
|
2506
|
+
null,
|
|
2507
|
+
null,
|
|
2508
|
+
!1
|
|
2509
|
+
],
|
|
2510
|
+
[
|
|
2511
|
+
"server_version_num",
|
|
2512
|
+
"170000",
|
|
2513
|
+
null,
|
|
2514
|
+
"Preset Options",
|
|
2515
|
+
"Shows the server version as an integer.",
|
|
2516
|
+
null,
|
|
2517
|
+
"internal",
|
|
2518
|
+
"integer",
|
|
2519
|
+
"default",
|
|
2520
|
+
null,
|
|
2521
|
+
null,
|
|
2522
|
+
null,
|
|
2523
|
+
"170000",
|
|
2524
|
+
"170000",
|
|
2525
|
+
null,
|
|
2526
|
+
null,
|
|
2527
|
+
!1
|
|
2528
|
+
],
|
|
2529
|
+
[
|
|
2530
|
+
"server_encoding",
|
|
2531
|
+
"UTF8",
|
|
2532
|
+
null,
|
|
2533
|
+
"Preset Options",
|
|
2534
|
+
"Shows the server encoding.",
|
|
2535
|
+
null,
|
|
2536
|
+
"internal",
|
|
2537
|
+
"string",
|
|
2538
|
+
"default",
|
|
2539
|
+
null,
|
|
2540
|
+
null,
|
|
2541
|
+
null,
|
|
2542
|
+
"UTF8",
|
|
2543
|
+
"UTF8",
|
|
2544
|
+
null,
|
|
2545
|
+
null,
|
|
2546
|
+
!1
|
|
2547
|
+
],
|
|
2548
|
+
[
|
|
2549
|
+
"client_encoding",
|
|
2550
|
+
"UTF8",
|
|
2551
|
+
null,
|
|
2552
|
+
"Client Connection Defaults",
|
|
2553
|
+
"Sets the client encoding.",
|
|
2554
|
+
null,
|
|
2555
|
+
"user",
|
|
2556
|
+
"string",
|
|
2557
|
+
"default",
|
|
2558
|
+
null,
|
|
2559
|
+
null,
|
|
2560
|
+
null,
|
|
2561
|
+
"UTF8",
|
|
2562
|
+
"UTF8",
|
|
2563
|
+
null,
|
|
2564
|
+
null,
|
|
2565
|
+
!1
|
|
2566
|
+
],
|
|
2567
|
+
[
|
|
2568
|
+
"lc_collate",
|
|
2569
|
+
"en_US.UTF-8",
|
|
2570
|
+
null,
|
|
2571
|
+
"Preset Options",
|
|
2572
|
+
"Shows the collation order locale.",
|
|
2573
|
+
null,
|
|
2574
|
+
"internal",
|
|
2575
|
+
"string",
|
|
2576
|
+
"default",
|
|
2577
|
+
null,
|
|
2578
|
+
null,
|
|
2579
|
+
null,
|
|
2580
|
+
"en_US.UTF-8",
|
|
2581
|
+
"en_US.UTF-8",
|
|
2582
|
+
null,
|
|
2583
|
+
null,
|
|
2584
|
+
!1
|
|
2585
|
+
],
|
|
2586
|
+
[
|
|
2587
|
+
"lc_ctype",
|
|
2588
|
+
"en_US.UTF-8",
|
|
2589
|
+
null,
|
|
2590
|
+
"Preset Options",
|
|
2591
|
+
"Shows the character classification locale.",
|
|
2592
|
+
null,
|
|
2593
|
+
"internal",
|
|
2594
|
+
"string",
|
|
2595
|
+
"default",
|
|
2596
|
+
null,
|
|
2597
|
+
null,
|
|
2598
|
+
null,
|
|
2599
|
+
"en_US.UTF-8",
|
|
2600
|
+
"en_US.UTF-8",
|
|
2601
|
+
null,
|
|
2602
|
+
null,
|
|
2603
|
+
!1
|
|
2604
|
+
],
|
|
2605
|
+
[
|
|
2606
|
+
"DateStyle",
|
|
2607
|
+
"ISO, MDY",
|
|
2608
|
+
null,
|
|
2609
|
+
"Client Connection Defaults",
|
|
2610
|
+
"Sets the display format for date and time.",
|
|
2611
|
+
null,
|
|
2612
|
+
"user",
|
|
2613
|
+
"string",
|
|
2614
|
+
"default",
|
|
2615
|
+
null,
|
|
2616
|
+
null,
|
|
2617
|
+
null,
|
|
2618
|
+
"ISO, MDY",
|
|
2619
|
+
"ISO, MDY",
|
|
2620
|
+
null,
|
|
2621
|
+
null,
|
|
2622
|
+
!1
|
|
2623
|
+
],
|
|
2624
|
+
[
|
|
2625
|
+
"TimeZone",
|
|
2626
|
+
"UTC",
|
|
2627
|
+
null,
|
|
2628
|
+
"Client Connection Defaults",
|
|
2629
|
+
"Sets the time zone.",
|
|
2630
|
+
null,
|
|
2631
|
+
"user",
|
|
2632
|
+
"string",
|
|
2633
|
+
"default",
|
|
2634
|
+
null,
|
|
2635
|
+
null,
|
|
2636
|
+
null,
|
|
2637
|
+
"UTC",
|
|
2638
|
+
"UTC",
|
|
2639
|
+
null,
|
|
2640
|
+
null,
|
|
2641
|
+
!1
|
|
2642
|
+
],
|
|
2643
|
+
[
|
|
2644
|
+
"standard_conforming_strings",
|
|
2645
|
+
"on",
|
|
2646
|
+
null,
|
|
2647
|
+
"Client Connection Defaults",
|
|
2648
|
+
"Causes strings to treat backslashes literally.",
|
|
2649
|
+
null,
|
|
2650
|
+
"user",
|
|
2651
|
+
"bool",
|
|
2652
|
+
"default",
|
|
2653
|
+
null,
|
|
2654
|
+
null,
|
|
2655
|
+
null,
|
|
2656
|
+
"on",
|
|
2657
|
+
"on",
|
|
2658
|
+
null,
|
|
2659
|
+
null,
|
|
2660
|
+
!1
|
|
2661
|
+
],
|
|
2662
|
+
[
|
|
2663
|
+
"search_path",
|
|
2664
|
+
'"$user", public',
|
|
2665
|
+
null,
|
|
2666
|
+
"Client Connection Defaults",
|
|
2667
|
+
"Sets the schema search order.",
|
|
2668
|
+
null,
|
|
2669
|
+
"user",
|
|
2670
|
+
"string",
|
|
2671
|
+
"default",
|
|
2672
|
+
null,
|
|
2673
|
+
null,
|
|
2674
|
+
null,
|
|
2675
|
+
'"$user", public',
|
|
2676
|
+
'"$user", public',
|
|
2677
|
+
null,
|
|
2678
|
+
null,
|
|
2679
|
+
!1
|
|
2680
|
+
],
|
|
2681
|
+
[
|
|
2682
|
+
"default_transaction_isolation",
|
|
2683
|
+
"read committed",
|
|
2684
|
+
null,
|
|
2685
|
+
"Client Connection Defaults",
|
|
2686
|
+
"Sets the default transaction isolation level.",
|
|
2687
|
+
null,
|
|
2688
|
+
"user",
|
|
2689
|
+
"enum",
|
|
2690
|
+
"default",
|
|
2691
|
+
null,
|
|
2692
|
+
null,
|
|
2693
|
+
"serializable,repeatable read,read committed,read uncommitted",
|
|
2694
|
+
"read committed",
|
|
2695
|
+
"read committed",
|
|
2696
|
+
null,
|
|
2697
|
+
null,
|
|
2698
|
+
!1
|
|
2699
|
+
],
|
|
2700
|
+
[
|
|
2701
|
+
"max_connections",
|
|
2702
|
+
"100",
|
|
2703
|
+
null,
|
|
2704
|
+
"Connections and Authentication",
|
|
2705
|
+
"Sets the maximum number of concurrent connections.",
|
|
2706
|
+
null,
|
|
2707
|
+
"postmaster",
|
|
2708
|
+
"integer",
|
|
2709
|
+
"default",
|
|
2710
|
+
"1",
|
|
2711
|
+
"262143",
|
|
2712
|
+
null,
|
|
2713
|
+
"100",
|
|
2714
|
+
"100",
|
|
2715
|
+
null,
|
|
2716
|
+
null,
|
|
2717
|
+
!1
|
|
2718
|
+
],
|
|
2719
|
+
[
|
|
2720
|
+
"shared_buffers",
|
|
2721
|
+
"16384",
|
|
2722
|
+
"8kB",
|
|
2723
|
+
"Resource Usage / Memory",
|
|
2724
|
+
"Sets the number of shared memory buffers.",
|
|
2725
|
+
null,
|
|
2726
|
+
"postmaster",
|
|
2727
|
+
"integer",
|
|
2728
|
+
"default",
|
|
2729
|
+
"16",
|
|
2730
|
+
"1073741823",
|
|
2731
|
+
null,
|
|
2732
|
+
"16384",
|
|
2733
|
+
"16384",
|
|
2734
|
+
null,
|
|
2735
|
+
null,
|
|
2736
|
+
!1
|
|
2737
|
+
],
|
|
2738
|
+
[
|
|
2739
|
+
"work_mem",
|
|
2740
|
+
"4096",
|
|
2741
|
+
"kB",
|
|
2742
|
+
"Resource Usage / Memory",
|
|
2743
|
+
"Sets the maximum memory for query operations.",
|
|
2744
|
+
null,
|
|
2745
|
+
"user",
|
|
2746
|
+
"integer",
|
|
2747
|
+
"default",
|
|
2748
|
+
"64",
|
|
2749
|
+
"2147483647",
|
|
2750
|
+
null,
|
|
2751
|
+
"4096",
|
|
2752
|
+
"4096",
|
|
2753
|
+
null,
|
|
2754
|
+
null,
|
|
2755
|
+
!1
|
|
2756
|
+
],
|
|
2757
|
+
[
|
|
2758
|
+
"is_superuser",
|
|
2759
|
+
"on",
|
|
2760
|
+
null,
|
|
2761
|
+
"Preset Options",
|
|
2762
|
+
"Shows whether the current user is a superuser.",
|
|
2763
|
+
null,
|
|
2764
|
+
"internal",
|
|
2765
|
+
"bool",
|
|
2766
|
+
"default",
|
|
2767
|
+
null,
|
|
2768
|
+
null,
|
|
2769
|
+
null,
|
|
2770
|
+
"on",
|
|
2771
|
+
"on",
|
|
2772
|
+
null,
|
|
2773
|
+
null,
|
|
2774
|
+
!1
|
|
2775
|
+
],
|
|
2776
|
+
[
|
|
2777
|
+
"transaction_isolation",
|
|
2778
|
+
"read committed",
|
|
2779
|
+
null,
|
|
2780
|
+
"Client Connection Defaults",
|
|
2781
|
+
"Shows the current transaction isolation level.",
|
|
2782
|
+
null,
|
|
2783
|
+
"user",
|
|
2784
|
+
"string",
|
|
2785
|
+
"override",
|
|
2786
|
+
null,
|
|
2787
|
+
null,
|
|
2788
|
+
null,
|
|
2789
|
+
"read committed",
|
|
2790
|
+
"read committed",
|
|
2791
|
+
null,
|
|
2792
|
+
null,
|
|
2793
|
+
!1
|
|
2794
|
+
],
|
|
2795
|
+
[
|
|
2796
|
+
"integer_datetimes",
|
|
2797
|
+
"on",
|
|
2798
|
+
null,
|
|
2799
|
+
"Preset Options",
|
|
2800
|
+
"Shows if datetimes are stored as 64-bit integers.",
|
|
2801
|
+
null,
|
|
2802
|
+
"internal",
|
|
2803
|
+
"bool",
|
|
2804
|
+
"default",
|
|
2805
|
+
null,
|
|
2806
|
+
null,
|
|
2807
|
+
null,
|
|
2808
|
+
"on",
|
|
2809
|
+
"on",
|
|
2810
|
+
null,
|
|
2811
|
+
null,
|
|
2812
|
+
!1
|
|
2813
|
+
]
|
|
2814
|
+
], n = [];
|
|
2815
|
+
for (const a of t)
|
|
2816
|
+
n.push({
|
|
2817
|
+
name: a[0],
|
|
2818
|
+
setting: a[1],
|
|
2819
|
+
unit: a[2],
|
|
2820
|
+
category: a[3],
|
|
2821
|
+
short_desc: a[4],
|
|
2822
|
+
extra_desc: a[5],
|
|
2823
|
+
context: a[6],
|
|
2824
|
+
vartype: a[7],
|
|
2825
|
+
source: a[8],
|
|
2826
|
+
min_val: a[9],
|
|
2827
|
+
max_val: a[10],
|
|
2828
|
+
enumvals: a[11],
|
|
2829
|
+
boot_val: a[12],
|
|
2830
|
+
reset_val: a[13],
|
|
2831
|
+
sourcefile: a[14],
|
|
2832
|
+
sourceline: a[15],
|
|
2833
|
+
pending_restart: a[16]
|
|
2834
|
+
});
|
|
2835
|
+
return [o, n];
|
|
2836
|
+
}
|
|
2837
|
+
// ==================================================================
|
|
2838
|
+
// pg_foreign_server
|
|
2839
|
+
// ==================================================================
|
|
2840
|
+
static _buildPgForeignServer(e, l) {
|
|
2841
|
+
const o = [
|
|
2842
|
+
"oid",
|
|
2843
|
+
"srvname",
|
|
2844
|
+
"srvowner",
|
|
2845
|
+
"srvfdw",
|
|
2846
|
+
"srvtype",
|
|
2847
|
+
"srvversion",
|
|
2848
|
+
"srvacl",
|
|
2849
|
+
"srvoptions"
|
|
2850
|
+
], t = [];
|
|
2851
|
+
for (const n of [...e._foreignServers.keys()].sort()) {
|
|
2852
|
+
const a = e._foreignServers.get(n), s = l.get("foreign_server", n) ?? 0, i = l.get("fdw", a.fdwType) ?? 0, r = Object.entries(a.options).sort(([c], [_]) => c.localeCompare(_)).map(([c, _]) => `${c}=${_}`);
|
|
2853
|
+
t.push({
|
|
2854
|
+
oid: s,
|
|
2855
|
+
srvname: n,
|
|
2856
|
+
srvowner: T,
|
|
2857
|
+
srvfdw: i,
|
|
2858
|
+
srvtype: null,
|
|
2859
|
+
srvversion: null,
|
|
2860
|
+
srvacl: null,
|
|
2861
|
+
srvoptions: r.length > 0 ? `{${r.join(",")}}` : null
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
return [o, t];
|
|
2865
|
+
}
|
|
2866
|
+
// ==================================================================
|
|
2867
|
+
// pg_foreign_table
|
|
2868
|
+
// ==================================================================
|
|
2869
|
+
static _buildPgForeignTable(e, l) {
|
|
2870
|
+
const o = ["ftrelid", "ftserver", "ftoptions"], t = [];
|
|
2871
|
+
for (const n of [...e._foreignTables.keys()].sort()) {
|
|
2872
|
+
const a = e._foreignTables.get(n), s = l.get("foreign_table", n) ?? 0, i = l.get("foreign_server", a.serverName) ?? 0, r = Object.entries(a.options).sort(([c], [_]) => c.localeCompare(_)).map(([c, _]) => `${c}=${_}`);
|
|
2873
|
+
t.push({
|
|
2874
|
+
ftrelid: s,
|
|
2875
|
+
ftserver: i,
|
|
2876
|
+
ftoptions: r.length > 0 ? `{${r.join(",")}}` : null
|
|
2877
|
+
});
|
|
2878
|
+
}
|
|
2879
|
+
return [o, t];
|
|
2880
|
+
}
|
|
2881
|
+
// ==================================================================
|
|
2882
|
+
// pg_foreign_data_wrapper
|
|
2883
|
+
// ==================================================================
|
|
2884
|
+
static _buildPgForeignDataWrapper(e, l) {
|
|
2885
|
+
const o = [
|
|
2886
|
+
"oid",
|
|
2887
|
+
"fdwname",
|
|
2888
|
+
"fdwowner",
|
|
2889
|
+
"fdwhandler",
|
|
2890
|
+
"fdwvalidator",
|
|
2891
|
+
"fdwacl",
|
|
2892
|
+
"fdwoptions"
|
|
2893
|
+
], t = [], n = /* @__PURE__ */ new Set();
|
|
2894
|
+
for (const a of [...e._foreignServers.keys()].sort()) {
|
|
2895
|
+
const s = e._foreignServers.get(a);
|
|
2896
|
+
if (n.has(s.fdwType)) continue;
|
|
2897
|
+
n.add(s.fdwType);
|
|
2898
|
+
const i = l.get("fdw", s.fdwType) ?? 0;
|
|
2899
|
+
t.push({
|
|
2900
|
+
oid: i,
|
|
2901
|
+
fdwname: s.fdwType,
|
|
2902
|
+
fdwowner: T,
|
|
2903
|
+
fdwhandler: 0,
|
|
2904
|
+
fdwvalidator: 0,
|
|
2905
|
+
fdwacl: null,
|
|
2906
|
+
fdwoptions: null
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
return [o, t];
|
|
2910
|
+
}
|
|
2911
|
+
// ==================================================================
|
|
2912
|
+
// pg_description -- object comments
|
|
2913
|
+
// ==================================================================
|
|
2914
|
+
static _buildPgDescription(e, l) {
|
|
2915
|
+
return [["objoid", "classoid", "objsubid", "description"], []];
|
|
2916
|
+
}
|
|
2917
|
+
// ==================================================================
|
|
2918
|
+
// pg_depend -- object dependencies
|
|
2919
|
+
// ==================================================================
|
|
2920
|
+
static _buildPgDepend(e, l) {
|
|
2921
|
+
return [[
|
|
2922
|
+
"classid",
|
|
2923
|
+
"objid",
|
|
2924
|
+
"objsubid",
|
|
2925
|
+
"refclassid",
|
|
2926
|
+
"refobjid",
|
|
2927
|
+
"refobjsubid",
|
|
2928
|
+
"deptype"
|
|
2929
|
+
], []];
|
|
2930
|
+
}
|
|
2931
|
+
// ==================================================================
|
|
2932
|
+
// pg_stat_user_tables (also used for pg_stat_all_tables)
|
|
2933
|
+
// ==================================================================
|
|
2934
|
+
static _buildPgStatUserTables(e, l) {
|
|
2935
|
+
const o = [
|
|
2936
|
+
"relid",
|
|
2937
|
+
"schemaname",
|
|
2938
|
+
"relname",
|
|
2939
|
+
"seq_scan",
|
|
2940
|
+
"seq_tup_read",
|
|
2941
|
+
"idx_scan",
|
|
2942
|
+
"idx_tup_fetch",
|
|
2943
|
+
"n_tup_ins",
|
|
2944
|
+
"n_tup_upd",
|
|
2945
|
+
"n_tup_del",
|
|
2946
|
+
"n_tup_hot_upd",
|
|
2947
|
+
"n_live_tup",
|
|
2948
|
+
"n_dead_tup",
|
|
2949
|
+
"n_mod_since_analyze",
|
|
2950
|
+
"n_ins_since_vacuum",
|
|
2951
|
+
"last_vacuum",
|
|
2952
|
+
"last_autovacuum",
|
|
2953
|
+
"last_analyze",
|
|
2954
|
+
"last_autoanalyze",
|
|
2955
|
+
"vacuum_count",
|
|
2956
|
+
"autovacuum_count",
|
|
2957
|
+
"analyze_count",
|
|
2958
|
+
"autoanalyze_count"
|
|
2959
|
+
], t = [];
|
|
2960
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
2961
|
+
const a = e._tables.get(n), s = l.get("table", n) ?? 0, i = a.rowCount, r = !!a._stats;
|
|
2962
|
+
t.push({
|
|
2963
|
+
relid: s,
|
|
2964
|
+
schemaname: N,
|
|
2965
|
+
relname: n,
|
|
2966
|
+
seq_scan: 0,
|
|
2967
|
+
seq_tup_read: 0,
|
|
2968
|
+
idx_scan: 0,
|
|
2969
|
+
idx_tup_fetch: 0,
|
|
2970
|
+
n_tup_ins: i,
|
|
2971
|
+
n_tup_upd: 0,
|
|
2972
|
+
n_tup_del: 0,
|
|
2973
|
+
n_tup_hot_upd: 0,
|
|
2974
|
+
n_live_tup: i,
|
|
2975
|
+
n_dead_tup: 0,
|
|
2976
|
+
n_mod_since_analyze: r ? 0 : i,
|
|
2977
|
+
n_ins_since_vacuum: i,
|
|
2978
|
+
last_vacuum: null,
|
|
2979
|
+
last_autovacuum: null,
|
|
2980
|
+
last_analyze: null,
|
|
2981
|
+
last_autoanalyze: null,
|
|
2982
|
+
vacuum_count: 0,
|
|
2983
|
+
autovacuum_count: 0,
|
|
2984
|
+
analyze_count: r ? 1 : 0,
|
|
2985
|
+
autoanalyze_count: 0
|
|
2986
|
+
});
|
|
2987
|
+
}
|
|
2988
|
+
return [o, t];
|
|
2989
|
+
}
|
|
2990
|
+
// ==================================================================
|
|
2991
|
+
// pg_stat_user_indexes
|
|
2992
|
+
// ==================================================================
|
|
2993
|
+
static _buildPgStatUserIndexes(e, l) {
|
|
2994
|
+
const o = [
|
|
2995
|
+
"relid",
|
|
2996
|
+
"indexrelid",
|
|
2997
|
+
"schemaname",
|
|
2998
|
+
"relname",
|
|
2999
|
+
"indexrelname",
|
|
3000
|
+
"idx_scan",
|
|
3001
|
+
"idx_tup_read",
|
|
3002
|
+
"idx_tup_fetch"
|
|
3003
|
+
], t = [];
|
|
3004
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
3005
|
+
const a = e._tables.get(n), s = l.get("table", n) ?? 0;
|
|
3006
|
+
if (a.primaryKey) {
|
|
3007
|
+
const i = `${n}_pkey`, r = l.get("index", i) ?? 0;
|
|
3008
|
+
t.push({
|
|
3009
|
+
relid: s,
|
|
3010
|
+
indexrelid: r,
|
|
3011
|
+
schemaname: N,
|
|
3012
|
+
relname: n,
|
|
3013
|
+
indexrelname: i,
|
|
3014
|
+
idx_scan: 0,
|
|
3015
|
+
idx_tup_read: 0,
|
|
3016
|
+
idx_tup_fetch: 0
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
for (const [i, r] of a.columns)
|
|
3020
|
+
if (r.unique && !r.primaryKey) {
|
|
3021
|
+
const c = `${n}_${i}_key`, _ = l.get("index", c) ?? 0;
|
|
3022
|
+
t.push({
|
|
3023
|
+
relid: s,
|
|
3024
|
+
indexrelid: _,
|
|
3025
|
+
schemaname: N,
|
|
3026
|
+
relname: n,
|
|
3027
|
+
indexrelname: c,
|
|
3028
|
+
idx_scan: 0,
|
|
3029
|
+
idx_tup_read: 0,
|
|
3030
|
+
idx_tup_fetch: 0
|
|
3031
|
+
});
|
|
3032
|
+
}
|
|
3033
|
+
}
|
|
3034
|
+
return [o, t];
|
|
3035
|
+
}
|
|
3036
|
+
// ==================================================================
|
|
3037
|
+
// pg_stat_activity -- active sessions
|
|
3038
|
+
// ==================================================================
|
|
3039
|
+
static _buildPgStatActivity(e, l) {
|
|
3040
|
+
const o = [
|
|
3041
|
+
"datid",
|
|
3042
|
+
"datname",
|
|
3043
|
+
"pid",
|
|
3044
|
+
"leader_pid",
|
|
3045
|
+
"usesysid",
|
|
3046
|
+
"usename",
|
|
3047
|
+
"application_name",
|
|
3048
|
+
"client_addr",
|
|
3049
|
+
"client_hostname",
|
|
3050
|
+
"client_port",
|
|
3051
|
+
"backend_start",
|
|
3052
|
+
"xact_start",
|
|
3053
|
+
"query_start",
|
|
3054
|
+
"state_change",
|
|
3055
|
+
"wait_event_type",
|
|
3056
|
+
"wait_event",
|
|
3057
|
+
"state",
|
|
3058
|
+
"backend_xid",
|
|
3059
|
+
"backend_xmin",
|
|
3060
|
+
"query_id",
|
|
3061
|
+
"query",
|
|
3062
|
+
"backend_type"
|
|
3063
|
+
], t = xe();
|
|
3064
|
+
let n;
|
|
3065
|
+
return t.length > 0 ? n = t.map((a) => {
|
|
3066
|
+
var s, i, r, c;
|
|
3067
|
+
return {
|
|
3068
|
+
datid: R,
|
|
3069
|
+
datname: a.database || G,
|
|
3070
|
+
pid: a.pid,
|
|
3071
|
+
leader_pid: null,
|
|
3072
|
+
usesysid: T,
|
|
3073
|
+
usename: a.username || $,
|
|
3074
|
+
application_name: a.applicationName,
|
|
3075
|
+
client_addr: a.clientAddr,
|
|
3076
|
+
client_hostname: null,
|
|
3077
|
+
client_port: a.clientPort,
|
|
3078
|
+
backend_start: ((s = a.backendStart) == null ? void 0 : s.toISOString()) ?? null,
|
|
3079
|
+
xact_start: ((i = a.xactStart) == null ? void 0 : i.toISOString()) ?? null,
|
|
3080
|
+
query_start: ((r = a.queryStart) == null ? void 0 : r.toISOString()) ?? null,
|
|
3081
|
+
state_change: ((c = a.stateChange) == null ? void 0 : c.toISOString()) ?? null,
|
|
3082
|
+
wait_event_type: null,
|
|
3083
|
+
wait_event: null,
|
|
3084
|
+
state: a.state,
|
|
3085
|
+
backend_xid: null,
|
|
3086
|
+
backend_xmin: null,
|
|
3087
|
+
query_id: null,
|
|
3088
|
+
query: a.query,
|
|
3089
|
+
backend_type: a.backendType
|
|
3090
|
+
};
|
|
3091
|
+
}) : n = [
|
|
3092
|
+
{
|
|
3093
|
+
datid: R,
|
|
3094
|
+
datname: G,
|
|
3095
|
+
pid: process.pid,
|
|
3096
|
+
leader_pid: null,
|
|
3097
|
+
usesysid: T,
|
|
3098
|
+
usename: $,
|
|
3099
|
+
application_name: "usqldb",
|
|
3100
|
+
client_addr: null,
|
|
3101
|
+
client_hostname: null,
|
|
3102
|
+
client_port: -1,
|
|
3103
|
+
backend_start: null,
|
|
3104
|
+
xact_start: null,
|
|
3105
|
+
query_start: null,
|
|
3106
|
+
state_change: null,
|
|
3107
|
+
wait_event_type: null,
|
|
3108
|
+
wait_event: null,
|
|
3109
|
+
state: "active",
|
|
3110
|
+
backend_xid: null,
|
|
3111
|
+
backend_xmin: null,
|
|
3112
|
+
query_id: null,
|
|
3113
|
+
query: "",
|
|
3114
|
+
backend_type: "client backend"
|
|
3115
|
+
}
|
|
3116
|
+
], [o, n];
|
|
3117
|
+
}
|
|
3118
|
+
// ==================================================================
|
|
3119
|
+
// pg_proc -- functions/procedures
|
|
3120
|
+
// ==================================================================
|
|
3121
|
+
static _buildPgProc(e, l) {
|
|
3122
|
+
const o = [
|
|
3123
|
+
"oid",
|
|
3124
|
+
"proname",
|
|
3125
|
+
"pronamespace",
|
|
3126
|
+
"proowner",
|
|
3127
|
+
"prolang",
|
|
3128
|
+
"procost",
|
|
3129
|
+
"prorows",
|
|
3130
|
+
"provariadic",
|
|
3131
|
+
"prosupport",
|
|
3132
|
+
"prokind",
|
|
3133
|
+
"prosecdef",
|
|
3134
|
+
"proleakproof",
|
|
3135
|
+
"proisstrict",
|
|
3136
|
+
"proretset",
|
|
3137
|
+
"provolatile",
|
|
3138
|
+
"proparallel",
|
|
3139
|
+
"pronargs",
|
|
3140
|
+
"pronargdefaults",
|
|
3141
|
+
"prorettype",
|
|
3142
|
+
"proargtypes",
|
|
3143
|
+
"proallargtypes",
|
|
3144
|
+
"proargmodes",
|
|
3145
|
+
"proargnames",
|
|
3146
|
+
"proargdefaults",
|
|
3147
|
+
"protrftypes",
|
|
3148
|
+
"prosrc",
|
|
3149
|
+
"probin",
|
|
3150
|
+
"prosqlbody",
|
|
3151
|
+
"proconfig",
|
|
3152
|
+
"proacl"
|
|
3153
|
+
], t = [
|
|
3154
|
+
["text_match", 2, 25, "25 25"],
|
|
3155
|
+
["bayesian_match", 2, 25, "25 25"],
|
|
3156
|
+
["knn_match", 3, 25, "25 2277 23"],
|
|
3157
|
+
["traverse_match", 3, 25, "23 25 23"],
|
|
3158
|
+
["fuse_log_odds", 0, 25, ""],
|
|
3159
|
+
["fuse_prob_and", 0, 25, ""],
|
|
3160
|
+
["fuse_prob_or", 0, 25, ""],
|
|
3161
|
+
["fuse_prob_not", 1, 25, "25"],
|
|
3162
|
+
["spatial_within", 4, 25, "25 600 600 701"]
|
|
3163
|
+
], n = [], a = U;
|
|
3164
|
+
for (const [s, i, r, c] of t) {
|
|
3165
|
+
const _ = l.getOrAlloc("function", s);
|
|
3166
|
+
n.push({
|
|
3167
|
+
oid: _,
|
|
3168
|
+
proname: s,
|
|
3169
|
+
pronamespace: a,
|
|
3170
|
+
proowner: T,
|
|
3171
|
+
prolang: 14,
|
|
3172
|
+
// SQL
|
|
3173
|
+
procost: 100,
|
|
3174
|
+
prorows: 0,
|
|
3175
|
+
provariadic: 0,
|
|
3176
|
+
prosupport: "",
|
|
3177
|
+
prokind: "f",
|
|
3178
|
+
prosecdef: !1,
|
|
3179
|
+
proleakproof: !1,
|
|
3180
|
+
proisstrict: !1,
|
|
3181
|
+
proretset: !1,
|
|
3182
|
+
provolatile: "v",
|
|
3183
|
+
proparallel: "u",
|
|
3184
|
+
pronargs: i,
|
|
3185
|
+
pronargdefaults: 0,
|
|
3186
|
+
prorettype: r,
|
|
3187
|
+
proargtypes: c,
|
|
3188
|
+
proallargtypes: null,
|
|
3189
|
+
proargmodes: null,
|
|
3190
|
+
proargnames: null,
|
|
3191
|
+
proargdefaults: null,
|
|
3192
|
+
protrftypes: null,
|
|
3193
|
+
prosrc: s,
|
|
3194
|
+
probin: null,
|
|
3195
|
+
prosqlbody: null,
|
|
3196
|
+
proconfig: null,
|
|
3197
|
+
proacl: null
|
|
3198
|
+
});
|
|
3199
|
+
}
|
|
3200
|
+
return [o, n];
|
|
3201
|
+
}
|
|
3202
|
+
// ==================================================================
|
|
3203
|
+
// pg_extension
|
|
3204
|
+
// ==================================================================
|
|
3205
|
+
static _buildPgExtension(e, l) {
|
|
3206
|
+
return [[
|
|
3207
|
+
"oid",
|
|
3208
|
+
"extname",
|
|
3209
|
+
"extowner",
|
|
3210
|
+
"extnamespace",
|
|
3211
|
+
"extrelocatable",
|
|
3212
|
+
"extversion",
|
|
3213
|
+
"extconfig",
|
|
3214
|
+
"extcondition"
|
|
3215
|
+
], [
|
|
3216
|
+
{
|
|
3217
|
+
oid: 13181,
|
|
3218
|
+
extname: "plpgsql",
|
|
3219
|
+
extowner: T,
|
|
3220
|
+
extnamespace: E,
|
|
3221
|
+
extrelocatable: !1,
|
|
3222
|
+
extversion: "1.0",
|
|
3223
|
+
extconfig: null,
|
|
3224
|
+
extcondition: null
|
|
3225
|
+
}
|
|
3226
|
+
]];
|
|
3227
|
+
}
|
|
3228
|
+
// ==================================================================
|
|
3229
|
+
// pg_collation
|
|
3230
|
+
// ==================================================================
|
|
3231
|
+
static _buildPgCollation(e, l) {
|
|
3232
|
+
return [[
|
|
3233
|
+
"oid",
|
|
3234
|
+
"collname",
|
|
3235
|
+
"collnamespace",
|
|
3236
|
+
"collowner",
|
|
3237
|
+
"collprovider",
|
|
3238
|
+
"collisdeterministic",
|
|
3239
|
+
"collencoding",
|
|
3240
|
+
"collcollate",
|
|
3241
|
+
"collctype",
|
|
3242
|
+
"colliculocale",
|
|
3243
|
+
"collicurules",
|
|
3244
|
+
"collversion"
|
|
3245
|
+
], [
|
|
3246
|
+
{
|
|
3247
|
+
oid: 100,
|
|
3248
|
+
collname: "default",
|
|
3249
|
+
collnamespace: E,
|
|
3250
|
+
collowner: T,
|
|
3251
|
+
collprovider: "d",
|
|
3252
|
+
collisdeterministic: !0,
|
|
3253
|
+
collencoding: -1,
|
|
3254
|
+
collcollate: "",
|
|
3255
|
+
collctype: "",
|
|
3256
|
+
colliculocale: null,
|
|
3257
|
+
collicurules: null,
|
|
3258
|
+
collversion: null
|
|
3259
|
+
},
|
|
3260
|
+
{
|
|
3261
|
+
oid: 950,
|
|
3262
|
+
collname: "C",
|
|
3263
|
+
collnamespace: E,
|
|
3264
|
+
collowner: T,
|
|
3265
|
+
collprovider: "c",
|
|
3266
|
+
collisdeterministic: !0,
|
|
3267
|
+
collencoding: -1,
|
|
3268
|
+
collcollate: "C",
|
|
3269
|
+
collctype: "C",
|
|
3270
|
+
colliculocale: null,
|
|
3271
|
+
collicurules: null,
|
|
3272
|
+
collversion: null
|
|
3273
|
+
},
|
|
3274
|
+
{
|
|
3275
|
+
oid: 951,
|
|
3276
|
+
collname: "POSIX",
|
|
3277
|
+
collnamespace: E,
|
|
3278
|
+
collowner: T,
|
|
3279
|
+
collprovider: "c",
|
|
3280
|
+
collisdeterministic: !0,
|
|
3281
|
+
collencoding: -1,
|
|
3282
|
+
collcollate: "POSIX",
|
|
3283
|
+
collctype: "POSIX",
|
|
3284
|
+
colliculocale: null,
|
|
3285
|
+
collicurules: null,
|
|
3286
|
+
collversion: null
|
|
3287
|
+
}
|
|
3288
|
+
]];
|
|
3289
|
+
}
|
|
3290
|
+
// ==================================================================
|
|
3291
|
+
// pg_enum (empty -- UQA has no enum types)
|
|
3292
|
+
// ==================================================================
|
|
3293
|
+
static _buildPgEnum(e, l) {
|
|
3294
|
+
return [["oid", "enumtypid", "enumsortorder", "enumlabel"], []];
|
|
3295
|
+
}
|
|
3296
|
+
// ==================================================================
|
|
3297
|
+
// pg_inherits (empty -- no inheritance)
|
|
3298
|
+
// ==================================================================
|
|
3299
|
+
static _buildPgInherits(e, l) {
|
|
3300
|
+
return [["inhrelid", "inhparent", "inhseqno", "inhdetachpending"], []];
|
|
3301
|
+
}
|
|
3302
|
+
// ==================================================================
|
|
3303
|
+
// pg_trigger (empty -- no triggers)
|
|
3304
|
+
// ==================================================================
|
|
3305
|
+
static _buildPgTrigger(e, l) {
|
|
3306
|
+
return [[
|
|
3307
|
+
"oid",
|
|
3308
|
+
"tgrelid",
|
|
3309
|
+
"tgparentid",
|
|
3310
|
+
"tgname",
|
|
3311
|
+
"tgfoid",
|
|
3312
|
+
"tgtype",
|
|
3313
|
+
"tgenabled",
|
|
3314
|
+
"tgisinternal",
|
|
3315
|
+
"tgconstrrelid",
|
|
3316
|
+
"tgconstrindid",
|
|
3317
|
+
"tgconstraint",
|
|
3318
|
+
"tgdeferrable",
|
|
3319
|
+
"tginitdeferred",
|
|
3320
|
+
"tgnargs",
|
|
3321
|
+
"tgattr",
|
|
3322
|
+
"tgargs",
|
|
3323
|
+
"tgqual",
|
|
3324
|
+
"tgoldtable",
|
|
3325
|
+
"tgnewtable"
|
|
3326
|
+
], []];
|
|
3327
|
+
}
|
|
3328
|
+
// ==================================================================
|
|
3329
|
+
// pg_statio_user_tables
|
|
3330
|
+
// ==================================================================
|
|
3331
|
+
static _buildPgStatioUserTables(e, l) {
|
|
3332
|
+
const o = [
|
|
3333
|
+
"relid",
|
|
3334
|
+
"schemaname",
|
|
3335
|
+
"relname",
|
|
3336
|
+
"heap_blks_read",
|
|
3337
|
+
"heap_blks_hit",
|
|
3338
|
+
"idx_blks_read",
|
|
3339
|
+
"idx_blks_hit",
|
|
3340
|
+
"toast_blks_read",
|
|
3341
|
+
"toast_blks_hit",
|
|
3342
|
+
"tidx_blks_read",
|
|
3343
|
+
"tidx_blks_hit"
|
|
3344
|
+
], t = [];
|
|
3345
|
+
for (const n of [...e._tables.keys()].sort()) {
|
|
3346
|
+
const a = l.get("table", n) ?? 0;
|
|
3347
|
+
t.push({
|
|
3348
|
+
relid: a,
|
|
3349
|
+
schemaname: N,
|
|
3350
|
+
relname: n,
|
|
3351
|
+
heap_blks_read: 0,
|
|
3352
|
+
heap_blks_hit: 0,
|
|
3353
|
+
idx_blks_read: 0,
|
|
3354
|
+
idx_blks_hit: 0,
|
|
3355
|
+
toast_blks_read: 0,
|
|
3356
|
+
toast_blks_hit: 0,
|
|
3357
|
+
tidx_blks_read: 0,
|
|
3358
|
+
tidx_blks_hit: 0
|
|
3359
|
+
});
|
|
3360
|
+
}
|
|
3361
|
+
return [o, t];
|
|
3362
|
+
}
|
|
3363
|
+
// ==================================================================
|
|
3364
|
+
// pg_auth_members (empty -- single user)
|
|
3365
|
+
// ==================================================================
|
|
3366
|
+
static _buildPgAuthMembers(e, l) {
|
|
3367
|
+
return [[
|
|
3368
|
+
"oid",
|
|
3369
|
+
"roleid",
|
|
3370
|
+
"member",
|
|
3371
|
+
"grantor",
|
|
3372
|
+
"admin_option",
|
|
3373
|
+
"inherit_option",
|
|
3374
|
+
"set_option"
|
|
3375
|
+
], []];
|
|
3376
|
+
}
|
|
3377
|
+
// ==================================================================
|
|
3378
|
+
// pg_available_extensions
|
|
3379
|
+
// ==================================================================
|
|
3380
|
+
static _buildPgAvailableExtensions(e, l) {
|
|
3381
|
+
return [["name", "default_version", "installed_version", "comment"], [
|
|
3382
|
+
{
|
|
3383
|
+
name: "plpgsql",
|
|
3384
|
+
default_version: "1.0",
|
|
3385
|
+
installed_version: "1.0",
|
|
3386
|
+
comment: "PL/pgSQL procedural language"
|
|
3387
|
+
}
|
|
3388
|
+
]];
|
|
3389
|
+
}
|
|
3390
|
+
};
|
|
3391
|
+
A(g, "_TABLES", {
|
|
3392
|
+
pg_namespace: g._buildPgNamespace,
|
|
3393
|
+
pg_class: g._buildPgClass,
|
|
3394
|
+
pg_attribute: g._buildPgAttribute,
|
|
3395
|
+
pg_type: g._buildPgType,
|
|
3396
|
+
pg_constraint: g._buildPgConstraint,
|
|
3397
|
+
pg_index: g._buildPgIndex,
|
|
3398
|
+
pg_attrdef: g._buildPgAttrdef,
|
|
3399
|
+
pg_am: g._buildPgAm,
|
|
3400
|
+
pg_database: g._buildPgDatabase,
|
|
3401
|
+
pg_roles: g._buildPgRoles,
|
|
3402
|
+
pg_user: g._buildPgUser,
|
|
3403
|
+
pg_tables: g._buildPgTables,
|
|
3404
|
+
pg_views: g._buildPgViews,
|
|
3405
|
+
pg_indexes: g._buildPgIndexes,
|
|
3406
|
+
pg_matviews: g._buildPgMatviews,
|
|
3407
|
+
pg_sequences: g._buildPgSequences,
|
|
3408
|
+
pg_settings: g._buildPgSettings,
|
|
3409
|
+
pg_foreign_server: g._buildPgForeignServer,
|
|
3410
|
+
pg_foreign_table: g._buildPgForeignTable,
|
|
3411
|
+
pg_foreign_data_wrapper: g._buildPgForeignDataWrapper,
|
|
3412
|
+
pg_description: g._buildPgDescription,
|
|
3413
|
+
pg_depend: g._buildPgDepend,
|
|
3414
|
+
pg_stat_user_tables: g._buildPgStatUserTables,
|
|
3415
|
+
pg_stat_user_indexes: g._buildPgStatUserIndexes,
|
|
3416
|
+
pg_stat_activity: g._buildPgStatActivity,
|
|
3417
|
+
pg_proc: g._buildPgProc,
|
|
3418
|
+
pg_extension: g._buildPgExtension,
|
|
3419
|
+
pg_collation: g._buildPgCollation,
|
|
3420
|
+
pg_enum: g._buildPgEnum,
|
|
3421
|
+
pg_inherits: g._buildPgInherits,
|
|
3422
|
+
pg_trigger: g._buildPgTrigger,
|
|
3423
|
+
pg_statio_user_tables: g._buildPgStatioUserTables,
|
|
3424
|
+
pg_auth_members: g._buildPgAuthMembers,
|
|
3425
|
+
pg_available_extensions: g._buildPgAvailableExtensions,
|
|
3426
|
+
pg_stat_all_tables: g._buildPgStatUserTables
|
|
3427
|
+
});
|
|
3428
|
+
let F = g;
|
|
3429
|
+
const X = new Set(
|
|
3430
|
+
F.supportedTables()
|
|
3431
|
+
), Q = new Set(
|
|
3432
|
+
D.supportedViews()
|
|
3433
|
+
);
|
|
3434
|
+
function re(u, e) {
|
|
3435
|
+
return {
|
|
3436
|
+
_tables: u._tables,
|
|
3437
|
+
_views: u._views,
|
|
3438
|
+
_sequences: u._sequences,
|
|
3439
|
+
_foreignServers: u._foreignServers,
|
|
3440
|
+
_foreignTables: u._foreignTables,
|
|
3441
|
+
_tempTables: e._tempTables ?? /* @__PURE__ */ new Set(),
|
|
3442
|
+
_indexManager: e._indexManager ?? null
|
|
3443
|
+
};
|
|
3444
|
+
}
|
|
3445
|
+
function Oe(u) {
|
|
3446
|
+
if (u.length === 0) return !0;
|
|
3447
|
+
if (u.length !== 1) return !1;
|
|
3448
|
+
try {
|
|
3449
|
+
return "A_Star" in u[0].ResTarget.val.ColumnRef.fields[0];
|
|
3450
|
+
} catch {
|
|
3451
|
+
return !1;
|
|
3452
|
+
}
|
|
3453
|
+
}
|
|
3454
|
+
class qe extends de {
|
|
3455
|
+
constructor(l) {
|
|
3456
|
+
super(l);
|
|
3457
|
+
A(this, "_oidAllocator", null);
|
|
3458
|
+
this._patchCompiler();
|
|
3459
|
+
}
|
|
3460
|
+
_patchCompiler() {
|
|
3461
|
+
const l = this._compiler, o = this._getOids.bind(this), t = this, n = l._applyAlias, a = l._resultToTable;
|
|
3462
|
+
function s(p, f, b, x) {
|
|
3463
|
+
const y = me(x), S = a.call(p, f, {
|
|
3464
|
+
columns: b,
|
|
3465
|
+
rows: y
|
|
3466
|
+
}), w = p._tables, O = p._shadowedTables, C = p._expandedViews, j = w.get(f);
|
|
3467
|
+
return j !== void 0 && !O.has(f) && O.set(f, j), w.set(f, S), C.push(f), f;
|
|
3468
|
+
}
|
|
3469
|
+
function i(p, f) {
|
|
3470
|
+
const b = re(p, t), x = o(b), [y, S] = D.build(
|
|
3471
|
+
f,
|
|
3472
|
+
b,
|
|
3473
|
+
x
|
|
3474
|
+
);
|
|
3475
|
+
return s(p, `_info_schema_${f}`, y, S);
|
|
3476
|
+
}
|
|
3477
|
+
function r(p, f) {
|
|
3478
|
+
const b = re(p, t), x = o(b), [y, S] = F.build(f, b, x);
|
|
3479
|
+
return s(p, `_pg_${f}`, y, S);
|
|
3480
|
+
}
|
|
3481
|
+
function c(p, f, b) {
|
|
3482
|
+
const y = p._tables.get(f);
|
|
3483
|
+
if (!y) return [];
|
|
3484
|
+
const S = y.documentStore, w = [];
|
|
3485
|
+
for (const [, O] of S.iterAll())
|
|
3486
|
+
w.push({ ...O });
|
|
3487
|
+
return n.call(p, w, b);
|
|
3488
|
+
}
|
|
3489
|
+
const _ = l._resolveFromItem;
|
|
3490
|
+
l._resolveFromItem = function(p, f) {
|
|
3491
|
+
const b = p == null ? void 0 : p.RangeVar;
|
|
3492
|
+
if (b) {
|
|
3493
|
+
const x = b.schemaname || null, y = b.relname, S = b.alias, w = S && S.aliasname || y;
|
|
3494
|
+
if (x === "information_schema") {
|
|
3495
|
+
const O = i(
|
|
3496
|
+
this,
|
|
3497
|
+
y
|
|
3498
|
+
);
|
|
3499
|
+
return c(this, O, w);
|
|
3500
|
+
}
|
|
3501
|
+
if (x === "pg_catalog") {
|
|
3502
|
+
const O = r(
|
|
3503
|
+
this,
|
|
3504
|
+
y
|
|
3505
|
+
);
|
|
3506
|
+
return c(this, O, w);
|
|
3507
|
+
}
|
|
3508
|
+
if (x === null && y) {
|
|
3509
|
+
const O = this._tables, C = this._views, j = this._foreignTables, ce = this._inlinedCTEs;
|
|
3510
|
+
if (!O.has(y) && !C.has(y) && !j.has(y) && !ce.has(y)) {
|
|
3511
|
+
if (X.has(y)) {
|
|
3512
|
+
const M = r(
|
|
3513
|
+
this,
|
|
3514
|
+
y
|
|
3515
|
+
);
|
|
3516
|
+
return c(
|
|
3517
|
+
this,
|
|
3518
|
+
M,
|
|
3519
|
+
w
|
|
3520
|
+
);
|
|
3521
|
+
}
|
|
3522
|
+
if (Q.has(y)) {
|
|
3523
|
+
const M = i(
|
|
3524
|
+
this,
|
|
3525
|
+
y
|
|
3526
|
+
);
|
|
3527
|
+
return c(
|
|
3528
|
+
this,
|
|
3529
|
+
M,
|
|
3530
|
+
w
|
|
3531
|
+
);
|
|
3532
|
+
}
|
|
3533
|
+
}
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
return _.call(this, p, f);
|
|
3537
|
+
};
|
|
3538
|
+
const d = l._projectColumns;
|
|
3539
|
+
l._projectColumns = function(p, f, b) {
|
|
3540
|
+
if (f.length === 0 && Oe(p)) {
|
|
3541
|
+
const x = this._expandedViews, y = this._tables;
|
|
3542
|
+
for (let S = x.length - 1; S >= 0; S--) {
|
|
3543
|
+
const w = x[S];
|
|
3544
|
+
if (w.startsWith("_pg_") || w.startsWith("_info_schema_")) {
|
|
3545
|
+
const O = y.get(w);
|
|
3546
|
+
if (O) {
|
|
3547
|
+
const C = O.columns;
|
|
3548
|
+
if (C.size > 0)
|
|
3549
|
+
return [[...C.keys()], []];
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
}
|
|
3554
|
+
return d.call(this, p, f, b);
|
|
3555
|
+
};
|
|
3556
|
+
const v = l.constructor;
|
|
3557
|
+
v._walkAstForTables = function p(f, b) {
|
|
3558
|
+
if (f == null || typeof f != "object") return;
|
|
3559
|
+
if (Array.isArray(f)) {
|
|
3560
|
+
for (const w of f)
|
|
3561
|
+
p(w, b);
|
|
3562
|
+
return;
|
|
3563
|
+
}
|
|
3564
|
+
const x = f, y = x.RangeVar;
|
|
3565
|
+
if (y !== void 0) {
|
|
3566
|
+
const w = y.schemaname;
|
|
3567
|
+
if (w === "information_schema" || w === "pg_catalog")
|
|
3568
|
+
return;
|
|
3569
|
+
const O = y.relname;
|
|
3570
|
+
if (!w && O && (X.has(O) || Q.has(O)))
|
|
3571
|
+
return;
|
|
3572
|
+
O && b.add(O);
|
|
3573
|
+
return;
|
|
3574
|
+
}
|
|
3575
|
+
const S = x.relname;
|
|
3576
|
+
if (typeof S == "string" && S) {
|
|
3577
|
+
const w = x.schemaname;
|
|
3578
|
+
w === "information_schema" || w === "pg_catalog" || !w && (X.has(S) || Q.has(S)) || b.add(S);
|
|
3579
|
+
}
|
|
3580
|
+
for (const w of Object.values(x))
|
|
3581
|
+
w !== null && typeof w == "object" && p(w, b);
|
|
3582
|
+
};
|
|
3583
|
+
}
|
|
3584
|
+
_getOids(l) {
|
|
3585
|
+
return this._oidAllocator === null && (this._oidAllocator = new he(l ?? this)), this._oidAllocator;
|
|
3586
|
+
}
|
|
3587
|
+
async sql(l, o) {
|
|
3588
|
+
return this._oidAllocator = null, await this.init(), super.sql(l, o);
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
export {
|
|
3592
|
+
D as InformationSchemaProvider,
|
|
3593
|
+
he as OIDAllocator,
|
|
3594
|
+
F as PGCatalogProvider,
|
|
3595
|
+
qe as USQLEngine,
|
|
3596
|
+
me as normalizeRows
|
|
3597
|
+
};
|
|
3598
|
+
//# sourceMappingURL=usqldb.es.js.map
|