1VACUUM;
2--
3-- sanity check, if we don't have indices the test will take years to
4-- complete.  But skip TOAST relations (since they will have varying
5-- names depending on the current OID counter) as well as temp tables
6-- of other backends (to avoid timing-dependent behavior).
7--
8-- temporarily disable fancy output, so catalog changes create less diff noise
9\a\t
10SELECT relname, relhasindex
11   FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
12   WHERE relkind = 'r' AND (nspname ~ '^pg_temp_') IS NOT TRUE
13   ORDER BY relname;
14a|f
15a_star|f
16aggtest|f
17array_index_op_test|t
18array_op_test|f
19b|f
20b_star|f
21box_tbl|f
22bprime|f
23bt_f8_heap|t
24bt_i4_heap|t
25bt_name_heap|t
26bt_txt_heap|t
27c|f
28c_star|f
29char_tbl|f
30check2_tbl|f
31check_tbl|f
32circle_tbl|t
33city|f
34copy_tbl|f
35d|f
36d_star|f
37date_tbl|f
38default_tbl|f
39defaultexpr_tbl|f
40dept|f
41dupindexcols|t
42e_star|f
43emp|f
44equipment_r|f
45f_star|f
46fast_emp4000|t
47float4_tbl|f
48float8_tbl|f
49func_index_heap|t
50hash_f8_heap|t
51hash_i4_heap|t
52hash_name_heap|t
53hash_txt_heap|t
54hobbies_r|f
55ihighway|t
56inet_tbl|f
57inhf|f
58inhx|t
59insert_tbl|f
60int2_tbl|f
61int4_tbl|f
62int8_tbl|f
63interval_tbl|f
64invalid_check_con|f
65invalid_check_con_child|f
66iportaltest|f
67kd_point_tbl|t
68line_tbl|f
69log_table|f
70lseg_tbl|f
71main_table|f
72money_data|f
73num_data|f
74num_exp_add|t
75num_exp_div|t
76num_exp_ln|t
77num_exp_log10|t
78num_exp_mul|t
79num_exp_power_10_ln|t
80num_exp_sqrt|t
81num_exp_sub|t
82num_input_test|f
83num_result|f
84numrange_test|t
85onek|t
86onek2|t
87path_tbl|f
88person|f
89pg_aggregate|t
90pg_am|t
91pg_amop|t
92pg_amproc|t
93pg_attrdef|t
94pg_attribute|t
95pg_auth_members|t
96pg_authid|t
97pg_cast|t
98pg_class|t
99pg_collation|t
100pg_constraint|t
101pg_conversion|t
102pg_database|t
103pg_db_role_setting|t
104pg_default_acl|t
105pg_depend|t
106pg_description|t
107pg_enum|t
108pg_event_trigger|t
109pg_extension|t
110pg_foreign_data_wrapper|t
111pg_foreign_server|t
112pg_foreign_table|t
113pg_index|t
114pg_inherits|t
115pg_init_privs|t
116pg_language|t
117pg_largeobject|t
118pg_largeobject_metadata|t
119pg_namespace|t
120pg_opclass|t
121pg_operator|t
122pg_opfamily|t
123pg_pltemplate|t
124pg_policy|t
125pg_proc|t
126pg_range|t
127pg_replication_origin|t
128pg_rewrite|t
129pg_seclabel|t
130pg_shdepend|t
131pg_shdescription|t
132pg_shseclabel|t
133pg_statistic|t
134pg_tablespace|t
135pg_transform|t
136pg_trigger|t
137pg_ts_config|t
138pg_ts_config_map|t
139pg_ts_dict|t
140pg_ts_parser|t
141pg_ts_template|t
142pg_type|t
143pg_user_mapping|t
144point_tbl|t
145polygon_tbl|t
146quad_box_tbl|t
147quad_point_tbl|t
148radix_text_tbl|t
149ramp|f
150real_city|f
151road|t
152shighway|t
153slow_emp4000|f
154sql_features|f
155sql_implementation_info|f
156sql_languages|f
157sql_packages|f
158sql_parts|f
159sql_sizing|f
160sql_sizing_profiles|f
161stud_emp|f
162student|f
163tenk1|t
164tenk2|t
165test_range_excl|t
166test_range_gist|t
167test_range_spgist|t
168test_tsvector|f
169testjsonb|f
170text_tbl|f
171textrange_test|t
172time_tbl|f
173timestamp_tbl|f
174timestamptz_tbl|f
175timetz_tbl|f
176varchar_tbl|f
177view_base_table|t
178-- restore normal output mode
179\a\t
180--
181-- another sanity check: every system catalog that has OIDs should have
182-- a unique index on OID.  This ensures that the OIDs will be unique,
183-- even after the OID counter wraps around.
184-- We exclude non-system tables from the check by looking at nspname.
185--
186SELECT relname, nspname
187FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace
188WHERE relhasoids
189    AND ((nspname ~ '^pg_') IS NOT FALSE)
190    AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
191                    AND indkey[0] = -2 AND indnatts = 1
192                    AND indisunique AND indimmediate);
193 relname | nspname
194---------+---------
195(0 rows)
196
197