-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
pg_catalog
1933 lines (1722 loc) · 97.2 KB
/
pg_catalog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# LogicTest: local local-opt local-parallel-stmts
# Verify pg_catalog database handles mutation statements correctly.
query error database "pg_catalog" does not exist
ALTER DATABASE pg_catalog RENAME TO not_pg_catalog
statement error schema cannot be modified: "pg_catalog"
CREATE TABLE pg_catalog.t (x INT)
query error database "pg_catalog" does not exist
DROP DATABASE pg_catalog
query T
SHOW TABLES FROM pg_catalog
----
pg_am
pg_attrdef
pg_attribute
pg_auth_members
pg_class
pg_collation
pg_constraint
pg_database
pg_depend
pg_description
pg_enum
pg_extension
pg_foreign_data_wrapper
pg_foreign_server
pg_foreign_table
pg_index
pg_indexes
pg_inherits
pg_language
pg_namespace
pg_operator
pg_proc
pg_range
pg_rewrite
pg_roles
pg_seclabel
pg_sequence
pg_settings
pg_shdescription
pg_shseclabel
pg_stat_activity
pg_tables
pg_tablespace
pg_trigger
pg_type
pg_user
pg_user_mapping
pg_views
# Verify "pg_catalog" is a regular db name
statement ok
CREATE DATABASE other_db
statement ok
ALTER DATABASE other_db RENAME TO pg_catalog
statement error database "pg_catalog" already exists
CREATE DATABASE pg_catalog
statement ok
DROP DATABASE pg_catalog
# the following query checks that the planDataSource instantiated from
# a virtual table in the FROM clause is properly deallocated even when
# query preparation causes an error. #9853
query error unknown function
SELECT * FROM pg_catalog.pg_class c WHERE nonexistent_function()
# Verify pg_catalog handles reflection correctly.
query T
SHOW TABLES FROM test.pg_catalog
----
pg_am
pg_attrdef
pg_attribute
pg_auth_members
pg_class
pg_collation
pg_constraint
pg_database
pg_depend
pg_description
pg_enum
pg_extension
pg_foreign_data_wrapper
pg_foreign_server
pg_foreign_table
pg_index
pg_indexes
pg_inherits
pg_language
pg_namespace
pg_operator
pg_proc
pg_range
pg_rewrite
pg_roles
pg_seclabel
pg_sequence
pg_settings
pg_shdescription
pg_shseclabel
pg_stat_activity
pg_tables
pg_tablespace
pg_trigger
pg_type
pg_user
pg_user_mapping
pg_views
query TT colnames
SHOW CREATE TABLE pg_catalog.pg_namespace
----
table_name create_statement
pg_catalog.pg_namespace CREATE TABLE pg_namespace (
oid OID NULL,
nspname NAME NOT NULL,
nspowner OID NULL,
nspacl STRING[] NULL
)
query TTBTTTB colnames
SHOW COLUMNS FROM pg_catalog.pg_namespace
----
column_name data_type is_nullable column_default generation_expression indices is_hidden
oid OID true NULL · {} false
nspname NAME false NULL · {} false
nspowner OID true NULL · {} false
nspacl STRING[] true NULL · {} false
query TTBITTBB colnames
SHOW INDEXES FROM pg_catalog.pg_namespace
----
table_name index_name non_unique seq_in_index column_name direction storing implicit
query TTTTB colnames
SHOW CONSTRAINTS FROM pg_catalog.pg_namespace
----
table_name constraint_name constraint_type details validated
query TTTTT colnames
SHOW GRANTS ON pg_catalog.pg_namespace
----
database_name schema_name table_name grantee privilege_type
test pg_catalog pg_namespace public SELECT
# Verify selecting from pg_catalog.
statement ok
CREATE DATABASE constraint_db
statement ok
CREATE TABLE constraint_db.t1 (
p FLOAT PRIMARY KEY,
a INT UNIQUE,
b INT,
c INT DEFAULT 12,
UNIQUE INDEX index_key(b, c)
)
statement ok
CREATE TABLE constraint_db.t2 (
t1_ID INT,
CONSTRAINT fk FOREIGN KEY (t1_ID) REFERENCES constraint_db.t1(a),
INDEX (t1_ID)
)
statement ok
CREATE TABLE constraint_db.t3 (
a INT,
b INT CHECK (b > 11),
c STRING DEFAULT 'FOO',
CONSTRAINT fk FOREIGN KEY (a, b) REFERENCES constraint_db.t1(b, c),
INDEX (a, b DESC) STORING (c)
)
statement ok
CREATE VIEW constraint_db.v1 AS SELECT p,a,b,c FROM constraint_db.t1
## pg_catalog.pg_namespace
query OTOT colnames
SELECT * FROM pg_catalog.pg_namespace
----
oid nspname nspowner nspacl
3604332469 crdb_internal NULL NULL
3672231114 information_schema NULL NULL
2508829085 pg_catalog NULL NULL
3426283741 public NULL NULL
## pg_catalog.pg_database
query OTOITTBB colnames
SELECT oid, datname, datdba, encoding, datcollate, datctype, datistemplate, datallowconn
FROM pg_catalog.pg_database
ORDER BY oid
----
oid datname datdba encoding datcollate datctype datistemplate datallowconn
1 system NULL 6 en_US.utf8 en_US.utf8 false true
50 defaultdb NULL 6 en_US.utf8 en_US.utf8 false true
51 postgres NULL 6 en_US.utf8 en_US.utf8 false true
52 test NULL 6 en_US.utf8 en_US.utf8 false true
54 constraint_db NULL 6 en_US.utf8 en_US.utf8 false true
query OTIOIIOT colnames
SELECT oid, datname, datconnlimit, datlastsysoid, datfrozenxid, datminmxid, dattablespace, datacl
FROM pg_catalog.pg_database
ORDER BY oid
----
oid datname datconnlimit datlastsysoid datfrozenxid datminmxid dattablespace datacl
1 system -1 NULL NULL NULL 0 NULL
50 defaultdb -1 NULL NULL NULL 0 NULL
51 postgres -1 NULL NULL NULL 0 NULL
52 test -1 NULL NULL NULL 0 NULL
54 constraint_db -1 NULL NULL NULL 0 NULL
## pg_catalog.pg_tables
statement ok
SET DATABASE = constraint_db
query TTTTBBBB colnames
SELECT * FROM constraint_db.pg_catalog.pg_tables WHERE schemaname = 'public'
----
schemaname tablename tableowner tablespace hasindexes hasrules hastriggers rowsecurity
public t1 NULL NULL true false false false
public t2 NULL NULL true false false false
public t3 NULL NULL true false false false
query TB colnames
SELECT tablename, hasindexes FROM pg_catalog.pg_tables WHERE schemaname = 'information_schema' AND tablename LIKE '%table%'
----
tablename hasindexes
role_table_grants false
table_constraints false
table_privileges false
tables false
## pg_catalog.pg_tablespace
query OTOTT colnames
SELECT oid, spcname, spcowner, spcacl, spcoptions FROM pg_tablespace
----
oid spcname spcowner spcacl spcoptions
0 pg_default NULL NULL NULL
## pg_catalog.pg_views
query TTTT colnames
SELECT * FROM pg_catalog.pg_views
----
schemaname viewname viewowner definition
public v1 NULL SELECT p, a, b, c FROM constraint_db.public.t1
## pg_catalog.pg_class
query OTOOOOOO colnames
SELECT c.oid, relname, relnamespace, reltype, relowner, relam, relfilenode, reltablespace
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
oid relname relnamespace reltype relowner relam relfilenode reltablespace
55 t1 2332901747 0 NULL NULL 0 0
450499963 primary 2332901747 0 NULL NULL 0 0
450499960 t1_a_key 2332901747 0 NULL NULL 0 0
450499961 index_key 2332901747 0 NULL NULL 0 0
56 t2 2332901747 0 NULL NULL 0 0
2315049508 primary 2332901747 0 NULL NULL 0 0
2315049511 t2_t1_id_idx 2332901747 0 NULL NULL 0 0
57 t3 2332901747 0 NULL NULL 0 0
969972501 primary 2332901747 0 NULL NULL 0 0
969972502 t3_a_b_idx 2332901747 0 NULL NULL 0 0
58 v1 2332901747 0 NULL NULL 0 0
query TIRIOBBT colnames
SELECT relname, relpages, reltuples, relallvisible, reltoastrelid, relhasindex, relisshared, relpersistence
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
relname relpages reltuples relallvisible reltoastrelid relhasindex relisshared relpersistence
t1 NULL NULL 0 0 true false p
primary NULL NULL 0 0 false false p
t1_a_key NULL NULL 0 0 false false p
index_key NULL NULL 0 0 false false p
t2 NULL NULL 0 0 true false p
primary NULL NULL 0 0 false false p
t2_t1_id_idx NULL NULL 0 0 false false p
t3 NULL NULL 0 0 true false p
primary NULL NULL 0 0 false false p
t3_a_b_idx NULL NULL 0 0 false false p
v1 NULL NULL 0 0 false false p
query TBTIIBB colnames
SELECT relname, relistemp, relkind, relnatts, relchecks, relhasoids, relhaspkey
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
relname relistemp relkind relnatts relchecks relhasoids relhaspkey
t1 false r 4 0 false true
primary false i 1 0 false false
t1_a_key false i 1 0 false false
index_key false i 2 0 false false
t2 false r 2 0 false true
primary false i 1 0 false false
t2_t1_id_idx false i 1 0 false false
t3 false r 4 1 false true
primary false i 1 0 false false
t3_a_b_idx false i 2 0 false false
v1 false v 4 0 false false
query TBBBITT colnames
SELECT relname, relhasrules, relhastriggers, relhassubclass, relfrozenxid, relacl, reloptions
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
relname relhasrules relhastriggers relhassubclass relfrozenxid relacl reloptions
t1 false false false 0 NULL NULL
primary false false false 0 NULL NULL
t1_a_key false false false 0 NULL NULL
index_key false false false 0 NULL NULL
t2 false false false 0 NULL NULL
primary false false false 0 NULL NULL
t2_t1_id_idx false false false 0 NULL NULL
t3 false false false 0 NULL NULL
primary false false false 0 NULL NULL
t3_a_b_idx false false false 0 NULL NULL
v1 false false false 0 NULL NULL
## pg_catalog.pg_attribute
query OTTOIIIII colnames
SELECT attrelid, c.relname, attname, atttypid, attstattarget, attlen, attnum, attndims, attcacheoff
FROM pg_catalog.pg_attribute a
JOIN pg_catalog.pg_class c ON a.attrelid = c.oid
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
attrelid relname attname atttypid attstattarget attlen attnum attndims attcacheoff
55 t1 p 701 0 8 1 0 -1
55 t1 a 20 0 8 2 0 -1
55 t1 b 20 0 8 3 0 -1
55 t1 c 20 0 8 4 0 -1
450499963 primary p 701 0 8 1 0 -1
450499960 t1_a_key a 20 0 8 2 0 -1
450499961 index_key b 20 0 8 3 0 -1
450499961 index_key c 20 0 8 4 0 -1
56 t2 t1_id 20 0 8 1 0 -1
56 t2 rowid 20 0 8 2 0 -1
2315049508 primary rowid 20 0 8 2 0 -1
2315049511 t2_t1_id_idx t1_id 20 0 8 1 0 -1
57 t3 a 20 0 8 1 0 -1
57 t3 b 20 0 8 2 0 -1
57 t3 c 25 0 -1 3 0 -1
57 t3 rowid 20 0 8 4 0 -1
969972501 primary rowid 20 0 8 4 0 -1
969972502 t3_a_b_idx a 20 0 8 1 0 -1
969972502 t3_a_b_idx b 20 0 8 2 0 -1
58 v1 p 701 0 8 1 0 -1
58 v1 a 20 0 8 2 0 -1
58 v1 b 20 0 8 3 0 -1
58 v1 c 20 0 8 4 0 -1
query TTIBTTBB colnames
SELECT c.relname, attname, atttypmod, attbyval, attstorage, attalign, attnotnull, atthasdef
FROM pg_catalog.pg_attribute a
JOIN pg_catalog.pg_class c ON a.attrelid = c.oid
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
relname attname atttypmod attbyval attstorage attalign attnotnull atthasdef
t1 p -1 NULL NULL NULL true false
t1 a -1 NULL NULL NULL false false
t1 b -1 NULL NULL NULL false false
t1 c -1 NULL NULL NULL false true
primary p -1 NULL NULL NULL true false
t1_a_key a -1 NULL NULL NULL false false
index_key b -1 NULL NULL NULL false false
index_key c -1 NULL NULL NULL false true
t2 t1_id -1 NULL NULL NULL false false
t2 rowid -1 NULL NULL NULL true true
primary rowid -1 NULL NULL NULL true true
t2_t1_id_idx t1_id -1 NULL NULL NULL false false
t3 a -1 NULL NULL NULL false false
t3 b -1 NULL NULL NULL false false
t3 c -1 NULL NULL NULL false true
t3 rowid -1 NULL NULL NULL true true
primary rowid -1 NULL NULL NULL true true
t3_a_b_idx a -1 NULL NULL NULL false false
t3_a_b_idx b -1 NULL NULL NULL false false
v1 p -1 NULL NULL NULL true false
v1 a -1 NULL NULL NULL true false
v1 b -1 NULL NULL NULL true false
v1 c -1 NULL NULL NULL true false
query TTBBITTT colnames
SELECT c.relname, attname, attisdropped, attislocal, attinhcount, attacl, attoptions, attfdwoptions
FROM pg_catalog.pg_attribute a
JOIN pg_catalog.pg_class c ON a.attrelid = c.oid
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
relname attname attisdropped attislocal attinhcount attacl attoptions attfdwoptions
t1 p false true 0 NULL NULL NULL
t1 a false true 0 NULL NULL NULL
t1 b false true 0 NULL NULL NULL
t1 c false true 0 NULL NULL NULL
primary p false true 0 NULL NULL NULL
t1_a_key a false true 0 NULL NULL NULL
index_key b false true 0 NULL NULL NULL
index_key c false true 0 NULL NULL NULL
t2 t1_id false true 0 NULL NULL NULL
t2 rowid false true 0 NULL NULL NULL
primary rowid false true 0 NULL NULL NULL
t2_t1_id_idx t1_id false true 0 NULL NULL NULL
t3 a false true 0 NULL NULL NULL
t3 b false true 0 NULL NULL NULL
t3 c false true 0 NULL NULL NULL
t3 rowid false true 0 NULL NULL NULL
primary rowid false true 0 NULL NULL NULL
t3_a_b_idx a false true 0 NULL NULL NULL
t3_a_b_idx b false true 0 NULL NULL NULL
v1 p false true 0 NULL NULL NULL
v1 a false true 0 NULL NULL NULL
v1 b false true 0 NULL NULL NULL
v1 c false true 0 NULL NULL NULL
# Check relkind codes.
statement ok
CREATE DATABASE relkinds
statement ok
SET DATABASE = relkinds
statement ok
CREATE TABLE tbl_test (k int primary key, v int)
statement ok
CREATE INDEX tbl_test_v_idx ON tbl_test (v)
statement ok
CREATE VIEW view_test AS SELECT k, v FROM tbl_test ORDER BY v
statement ok
CREATE SEQUENCE seq_test
query TT
SELECT relname, relkind
FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
ORDER BY relname
----
primary i
seq_test S
tbl_test r
tbl_test_v_idx i
view_test v
statement ok
DROP DATABASE relkinds
statement ok
SET DATABASE = constraint_db
# Select all columns with collations.
query TTTOT colnames
SELECT c.relname, attname, t.typname, attcollation, k.collname
FROM pg_catalog.pg_attribute a
JOIN pg_catalog.pg_class c ON a.attrelid = c.oid
JOIN pg_catalog.pg_type t ON a.atttypid = t.oid
JOIN pg_catalog.pg_collation k ON a.attcollation = k.oid
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
relname attname typname attcollation collname
t3 c text 3903121477 en-US
## pg_catalog.pg_am
query OTIIBBBBBBBBBBBOOOOOOOOOOOOOOOOOT colnames
SELECT *
FROM pg_catalog.pg_am
----
oid amname amstrategies amsupport amcanorder amcanorderbyop amcanbackward amcanunique amcanmulticol amoptionalkey amsearcharray amsearchnulls amstorage amclusterable ampredlocks amkeytype aminsert ambeginscan amgettuple amgetbitmap amrescan amendscan ammarkpos amrestrpos ambuild ambuildempty ambulkdelete amvacuumcleanup amcanreturn amcostestimate amoptions amhandler amtype
2631952481 prefix 0 0 true false true true true true true true false false false 0 NULL NULL 0 0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL i
## pg_catalog.pg_attrdef
query OTOITT colnames
SELECT ad.oid, c.relname, adrelid, adnum, adbin, adsrc
FROM pg_catalog.pg_attrdef ad
JOIN pg_catalog.pg_class c ON ad.adrelid = c.oid
JOIN pg_catalog.pg_namespace n ON c.relnamespace = n.oid
WHERE n.nspname = 'public'
----
oid relname adrelid adnum adbin adsrc
1666782879 t1 55 4 12:::INT8 12:::INT8
841178406 t2 56 2 unique_rowid() unique_rowid()
2186255414 t3 57 3 'FOO':::STRING 'FOO':::STRING
2186255409 t3 57 4 unique_rowid() unique_rowid()
## pg_catalog.pg_indexes
query OTTTT colnames
SELECT crdb_oid, schemaname, tablename, indexname, tablespace
FROM pg_catalog.pg_indexes
WHERE schemaname = 'public'
----
crdb_oid schemaname tablename indexname tablespace
450499963 public t1 primary NULL
450499960 public t1 t1_a_key NULL
450499961 public t1 index_key NULL
2315049508 public t2 primary NULL
2315049511 public t2 t2_t1_id_idx NULL
969972501 public t3 primary NULL
969972502 public t3 t3_a_b_idx NULL
query OTTT colnames
SELECT crdb_oid, tablename, indexname, indexdef
FROM pg_catalog.pg_indexes
WHERE schemaname = 'public'
----
crdb_oid tablename indexname indexdef
450499963 t1 primary CREATE UNIQUE INDEX "primary" ON constraint_db.public.t1 (p ASC)
450499960 t1 t1_a_key CREATE UNIQUE INDEX t1_a_key ON constraint_db.public.t1 (a ASC)
450499961 t1 index_key CREATE UNIQUE INDEX index_key ON constraint_db.public.t1 (b ASC, c ASC)
2315049508 t2 primary CREATE UNIQUE INDEX "primary" ON constraint_db.public.t2 (rowid ASC)
2315049511 t2 t2_t1_id_idx CREATE INDEX t2_t1_id_idx ON constraint_db.public.t2 (t1_id ASC)
969972501 t3 primary CREATE UNIQUE INDEX "primary" ON constraint_db.public.t3 (rowid ASC)
969972502 t3 t3_a_b_idx CREATE INDEX t3_a_b_idx ON constraint_db.public.t3 (a ASC, b DESC) STORING (c)
## pg_catalog.pg_index
query OOIBBB colnames
SELECT indexrelid, indrelid, indnatts, indisunique, indisprimary, indisexclusion
FROM pg_catalog.pg_index
WHERE indnatts = 2
----
indexrelid indrelid indnatts indisunique indisprimary indisexclusion
450499961 55 2 true false false
969972502 57 2 false false false
query OBBBBB colnames
SELECT indexrelid, indimmediate, indisclustered, indisvalid, indcheckxmin, indisready
FROM pg_catalog.pg_index
WHERE indnatts = 2
----
indexrelid indimmediate indisclustered indisvalid indcheckxmin indisready
450499961 true false true false false
969972502 false false true false false
query OOBBTTTTTT colnames
SELECT indexrelid, indrelid, indislive, indisreplident, indkey, indcollation, indclass, indoption, indexprs, indpred
FROM pg_catalog.pg_index
WHERE indnatts = 2
----
indexrelid indrelid indislive indisreplident indkey indcollation indclass indoption indexprs indpred
450499961 55 true false 3 4 0 0 0 0 0 0 NULL NULL
969972502 57 true false 1 2 0 0 0 0 0 0 NULL NULL
statement ok
SET DATABASE = system
query OOIBBBBBBBBBBTTTTTT colnames
SELECT *
FROM pg_catalog.pg_index
ORDER BY indexrelid
----
indexrelid indrelid indnatts indisunique indisprimary indisexclusion indimmediate indisclustered indisvalid indcheckxmin indisready indislive indisreplident indkey indcollation indclass indoption indexprs indpred
543291288 23 1 false false false false false true false false true false 1 3903121477 0 0 NULL NULL
543291289 23 1 false false false false false true false false true false 2 3903121477 0 0 NULL NULL
543291291 23 2 true true false true false true false false true false 1 2 3903121477 3903121477 0 0 0 0 NULL NULL
1276104432 12 2 true true false true false true false false true false 1 6 0 0 0 0 0 0 NULL NULL
1582236367 3 1 true true false true false true false false true false 1 0 0 0 NULL NULL
1628632028 19 1 false false false false false true false false true false 5 0 0 0 NULL NULL
1628632029 19 1 false false false false false true false false true false 4 0 0 0 NULL NULL
1628632031 19 1 true true false true false true false false true false 1 0 0 0 NULL NULL
1841972634 6 1 true true false true false true false false true false 1 3903121477 0 0 NULL NULL
2101708905 5 1 true true false true false true false false true false 1 0 0 0 NULL NULL
2148104569 21 2 true true false true false true false false true false 1 2 3903121477 3903121477 0 0 0 0 NULL NULL
2407840836 24 3 true true false true false true false false true false 1 2 3 0 0 0 0 0 0 0 0 0 NULL NULL
2621181440 15 2 false false false false false true false false true false 2 3 3903121477 0 0 0 0 0 NULL NULL
2621181443 15 1 true true false true false true false false true false 1 0 0 0 NULL NULL
2927313374 2 2 true true false true false true false false true false 1 2 0 3903121477 0 0 0 0 NULL NULL
3446785912 4 1 true true false true false true false false true false 1 3903121477 0 0 NULL NULL
3493181576 20 2 true true false true false true false false true false 1 2 0 0 0 0 0 0 NULL NULL
3706522183 11 4 true true false true false true false false true false 1 2 4 3 0 0 0 0 0 0 0 0 0 0 0 0 NULL NULL
3966258450 14 1 true true false true false true false false true false 1 3903121477 0 0 NULL NULL
4225994721 13 2 true true false true false true false false true false 1 7 0 0 0 0 0 0 NULL NULL
# From #26504
query OOI colnames
SELECT indexrelid,
(information_schema._pg_expandarray(indclass)).x AS operator_argument_type_oid,
(information_schema._pg_expandarray(indclass)).n AS operator_argument_position
FROM pg_index
ORDER BY indexrelid, operator_argument_position
----
indexrelid operator_argument_type_oid operator_argument_position
543291288 0 1
543291289 0 1
543291291 0 1
543291291 0 2
1276104432 0 1
1276104432 0 2
1582236367 0 1
1628632028 0 1
1628632029 0 1
1628632031 0 1
1841972634 0 1
2101708905 0 1
2148104569 0 1
2148104569 0 2
2407840836 0 1
2407840836 0 2
2407840836 0 3
2621181440 0 1
2621181440 0 2
2621181443 0 1
2927313374 0 1
2927313374 0 2
3446785912 0 1
3493181576 0 1
3493181576 0 2
3706522183 0 1
3706522183 0 2
3706522183 0 3
3706522183 0 4
3966258450 0 1
4225994721 0 1
4225994721 0 2
## pg_catalog.pg_collation
statement ok
SET DATABASE = constraint_db
query OTOOITT colnames
SELECT * FROM pg_collation
WHERE collname='en-US'
----
oid collname collnamespace collowner collencoding collcollate collctype
3903121477 en-US 2332901747 NULL 6 NULL NULL
## pg_catalog.pg_constraint
##
## These order of this virtual table is non-deterministic, so all queries must
## explicitly add an ORDER BY clause.
query OTOT colnames
SELECT con.oid, conname, connamespace, contype
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public'
ORDER BY con.oid
----
oid conname connamespace contype
178791267 fk 2332901747 f
3236224800 check_b 2332901747 c
3318155331 fk 2332901747 f
3572320190 primary 2332901747 p
4243354484 t1_a_key 2332901747 u
4243354485 index_key 2332901747 u
query TTBBBOOO colnames
SELECT conname, contype, condeferrable, condeferred, convalidated, conrelid, contypid, conindid
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public'
ORDER BY con.oid
----
conname contype condeferrable condeferred convalidated conrelid contypid conindid
fk f false false true 57 0 450499961
check_b c false false true 57 0 0
fk f false false true 56 0 450499960
primary p false false true 55 0 450499963
t1_a_key u false false true 55 0 450499960
index_key u false false true 55 0 450499961
query T
SELECT conname
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public' AND contype NOT IN ('c', 'f', 'p', 'u')
ORDER BY con.oid
----
query TOTTT colnames
SELECT conname, confrelid, confupdtype, confdeltype, confmatchtype
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public' AND contype IN ('c', 'p', 'u')
ORDER BY con.oid
----
conname confrelid confupdtype confdeltype confmatchtype
check_b 0 NULL NULL NULL
primary 0 NULL NULL NULL
t1_a_key 0 NULL NULL NULL
index_key 0 NULL NULL NULL
query TOTTT colnames
SELECT conname, confrelid, confupdtype, confdeltype, confmatchtype
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public' AND contype = 'f'
ORDER BY con.oid
----
conname confrelid confupdtype confdeltype confmatchtype
fk 55 a a s
fk 55 a a s
query TBIBT colnames
SELECT conname, conislocal, coninhcount, connoinherit, conkey
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public'
ORDER BY con.oid
----
conname conislocal coninhcount connoinherit conkey
fk true 0 true {1,2}
check_b true 0 true {2}
fk true 0 true {1}
primary true 0 true {1}
t1_a_key true 0 true {2}
index_key true 0 true {3,4}
query TTTTTTTT colnames
SELECT conname, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public' AND contype IN ('c', 'p', 'u')
ORDER BY con.oid
----
conname confkey conpfeqop conppeqop conffeqop conexclop conbin consrc
check_b NULL NULL NULL NULL NULL b > 11 b > 11
primary NULL NULL NULL NULL NULL NULL NULL
t1_a_key NULL NULL NULL NULL NULL NULL NULL
index_key NULL NULL NULL NULL NULL NULL NULL
query TTTTTTTT colnames
SELECT conname, confkey, conpfeqop, conppeqop, conffeqop, conexclop, conbin, consrc
FROM pg_catalog.pg_constraint con
JOIN pg_catalog.pg_namespace n ON con.connamespace = n.oid
WHERE n.nspname = 'public' AND contype = 'f'
ORDER BY con.oid
----
conname confkey conpfeqop conppeqop conffeqop conexclop conbin consrc
fk {3,4} NULL NULL NULL NULL NULL NULL
fk {2} NULL NULL NULL NULL NULL NULL
## pg_catalog.pg_depend
query OOIOOIT colnames
SELECT classid, objid, objsubid, refclassid, refobjid, refobjsubid, deptype
FROM pg_catalog.pg_depend
ORDER BY objid
----
classid objid objsubid refclassid refobjid refobjsubid deptype
4294967232 178791267 0 4294967234 450499961 0 n
4294967232 3318155331 0 4294967234 450499960 0 n
# All entries in pg_depend are dependency links from the pg_constraint system
# table to the pg_class system table.
query OOTT colnames
SELECT DISTINCT classid, refclassid, cla.relname AS tablename, refcla.relname AS reftablename
FROM pg_catalog.pg_depend
JOIN pg_class cla ON classid=cla.oid
JOIN pg_class refcla ON refclassid=refcla.oid
----
classid refclassid tablename reftablename
4294967232 4294967234 pg_constraint pg_class
# All entries in pg_depend are foreign key constraints that reference an index
# in pg_class.
query TT colnames
SELECT relname, relkind
FROM pg_depend
JOIN pg_class ON refobjid=pg_class.oid
ORDER BY relname
----
relname relkind
index_key i
t1_a_key i
# All entries are pg_depend are linked to a foreign key constraint whose
# supporting index is the referenced object id.
query T colnames
SELECT DISTINCT pg_constraint.contype
FROM pg_depend
JOIN pg_constraint ON objid=pg_constraint.oid AND refobjid=pg_constraint.conindid
----
contype
f
## pg_catalog.pg_type
query OTOOIBT colnames
SELECT oid, typname, typnamespace, typowner, typlen, typbyval, typtype
FROM pg_catalog.pg_type
ORDER BY oid
----
oid typname typnamespace typowner typlen typbyval typtype
16 bool 1307062959 NULL 1 true b
17 bytea 1307062959 NULL -1 false b
18 char 1307062959 NULL -1 false b
19 name 1307062959 NULL -1 false b
20 int8 1307062959 NULL 8 true b
21 int2 1307062959 NULL 8 true b
22 int2vector 1307062959 NULL -1 false b
23 int4 1307062959 NULL 8 true b
24 regproc 1307062959 NULL 8 true b
25 text 1307062959 NULL -1 false b
26 oid 1307062959 NULL 8 true b
30 oidvector 1307062959 NULL -1 false b
700 float4 1307062959 NULL 8 true b
701 float8 1307062959 NULL 8 true b
869 inet 1307062959 NULL 24 true b
1000 _bool 1307062959 NULL -1 false b
1001 _bytea 1307062959 NULL -1 false b
1002 _char 1307062959 NULL -1 false b
1003 _name 1307062959 NULL -1 false b
1005 _int2 1307062959 NULL -1 false b
1007 _int4 1307062959 NULL -1 false b
1009 _text 1307062959 NULL -1 false b
1014 _bpchar 1307062959 NULL -1 false b
1015 _varchar 1307062959 NULL -1 false b
1016 _int8 1307062959 NULL -1 false b
1021 _float4 1307062959 NULL -1 false b
1022 _float8 1307062959 NULL -1 false b
1028 _oid 1307062959 NULL -1 false b
1041 _inet 1307062959 NULL -1 false b
1042 bpchar 1307062959 NULL -1 false b
1043 varchar 1307062959 NULL -1 false b
1082 date 1307062959 NULL 16 true b
1083 time 1307062959 NULL 8 true b
1114 timestamp 1307062959 NULL 24 true b
1115 _timestamp 1307062959 NULL -1 false b
1182 _date 1307062959 NULL -1 false b
1183 _time 1307062959 NULL -1 false b
1184 timestamptz 1307062959 NULL 24 true b
1185 _timestamptz 1307062959 NULL -1 false b
1186 interval 1307062959 NULL 24 true b
1187 _interval 1307062959 NULL -1 false b
1231 _numeric 1307062959 NULL -1 false b
1560 bit 1307062959 NULL -1 false b
1561 _bit 1307062959 NULL -1 false b
1562 varbit 1307062959 NULL -1 false b
1563 _varbit 1307062959 NULL -1 false b
1700 numeric 1307062959 NULL -1 false b
2202 regprocedure 1307062959 NULL 8 true b
2205 regclass 1307062959 NULL 8 true b
2206 regtype 1307062959 NULL 8 true b
2249 record 1307062959 NULL 0 true p
2277 anyarray 1307062959 NULL -1 false p
2283 anyelement 1307062959 NULL -1 false p
2950 uuid 1307062959 NULL 16 true b
2951 _uuid 1307062959 NULL -1 false b
3802 jsonb 1307062959 NULL -1 false b
4089 regnamespace 1307062959 NULL 8 true b
query OTTBBTOOO colnames
SELECT oid, typname, typcategory, typispreferred, typisdefined, typdelim, typrelid, typelem, typarray
FROM pg_catalog.pg_type
ORDER BY oid
----
oid typname typcategory typispreferred typisdefined typdelim typrelid typelem typarray
16 bool B false true , 0 0 1000
17 bytea U false true , 0 0 1001
18 char S false true , 0 0 1002
19 name S false true , 0 0 1003
20 int8 N false true , 0 0 1016
21 int2 N false true , 0 0 1005
22 int2vector A false true , 0 21 0
23 int4 N false true , 0 0 1007
24 regproc N false true , 0 0 0
25 text S false true , 0 0 1009
26 oid N false true , 0 0 1028
30 oidvector A false true , 0 26 0
700 float4 N false true , 0 0 1021
701 float8 N false true , 0 0 1022
869 inet I false true , 0 0 1041
1000 _bool A false true , 0 16 0
1001 _bytea A false true , 0 17 0
1002 _char A false true , 0 18 0
1003 _name A false true , 0 19 0
1005 _int2 A false true , 0 21 0
1007 _int4 A false true , 0 23 0
1009 _text A false true , 0 25 0
1014 _bpchar A false true , 0 1042 0
1015 _varchar A false true , 0 1043 0
1016 _int8 A false true , 0 20 0
1021 _float4 A false true , 0 700 0
1022 _float8 A false true , 0 701 0
1028 _oid A false true , 0 26 0
1041 _inet A false true , 0 869 0
1042 bpchar S false true , 0 0 1014
1043 varchar S false true , 0 0 1015
1082 date D false true , 0 0 1182
1083 time D false true , 0 0 1183
1114 timestamp D false true , 0 0 1115
1115 _timestamp A false true , 0 1114 0
1182 _date A false true , 0 1082 0
1183 _time A false true , 0 1083 0
1184 timestamptz D false true , 0 0 1185
1185 _timestamptz A false true , 0 1184 0
1186 interval T false true , 0 0 1187
1187 _interval A false true , 0 1186 0
1231 _numeric A false true , 0 1700 0
1560 bit V false true , 0 0 1561
1561 _bit A false true , 0 1560 0
1562 varbit V false true , 0 0 1563
1563 _varbit A false true , 0 1562 0
1700 numeric N false true , 0 0 1231
2202 regprocedure N false true , 0 0 0
2205 regclass N false true , 0 0 0
2206 regtype N false true , 0 0 0
2249 record P false true , 0 0 0
2277 anyarray P false true , 0 0 0
2283 anyelement P false true , 0 0 2277
2950 uuid U false true , 0 0 2951
2951 _uuid A false true , 0 2950 0
3802 jsonb U false true , 0 0 0
4089 regnamespace N false true , 0 0 0
query OTOOOOOOO colnames
SELECT oid, typname, typinput, typoutput, typreceive, typsend, typmodin, typmodout, typanalyze
FROM pg_catalog.pg_type
ORDER BY oid
----
oid typname typinput typoutput typreceive typsend typmodin typmodout typanalyze
16 bool boolin boolout boolrecv boolsend 0 0 0
17 bytea byteain byteaout bytearecv byteasend 0 0 0
18 char charin charout charrecv charsend 0 0 0
19 name namein nameout namerecv namesend 0 0 0
20 int8 int8in int8out int8recv int8send 0 0 0
21 int2 int2in int2out int2recv int2send 0 0 0
22 int2vector int2vectorin int2vectorout int2vectorrecv int2vectorsend 0 0 0
23 int4 int4in int4out int4recv int4send 0 0 0
24 regproc regprocin regprocout regprocrecv regprocsend 0 0 0
25 text textin textout textrecv textsend 0 0 0
26 oid oidin oidout oidrecv oidsend 0 0 0
30 oidvector oidvectorin oidvectorout oidvectorrecv oidvectorsend 0 0 0
700 float4 float4in float4out float4recv float4send 0 0 0
701 float8 float8in float8out float8recv float8send 0 0 0
869 inet inetin inetout inetrecv inetsend 0 0 0
1000 _bool array_in array_out array_recv array_send 0 0 0
1001 _bytea array_in array_out array_recv array_send 0 0 0
1002 _char array_in array_out array_recv array_send 0 0 0
1003 _name array_in array_out array_recv array_send 0 0 0
1005 _int2 array_in array_out array_recv array_send 0 0 0
1007 _int4 array_in array_out array_recv array_send 0 0 0
1009 _text array_in array_out array_recv array_send 0 0 0
1014 _bpchar array_in array_out array_recv array_send 0 0 0
1015 _varchar array_in array_out array_recv array_send 0 0 0
1016 _int8 array_in array_out array_recv array_send 0 0 0
1021 _float4 array_in array_out array_recv array_send 0 0 0
1022 _float8 array_in array_out array_recv array_send 0 0 0
1028 _oid array_in array_out array_recv array_send 0 0 0
1041 _inet array_in array_out array_recv array_send 0 0 0
1042 bpchar bpcharin bpcharout bpcharrecv bpcharsend 0 0 0
1043 varchar varcharin varcharout varcharrecv varcharsend 0 0 0
1082 date date_in date_out date_recv date_send 0 0 0
1083 time time_in time_out time_recv time_send 0 0 0
1114 timestamp timestamp_in timestamp_out timestamp_recv timestamp_send 0 0 0
1115 _timestamp array_in array_out array_recv array_send 0 0 0
1182 _date array_in array_out array_recv array_send 0 0 0
1183 _time array_in array_out array_recv array_send 0 0 0
1184 timestamptz timestamptz_in timestamptz_out timestamptz_recv timestamptz_send 0 0 0
1185 _timestamptz array_in array_out array_recv array_send 0 0 0
1186 interval interval_in interval_out interval_recv interval_send 0 0 0
1187 _interval array_in array_out array_recv array_send 0 0 0
1231 _numeric array_in array_out array_recv array_send 0 0 0
1560 bit bit_in bit_out bit_recv bit_send 0 0 0
1561 _bit array_in array_out array_recv array_send 0 0 0
1562 varbit varbit_in varbit_out varbit_recv varbit_send 0 0 0
1563 _varbit array_in array_out array_recv array_send 0 0 0
1700 numeric numeric_in numeric_out numeric_recv numeric_send 0 0 0
2202 regprocedure regprocedurein regprocedureout regprocedurerecv regproceduresend 0 0 0
2205 regclass regclassin regclassout regclassrecv regclasssend 0 0 0
2206 regtype regtypein regtypeout regtyperecv regtypesend 0 0 0
2249 record record_in record_out record_recv record_send 0 0 0