1use std::collections::BTreeMap;
13use std::sync::LazyLock;
14
15use mz_pgrepr::oid;
16use mz_repr::namespaces::PG_CATALOG_SCHEMA;
17use mz_repr::{RelationDesc, SqlScalarType};
18use mz_sql::catalog::{
19 CatalogType, CatalogTypeDetails, CatalogTypePgMetadata, NameReference, ObjectType,
20};
21use mz_sql::rbac;
22use mz_sql::session::user::MZ_SYSTEM_ROLE_ID;
23
24use super::{BuiltinType, BuiltinView, PUBLIC_SELECT};
25
26pub const TYPE_BOOL: BuiltinType<NameReference> = BuiltinType {
46 name: "bool",
47 schema: PG_CATALOG_SCHEMA,
48 oid: oid::TYPE_BOOL_OID,
49 details: CatalogTypeDetails {
50 typ: CatalogType::Bool,
51 array_id: None,
52 pg_metadata: Some(CatalogTypePgMetadata {
53 typinput_oid: 1242,
54 typreceive_oid: 2436,
55 typsend_oid: 2437,
56 }),
57 },
58};
59
60pub const TYPE_BYTEA: BuiltinType<NameReference> = BuiltinType {
61 name: "bytea",
62 schema: PG_CATALOG_SCHEMA,
63 oid: oid::TYPE_BYTEA_OID,
64 details: CatalogTypeDetails {
65 typ: CatalogType::Bytes,
66 array_id: None,
67 pg_metadata: Some(CatalogTypePgMetadata {
68 typinput_oid: 1244,
69 typreceive_oid: 2412,
70 typsend_oid: 2413,
71 }),
72 },
73};
74
75pub const TYPE_INT8: BuiltinType<NameReference> = BuiltinType {
76 name: "int8",
77 schema: PG_CATALOG_SCHEMA,
78 oid: oid::TYPE_INT8_OID,
79 details: CatalogTypeDetails {
80 typ: CatalogType::Int64,
81 array_id: None,
82 pg_metadata: Some(CatalogTypePgMetadata {
83 typinput_oid: 460,
84 typreceive_oid: 2408,
85 typsend_oid: 2409,
86 }),
87 },
88};
89
90pub const TYPE_INT4: BuiltinType<NameReference> = BuiltinType {
91 name: "int4",
92 schema: PG_CATALOG_SCHEMA,
93 oid: oid::TYPE_INT4_OID,
94 details: CatalogTypeDetails {
95 typ: CatalogType::Int32,
96 array_id: None,
97 pg_metadata: Some(CatalogTypePgMetadata {
98 typinput_oid: 42,
99 typreceive_oid: 2406,
100 typsend_oid: 2407,
101 }),
102 },
103};
104
105pub const TYPE_TEXT: BuiltinType<NameReference> = BuiltinType {
106 name: "text",
107 schema: PG_CATALOG_SCHEMA,
108 oid: oid::TYPE_TEXT_OID,
109 details: CatalogTypeDetails {
110 typ: CatalogType::String,
111 array_id: None,
112 pg_metadata: Some(CatalogTypePgMetadata {
113 typinput_oid: 46,
114 typreceive_oid: 2414,
115 typsend_oid: 2415,
116 }),
117 },
118};
119
120pub const TYPE_OID: BuiltinType<NameReference> = BuiltinType {
121 name: "oid",
122 schema: PG_CATALOG_SCHEMA,
123 oid: oid::TYPE_OID_OID,
124 details: CatalogTypeDetails {
125 typ: CatalogType::Oid,
126 array_id: None,
127 pg_metadata: Some(CatalogTypePgMetadata {
128 typinput_oid: 1798,
129 typreceive_oid: 2418,
130 typsend_oid: 2419,
131 }),
132 },
133};
134
135pub const TYPE_FLOAT4: BuiltinType<NameReference> = BuiltinType {
136 name: "float4",
137 schema: PG_CATALOG_SCHEMA,
138 oid: oid::TYPE_FLOAT4_OID,
139 details: CatalogTypeDetails {
140 typ: CatalogType::Float32,
141 array_id: None,
142 pg_metadata: Some(CatalogTypePgMetadata {
143 typinput_oid: 200,
144 typreceive_oid: 2424,
145 typsend_oid: 2425,
146 }),
147 },
148};
149
150pub const TYPE_FLOAT8: BuiltinType<NameReference> = BuiltinType {
151 name: "float8",
152 schema: PG_CATALOG_SCHEMA,
153 oid: oid::TYPE_FLOAT8_OID,
154 details: CatalogTypeDetails {
155 typ: CatalogType::Float64,
156 array_id: None,
157 pg_metadata: Some(CatalogTypePgMetadata {
158 typinput_oid: 214,
159 typreceive_oid: 2426,
160 typsend_oid: 2427,
161 }),
162 },
163};
164
165pub const TYPE_BOOL_ARRAY: BuiltinType<NameReference> = BuiltinType {
166 name: "_bool",
167 schema: PG_CATALOG_SCHEMA,
168 oid: oid::TYPE_BOOL_ARRAY_OID,
169 details: CatalogTypeDetails {
170 typ: CatalogType::Array {
171 element_reference: TYPE_BOOL.name,
172 },
173 array_id: None,
174 pg_metadata: Some(CatalogTypePgMetadata {
175 typinput_oid: 750,
176 typreceive_oid: 2400,
177 typsend_oid: 2401,
178 }),
179 },
180};
181
182pub const TYPE_BYTEA_ARRAY: BuiltinType<NameReference> = BuiltinType {
183 name: "_bytea",
184 schema: PG_CATALOG_SCHEMA,
185 oid: oid::TYPE_BYTEA_ARRAY_OID,
186 details: CatalogTypeDetails {
187 typ: CatalogType::Array {
188 element_reference: TYPE_BYTEA.name,
189 },
190 array_id: None,
191 pg_metadata: Some(CatalogTypePgMetadata {
192 typinput_oid: 750,
193 typreceive_oid: 2400,
194 typsend_oid: 2401,
195 }),
196 },
197};
198
199pub const TYPE_INT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
200 name: "_int4",
201 schema: PG_CATALOG_SCHEMA,
202 oid: oid::TYPE_INT4_ARRAY_OID,
203 details: CatalogTypeDetails {
204 typ: CatalogType::Array {
205 element_reference: TYPE_INT4.name,
206 },
207 array_id: None,
208 pg_metadata: Some(CatalogTypePgMetadata {
209 typinput_oid: 750,
210 typreceive_oid: 2400,
211 typsend_oid: 2401,
212 }),
213 },
214};
215
216pub const TYPE_TEXT_ARRAY: BuiltinType<NameReference> = BuiltinType {
217 name: "_text",
218 schema: PG_CATALOG_SCHEMA,
219 oid: oid::TYPE_TEXT_ARRAY_OID,
220 details: CatalogTypeDetails {
221 typ: CatalogType::Array {
222 element_reference: TYPE_TEXT.name,
223 },
224 array_id: None,
225 pg_metadata: Some(CatalogTypePgMetadata {
226 typinput_oid: 750,
227 typreceive_oid: 2400,
228 typsend_oid: 2401,
229 }),
230 },
231};
232
233pub const TYPE_INT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
234 name: "_int8",
235 schema: PG_CATALOG_SCHEMA,
236 oid: oid::TYPE_INT8_ARRAY_OID,
237 details: CatalogTypeDetails {
238 typ: CatalogType::Array {
239 element_reference: TYPE_INT8.name,
240 },
241 array_id: None,
242 pg_metadata: Some(CatalogTypePgMetadata {
243 typinput_oid: 750,
244 typreceive_oid: 2400,
245 typsend_oid: 2401,
246 }),
247 },
248};
249
250pub const TYPE_FLOAT4_ARRAY: BuiltinType<NameReference> = BuiltinType {
251 name: "_float4",
252 schema: PG_CATALOG_SCHEMA,
253 oid: oid::TYPE_FLOAT4_ARRAY_OID,
254 details: CatalogTypeDetails {
255 typ: CatalogType::Array {
256 element_reference: TYPE_FLOAT4.name,
257 },
258 array_id: None,
259 pg_metadata: Some(CatalogTypePgMetadata {
260 typinput_oid: 750,
261 typreceive_oid: 2400,
262 typsend_oid: 2401,
263 }),
264 },
265};
266
267pub const TYPE_FLOAT8_ARRAY: BuiltinType<NameReference> = BuiltinType {
268 name: "_float8",
269 schema: PG_CATALOG_SCHEMA,
270 oid: oid::TYPE_FLOAT8_ARRAY_OID,
271 details: CatalogTypeDetails {
272 typ: CatalogType::Array {
273 element_reference: TYPE_FLOAT8.name,
274 },
275 array_id: None,
276 pg_metadata: Some(CatalogTypePgMetadata {
277 typinput_oid: 750,
278 typreceive_oid: 2400,
279 typsend_oid: 2401,
280 }),
281 },
282};
283
284pub const TYPE_OID_ARRAY: BuiltinType<NameReference> = BuiltinType {
285 name: "_oid",
286 schema: PG_CATALOG_SCHEMA,
287 oid: oid::TYPE_OID_ARRAY_OID,
288 details: CatalogTypeDetails {
289 typ: CatalogType::Array {
290 element_reference: TYPE_OID.name,
291 },
292 array_id: None,
293 pg_metadata: Some(CatalogTypePgMetadata {
294 typinput_oid: 750,
295 typreceive_oid: 2400,
296 typsend_oid: 2401,
297 }),
298 },
299};
300
301pub const TYPE_DATE: BuiltinType<NameReference> = BuiltinType {
302 name: "date",
303 schema: PG_CATALOG_SCHEMA,
304 oid: oid::TYPE_DATE_OID,
305 details: CatalogTypeDetails {
306 typ: CatalogType::Date,
307 array_id: None,
308 pg_metadata: Some(CatalogTypePgMetadata {
309 typinput_oid: 1084,
310 typreceive_oid: 2468,
311 typsend_oid: 2469,
312 }),
313 },
314};
315
316pub const TYPE_TIME: BuiltinType<NameReference> = BuiltinType {
317 name: "time",
318 schema: PG_CATALOG_SCHEMA,
319 oid: oid::TYPE_TIME_OID,
320 details: CatalogTypeDetails {
321 typ: CatalogType::Time,
322 array_id: None,
323 pg_metadata: Some(CatalogTypePgMetadata {
324 typinput_oid: 1143,
325 typreceive_oid: 2470,
326 typsend_oid: 2471,
327 }),
328 },
329};
330
331pub const TYPE_TIMESTAMP: BuiltinType<NameReference> = BuiltinType {
332 name: "timestamp",
333 schema: PG_CATALOG_SCHEMA,
334 oid: oid::TYPE_TIMESTAMP_OID,
335 details: CatalogTypeDetails {
336 typ: CatalogType::Timestamp,
337 array_id: None,
338 pg_metadata: Some(CatalogTypePgMetadata {
339 typinput_oid: 1312,
340 typreceive_oid: 2474,
341 typsend_oid: 2475,
342 }),
343 },
344};
345
346pub const TYPE_TIMESTAMP_ARRAY: BuiltinType<NameReference> = BuiltinType {
347 name: "_timestamp",
348 schema: PG_CATALOG_SCHEMA,
349 oid: oid::TYPE_TIMESTAMP_ARRAY_OID,
350 details: CatalogTypeDetails {
351 typ: CatalogType::Array {
352 element_reference: TYPE_TIMESTAMP.name,
353 },
354 array_id: None,
355 pg_metadata: Some(CatalogTypePgMetadata {
356 typinput_oid: 750,
357 typreceive_oid: 2400,
358 typsend_oid: 2401,
359 }),
360 },
361};
362
363pub const TYPE_DATE_ARRAY: BuiltinType<NameReference> = BuiltinType {
364 name: "_date",
365 schema: PG_CATALOG_SCHEMA,
366 oid: oid::TYPE_DATE_ARRAY_OID,
367 details: CatalogTypeDetails {
368 typ: CatalogType::Array {
369 element_reference: TYPE_DATE.name,
370 },
371 array_id: None,
372 pg_metadata: Some(CatalogTypePgMetadata {
373 typinput_oid: 750,
374 typreceive_oid: 2400,
375 typsend_oid: 2401,
376 }),
377 },
378};
379
380pub const TYPE_TIME_ARRAY: BuiltinType<NameReference> = BuiltinType {
381 name: "_time",
382 schema: PG_CATALOG_SCHEMA,
383 oid: oid::TYPE_TIME_ARRAY_OID,
384 details: CatalogTypeDetails {
385 typ: CatalogType::Array {
386 element_reference: TYPE_TIME.name,
387 },
388 array_id: None,
389 pg_metadata: Some(CatalogTypePgMetadata {
390 typinput_oid: 750,
391 typreceive_oid: 2400,
392 typsend_oid: 2401,
393 }),
394 },
395};
396
397pub const TYPE_TIMESTAMPTZ: BuiltinType<NameReference> = BuiltinType {
398 name: "timestamptz",
399 schema: PG_CATALOG_SCHEMA,
400 oid: oid::TYPE_TIMESTAMPTZ_OID,
401 details: CatalogTypeDetails {
402 typ: CatalogType::TimestampTz,
403 array_id: None,
404 pg_metadata: Some(CatalogTypePgMetadata {
405 typinput_oid: 1150,
406 typreceive_oid: 2476,
407 typsend_oid: 2477,
408 }),
409 },
410};
411
412pub const TYPE_TIMESTAMPTZ_ARRAY: BuiltinType<NameReference> = BuiltinType {
413 name: "_timestamptz",
414 schema: PG_CATALOG_SCHEMA,
415 oid: oid::TYPE_TIMESTAMPTZ_ARRAY_OID,
416 details: CatalogTypeDetails {
417 typ: CatalogType::Array {
418 element_reference: TYPE_TIMESTAMPTZ.name,
419 },
420 array_id: None,
421 pg_metadata: Some(CatalogTypePgMetadata {
422 typinput_oid: 750,
423 typreceive_oid: 2400,
424 typsend_oid: 2401,
425 }),
426 },
427};
428
429pub const TYPE_INTERVAL: BuiltinType<NameReference> = BuiltinType {
430 name: "interval",
431 schema: PG_CATALOG_SCHEMA,
432 oid: oid::TYPE_INTERVAL_OID,
433 details: CatalogTypeDetails {
434 typ: CatalogType::Interval,
435 array_id: None,
436 pg_metadata: Some(CatalogTypePgMetadata {
437 typinput_oid: 1160,
438 typreceive_oid: 2478,
439 typsend_oid: 2479,
440 }),
441 },
442};
443
444pub const TYPE_INTERVAL_ARRAY: BuiltinType<NameReference> = BuiltinType {
445 name: "_interval",
446 schema: PG_CATALOG_SCHEMA,
447 oid: oid::TYPE_INTERVAL_ARRAY_OID,
448 details: CatalogTypeDetails {
449 typ: CatalogType::Array {
450 element_reference: TYPE_INTERVAL.name,
451 },
452 array_id: None,
453 pg_metadata: Some(CatalogTypePgMetadata {
454 typinput_oid: 750,
455 typreceive_oid: 2400,
456 typsend_oid: 2401,
457 }),
458 },
459};
460
461pub const TYPE_NAME: BuiltinType<NameReference> = BuiltinType {
462 name: "name",
463 schema: PG_CATALOG_SCHEMA,
464 oid: oid::TYPE_NAME_OID,
465 details: CatalogTypeDetails {
466 typ: CatalogType::PgLegacyName,
467 array_id: None,
468 pg_metadata: Some(CatalogTypePgMetadata {
469 typinput_oid: 34,
470 typreceive_oid: 2422,
471 typsend_oid: 2423,
472 }),
473 },
474};
475
476pub const TYPE_NAME_ARRAY: BuiltinType<NameReference> = BuiltinType {
477 name: "_name",
478 schema: PG_CATALOG_SCHEMA,
479 oid: oid::TYPE_NAME_ARRAY_OID,
480 details: CatalogTypeDetails {
481 typ: CatalogType::Array {
482 element_reference: TYPE_NAME.name,
483 },
484 array_id: None,
485 pg_metadata: Some(CatalogTypePgMetadata {
486 typinput_oid: 750,
487 typreceive_oid: 2400,
488 typsend_oid: 2401,
489 }),
490 },
491};
492
493pub const TYPE_NUMERIC: BuiltinType<NameReference> = BuiltinType {
494 name: "numeric",
495 schema: PG_CATALOG_SCHEMA,
496 oid: oid::TYPE_NUMERIC_OID,
497 details: CatalogTypeDetails {
498 typ: CatalogType::Numeric,
499 array_id: None,
500 pg_metadata: Some(CatalogTypePgMetadata {
501 typinput_oid: 1701,
502 typreceive_oid: 2460,
503 typsend_oid: 2461,
504 }),
505 },
506};
507
508pub const TYPE_NUMERIC_ARRAY: BuiltinType<NameReference> = BuiltinType {
509 name: "_numeric",
510 schema: PG_CATALOG_SCHEMA,
511 oid: oid::TYPE_NUMERIC_ARRAY_OID,
512 details: CatalogTypeDetails {
513 typ: CatalogType::Array {
514 element_reference: TYPE_NUMERIC.name,
515 },
516 array_id: None,
517 pg_metadata: Some(CatalogTypePgMetadata {
518 typinput_oid: 750,
519 typreceive_oid: 2400,
520 typsend_oid: 2401,
521 }),
522 },
523};
524
525pub const TYPE_RECORD: BuiltinType<NameReference> = BuiltinType {
526 name: "record",
527 schema: PG_CATALOG_SCHEMA,
528 oid: oid::TYPE_RECORD_OID,
529 details: CatalogTypeDetails {
530 typ: CatalogType::Pseudo,
531 array_id: None,
532 pg_metadata: Some(CatalogTypePgMetadata {
533 typinput_oid: 2290,
534 typreceive_oid: 2402,
535 typsend_oid: 2403,
536 }),
537 },
538};
539
540pub const TYPE_RECORD_ARRAY: BuiltinType<NameReference> = BuiltinType {
541 name: "_record",
542 schema: PG_CATALOG_SCHEMA,
543 oid: oid::TYPE_RECORD_ARRAY_OID,
544 details: CatalogTypeDetails {
545 typ: CatalogType::Array {
546 element_reference: TYPE_RECORD.name,
547 },
548 array_id: None,
549 pg_metadata: Some(CatalogTypePgMetadata {
550 typinput_oid: 750,
551 typreceive_oid: 2400,
552 typsend_oid: 2401,
553 }),
554 },
555};
556
557pub const TYPE_UUID: BuiltinType<NameReference> = BuiltinType {
558 name: "uuid",
559 schema: PG_CATALOG_SCHEMA,
560 oid: oid::TYPE_UUID_OID,
561 details: CatalogTypeDetails {
562 typ: CatalogType::Uuid,
563 array_id: None,
564 pg_metadata: Some(CatalogTypePgMetadata {
565 typinput_oid: 2952,
566 typreceive_oid: 2961,
567 typsend_oid: 2962,
568 }),
569 },
570};
571
572pub const TYPE_UUID_ARRAY: BuiltinType<NameReference> = BuiltinType {
573 name: "_uuid",
574 schema: PG_CATALOG_SCHEMA,
575 oid: oid::TYPE_UUID_ARRAY_OID,
576 details: CatalogTypeDetails {
577 typ: CatalogType::Array {
578 element_reference: TYPE_UUID.name,
579 },
580 array_id: None,
581 pg_metadata: Some(CatalogTypePgMetadata {
582 typinput_oid: 750,
583 typreceive_oid: 2400,
584 typsend_oid: 2401,
585 }),
586 },
587};
588
589pub const TYPE_JSONB: BuiltinType<NameReference> = BuiltinType {
590 name: "jsonb",
591 schema: PG_CATALOG_SCHEMA,
592 oid: oid::TYPE_JSONB_OID,
593 details: CatalogTypeDetails {
594 typ: CatalogType::Jsonb,
595 array_id: None,
596 pg_metadata: Some(CatalogTypePgMetadata {
597 typinput_oid: 3806,
598 typreceive_oid: 3805,
599 typsend_oid: 3803,
600 }),
601 },
602};
603
604pub const TYPE_JSONB_ARRAY: BuiltinType<NameReference> = BuiltinType {
605 name: "_jsonb",
606 schema: PG_CATALOG_SCHEMA,
607 oid: oid::TYPE_JSONB_ARRAY_OID,
608 details: CatalogTypeDetails {
609 typ: CatalogType::Array {
610 element_reference: TYPE_JSONB.name,
611 },
612 array_id: None,
613 pg_metadata: Some(CatalogTypePgMetadata {
614 typinput_oid: 750,
615 typreceive_oid: 2400,
616 typsend_oid: 2401,
617 }),
618 },
619};
620
621pub const TYPE_ANY: BuiltinType<NameReference> = BuiltinType {
622 name: "any",
623 schema: PG_CATALOG_SCHEMA,
624 oid: oid::TYPE_ANY_OID,
625 details: CatalogTypeDetails {
626 typ: CatalogType::Pseudo,
627 array_id: None,
628 pg_metadata: Some(CatalogTypePgMetadata {
629 typinput_oid: 2294,
630 typreceive_oid: 0,
631 typsend_oid: 0,
632 }),
633 },
634};
635
636pub const TYPE_ANYARRAY: BuiltinType<NameReference> = BuiltinType {
637 name: "anyarray",
638 schema: PG_CATALOG_SCHEMA,
639 oid: oid::TYPE_ANYARRAY_OID,
640 details: CatalogTypeDetails {
641 typ: CatalogType::Pseudo,
642 array_id: None,
643 pg_metadata: Some(CatalogTypePgMetadata {
644 typinput_oid: 2296,
645 typreceive_oid: 2502,
646 typsend_oid: 2503,
647 }),
648 },
649};
650
651pub const TYPE_ANYELEMENT: BuiltinType<NameReference> = BuiltinType {
652 name: "anyelement",
653 schema: PG_CATALOG_SCHEMA,
654 oid: oid::TYPE_ANYELEMENT_OID,
655 details: CatalogTypeDetails {
656 typ: CatalogType::Pseudo,
657 array_id: None,
658 pg_metadata: Some(CatalogTypePgMetadata {
659 typinput_oid: 2312,
660 typreceive_oid: 0,
661 typsend_oid: 0,
662 }),
663 },
664};
665
666pub const TYPE_ANYNONARRAY: BuiltinType<NameReference> = BuiltinType {
667 name: "anynonarray",
668 schema: PG_CATALOG_SCHEMA,
669 oid: oid::TYPE_ANYNONARRAY_OID,
670 details: CatalogTypeDetails {
671 typ: CatalogType::Pseudo,
672 array_id: None,
673 pg_metadata: Some(CatalogTypePgMetadata {
674 typinput_oid: 2777,
675 typreceive_oid: 0,
676 typsend_oid: 0,
677 }),
678 },
679};
680
681pub const TYPE_ANYRANGE: BuiltinType<NameReference> = BuiltinType {
682 name: "anyrange",
683 schema: PG_CATALOG_SCHEMA,
684 oid: oid::TYPE_ANYRANGE_OID,
685 details: CatalogTypeDetails {
686 typ: CatalogType::Pseudo,
687 array_id: None,
688 pg_metadata: Some(CatalogTypePgMetadata {
689 typinput_oid: 3832,
690 typreceive_oid: 0,
691 typsend_oid: 0,
692 }),
693 },
694};
695
696pub const TYPE_CHAR: BuiltinType<NameReference> = BuiltinType {
697 name: "char",
698 schema: PG_CATALOG_SCHEMA,
699 oid: oid::TYPE_CHAR_OID,
700 details: CatalogTypeDetails {
701 typ: CatalogType::PgLegacyChar,
702 array_id: None,
703 pg_metadata: Some(CatalogTypePgMetadata {
704 typinput_oid: 1245,
705 typreceive_oid: 2434,
706 typsend_oid: 2435,
707 }),
708 },
709};
710
711pub const TYPE_VARCHAR: BuiltinType<NameReference> = BuiltinType {
712 name: "varchar",
713 schema: PG_CATALOG_SCHEMA,
714 oid: oid::TYPE_VARCHAR_OID,
715 details: CatalogTypeDetails {
716 typ: CatalogType::VarChar,
717 array_id: None,
718 pg_metadata: Some(CatalogTypePgMetadata {
719 typinput_oid: 1046,
720 typreceive_oid: 2432,
721 typsend_oid: 2433,
722 }),
723 },
724};
725
726pub const TYPE_INT2: BuiltinType<NameReference> = BuiltinType {
727 name: "int2",
728 schema: PG_CATALOG_SCHEMA,
729 oid: oid::TYPE_INT2_OID,
730 details: CatalogTypeDetails {
731 typ: CatalogType::Int16,
732 array_id: None,
733 pg_metadata: Some(CatalogTypePgMetadata {
734 typinput_oid: 38,
735 typreceive_oid: 2404,
736 typsend_oid: 2405,
737 }),
738 },
739};
740
741pub const TYPE_INT2_ARRAY: BuiltinType<NameReference> = BuiltinType {
742 name: "_int2",
743 schema: PG_CATALOG_SCHEMA,
744 oid: oid::TYPE_INT2_ARRAY_OID,
745 details: CatalogTypeDetails {
746 typ: CatalogType::Array {
747 element_reference: TYPE_INT2.name,
748 },
749 array_id: None,
750 pg_metadata: Some(CatalogTypePgMetadata {
751 typinput_oid: 750,
752 typreceive_oid: 2400,
753 typsend_oid: 2401,
754 }),
755 },
756};
757
758pub const TYPE_BPCHAR: BuiltinType<NameReference> = BuiltinType {
759 name: "bpchar",
760 schema: PG_CATALOG_SCHEMA,
761 oid: oid::TYPE_BPCHAR_OID,
762 details: CatalogTypeDetails {
763 typ: CatalogType::Char,
764 array_id: None,
765 pg_metadata: Some(CatalogTypePgMetadata {
766 typinput_oid: 1044,
767 typreceive_oid: 2430,
768 typsend_oid: 2431,
769 }),
770 },
771};
772
773pub const TYPE_CHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
774 name: "_char",
775 schema: PG_CATALOG_SCHEMA,
776 oid: oid::TYPE_CHAR_ARRAY_OID,
777 details: CatalogTypeDetails {
778 typ: CatalogType::Array {
779 element_reference: TYPE_CHAR.name,
780 },
781 array_id: None,
782 pg_metadata: Some(CatalogTypePgMetadata {
783 typinput_oid: 750,
784 typreceive_oid: 2400,
785 typsend_oid: 2401,
786 }),
787 },
788};
789
790pub const TYPE_VARCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
791 name: "_varchar",
792 schema: PG_CATALOG_SCHEMA,
793 oid: oid::TYPE_VARCHAR_ARRAY_OID,
794 details: CatalogTypeDetails {
795 typ: CatalogType::Array {
796 element_reference: TYPE_VARCHAR.name,
797 },
798 array_id: None,
799 pg_metadata: Some(CatalogTypePgMetadata {
800 typinput_oid: 750,
801 typreceive_oid: 2400,
802 typsend_oid: 2401,
803 }),
804 },
805};
806
807pub const TYPE_BPCHAR_ARRAY: BuiltinType<NameReference> = BuiltinType {
808 name: "_bpchar",
809 schema: PG_CATALOG_SCHEMA,
810 oid: oid::TYPE_BPCHAR_ARRAY_OID,
811 details: CatalogTypeDetails {
812 typ: CatalogType::Array {
813 element_reference: TYPE_BPCHAR.name,
814 },
815 array_id: None,
816 pg_metadata: Some(CatalogTypePgMetadata {
817 typinput_oid: 750,
818 typreceive_oid: 2400,
819 typsend_oid: 2401,
820 }),
821 },
822};
823
824pub const TYPE_REGPROC: BuiltinType<NameReference> = BuiltinType {
825 name: "regproc",
826 schema: PG_CATALOG_SCHEMA,
827 oid: oid::TYPE_REGPROC_OID,
828 details: CatalogTypeDetails {
829 typ: CatalogType::RegProc,
830 array_id: None,
831 pg_metadata: Some(CatalogTypePgMetadata {
832 typinput_oid: 44,
833 typreceive_oid: 2444,
834 typsend_oid: 2445,
835 }),
836 },
837};
838
839pub const TYPE_REGPROC_ARRAY: BuiltinType<NameReference> = BuiltinType {
840 name: "_regproc",
841 schema: PG_CATALOG_SCHEMA,
842 oid: oid::TYPE_REGPROC_ARRAY_OID,
843 details: CatalogTypeDetails {
844 typ: CatalogType::Array {
845 element_reference: TYPE_REGPROC.name,
846 },
847 array_id: None,
848 pg_metadata: Some(CatalogTypePgMetadata {
849 typinput_oid: 750,
850 typreceive_oid: 2400,
851 typsend_oid: 2401,
852 }),
853 },
854};
855
856pub const TYPE_REGTYPE: BuiltinType<NameReference> = BuiltinType {
857 name: "regtype",
858 schema: PG_CATALOG_SCHEMA,
859 oid: oid::TYPE_REGTYPE_OID,
860 details: CatalogTypeDetails {
861 typ: CatalogType::RegType,
862 array_id: None,
863 pg_metadata: Some(CatalogTypePgMetadata {
864 typinput_oid: 2220,
865 typreceive_oid: 2454,
866 typsend_oid: 2455,
867 }),
868 },
869};
870
871pub const TYPE_REGTYPE_ARRAY: BuiltinType<NameReference> = BuiltinType {
872 name: "_regtype",
873 schema: PG_CATALOG_SCHEMA,
874 oid: oid::TYPE_REGTYPE_ARRAY_OID,
875 details: CatalogTypeDetails {
876 typ: CatalogType::Array {
877 element_reference: TYPE_REGTYPE.name,
878 },
879 array_id: None,
880 pg_metadata: Some(CatalogTypePgMetadata {
881 typinput_oid: 750,
882 typreceive_oid: 2400,
883 typsend_oid: 2401,
884 }),
885 },
886};
887
888pub const TYPE_REGCLASS: BuiltinType<NameReference> = BuiltinType {
889 name: "regclass",
890 schema: PG_CATALOG_SCHEMA,
891 oid: oid::TYPE_REGCLASS_OID,
892 details: CatalogTypeDetails {
893 typ: CatalogType::RegClass,
894 array_id: None,
895 pg_metadata: Some(CatalogTypePgMetadata {
896 typinput_oid: 2218,
897 typreceive_oid: 2452,
898 typsend_oid: 2453,
899 }),
900 },
901};
902
903pub const TYPE_REGCLASS_ARRAY: BuiltinType<NameReference> = BuiltinType {
904 name: "_regclass",
905 schema: PG_CATALOG_SCHEMA,
906 oid: oid::TYPE_REGCLASS_ARRAY_OID,
907 details: CatalogTypeDetails {
908 typ: CatalogType::Array {
909 element_reference: TYPE_REGCLASS.name,
910 },
911 array_id: None,
912 pg_metadata: Some(CatalogTypePgMetadata {
913 typinput_oid: 750,
914 typreceive_oid: 2400,
915 typsend_oid: 2401,
916 }),
917 },
918};
919
920pub const TYPE_INT2_VECTOR: BuiltinType<NameReference> = BuiltinType {
921 name: "int2vector",
922 schema: PG_CATALOG_SCHEMA,
923 oid: oid::TYPE_INT2_VECTOR_OID,
924 details: CatalogTypeDetails {
925 typ: CatalogType::Int2Vector,
926 array_id: None,
927 pg_metadata: Some(CatalogTypePgMetadata {
928 typinput_oid: 40,
929 typreceive_oid: 2410,
930 typsend_oid: 2411,
931 }),
932 },
933};
934
935pub const TYPE_INT2_VECTOR_ARRAY: BuiltinType<NameReference> = BuiltinType {
936 name: "_int2vector",
937 schema: PG_CATALOG_SCHEMA,
938 oid: oid::TYPE_INT2_VECTOR_ARRAY_OID,
939 details: CatalogTypeDetails {
940 typ: CatalogType::Array {
941 element_reference: TYPE_INT2_VECTOR.name,
942 },
943 array_id: None,
944 pg_metadata: Some(CatalogTypePgMetadata {
945 typinput_oid: 750,
946 typreceive_oid: 2400,
947 typsend_oid: 2401,
948 }),
949 },
950};
951
952pub const TYPE_ANYCOMPATIBLE: BuiltinType<NameReference> = BuiltinType {
953 name: "anycompatible",
954 schema: PG_CATALOG_SCHEMA,
955 oid: oid::TYPE_ANYCOMPATIBLE_OID,
956 details: CatalogTypeDetails {
957 typ: CatalogType::Pseudo,
958 array_id: None,
959 pg_metadata: Some(CatalogTypePgMetadata {
960 typinput_oid: 5086,
961 typreceive_oid: 0,
962 typsend_oid: 0,
963 }),
964 },
965};
966
967pub const TYPE_ANYCOMPATIBLEARRAY: BuiltinType<NameReference> = BuiltinType {
968 name: "anycompatiblearray",
969 schema: PG_CATALOG_SCHEMA,
970 oid: oid::TYPE_ANYCOMPATIBLEARRAY_OID,
971 details: CatalogTypeDetails {
972 typ: CatalogType::Pseudo,
973 array_id: None,
974 pg_metadata: Some(CatalogTypePgMetadata {
975 typinput_oid: 5088,
976 typreceive_oid: 5090,
977 typsend_oid: 5091,
978 }),
979 },
980};
981
982pub const TYPE_ANYCOMPATIBLENONARRAY: BuiltinType<NameReference> = BuiltinType {
983 name: "anycompatiblenonarray",
984 schema: PG_CATALOG_SCHEMA,
985 oid: oid::TYPE_ANYCOMPATIBLENONARRAY_OID,
986 details: CatalogTypeDetails {
987 typ: CatalogType::Pseudo,
988 array_id: None,
989 pg_metadata: Some(CatalogTypePgMetadata {
990 typinput_oid: 5092,
991 typreceive_oid: 0,
992 typsend_oid: 0,
993 }),
994 },
995};
996
997pub const TYPE_ANYCOMPATIBLERANGE: BuiltinType<NameReference> = BuiltinType {
998 name: "anycompatiblerange",
999 schema: PG_CATALOG_SCHEMA,
1000 oid: oid::TYPE_ANYCOMPATIBLERANGE_OID,
1001 details: CatalogTypeDetails {
1002 typ: CatalogType::Pseudo,
1003 array_id: None,
1004 pg_metadata: Some(CatalogTypePgMetadata {
1005 typinput_oid: 5094,
1006 typreceive_oid: 0,
1007 typsend_oid: 0,
1008 }),
1009 },
1010};
1011
1012pub const TYPE_INT4_RANGE: BuiltinType<NameReference> = BuiltinType {
1013 name: "int4range",
1014 schema: PG_CATALOG_SCHEMA,
1015 oid: mz_pgrepr::oid::TYPE_INT4RANGE_OID,
1016 details: CatalogTypeDetails {
1017 typ: CatalogType::Range {
1018 element_reference: TYPE_INT4.name,
1019 },
1020 array_id: None,
1021 pg_metadata: Some(CatalogTypePgMetadata {
1022 typinput_oid: 3834,
1023 typreceive_oid: 3836,
1024 typsend_oid: 3837,
1025 }),
1026 },
1027};
1028
1029pub const TYPE_INT4_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1030 name: "_int4range",
1031 schema: PG_CATALOG_SCHEMA,
1032 oid: mz_pgrepr::oid::TYPE_INT4RANGE_ARRAY_OID,
1033 details: CatalogTypeDetails {
1034 typ: CatalogType::Array {
1035 element_reference: TYPE_INT4_RANGE.name,
1036 },
1037 array_id: None,
1038 pg_metadata: Some(CatalogTypePgMetadata {
1039 typinput_oid: 750,
1040 typreceive_oid: 2400,
1041 typsend_oid: 2401,
1042 }),
1043 },
1044};
1045
1046pub const TYPE_INT8_RANGE: BuiltinType<NameReference> = BuiltinType {
1047 name: "int8range",
1048 schema: PG_CATALOG_SCHEMA,
1049 oid: mz_pgrepr::oid::TYPE_INT8RANGE_OID,
1050 details: CatalogTypeDetails {
1051 typ: CatalogType::Range {
1052 element_reference: TYPE_INT8.name,
1053 },
1054 array_id: None,
1055 pg_metadata: Some(CatalogTypePgMetadata {
1056 typinput_oid: 3834,
1057 typreceive_oid: 3836,
1058 typsend_oid: 3837,
1059 }),
1060 },
1061};
1062
1063pub const TYPE_INT8_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1064 name: "_int8range",
1065 schema: PG_CATALOG_SCHEMA,
1066 oid: mz_pgrepr::oid::TYPE_INT8RANGE_ARRAY_OID,
1067 details: CatalogTypeDetails {
1068 typ: CatalogType::Array {
1069 element_reference: TYPE_INT8_RANGE.name,
1070 },
1071 array_id: None,
1072 pg_metadata: Some(CatalogTypePgMetadata {
1073 typinput_oid: 750,
1074 typreceive_oid: 2400,
1075 typsend_oid: 2401,
1076 }),
1077 },
1078};
1079
1080pub const TYPE_DATE_RANGE: BuiltinType<NameReference> = BuiltinType {
1081 name: "daterange",
1082 schema: PG_CATALOG_SCHEMA,
1083 oid: mz_pgrepr::oid::TYPE_DATERANGE_OID,
1084 details: CatalogTypeDetails {
1085 typ: CatalogType::Range {
1086 element_reference: TYPE_DATE.name,
1087 },
1088 array_id: None,
1089 pg_metadata: Some(CatalogTypePgMetadata {
1090 typinput_oid: 3834,
1091 typreceive_oid: 3836,
1092 typsend_oid: 3837,
1093 }),
1094 },
1095};
1096
1097pub const TYPE_DATE_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1098 name: "_daterange",
1099 schema: PG_CATALOG_SCHEMA,
1100 oid: mz_pgrepr::oid::TYPE_DATERANGE_ARRAY_OID,
1101 details: CatalogTypeDetails {
1102 typ: CatalogType::Array {
1103 element_reference: TYPE_DATE_RANGE.name,
1104 },
1105 array_id: None,
1106 pg_metadata: Some(CatalogTypePgMetadata {
1107 typinput_oid: 750,
1108 typreceive_oid: 2400,
1109 typsend_oid: 2401,
1110 }),
1111 },
1112};
1113
1114pub const TYPE_NUM_RANGE: BuiltinType<NameReference> = BuiltinType {
1115 name: "numrange",
1116 schema: PG_CATALOG_SCHEMA,
1117 oid: mz_pgrepr::oid::TYPE_NUMRANGE_OID,
1118 details: CatalogTypeDetails {
1119 typ: CatalogType::Range {
1120 element_reference: TYPE_NUMERIC.name,
1121 },
1122 array_id: None,
1123 pg_metadata: Some(CatalogTypePgMetadata {
1124 typinput_oid: 3834,
1125 typreceive_oid: 3836,
1126 typsend_oid: 3837,
1127 }),
1128 },
1129};
1130
1131pub const TYPE_NUM_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1132 name: "_numrange",
1133 schema: PG_CATALOG_SCHEMA,
1134 oid: mz_pgrepr::oid::TYPE_NUMRANGE_ARRAY_OID,
1135 details: CatalogTypeDetails {
1136 typ: CatalogType::Array {
1137 element_reference: TYPE_NUM_RANGE.name,
1138 },
1139 array_id: None,
1140 pg_metadata: Some(CatalogTypePgMetadata {
1141 typinput_oid: 750,
1142 typreceive_oid: 2400,
1143 typsend_oid: 2401,
1144 }),
1145 },
1146};
1147
1148pub const TYPE_TS_RANGE: BuiltinType<NameReference> = BuiltinType {
1149 name: "tsrange",
1150 schema: PG_CATALOG_SCHEMA,
1151 oid: mz_pgrepr::oid::TYPE_TSRANGE_OID,
1152 details: CatalogTypeDetails {
1153 typ: CatalogType::Range {
1154 element_reference: TYPE_TIMESTAMP.name,
1155 },
1156 array_id: None,
1157 pg_metadata: Some(CatalogTypePgMetadata {
1158 typinput_oid: 3834,
1159 typreceive_oid: 3836,
1160 typsend_oid: 3837,
1161 }),
1162 },
1163};
1164
1165pub const TYPE_TS_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1166 name: "_tsrange",
1167 schema: PG_CATALOG_SCHEMA,
1168 oid: mz_pgrepr::oid::TYPE_TSRANGE_ARRAY_OID,
1169 details: CatalogTypeDetails {
1170 typ: CatalogType::Array {
1171 element_reference: TYPE_TS_RANGE.name,
1172 },
1173 array_id: None,
1174 pg_metadata: Some(CatalogTypePgMetadata {
1175 typinput_oid: 750,
1176 typreceive_oid: 2400,
1177 typsend_oid: 2401,
1178 }),
1179 },
1180};
1181
1182pub const TYPE_TSTZ_RANGE: BuiltinType<NameReference> = BuiltinType {
1183 name: "tstzrange",
1184 schema: PG_CATALOG_SCHEMA,
1185 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_OID,
1186 details: CatalogTypeDetails {
1187 typ: CatalogType::Range {
1188 element_reference: TYPE_TIMESTAMPTZ.name,
1189 },
1190 array_id: None,
1191 pg_metadata: Some(CatalogTypePgMetadata {
1192 typinput_oid: 3834,
1193 typreceive_oid: 3836,
1194 typsend_oid: 3837,
1195 }),
1196 },
1197};
1198
1199pub const TYPE_TSTZ_RANGE_ARRAY: BuiltinType<NameReference> = BuiltinType {
1200 name: "_tstzrange",
1201 schema: PG_CATALOG_SCHEMA,
1202 oid: mz_pgrepr::oid::TYPE_TSTZRANGE_ARRAY_OID,
1203 details: CatalogTypeDetails {
1204 typ: CatalogType::Array {
1205 element_reference: TYPE_TSTZ_RANGE.name,
1206 },
1207 array_id: None,
1208 pg_metadata: Some(CatalogTypePgMetadata {
1209 typinput_oid: 750,
1210 typreceive_oid: 2400,
1211 typsend_oid: 2401,
1212 }),
1213 },
1214};
1215
1216pub const TYPE_ACL_ITEM: BuiltinType<NameReference> = BuiltinType {
1217 name: "aclitem",
1218 schema: PG_CATALOG_SCHEMA,
1219 oid: 1033,
1220 details: CatalogTypeDetails {
1221 typ: CatalogType::AclItem,
1222 array_id: None,
1223 pg_metadata: Some(CatalogTypePgMetadata {
1224 typinput_oid: 1031,
1225 typreceive_oid: 0,
1226 typsend_oid: 0,
1227 }),
1228 },
1229};
1230
1231pub const TYPE_ACL_ITEM_ARRAY: BuiltinType<NameReference> = BuiltinType {
1232 name: "_aclitem",
1233 schema: PG_CATALOG_SCHEMA,
1234 oid: 1034,
1235 details: CatalogTypeDetails {
1236 typ: CatalogType::Array {
1237 element_reference: TYPE_ACL_ITEM.name,
1238 },
1239 array_id: None,
1240 pg_metadata: Some(CatalogTypePgMetadata {
1241 typinput_oid: 750,
1242 typreceive_oid: 2400,
1243 typsend_oid: 2401,
1244 }),
1245 },
1246};
1247
1248pub const TYPE_INTERNAL: BuiltinType<NameReference> = BuiltinType {
1249 name: "internal",
1250 schema: PG_CATALOG_SCHEMA,
1251 oid: 2281,
1252 details: CatalogTypeDetails {
1253 typ: CatalogType::Pseudo,
1254 array_id: None,
1255 pg_metadata: Some(CatalogTypePgMetadata {
1256 typinput_oid: 2304,
1257 typreceive_oid: 0,
1258 typsend_oid: 0,
1259 }),
1260 },
1261};
1262
1263pub static PG_NAMESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1264 name: "pg_namespace",
1265 schema: PG_CATALOG_SCHEMA,
1266 oid: oid::VIEW_PG_NAMESPACE_OID,
1267 desc: RelationDesc::builder()
1268 .with_column("oid", SqlScalarType::Oid.nullable(false))
1269 .with_column("nspname", SqlScalarType::String.nullable(false))
1270 .with_column("nspowner", SqlScalarType::Oid.nullable(false))
1271 .with_column(
1272 "nspacl",
1273 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
1274 )
1275 .finish(),
1276 column_comments: BTreeMap::new(),
1277 sql: "
1278SELECT
1279 oid, nspname, nspowner, nspacl
1280FROM mz_internal.pg_namespace_all_databases
1281WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
1282 access: vec![PUBLIC_SELECT],
1283 ontology: None,
1284});
1285
1286pub static PG_CLASS: LazyLock<BuiltinView> = LazyLock::new(|| {
1287 BuiltinView {
1288 name: "pg_class",
1289 schema: PG_CATALOG_SCHEMA,
1290 oid: oid::VIEW_PG_CLASS_OID,
1291 desc: RelationDesc::builder()
1292 .with_column("oid", SqlScalarType::Oid.nullable(false))
1293 .with_column("relname", SqlScalarType::String.nullable(false))
1294 .with_column("relnamespace", SqlScalarType::Oid.nullable(false))
1295 .with_column("reloftype", SqlScalarType::Oid.nullable(false))
1296 .with_column("relowner", SqlScalarType::Oid.nullable(false))
1297 .with_column("relam", SqlScalarType::Oid.nullable(false))
1298 .with_column("reltablespace", SqlScalarType::Oid.nullable(false))
1299 .with_column("reltuples", SqlScalarType::Float32.nullable(false))
1300 .with_column("reltoastrelid", SqlScalarType::Oid.nullable(false))
1301 .with_column("relhasindex", SqlScalarType::Bool.nullable(false))
1302 .with_column("relpersistence", SqlScalarType::PgLegacyChar.nullable(false))
1303 .with_column("relkind", SqlScalarType::String.nullable(true))
1304 .with_column("relnatts", SqlScalarType::Int16.nullable(false))
1305 .with_column("relchecks", SqlScalarType::Int16.nullable(false))
1306 .with_column("relhasrules", SqlScalarType::Bool.nullable(false))
1307 .with_column("relhastriggers", SqlScalarType::Bool.nullable(false))
1308 .with_column("relhassubclass", SqlScalarType::Bool.nullable(false))
1309 .with_column("relrowsecurity", SqlScalarType::Bool.nullable(false))
1310 .with_column("relforcerowsecurity", SqlScalarType::Bool.nullable(false))
1311 .with_column("relreplident", SqlScalarType::PgLegacyChar.nullable(false))
1312 .with_column("relispartition", SqlScalarType::Bool.nullable(false))
1313 .with_column("relhasoids", SqlScalarType::Bool.nullable(false))
1314 .with_column(
1315 "reloptions",
1316 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
1317 )
1318 .finish(),
1319 column_comments: BTreeMap::new(),
1320 sql: "
1321SELECT
1322 oid, relname, relnamespace, reloftype, relowner, relam, reltablespace, reltuples, reltoastrelid,
1323 relhasindex, relpersistence, relkind, relnatts, relchecks, relhasrules, relhastriggers, relhassubclass,
1324 relrowsecurity, relforcerowsecurity, relreplident, relispartition, relhasoids, reloptions
1325FROM mz_internal.pg_class_all_databases
1326WHERE database_name IS NULL OR database_name = pg_catalog.current_database();
1327",
1328 access: vec![PUBLIC_SELECT],
1329 ontology: None,
1330}
1331});
1332
1333pub static PG_DEPEND: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1334 name: "pg_depend",
1335 schema: PG_CATALOG_SCHEMA,
1336 oid: oid::VIEW_PG_DEPEND_OID,
1337 desc: RelationDesc::builder()
1338 .with_column("classid", SqlScalarType::Oid.nullable(true))
1339 .with_column("objid", SqlScalarType::Oid.nullable(false))
1340 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
1341 .with_column("refclassid", SqlScalarType::Oid.nullable(true))
1342 .with_column("refobjid", SqlScalarType::Oid.nullable(false))
1343 .with_column("refobjsubid", SqlScalarType::Int32.nullable(false))
1344 .with_column("deptype", SqlScalarType::PgLegacyChar.nullable(false))
1345 .finish(),
1346 column_comments: BTreeMap::new(),
1347 sql: "
1348WITH class_objects AS (
1349 SELECT
1350 CASE
1351 WHEN type = 'table' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
1352 WHEN type = 'source' THEN 'pg_tables'::pg_catalog.regclass::pg_catalog.oid
1353 WHEN type = 'view' THEN 'pg_views'::pg_catalog.regclass::pg_catalog.oid
1354 WHEN type = 'materialized-view' THEN 'pg_matviews'::pg_catalog.regclass::pg_catalog.oid
1355 END classid,
1356 id,
1357 oid,
1358 schema_id
1359 FROM mz_catalog.mz_relations
1360 UNION ALL
1361 SELECT
1362 'pg_index'::pg_catalog.regclass::pg_catalog.oid AS classid,
1363 i.id,
1364 i.oid,
1365 r.schema_id
1366 FROM mz_catalog.mz_indexes i
1367 JOIN mz_catalog.mz_relations r ON i.on_id = r.id
1368),
1369
1370current_objects AS (
1371 SELECT class_objects.*
1372 FROM class_objects
1373 JOIN mz_catalog.mz_schemas ON mz_schemas.id = class_objects.schema_id
1374 LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
1375 -- This filter is tricky, as it filters out not just objects outside the
1376 -- database, but *dependencies* on objects outside this database. It's not
1377 -- clear that this is the right choice, but because PostgreSQL doesn't
1378 -- support cross-database references, it's not clear that the other choice
1379 -- is better.
1380 WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
1381)
1382
1383SELECT
1384 objects.classid::pg_catalog.oid,
1385 objects.oid::pg_catalog.oid AS objid,
1386 0::pg_catalog.int4 AS objsubid,
1387 dependents.classid::pg_catalog.oid AS refclassid,
1388 dependents.oid::pg_catalog.oid AS refobjid,
1389 0::pg_catalog.int4 AS refobjsubid,
1390 'n'::pg_catalog.char AS deptype
1391FROM mz_internal.mz_object_dependencies
1392JOIN current_objects objects ON object_id = objects.id
1393JOIN current_objects dependents ON referenced_object_id = dependents.id",
1394 access: vec![PUBLIC_SELECT],
1395 ontology: None,
1396});
1397
1398pub static PG_DATABASE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1399 name: "pg_database",
1400 schema: PG_CATALOG_SCHEMA,
1401 oid: oid::VIEW_PG_DATABASE_OID,
1402 desc: RelationDesc::builder()
1403 .with_column("oid", SqlScalarType::Oid.nullable(false))
1404 .with_column("datname", SqlScalarType::String.nullable(false))
1405 .with_column("datdba", SqlScalarType::Oid.nullable(false))
1406 .with_column("encoding", SqlScalarType::Int32.nullable(false))
1407 .with_column("datistemplate", SqlScalarType::Bool.nullable(false))
1408 .with_column("datallowconn", SqlScalarType::Bool.nullable(false))
1409 .with_column("datcollate", SqlScalarType::String.nullable(false))
1410 .with_column("datctype", SqlScalarType::String.nullable(false))
1411 .with_column(
1412 "datacl",
1413 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
1414 )
1415 .with_key(vec![0])
1416 .finish(),
1417 column_comments: BTreeMap::new(),
1418 sql: "SELECT
1419 d.oid as oid,
1420 d.name as datname,
1421 role_owner.oid as datdba,
1422 6 as encoding,
1423 -- Materialize doesn't support database cloning.
1424 FALSE AS datistemplate,
1425 TRUE AS datallowconn,
1426 'C' as datcollate,
1427 'C' as datctype,
1428 NULL::pg_catalog.text[] as datacl
1429FROM mz_catalog.mz_databases d
1430JOIN mz_catalog.mz_roles role_owner ON role_owner.id = d.owner_id",
1431 access: vec![PUBLIC_SELECT],
1432 ontology: None,
1433});
1434
1435pub static PG_INDEX: LazyLock<BuiltinView> = LazyLock::new(|| {
1436 BuiltinView {
1437 name: "pg_index",
1438 schema: PG_CATALOG_SCHEMA,
1439 oid: oid::VIEW_PG_INDEX_OID,
1440 desc: RelationDesc::builder()
1441 .with_column("indexrelid", SqlScalarType::Oid.nullable(false))
1442 .with_column("indrelid", SqlScalarType::Oid.nullable(false))
1443 .with_column("indnatts", SqlScalarType::Int16.nullable(false))
1444 .with_column("indisunique", SqlScalarType::Bool.nullable(false))
1445 .with_column("indisprimary", SqlScalarType::Bool.nullable(false))
1446 .with_column("indimmediate", SqlScalarType::Bool.nullable(false))
1447 .with_column("indisclustered", SqlScalarType::Bool.nullable(false))
1448 .with_column("indisvalid", SqlScalarType::Bool.nullable(false))
1449 .with_column("indisreplident", SqlScalarType::Bool.nullable(false))
1450 .with_column("indkey", SqlScalarType::Int2Vector.nullable(false))
1451 .with_column("indoption", SqlScalarType::Int2Vector.nullable(false))
1452 .with_column("indexprs", SqlScalarType::String.nullable(true))
1453 .with_column("indpred", SqlScalarType::String.nullable(true))
1454 .with_key(vec![0, 1])
1455 .finish(),
1456 column_comments: BTreeMap::new(),
1457 sql: "SELECT
1458 mz_indexes.oid AS indexrelid,
1459 mz_relations.oid AS indrelid,
1460 count(mz_index_columns.index_position)::pg_catalog.int2 AS indnatts,
1461 -- MZ doesn't support creating unique indexes so indisunique is filled with false
1462 false::pg_catalog.bool AS indisunique,
1463 false::pg_catalog.bool AS indisprimary,
1464 -- MZ doesn't support unique indexes so indimmediate is filled with false
1465 false::pg_catalog.bool AS indimmediate,
1466 -- MZ doesn't support CLUSTER so indisclustered is filled with false
1467 false::pg_catalog.bool AS indisclustered,
1468 -- MZ never creates invalid indexes so indisvalid is filled with true
1469 true::pg_catalog.bool AS indisvalid,
1470 -- MZ doesn't support replication so indisreplident is filled with false
1471 false::pg_catalog.bool AS indisreplident,
1472 -- Return zero if the index attribute is not a simple column reference, column position otherwise
1473 pg_catalog.string_agg(coalesce(mz_index_columns.on_position::int8, 0)::pg_catalog.text, ' ' ORDER BY mz_index_columns.index_position::int8)::pg_catalog.int2vector AS indkey,
1474 -- MZ doesn't have per-column flags, so returning a 0 for each column in the index
1475 pg_catalog.string_agg('0', ' ')::pg_catalog.int2vector AS indoption,
1476 -- Index expressions are returned in MZ format
1477 CASE pg_catalog.string_agg(mz_index_columns.on_expression, ' ' ORDER BY mz_index_columns.index_position::int8)
1478 WHEN NULL THEN NULL
1479 ELSE '{' || pg_catalog.string_agg(mz_index_columns.on_expression, '}, {' ORDER BY mz_index_columns.index_position::int8) || '}'
1480 END AS indexprs,
1481 -- MZ doesn't support indexes with predicates
1482 NULL::pg_catalog.text AS indpred
1483FROM mz_catalog.mz_indexes
1484JOIN mz_catalog.mz_relations ON mz_indexes.on_id = mz_relations.id
1485JOIN mz_catalog.mz_index_columns ON mz_index_columns.index_id = mz_indexes.id
1486JOIN mz_catalog.mz_schemas ON mz_schemas.id = mz_relations.schema_id
1487LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
1488WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()
1489GROUP BY mz_indexes.oid, mz_relations.oid",
1490 access: vec![PUBLIC_SELECT],
1491 ontology: None,
1492 }
1493});
1494
1495pub static PG_INDEXES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1496 name: "pg_indexes",
1497 schema: PG_CATALOG_SCHEMA,
1498 oid: oid::VIEW_PG_INDEXES_OID,
1499 desc: RelationDesc::builder()
1500 .with_column("table_catalog", SqlScalarType::String.nullable(false))
1501 .with_column("schemaname", SqlScalarType::String.nullable(false))
1502 .with_column("tablename", SqlScalarType::String.nullable(false))
1503 .with_column("indexname", SqlScalarType::String.nullable(false))
1504 .with_column("tablespace", SqlScalarType::String.nullable(true))
1505 .with_column("indexdef", SqlScalarType::String.nullable(true))
1506 .finish(),
1507 column_comments: BTreeMap::new(),
1508 sql: "SELECT
1509 current_database() as table_catalog,
1510 s.name AS schemaname,
1511 r.name AS tablename,
1512 i.name AS indexname,
1513 NULL::text AS tablespace,
1514 -- TODO(jkosh44) Fill in with actual index definition.
1515 NULL::text AS indexdef
1516FROM mz_catalog.mz_indexes i
1517JOIN mz_catalog.mz_relations r ON i.on_id = r.id
1518JOIN mz_catalog.mz_schemas s ON s.id = r.schema_id
1519LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
1520WHERE s.database_id IS NULL OR d.name = current_database()",
1521 access: vec![PUBLIC_SELECT],
1522 ontology: None,
1523});
1524
1525pub static PG_DESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1529 name: "pg_description",
1530 schema: PG_CATALOG_SCHEMA,
1531 oid: oid::VIEW_PG_DESCRIPTION_OID,
1532 desc: RelationDesc::builder()
1533 .with_column("objoid", SqlScalarType::Oid.nullable(false))
1534 .with_column("classoid", SqlScalarType::Oid.nullable(true))
1535 .with_column("objsubid", SqlScalarType::Int32.nullable(false))
1536 .with_column("description", SqlScalarType::String.nullable(false))
1537 .finish(),
1538 column_comments: BTreeMap::new(),
1539 sql: "
1540SELECT
1541 objoid,
1542 classoid,
1543 objsubid,
1544 description
1545FROM
1546 mz_internal.pg_description_all_databases
1547WHERE
1548 (oid_database_name IS NULL OR oid_database_name = pg_catalog.current_database()) AND
1549 (class_database_name IS NULL OR class_database_name = pg_catalog.current_database());",
1550 access: vec![PUBLIC_SELECT],
1551 ontology: None,
1552});
1553
1554pub static PG_TYPE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1555 name: "pg_type",
1556 schema: PG_CATALOG_SCHEMA,
1557 oid: oid::VIEW_PG_TYPE_OID,
1558 desc: RelationDesc::builder()
1559 .with_column("oid", SqlScalarType::Oid.nullable(false))
1560 .with_column("typname", SqlScalarType::String.nullable(false))
1561 .with_column("typnamespace", SqlScalarType::Oid.nullable(false))
1562 .with_column("typowner", SqlScalarType::Oid.nullable(false))
1563 .with_column("typlen", SqlScalarType::Int16.nullable(true))
1564 .with_column("typtype", SqlScalarType::PgLegacyChar.nullable(false))
1565 .with_column("typcategory", SqlScalarType::PgLegacyChar.nullable(true))
1566 .with_column("typdelim", SqlScalarType::PgLegacyChar.nullable(false))
1567 .with_column("typrelid", SqlScalarType::Oid.nullable(false))
1568 .with_column("typelem", SqlScalarType::Oid.nullable(false))
1569 .with_column("typarray", SqlScalarType::Oid.nullable(false))
1570 .with_column("typinput", SqlScalarType::RegProc.nullable(true))
1571 .with_column("typreceive", SqlScalarType::RegProc.nullable(false))
1575 .with_column("typnotnull", SqlScalarType::Bool.nullable(false))
1576 .with_column("typbasetype", SqlScalarType::Oid.nullable(false))
1577 .with_column("typtypmod", SqlScalarType::Int32.nullable(false))
1578 .with_column("typcollation", SqlScalarType::Oid.nullable(false))
1579 .with_column("typdefault", SqlScalarType::String.nullable(true))
1580 .with_column("typsend", SqlScalarType::RegProc.nullable(false))
1581 .finish(),
1582 column_comments: BTreeMap::new(),
1583 sql: "SELECT
1584 oid, typname, typnamespace, typowner, typlen, typtype, typcategory, typdelim, typrelid, typelem,
1585 typarray, typinput, typreceive::pg_catalog.regproc AS typreceive, typnotnull, typbasetype,
1586 typtypmod, typcollation, typdefault, typsend
1587FROM mz_internal.pg_type_all_databases
1588WHERE database_name IS NULL OR database_name = pg_catalog.current_database();",
1589 access: vec![PUBLIC_SELECT],
1590 ontology: None,
1591});
1592
1593pub static PG_ATTRIBUTE: LazyLock<BuiltinView> = LazyLock::new(|| {
1595 BuiltinView {
1596 name: "pg_attribute",
1597 schema: PG_CATALOG_SCHEMA,
1598 oid: oid::VIEW_PG_ATTRIBUTE_OID,
1599 desc: RelationDesc::builder()
1600 .with_column("attrelid", SqlScalarType::Oid.nullable(false))
1601 .with_column("attname", SqlScalarType::String.nullable(false))
1602 .with_column("atttypid", SqlScalarType::Oid.nullable(false))
1603 .with_column("attlen", SqlScalarType::Int16.nullable(true))
1604 .with_column("attnum", SqlScalarType::Int16.nullable(false))
1605 .with_column("atttypmod", SqlScalarType::Int32.nullable(false))
1606 .with_column("attndims", SqlScalarType::Int16.nullable(false))
1607 .with_column("attnotnull", SqlScalarType::Bool.nullable(false))
1608 .with_column("atthasdef", SqlScalarType::Bool.nullable(false))
1609 .with_column("attidentity", SqlScalarType::PgLegacyChar.nullable(false))
1610 .with_column("attgenerated", SqlScalarType::PgLegacyChar.nullable(false))
1611 .with_column("attisdropped", SqlScalarType::Bool.nullable(false))
1612 .with_column("attcollation", SqlScalarType::Oid.nullable(false))
1613 .finish(),
1614 column_comments: BTreeMap::new(),
1615 sql: "
1616SELECT
1617 attrelid, attname, atttypid, attlen, attnum, atttypmod, attndims, attnotnull, atthasdef,
1618 attidentity, attgenerated, attisdropped, attcollation
1619FROM mz_internal.pg_attribute_all_databases
1620WHERE
1621 (database_name IS NULL OR database_name = pg_catalog.current_database()) AND
1622 (pg_type_database_name IS NULL OR pg_type_database_name = pg_catalog.current_database());",
1623 access: vec![PUBLIC_SELECT],
1626 ontology: None,
1627 }
1628});
1629
1630pub static PG_PROC: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1631 name: "pg_proc",
1632 schema: PG_CATALOG_SCHEMA,
1633 oid: oid::VIEW_PG_PROC_OID,
1634 desc: RelationDesc::builder()
1635 .with_column("oid", SqlScalarType::Oid.nullable(false))
1636 .with_column("proname", SqlScalarType::String.nullable(false))
1637 .with_column("pronamespace", SqlScalarType::Oid.nullable(false))
1638 .with_column("proowner", SqlScalarType::Oid.nullable(false))
1639 .with_column("proargdefaults", SqlScalarType::String.nullable(true))
1640 .with_column("prorettype", SqlScalarType::Oid.nullable(false))
1641 .finish(),
1642 column_comments: BTreeMap::new(),
1643 sql: "SELECT
1644 mz_functions.oid,
1645 mz_functions.name AS proname,
1646 mz_schemas.oid AS pronamespace,
1647 role_owner.oid AS proowner,
1648 NULL::pg_catalog.text AS proargdefaults,
1649 ret_type.oid AS prorettype
1650FROM mz_catalog.mz_functions
1651JOIN mz_catalog.mz_schemas ON mz_functions.schema_id = mz_schemas.id
1652LEFT JOIN mz_catalog.mz_databases d ON d.id = mz_schemas.database_id
1653JOIN mz_catalog.mz_types AS ret_type ON mz_functions.return_type_id = ret_type.id
1654JOIN mz_catalog.mz_roles role_owner ON role_owner.id = mz_functions.owner_id
1655WHERE mz_schemas.database_id IS NULL OR d.name = pg_catalog.current_database()",
1656 access: vec![PUBLIC_SELECT],
1657 ontology: None,
1658});
1659
1660pub static PG_OPERATOR: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1661 name: "pg_operator",
1662 schema: PG_CATALOG_SCHEMA,
1663 oid: oid::VIEW_PG_OPERATOR_OID,
1664 desc: RelationDesc::builder()
1665 .with_column("oid", SqlScalarType::Oid.nullable(false))
1666 .with_column("oprname", SqlScalarType::String.nullable(false))
1667 .with_column("oprresult", SqlScalarType::Oid.nullable(false))
1668 .with_column("oprleft", SqlScalarType::Oid.nullable(false))
1669 .with_column("oprright", SqlScalarType::Oid.nullable(false))
1670 .with_key(vec![0, 1, 2, 3, 4])
1671 .finish(),
1672 column_comments: BTreeMap::new(),
1673 sql: "SELECT
1674 mz_operators.oid,
1675 mz_operators.name AS oprname,
1676 ret_type.oid AS oprresult,
1677 left_type.oid as oprleft,
1678 right_type.oid as oprright
1679FROM mz_catalog.mz_operators
1680JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
1681JOIN mz_catalog.mz_types AS left_type ON mz_operators.argument_type_ids[1] = left_type.id
1682JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[2] = right_type.id
1683WHERE array_length(mz_operators.argument_type_ids, 1) = 2
1684UNION SELECT
1685 mz_operators.oid,
1686 mz_operators.name AS oprname,
1687 ret_type.oid AS oprresult,
1688 0 as oprleft,
1689 right_type.oid as oprright
1690FROM mz_catalog.mz_operators
1691JOIN mz_catalog.mz_types AS ret_type ON mz_operators.return_type_id = ret_type.id
1692JOIN mz_catalog.mz_types AS right_type ON mz_operators.argument_type_ids[1] = right_type.id
1693WHERE array_length(mz_operators.argument_type_ids, 1) = 1",
1694 access: vec![PUBLIC_SELECT],
1695 ontology: None,
1696});
1697
1698pub static PG_RANGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1699 name: "pg_range",
1700 schema: PG_CATALOG_SCHEMA,
1701 oid: oid::VIEW_PG_RANGE_OID,
1702 desc: RelationDesc::builder()
1703 .with_column("rngtypid", SqlScalarType::Oid.nullable(false))
1704 .with_column("rngsubtype", SqlScalarType::Oid.nullable(false))
1705 .with_key(vec![])
1706 .finish(),
1707 column_comments: BTreeMap::new(),
1708 sql: "SELECT
1709 NULL::pg_catalog.oid AS rngtypid,
1710 NULL::pg_catalog.oid AS rngsubtype
1711WHERE false",
1712 access: vec![PUBLIC_SELECT],
1713 ontology: None,
1714});
1715
1716pub static PG_ENUM: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1717 name: "pg_enum",
1718 schema: PG_CATALOG_SCHEMA,
1719 oid: oid::VIEW_PG_ENUM_OID,
1720 desc: RelationDesc::builder()
1721 .with_column("oid", SqlScalarType::Oid.nullable(false))
1722 .with_column("enumtypid", SqlScalarType::Oid.nullable(false))
1723 .with_column("enumsortorder", SqlScalarType::Float32.nullable(false))
1724 .with_column("enumlabel", SqlScalarType::String.nullable(false))
1725 .with_key(vec![])
1726 .finish(),
1727 column_comments: BTreeMap::new(),
1728 sql: "SELECT
1729 NULL::pg_catalog.oid AS oid,
1730 NULL::pg_catalog.oid AS enumtypid,
1731 NULL::pg_catalog.float4 AS enumsortorder,
1732 NULL::pg_catalog.text AS enumlabel
1733WHERE false",
1734 access: vec![PUBLIC_SELECT],
1735 ontology: None,
1736});
1737
1738pub static PG_ATTRDEF: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1739 name: "pg_attrdef",
1740 schema: PG_CATALOG_SCHEMA,
1741 oid: oid::VIEW_PG_ATTRDEF_OID,
1742 desc: RelationDesc::builder()
1743 .with_column("oid", SqlScalarType::Oid.nullable(true))
1744 .with_column("adrelid", SqlScalarType::Oid.nullable(false))
1745 .with_column("adnum", SqlScalarType::Int64.nullable(false))
1746 .with_column("adbin", SqlScalarType::String.nullable(false))
1747 .with_column("adsrc", SqlScalarType::String.nullable(false))
1748 .finish(),
1749 column_comments: BTreeMap::new(),
1750 sql: "
1751SELECT
1752 pg_attrdef_all_databases.oid as oid,
1753 adrelid,
1754 adnum,
1755 adbin,
1756 adsrc
1757FROM mz_internal.pg_attrdef_all_databases
1758 JOIN mz_catalog.mz_databases d ON (d.id IS NULL OR d.name = pg_catalog.current_database());",
1759 access: vec![PUBLIC_SELECT],
1760 ontology: None,
1761});
1762
1763pub static PG_SETTINGS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1764 name: "pg_settings",
1765 schema: PG_CATALOG_SCHEMA,
1766 oid: oid::VIEW_PG_SETTINGS_OID,
1767 desc: RelationDesc::builder()
1768 .with_column("name", SqlScalarType::String.nullable(false))
1769 .with_column("setting", SqlScalarType::String.nullable(false))
1770 .with_key(vec![])
1771 .finish(),
1772 column_comments: BTreeMap::new(),
1773 sql: "SELECT
1774 name, setting
1775FROM (VALUES
1776 ('max_index_keys'::pg_catalog.text, '1000'::pg_catalog.text)
1777) AS _ (name, setting)",
1778 access: vec![PUBLIC_SELECT],
1779 ontology: None,
1780});
1781
1782pub static PG_AUTH_MEMBERS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1783 name: "pg_auth_members",
1784 schema: PG_CATALOG_SCHEMA,
1785 oid: oid::VIEW_PG_AUTH_MEMBERS_OID,
1786 desc: RelationDesc::builder()
1787 .with_column("roleid", SqlScalarType::Oid.nullable(false))
1788 .with_column("member", SqlScalarType::Oid.nullable(false))
1789 .with_column("grantor", SqlScalarType::Oid.nullable(false))
1790 .with_column("admin_option", SqlScalarType::Bool.nullable(false))
1791 .finish(),
1792 column_comments: BTreeMap::new(),
1793 sql: "SELECT
1794 role.oid AS roleid,
1795 member.oid AS member,
1796 grantor.oid AS grantor,
1797 -- Materialize hasn't implemented admin_option.
1798 false as admin_option
1799FROM mz_catalog.mz_role_members membership
1800JOIN mz_catalog.mz_roles role ON membership.role_id = role.id
1801JOIN mz_catalog.mz_roles member ON membership.member = member.id
1802JOIN mz_catalog.mz_roles grantor ON membership.grantor = grantor.id",
1803 access: vec![PUBLIC_SELECT],
1804 ontology: None,
1805});
1806
1807pub static PG_EVENT_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1808 name: "pg_event_trigger",
1809 schema: PG_CATALOG_SCHEMA,
1810 oid: oid::VIEW_PG_EVENT_TRIGGER_OID,
1811 desc: RelationDesc::builder()
1812 .with_column("oid", SqlScalarType::Oid.nullable(false))
1813 .with_column("evtname", SqlScalarType::String.nullable(false))
1814 .with_column("evtevent", SqlScalarType::String.nullable(false))
1815 .with_column("evtowner", SqlScalarType::Oid.nullable(false))
1816 .with_column("evtfoid", SqlScalarType::Oid.nullable(false))
1817 .with_column("evtenabled", SqlScalarType::PgLegacyChar.nullable(false))
1818 .with_column(
1819 "evttags",
1820 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
1821 )
1822 .with_key(vec![])
1823 .finish(),
1824 column_comments: BTreeMap::new(),
1825 sql: "SELECT
1826 NULL::pg_catalog.oid AS oid,
1827 NULL::pg_catalog.text AS evtname,
1828 NULL::pg_catalog.text AS evtevent,
1829 NULL::pg_catalog.oid AS evtowner,
1830 NULL::pg_catalog.oid AS evtfoid,
1831 NULL::pg_catalog.char AS evtenabled,
1832 NULL::pg_catalog.text[] AS evttags
1833 WHERE false",
1834 access: vec![PUBLIC_SELECT],
1835 ontology: None,
1836});
1837
1838pub static PG_LANGUAGE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1839 name: "pg_language",
1840 schema: PG_CATALOG_SCHEMA,
1841 oid: oid::VIEW_PG_LANGUAGE_OID,
1842 desc: RelationDesc::builder()
1843 .with_column("oid", SqlScalarType::Oid.nullable(false))
1844 .with_column("lanname", SqlScalarType::String.nullable(false))
1845 .with_column("lanowner", SqlScalarType::Oid.nullable(false))
1846 .with_column("lanispl", SqlScalarType::Bool.nullable(false))
1847 .with_column("lanpltrusted", SqlScalarType::Bool.nullable(false))
1848 .with_column("lanplcallfoid", SqlScalarType::Oid.nullable(false))
1849 .with_column("laninline", SqlScalarType::Oid.nullable(false))
1850 .with_column("lanvalidator", SqlScalarType::Oid.nullable(false))
1851 .with_column(
1852 "lanacl",
1853 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
1854 )
1855 .with_key(vec![])
1856 .finish(),
1857 column_comments: BTreeMap::new(),
1858 sql: "SELECT
1859 NULL::pg_catalog.oid AS oid,
1860 NULL::pg_catalog.text AS lanname,
1861 NULL::pg_catalog.oid AS lanowner,
1862 NULL::pg_catalog.bool AS lanispl,
1863 NULL::pg_catalog.bool AS lanpltrusted,
1864 NULL::pg_catalog.oid AS lanplcallfoid,
1865 NULL::pg_catalog.oid AS laninline,
1866 NULL::pg_catalog.oid AS lanvalidator,
1867 NULL::pg_catalog.text[] AS lanacl
1868 WHERE false",
1869 access: vec![PUBLIC_SELECT],
1870 ontology: None,
1871});
1872
1873pub static PG_SHDESCRIPTION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1874 name: "pg_shdescription",
1875 schema: PG_CATALOG_SCHEMA,
1876 oid: oid::VIEW_PG_SHDESCRIPTION_OID,
1877 desc: RelationDesc::builder()
1878 .with_column("objoid", SqlScalarType::Oid.nullable(false))
1879 .with_column("classoid", SqlScalarType::Oid.nullable(false))
1880 .with_column("description", SqlScalarType::String.nullable(false))
1881 .with_key(vec![])
1882 .finish(),
1883 column_comments: BTreeMap::new(),
1884 sql: "SELECT
1885 NULL::pg_catalog.oid AS objoid,
1886 NULL::pg_catalog.oid AS classoid,
1887 NULL::pg_catalog.text AS description
1888 WHERE false",
1889 access: vec![PUBLIC_SELECT],
1890 ontology: None,
1891});
1892
1893pub static PG_TIMEZONE_ABBREVS: LazyLock<BuiltinView> = LazyLock::new(|| {
1894 BuiltinView {
1895 name: "pg_timezone_abbrevs",
1896 schema: PG_CATALOG_SCHEMA,
1897 oid: oid::VIEW_PG_TIMEZONE_ABBREVS_OID,
1898 desc: RelationDesc::builder()
1899 .with_column("abbrev", SqlScalarType::String.nullable(false))
1900 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
1901 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
1902 .with_key(vec![0])
1903 .finish(),
1904 column_comments: BTreeMap::new(),
1905 sql: "SELECT
1906 abbreviation AS abbrev,
1907 COALESCE(utc_offset, timezone_offset(timezone_name, now()).base_utc_offset + timezone_offset(timezone_name, now()).dst_offset)
1908 AS utc_offset,
1909 COALESCE(dst, timezone_offset(timezone_name, now()).dst_offset <> INTERVAL '0')
1910 AS is_dst
1911FROM mz_catalog.mz_timezone_abbreviations",
1912 access: vec![PUBLIC_SELECT],
1913 ontology: None,
1914 }
1915});
1916
1917pub static PG_TIMEZONE_NAMES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1918 name: "pg_timezone_names",
1919 schema: PG_CATALOG_SCHEMA,
1920 oid: oid::VIEW_PG_TIMEZONE_NAMES_OID,
1921 desc: RelationDesc::builder()
1922 .with_column("name", SqlScalarType::String.nullable(false))
1923 .with_column("abbrev", SqlScalarType::String.nullable(true))
1924 .with_column("utc_offset", SqlScalarType::Interval.nullable(true))
1925 .with_column("is_dst", SqlScalarType::Bool.nullable(true))
1926 .with_key(vec![0])
1927 .finish(),
1928 column_comments: BTreeMap::new(),
1929 sql: "SELECT
1930 name,
1931 timezone_offset(name, now()).abbrev AS abbrev,
1932 timezone_offset(name, now()).base_utc_offset + timezone_offset(name, now()).dst_offset
1933 AS utc_offset,
1934 timezone_offset(name, now()).dst_offset <> INTERVAL '0'
1935 AS is_dst
1936FROM mz_catalog.mz_timezone_names",
1937 access: vec![PUBLIC_SELECT],
1938 ontology: None,
1939});
1940
1941pub static PG_CONSTRAINT: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
1944 name: "pg_constraint",
1945 schema: PG_CATALOG_SCHEMA,
1946 oid: oid::VIEW_PG_CONSTRAINT_OID,
1947 desc: RelationDesc::builder()
1948 .with_column("oid", SqlScalarType::Oid.nullable(false))
1949 .with_column("conname", SqlScalarType::String.nullable(false))
1950 .with_column("connamespace", SqlScalarType::Oid.nullable(false))
1951 .with_column("contype", SqlScalarType::PgLegacyChar.nullable(false))
1952 .with_column("condeferrable", SqlScalarType::Bool.nullable(false))
1953 .with_column("condeferred", SqlScalarType::Bool.nullable(false))
1954 .with_column("convalidated", SqlScalarType::Bool.nullable(false))
1955 .with_column("conrelid", SqlScalarType::Oid.nullable(false))
1956 .with_column("contypid", SqlScalarType::Oid.nullable(false))
1957 .with_column("conindid", SqlScalarType::Oid.nullable(false))
1958 .with_column("conparentid", SqlScalarType::Oid.nullable(false))
1959 .with_column("confrelid", SqlScalarType::Oid.nullable(false))
1960 .with_column("confupdtype", SqlScalarType::PgLegacyChar.nullable(false))
1961 .with_column("confdeltype", SqlScalarType::PgLegacyChar.nullable(false))
1962 .with_column("confmatchtype", SqlScalarType::PgLegacyChar.nullable(false))
1963 .with_column("conislocal", SqlScalarType::Bool.nullable(false))
1964 .with_column("coninhcount", SqlScalarType::Int32.nullable(false))
1965 .with_column("connoinherit", SqlScalarType::Bool.nullable(false))
1966 .with_column(
1967 "conkey",
1968 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
1969 )
1970 .with_column(
1971 "confkey",
1972 SqlScalarType::Array(Box::new(SqlScalarType::Int16)).nullable(false),
1973 )
1974 .with_column(
1975 "conpfeqop",
1976 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
1977 )
1978 .with_column(
1979 "conppeqop",
1980 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
1981 )
1982 .with_column(
1983 "conffeqop",
1984 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
1985 )
1986 .with_column(
1987 "conexclop",
1988 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
1989 )
1990 .with_column("conbin", SqlScalarType::String.nullable(false))
1991 .with_key(vec![])
1992 .finish(),
1993 column_comments: BTreeMap::new(),
1994 sql: "SELECT
1995 NULL::pg_catalog.oid as oid,
1996 NULL::pg_catalog.text as conname,
1997 NULL::pg_catalog.oid as connamespace,
1998 NULL::pg_catalog.\"char\" as contype,
1999 NULL::pg_catalog.bool as condeferrable,
2000 NULL::pg_catalog.bool as condeferred,
2001 NULL::pg_catalog.bool as convalidated,
2002 NULL::pg_catalog.oid as conrelid,
2003 NULL::pg_catalog.oid as contypid,
2004 NULL::pg_catalog.oid as conindid,
2005 NULL::pg_catalog.oid as conparentid,
2006 NULL::pg_catalog.oid as confrelid,
2007 NULL::pg_catalog.\"char\" as confupdtype,
2008 NULL::pg_catalog.\"char\" as confdeltype,
2009 NULL::pg_catalog.\"char\" as confmatchtype,
2010 NULL::pg_catalog.bool as conislocal,
2011 NULL::pg_catalog.int4 as coninhcount,
2012 NULL::pg_catalog.bool as connoinherit,
2013 NULL::pg_catalog.int2[] as conkey,
2014 NULL::pg_catalog.int2[] as confkey,
2015 NULL::pg_catalog.oid[] as conpfeqop,
2016 NULL::pg_catalog.oid[] as conppeqop,
2017 NULL::pg_catalog.oid[] as conffeqop,
2018 NULL::pg_catalog.oid[] as conexclop,
2019 NULL::pg_catalog.text as conbin
2020WHERE false",
2021 access: vec![PUBLIC_SELECT],
2022 ontology: None,
2023});
2024
2025pub static PG_TABLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2026 name: "pg_tables",
2027 schema: PG_CATALOG_SCHEMA,
2028 oid: oid::VIEW_PG_TABLES_OID,
2029 desc: RelationDesc::builder()
2030 .with_column("schemaname", SqlScalarType::String.nullable(true))
2031 .with_column("tablename", SqlScalarType::String.nullable(false))
2032 .with_column("tableowner", SqlScalarType::String.nullable(false))
2033 .finish(),
2034 column_comments: BTreeMap::new(),
2035 sql: "
2036SELECT n.nspname AS schemaname,
2037 c.relname AS tablename,
2038 pg_catalog.pg_get_userbyid(c.relowner) AS tableowner
2039FROM pg_catalog.pg_class c
2040LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
2041WHERE c.relkind IN ('r', 'p')",
2042 access: vec![PUBLIC_SELECT],
2043 ontology: None,
2044});
2045
2046pub static PG_TABLESPACE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2047 name: "pg_tablespace",
2048 schema: PG_CATALOG_SCHEMA,
2049 oid: oid::VIEW_PG_TABLESPACE_OID,
2050 desc: RelationDesc::builder()
2051 .with_column("oid", SqlScalarType::Oid.nullable(false))
2052 .with_column("spcname", SqlScalarType::String.nullable(false))
2053 .with_column("spcowner", SqlScalarType::Oid.nullable(true))
2054 .with_column(
2055 "spcacl",
2056 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
2057 )
2058 .with_column(
2059 "spcoptions",
2060 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
2061 )
2062 .with_key(vec![])
2063 .finish(),
2064 column_comments: BTreeMap::new(),
2065 sql: "
2066 SELECT oid, spcname, spcowner, spcacl, spcoptions
2067 FROM (
2068 VALUES (
2069 --These are the same defaults CockroachDB uses.
2070 0::pg_catalog.oid,
2071 'pg_default'::pg_catalog.text,
2072 NULL::pg_catalog.oid,
2073 NULL::pg_catalog.text[],
2074 NULL::pg_catalog.text[]
2075 )
2076 ) AS _ (oid, spcname, spcowner, spcacl, spcoptions)
2077",
2078 access: vec![PUBLIC_SELECT],
2079 ontology: None,
2080});
2081
2082pub static PG_ACCESS_METHODS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2083 name: "pg_am",
2084 schema: PG_CATALOG_SCHEMA,
2085 oid: oid::VIEW_PG_AM_OID,
2086 desc: RelationDesc::builder()
2087 .with_column("oid", SqlScalarType::Oid.nullable(false))
2088 .with_column("amname", SqlScalarType::String.nullable(false))
2089 .with_column("amhandler", SqlScalarType::RegProc.nullable(false))
2090 .with_column("amtype", SqlScalarType::PgLegacyChar.nullable(false))
2091 .with_key(vec![])
2092 .finish(),
2093 column_comments: BTreeMap::new(),
2094 sql: "
2095SELECT NULL::pg_catalog.oid AS oid,
2096 NULL::pg_catalog.text AS amname,
2097 NULL::pg_catalog.regproc AS amhandler,
2098 NULL::pg_catalog.\"char\" AS amtype
2099WHERE false",
2100 access: vec![PUBLIC_SELECT],
2101 ontology: None,
2102});
2103
2104pub static PG_ROLES: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2105 name: "pg_roles",
2106 schema: PG_CATALOG_SCHEMA,
2107 oid: oid::VIEW_PG_ROLES_OID,
2108 desc: RelationDesc::builder()
2109 .with_column("rolname", SqlScalarType::String.nullable(false))
2110 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
2111 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
2112 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
2113 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
2114 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
2115 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
2116 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
2117 .with_column("rolpassword", SqlScalarType::String.nullable(false))
2118 .with_column(
2119 "rolvaliduntil",
2120 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2121 )
2122 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
2123 .with_column(
2124 "rolconfig",
2125 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
2126 )
2127 .with_column("oid", SqlScalarType::Oid.nullable(false))
2128 .finish(),
2129 column_comments: BTreeMap::new(),
2130 sql: "SELECT
2131 rolname,
2132 rolsuper,
2133 rolinherit,
2134 rolcreaterole,
2135 rolcreatedb,
2136 COALESCE(rolcanlogin, false) AS rolcanlogin,
2137 rolreplication,
2138 rolconnlimit,
2139 '********' as rolpassword,
2140 rolvaliduntil,
2141 rolbypassrls,
2142 (
2143 SELECT array_agg(parameter_name || '=' || parameter_value)
2144 FROM mz_catalog.mz_role_parameters rp
2145 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
2146 WHERE ai.oid = r.oid
2147 ) AS rolconfig,
2148 oid
2149FROM pg_catalog.pg_authid ai",
2150 access: vec![PUBLIC_SELECT],
2151 ontology: None,
2152});
2153
2154pub static PG_USER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2155 name: "pg_user",
2156 schema: PG_CATALOG_SCHEMA,
2157 oid: oid::VIEW_PG_USER_OID,
2158 desc: RelationDesc::builder()
2159 .with_column("usename", SqlScalarType::String.nullable(false))
2160 .with_column("usesysid", SqlScalarType::Oid.nullable(false))
2161 .with_column("usecreatedb", SqlScalarType::Bool.nullable(true))
2162 .with_column("usesuper", SqlScalarType::Bool.nullable(true))
2163 .with_column("userepl", SqlScalarType::Bool.nullable(false))
2164 .with_column("usebypassrls", SqlScalarType::Bool.nullable(false))
2165 .with_column("passwd", SqlScalarType::String.nullable(false))
2166 .with_column(
2167 "valuntil",
2168 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2169 )
2170 .with_column(
2171 "useconfig",
2172 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(true),
2173 )
2174 .finish(),
2175 column_comments: BTreeMap::new(),
2176 sql: "
2177SELECT
2178 rolname as usename,
2179 ai.oid as usesysid,
2180 rolcreatedb AS usecreatedb,
2181 rolsuper AS usesuper,
2182 rolreplication AS userepl,
2183 rolbypassrls AS usebypassrls,
2184 '********' as passwd,
2185 rolvaliduntil as valuntil,
2186 (
2187 SELECT array_agg(parameter_name || '=' || parameter_value)
2188 FROM mz_catalog.mz_role_parameters rp
2189 JOIN mz_catalog.mz_roles r ON r.id = rp.role_id
2190 WHERE ai.oid = r.oid
2191 ) AS useconfig
2192FROM pg_catalog.pg_authid ai
2193WHERE rolcanlogin",
2194 access: vec![PUBLIC_SELECT],
2195 ontology: None,
2196});
2197
2198pub static PG_VIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2199 name: "pg_views",
2200 schema: PG_CATALOG_SCHEMA,
2201 oid: oid::VIEW_PG_VIEWS_OID,
2202 desc: RelationDesc::builder()
2203 .with_column("schemaname", SqlScalarType::String.nullable(true))
2204 .with_column("viewname", SqlScalarType::String.nullable(false))
2205 .with_column("viewowner", SqlScalarType::Oid.nullable(false))
2206 .with_column("definition", SqlScalarType::String.nullable(false))
2207 .finish(),
2208 column_comments: BTreeMap::new(),
2209 sql: "SELECT
2210 s.name AS schemaname,
2211 v.name AS viewname,
2212 role_owner.oid AS viewowner,
2213 v.definition AS definition
2214FROM mz_catalog.mz_views v
2215LEFT JOIN mz_catalog.mz_schemas s ON s.id = v.schema_id
2216LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
2217JOIN mz_catalog.mz_roles role_owner ON role_owner.id = v.owner_id
2218WHERE s.database_id IS NULL OR d.name = current_database()",
2219 access: vec![PUBLIC_SELECT],
2220 ontology: None,
2221});
2222
2223pub static PG_MATVIEWS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2224 name: "pg_matviews",
2225 schema: PG_CATALOG_SCHEMA,
2226 oid: oid::VIEW_PG_MATVIEWS_OID,
2227 desc: RelationDesc::builder()
2228 .with_column("schemaname", SqlScalarType::String.nullable(true))
2229 .with_column("matviewname", SqlScalarType::String.nullable(false))
2230 .with_column("matviewowner", SqlScalarType::Oid.nullable(false))
2231 .with_column("definition", SqlScalarType::String.nullable(false))
2232 .finish(),
2233 column_comments: BTreeMap::new(),
2234 sql: "SELECT
2235 s.name AS schemaname,
2236 m.name AS matviewname,
2237 role_owner.oid AS matviewowner,
2238 m.definition AS definition
2239FROM mz_catalog.mz_materialized_views m
2240LEFT JOIN mz_catalog.mz_schemas s ON s.id = m.schema_id
2241LEFT JOIN mz_catalog.mz_databases d ON d.id = s.database_id
2242JOIN mz_catalog.mz_roles role_owner ON role_owner.id = m.owner_id
2243WHERE s.database_id IS NULL OR d.name = current_database()",
2244 access: vec![PUBLIC_SELECT],
2245 ontology: None,
2246});
2247
2248pub static PG_COLLATION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2251 name: "pg_collation",
2252 schema: PG_CATALOG_SCHEMA,
2253 oid: oid::VIEW_PG_COLLATION_OID,
2254 desc: RelationDesc::builder()
2255 .with_column("oid", SqlScalarType::Oid.nullable(false))
2256 .with_column("collname", SqlScalarType::String.nullable(false))
2257 .with_column("collnamespace", SqlScalarType::Oid.nullable(false))
2258 .with_column("collowner", SqlScalarType::Oid.nullable(false))
2259 .with_column("collprovider", SqlScalarType::PgLegacyChar.nullable(false))
2260 .with_column("collisdeterministic", SqlScalarType::Bool.nullable(false))
2261 .with_column("collencoding", SqlScalarType::Int32.nullable(false))
2262 .with_column("collcollate", SqlScalarType::String.nullable(false))
2263 .with_column("collctype", SqlScalarType::String.nullable(false))
2264 .with_column("collversion", SqlScalarType::String.nullable(false))
2265 .with_key(vec![])
2266 .finish(),
2267 column_comments: BTreeMap::new(),
2268 sql: "
2269SELECT
2270 NULL::pg_catalog.oid AS oid,
2271 NULL::pg_catalog.text AS collname,
2272 NULL::pg_catalog.oid AS collnamespace,
2273 NULL::pg_catalog.oid AS collowner,
2274 NULL::pg_catalog.\"char\" AS collprovider,
2275 NULL::pg_catalog.bool AS collisdeterministic,
2276 NULL::pg_catalog.int4 AS collencoding,
2277 NULL::pg_catalog.text AS collcollate,
2278 NULL::pg_catalog.text AS collctype,
2279 NULL::pg_catalog.text AS collversion
2280WHERE false",
2281 access: vec![PUBLIC_SELECT],
2282 ontology: None,
2283});
2284
2285pub static PG_POLICY: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2287 name: "pg_policy",
2288 schema: PG_CATALOG_SCHEMA,
2289 oid: oid::VIEW_PG_POLICY_OID,
2290 desc: RelationDesc::builder()
2291 .with_column("oid", SqlScalarType::Oid.nullable(false))
2292 .with_column("polname", SqlScalarType::String.nullable(false))
2293 .with_column("polrelid", SqlScalarType::Oid.nullable(false))
2294 .with_column("polcmd", SqlScalarType::PgLegacyChar.nullable(false))
2295 .with_column("polpermissive", SqlScalarType::Bool.nullable(false))
2296 .with_column(
2297 "polroles",
2298 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
2299 )
2300 .with_column("polqual", SqlScalarType::String.nullable(false))
2301 .with_column("polwithcheck", SqlScalarType::String.nullable(false))
2302 .with_key(vec![])
2303 .finish(),
2304 column_comments: BTreeMap::new(),
2305 sql: "
2306SELECT
2307 NULL::pg_catalog.oid AS oid,
2308 NULL::pg_catalog.text AS polname,
2309 NULL::pg_catalog.oid AS polrelid,
2310 NULL::pg_catalog.\"char\" AS polcmd,
2311 NULL::pg_catalog.bool AS polpermissive,
2312 NULL::pg_catalog.oid[] AS polroles,
2313 NULL::pg_catalog.text AS polqual,
2314 NULL::pg_catalog.text AS polwithcheck
2315WHERE false",
2316 access: vec![PUBLIC_SELECT],
2317 ontology: None,
2318});
2319
2320pub static PG_INHERITS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2322 name: "pg_inherits",
2323 schema: PG_CATALOG_SCHEMA,
2324 oid: oid::VIEW_PG_INHERITS_OID,
2325 desc: RelationDesc::builder()
2326 .with_column("inhrelid", SqlScalarType::Oid.nullable(false))
2327 .with_column("inhparent", SqlScalarType::Oid.nullable(false))
2328 .with_column("inhseqno", SqlScalarType::Int32.nullable(false))
2329 .with_column("inhdetachpending", SqlScalarType::Bool.nullable(false))
2330 .with_key(vec![])
2331 .finish(),
2332 column_comments: BTreeMap::new(),
2333 sql: "
2334SELECT
2335 NULL::pg_catalog.oid AS inhrelid,
2336 NULL::pg_catalog.oid AS inhparent,
2337 NULL::pg_catalog.int4 AS inhseqno,
2338 NULL::pg_catalog.bool AS inhdetachpending
2339WHERE false",
2340 access: vec![PUBLIC_SELECT],
2341 ontology: None,
2342});
2343
2344pub static PG_LOCKS: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2345 name: "pg_locks",
2346 schema: PG_CATALOG_SCHEMA,
2347 oid: oid::VIEW_PG_LOCKS_OID,
2348 desc: RelationDesc::builder()
2349 .with_column("locktype", SqlScalarType::String.nullable(false))
2350 .with_column("database", SqlScalarType::Oid.nullable(false))
2351 .with_column("relation", SqlScalarType::Oid.nullable(false))
2352 .with_column("page", SqlScalarType::Int32.nullable(false))
2353 .with_column("tuple", SqlScalarType::Int16.nullable(false))
2354 .with_column("virtualxid", SqlScalarType::String.nullable(false))
2355 .with_column("transactionid", SqlScalarType::String.nullable(false))
2356 .with_column("classid", SqlScalarType::Oid.nullable(false))
2357 .with_column("objid", SqlScalarType::Oid.nullable(false))
2358 .with_column("objsubid", SqlScalarType::Int16.nullable(false))
2359 .with_column("virtualtransaction", SqlScalarType::String.nullable(false))
2360 .with_column("pid", SqlScalarType::Int32.nullable(false))
2361 .with_column("mode", SqlScalarType::String.nullable(false))
2362 .with_column("granted", SqlScalarType::Bool.nullable(false))
2363 .with_column("fastpath", SqlScalarType::Bool.nullable(false))
2364 .with_column(
2365 "waitstart",
2366 SqlScalarType::TimestampTz { precision: None }.nullable(false),
2367 )
2368 .with_key(vec![])
2369 .finish(),
2370 column_comments: BTreeMap::new(),
2371 sql: "
2372SELECT
2373-- While there exist locks in Materialize, we don't expose them, so all of these fields are NULL.
2374 NULL::pg_catalog.text AS locktype,
2375 NULL::pg_catalog.oid AS database,
2376 NULL::pg_catalog.oid AS relation,
2377 NULL::pg_catalog.int4 AS page,
2378 NULL::pg_catalog.int2 AS tuple,
2379 NULL::pg_catalog.text AS virtualxid,
2380 NULL::pg_catalog.text AS transactionid,
2381 NULL::pg_catalog.oid AS classid,
2382 NULL::pg_catalog.oid AS objid,
2383 NULL::pg_catalog.int2 AS objsubid,
2384 NULL::pg_catalog.text AS virtualtransaction,
2385 NULL::pg_catalog.int4 AS pid,
2386 NULL::pg_catalog.text AS mode,
2387 NULL::pg_catalog.bool AS granted,
2388 NULL::pg_catalog.bool AS fastpath,
2389 NULL::pg_catalog.timestamptz AS waitstart
2390WHERE false",
2391 access: vec![PUBLIC_SELECT],
2392 ontology: None,
2393});
2394
2395pub static PG_AUTHID: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2396 name: "pg_authid",
2397 schema: PG_CATALOG_SCHEMA,
2398 oid: oid::VIEW_PG_AUTHID_OID,
2399 desc: RelationDesc::builder()
2400 .with_column("oid", SqlScalarType::Oid.nullable(false))
2401 .with_column("rolname", SqlScalarType::String.nullable(false))
2402 .with_column("rolsuper", SqlScalarType::Bool.nullable(true))
2403 .with_column("rolinherit", SqlScalarType::Bool.nullable(false))
2404 .with_column("rolcreaterole", SqlScalarType::Bool.nullable(true))
2405 .with_column("rolcreatedb", SqlScalarType::Bool.nullable(true))
2406 .with_column("rolcanlogin", SqlScalarType::Bool.nullable(false))
2407 .with_column("rolreplication", SqlScalarType::Bool.nullable(false))
2408 .with_column("rolbypassrls", SqlScalarType::Bool.nullable(false))
2409 .with_column("rolconnlimit", SqlScalarType::Int32.nullable(false))
2410 .with_column("rolpassword", SqlScalarType::String.nullable(true))
2411 .with_column(
2412 "rolvaliduntil",
2413 SqlScalarType::TimestampTz { precision: None }.nullable(true),
2414 )
2415 .finish(),
2416 column_comments: BTreeMap::new(),
2417 sql: r#"
2433WITH extra AS (
2434 SELECT
2435 DISTINCT ON (oid)
2436 oid,
2437 mz_catalog.has_system_privilege(oid, 'CREATEROLE') AS rolcreaterole,
2438 mz_catalog.has_system_privilege(oid, 'CREATEDB') AS rolcreatedb
2439 FROM mz_internal.pg_authid_core
2440)
2441SELECT
2442 oid,
2443 rolname,
2444 rolsuper,
2445 rolinherit,
2446 extra.rolcreaterole,
2447 extra.rolcreatedb,
2448 rolcanlogin,
2449 rolreplication,
2450 rolbypassrls,
2451 rolconnlimit,
2452 rolpassword,
2453 rolvaliduntil
2454FROM mz_internal.pg_authid_core
2455LEFT JOIN extra USING (oid)"#,
2456 access: vec![rbac::owner_privilege(ObjectType::Table, MZ_SYSTEM_ROLE_ID)],
2457 ontology: None,
2458});
2459
2460pub static PG_AGGREGATE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2461 name: "pg_aggregate",
2462 schema: PG_CATALOG_SCHEMA,
2463 oid: oid::VIEW_PG_AGGREGATE_OID,
2464 desc: RelationDesc::builder()
2465 .with_column("aggfnoid", SqlScalarType::Oid.nullable(false))
2466 .with_column("aggkind", SqlScalarType::String.nullable(false))
2467 .with_column("aggnumdirectargs", SqlScalarType::Int16.nullable(false))
2468 .with_column("aggtransfn", SqlScalarType::RegProc.nullable(true))
2469 .with_column("aggfinalfn", SqlScalarType::RegProc.nullable(false))
2470 .with_column("aggcombinefn", SqlScalarType::RegProc.nullable(false))
2471 .with_column("aggserialfn", SqlScalarType::RegProc.nullable(false))
2472 .with_column("aggdeserialfn", SqlScalarType::RegProc.nullable(false))
2473 .with_column("aggmtransfn", SqlScalarType::RegProc.nullable(false))
2474 .with_column("aggminvtransfn", SqlScalarType::RegProc.nullable(false))
2475 .with_column("aggmfinalfn", SqlScalarType::RegProc.nullable(false))
2476 .with_column("aggfinalextra", SqlScalarType::Bool.nullable(false))
2477 .with_column("aggmfinalextra", SqlScalarType::Bool.nullable(false))
2478 .with_column("aggfinalmodify", SqlScalarType::PgLegacyChar.nullable(true))
2479 .with_column(
2480 "aggmfinalmodify",
2481 SqlScalarType::PgLegacyChar.nullable(true),
2482 )
2483 .with_column("aggsortop", SqlScalarType::Oid.nullable(false))
2484 .with_column("aggtranstype", SqlScalarType::Oid.nullable(true))
2485 .with_column("aggtransspace", SqlScalarType::Int32.nullable(true))
2486 .with_column("aggmtranstype", SqlScalarType::Oid.nullable(false))
2487 .with_column("aggmtransspace", SqlScalarType::Int32.nullable(true))
2488 .with_column("agginitval", SqlScalarType::String.nullable(true))
2489 .with_column("aggminitval", SqlScalarType::String.nullable(true))
2490 .finish(),
2491 column_comments: BTreeMap::new(),
2492 sql: "SELECT
2493 a.oid as aggfnoid,
2494 -- Currently Materialize only support 'normal' aggregate functions.
2495 a.agg_kind as aggkind,
2496 a.agg_num_direct_args as aggnumdirectargs,
2497 -- Materialize doesn't support these fields.
2498 NULL::pg_catalog.regproc as aggtransfn,
2499 '0'::pg_catalog.regproc as aggfinalfn,
2500 '0'::pg_catalog.regproc as aggcombinefn,
2501 '0'::pg_catalog.regproc as aggserialfn,
2502 '0'::pg_catalog.regproc as aggdeserialfn,
2503 '0'::pg_catalog.regproc as aggmtransfn,
2504 '0'::pg_catalog.regproc as aggminvtransfn,
2505 '0'::pg_catalog.regproc as aggmfinalfn,
2506 false as aggfinalextra,
2507 false as aggmfinalextra,
2508 NULL::pg_catalog.\"char\" AS aggfinalmodify,
2509 NULL::pg_catalog.\"char\" AS aggmfinalmodify,
2510 '0'::pg_catalog.oid as aggsortop,
2511 NULL::pg_catalog.oid as aggtranstype,
2512 NULL::pg_catalog.int4 as aggtransspace,
2513 '0'::pg_catalog.oid as aggmtranstype,
2514 NULL::pg_catalog.int4 as aggmtransspace,
2515 NULL::pg_catalog.text as agginitval,
2516 NULL::pg_catalog.text as aggminitval
2517FROM mz_internal.mz_aggregates a",
2518 access: vec![PUBLIC_SELECT],
2519 ontology: None,
2520});
2521
2522pub static PG_TRIGGER: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2523 name: "pg_trigger",
2524 schema: PG_CATALOG_SCHEMA,
2525 oid: oid::VIEW_PG_TRIGGER_OID,
2526 desc: RelationDesc::builder()
2527 .with_column("oid", SqlScalarType::Oid.nullable(false))
2528 .with_column("tgrelid", SqlScalarType::Oid.nullable(false))
2529 .with_column("tgparentid", SqlScalarType::Oid.nullable(false))
2530 .with_column("tgname", SqlScalarType::String.nullable(false))
2531 .with_column("tgfoid", SqlScalarType::Oid.nullable(false))
2532 .with_column("tgtype", SqlScalarType::Int16.nullable(false))
2533 .with_column("tgenabled", SqlScalarType::PgLegacyChar.nullable(false))
2534 .with_column("tgisinternal", SqlScalarType::Bool.nullable(false))
2535 .with_column("tgconstrrelid", SqlScalarType::Oid.nullable(false))
2536 .with_column("tgconstrindid", SqlScalarType::Oid.nullable(false))
2537 .with_column("tgconstraint", SqlScalarType::Oid.nullable(false))
2538 .with_column("tgdeferrable", SqlScalarType::Bool.nullable(false))
2539 .with_column("tginitdeferred", SqlScalarType::Bool.nullable(false))
2540 .with_column("tgnargs", SqlScalarType::Int16.nullable(false))
2541 .with_column("tgattr", SqlScalarType::Int2Vector.nullable(false))
2542 .with_column("tgargs", SqlScalarType::Bytes.nullable(false))
2543 .with_column("tgqual", SqlScalarType::String.nullable(false))
2544 .with_column("tgoldtable", SqlScalarType::String.nullable(false))
2545 .with_column("tgnewtable", SqlScalarType::String.nullable(false))
2546 .with_key(vec![])
2547 .finish(),
2548 column_comments: BTreeMap::new(),
2549 sql: "SELECT
2550 -- MZ doesn't support triggers so all of these fields are NULL.
2551 NULL::pg_catalog.oid AS oid,
2552 NULL::pg_catalog.oid AS tgrelid,
2553 NULL::pg_catalog.oid AS tgparentid,
2554 NULL::pg_catalog.text AS tgname,
2555 NULL::pg_catalog.oid AS tgfoid,
2556 NULL::pg_catalog.int2 AS tgtype,
2557 NULL::pg_catalog.\"char\" AS tgenabled,
2558 NULL::pg_catalog.bool AS tgisinternal,
2559 NULL::pg_catalog.oid AS tgconstrrelid,
2560 NULL::pg_catalog.oid AS tgconstrindid,
2561 NULL::pg_catalog.oid AS tgconstraint,
2562 NULL::pg_catalog.bool AS tgdeferrable,
2563 NULL::pg_catalog.bool AS tginitdeferred,
2564 NULL::pg_catalog.int2 AS tgnargs,
2565 NULL::pg_catalog.int2vector AS tgattr,
2566 NULL::pg_catalog.bytea AS tgargs,
2567 -- NOTE: The tgqual column is actually type `pg_node_tree` which we don't support. CockroachDB
2568 -- uses text as a placeholder, so we'll follow their lead here.
2569 NULL::pg_catalog.text AS tgqual,
2570 NULL::pg_catalog.text AS tgoldtable,
2571 NULL::pg_catalog.text AS tgnewtable
2572WHERE false
2573 ",
2574 access: vec![PUBLIC_SELECT],
2575 ontology: None,
2576});
2577
2578pub static PG_REWRITE: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2579 name: "pg_rewrite",
2580 schema: PG_CATALOG_SCHEMA,
2581 oid: oid::VIEW_PG_REWRITE_OID,
2582 desc: RelationDesc::builder()
2583 .with_column("oid", SqlScalarType::Oid.nullable(false))
2584 .with_column("rulename", SqlScalarType::String.nullable(false))
2585 .with_column("ev_class", SqlScalarType::Oid.nullable(false))
2586 .with_column("ev_type", SqlScalarType::PgLegacyChar.nullable(false))
2587 .with_column("ev_enabled", SqlScalarType::PgLegacyChar.nullable(false))
2588 .with_column("is_instead", SqlScalarType::Bool.nullable(false))
2589 .with_column("ev_qual", SqlScalarType::String.nullable(false))
2590 .with_column("ev_action", SqlScalarType::String.nullable(false))
2591 .with_key(vec![])
2592 .finish(),
2593 column_comments: BTreeMap::new(),
2594 sql: "SELECT
2595 -- MZ doesn't support rewrite rules so all of these fields are NULL.
2596 NULL::pg_catalog.oid AS oid,
2597 NULL::pg_catalog.text AS rulename,
2598 NULL::pg_catalog.oid AS ev_class,
2599 NULL::pg_catalog.\"char\" AS ev_type,
2600 NULL::pg_catalog.\"char\" AS ev_enabled,
2601 NULL::pg_catalog.bool AS is_instead,
2602 -- NOTE: The ev_qual and ev_action columns are actually type `pg_node_tree` which we don't
2603 -- support. CockroachDB uses text as a placeholder, so we'll follow their lead here.
2604 NULL::pg_catalog.text AS ev_qual,
2605 NULL::pg_catalog.text AS ev_action
2606WHERE false
2607 ",
2608 access: vec![PUBLIC_SELECT],
2609 ontology: None,
2610});
2611
2612pub static PG_EXTENSION: LazyLock<BuiltinView> = LazyLock::new(|| BuiltinView {
2613 name: "pg_extension",
2614 schema: PG_CATALOG_SCHEMA,
2615 oid: oid::VIEW_PG_EXTENSION_OID,
2616 desc: RelationDesc::builder()
2617 .with_column("oid", SqlScalarType::Oid.nullable(false))
2618 .with_column("extname", SqlScalarType::String.nullable(false))
2619 .with_column("extowner", SqlScalarType::Oid.nullable(false))
2620 .with_column("extnamespace", SqlScalarType::Oid.nullable(false))
2621 .with_column("extrelocatable", SqlScalarType::Bool.nullable(false))
2622 .with_column("extversion", SqlScalarType::String.nullable(false))
2623 .with_column(
2624 "extconfig",
2625 SqlScalarType::Array(Box::new(SqlScalarType::Oid)).nullable(false),
2626 )
2627 .with_column(
2628 "extcondition",
2629 SqlScalarType::Array(Box::new(SqlScalarType::String)).nullable(false),
2630 )
2631 .with_key(vec![])
2632 .finish(),
2633 column_comments: BTreeMap::new(),
2634 sql: "SELECT
2635 -- MZ doesn't support extensions so all of these fields are NULL.
2636 NULL::pg_catalog.oid AS oid,
2637 NULL::pg_catalog.text AS extname,
2638 NULL::pg_catalog.oid AS extowner,
2639 NULL::pg_catalog.oid AS extnamespace,
2640 NULL::pg_catalog.bool AS extrelocatable,
2641 NULL::pg_catalog.text AS extversion,
2642 NULL::pg_catalog.oid[] AS extconfig,
2643 NULL::pg_catalog.text[] AS extcondition
2644WHERE false
2645 ",
2646 access: vec![PUBLIC_SELECT],
2647 ontology: None,
2648});