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 IN ('r', 'p') 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
21bit_defaults|f
22box_tbl|f
23bprime|f
24bt_f8_heap|t
25bt_i4_heap|t
26bt_name_heap|t
27bt_txt_heap|t
28c|f
29c_star|f
30char_tbl|f
31check2_tbl|f
32check_tbl|f
33circle_tbl|t
34city|f
35copy_tbl|f
36d|f
37d_star|f
38date_tbl|f
39default_tbl|f
40defaultexpr_tbl|f
41dept|f
42dupindexcols|t
43e_star|f
44emp|f
45equipment_r|f
46extra_wide_table|f
47f_star|f
48fast_emp4000|t
49float4_tbl|f
50float8_tbl|f
51func_index_heap|t
52hash_f8_heap|t
53hash_i4_heap|t
54hash_name_heap|t
55hash_txt_heap|t
56hobbies_r|f
57ihighway|t
58inet_tbl|f
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
72mlparted|f
73mlparted1|f
74mlparted11|f
75mlparted12|f
76mlparted2|f
77mlparted3|f
78mlparted4|f
79mlparted_def|f
80mlparted_def1|f
81mlparted_def2|f
82mlparted_defd|f
83money_data|f
84num_data|f
85num_exp_add|t
86num_exp_div|t
87num_exp_ln|t
88num_exp_log10|t
89num_exp_mul|t
90num_exp_power_10_ln|t
91num_exp_sqrt|t
92num_exp_sub|t
93num_input_test|f
94num_result|f
95numrange_test|t
96onek|t
97onek2|t
98path_tbl|f
99person|f
100persons|f
101persons2|t
102persons3|t
103pg_aggregate|t
104pg_am|t
105pg_amop|t
106pg_amproc|t
107pg_attrdef|t
108pg_attribute|t
109pg_auth_members|t
110pg_authid|t
111pg_cast|t
112pg_class|t
113pg_collation|t
114pg_constraint|t
115pg_conversion|t
116pg_database|t
117pg_db_role_setting|t
118pg_default_acl|t
119pg_depend|t
120pg_description|t
121pg_enum|t
122pg_event_trigger|t
123pg_extension|t
124pg_foreign_data_wrapper|t
125pg_foreign_server|t
126pg_foreign_table|t
127pg_index|t
128pg_inherits|t
129pg_init_privs|t
130pg_language|t
131pg_largeobject|t
132pg_largeobject_metadata|t
133pg_namespace|t
134pg_opclass|t
135pg_operator|t
136pg_opfamily|t
137pg_partitioned_table|t
138pg_pltemplate|t
139pg_policy|t
140pg_proc|t
141pg_publication|t
142pg_publication_rel|t
143pg_range|t
144pg_replication_origin|t
145pg_rewrite|t
146pg_seclabel|t
147pg_sequence|t
148pg_shdepend|t
149pg_shdescription|t
150pg_shseclabel|t
151pg_statistic|t
152pg_statistic_ext|t
153pg_statistic_ext_data|t
154pg_subscription|t
155pg_subscription_rel|t
156pg_tablespace|t
157pg_transform|t
158pg_trigger|t
159pg_ts_config|t
160pg_ts_config_map|t
161pg_ts_dict|t
162pg_ts_parser|t
163pg_ts_template|t
164pg_type|t
165pg_user_mapping|t
166point_tbl|t
167polygon_tbl|t
168quad_box_tbl|t
169quad_point_tbl|t
170quad_poly_tbl|t
171radix_text_tbl|t
172ramp|f
173real_city|f
174road|t
175shighway|t
176slow_emp4000|f
177sql_features|f
178sql_implementation_info|f
179sql_languages|f
180sql_packages|f
181sql_parts|f
182sql_sizing|f
183sql_sizing_profiles|f
184stud_emp|f
185student|f
186tableam_parted_a_heap2|f
187tableam_parted_b_heap2|f
188tableam_parted_c_heap2|f
189tableam_parted_d_heap2|f
190tableam_parted_heap2|f
191tableam_tbl_heap2|f
192tableam_tblas_heap2|f
193tbl_include_box|t
194tbl_include_box_pk|f
195tbl_include_pk|t
196tbl_include_reg|t
197tbl_include_unique1|t
198tbl_include_unique2|f
199tenk1|t
200tenk2|t
201test_range_excl|t
202test_range_gist|t
203test_range_spgist|t
204test_tsvector|f
205testjsonb|f
206text_tbl|f
207textrange_test|t
208time_tbl|f
209timestamp_tbl|f
210timestamptz_tbl|f
211timetz_tbl|f
212tmp|f
213trigger_parted|t
214trigger_parted_p1|t
215trigger_parted_p1_1|t
216trigger_parted_p2|t
217trigger_parted_p2_2|t
218varchar_tbl|f
219view_base_table|t
220-- restore normal output mode
221\a\t
222--
223-- another sanity check: every system catalog that has OIDs should have
224-- a unique index on OID.  This ensures that the OIDs will be unique,
225-- even after the OID counter wraps around.
226-- We exclude non-system tables from the check by looking at nspname.
227--
228SELECT relname, nspname
229 FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = relnamespace JOIN pg_attribute a ON (attrelid = c.oid AND attname = 'oid')
230 WHERE relkind = 'r' and c.oid < 16384
231     AND ((nspname ~ '^pg_') IS NOT FALSE)
232     AND NOT EXISTS (SELECT 1 FROM pg_index i WHERE indrelid = c.oid
233                     AND indkey[0] = a.attnum AND indnatts = 1
234                     AND indisunique AND indimmediate);
235 relname | nspname
236---------+---------
237(0 rows)
238
239-- check that relations without storage don't have relfilenode
240SELECT relname, relkind
241  FROM pg_class
242 WHERE relkind IN ('v', 'c', 'f', 'p', 'I')
243       AND relfilenode <> 0;
244 relname | relkind
245---------+---------
246(0 rows)
247
248