2 -- Test assorted system views
4 -- This test is mainly meant to provide some code coverage for the
5 -- set-returning functions that underlie certain system views.
6 -- The output of most of these functions is very environment-dependent,
7 -- so our ability to test with fixed expected output is pretty limited;
8 -- but even a trivial check of count(*) will exercise the normal code path
10 select count(*) >= 0 as ok from pg_available_extension_versions;
16 select count(*) >= 0 as ok from pg_available_extensions;
22 -- The entire output of pg_backend_memory_contexts is not stable,
23 -- we test only the existence and basic condition of TopMemoryContext.
24 select name, ident, parent, level, total_bytes >= free_bytes
25 from pg_backend_memory_contexts where level = 0;
26 name | ident | parent | level | ?column?
27 ------------------+-------+--------+-------+----------
28 TopMemoryContext | | | 0 | t
31 -- At introduction, pg_config had 23 entries; it may grow
32 select count(*) > 20 as ok from pg_config;
38 -- We expect no cursors in this test; see also portals.sql
39 select count(*) = 0 as ok from pg_cursors;
45 select count(*) >= 0 as ok from pg_file_settings;
51 -- There will surely be at least one rule, with no errors.
52 select count(*) > 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err
53 from pg_hba_file_rules;
59 -- There may be no rules, and there should be no errors.
60 select count(*) >= 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err
61 from pg_ident_file_mappings;
67 -- There will surely be at least one active lock
68 select count(*) > 0 as ok from pg_locks;
74 -- We expect no prepared statements in this test; see also prepare.sql
75 select count(*) = 0 as ok from pg_prepared_statements;
81 -- See also prepared_xacts.sql
82 select count(*) >= 0 as ok from pg_prepared_xacts;
88 -- There will surely be at least one SLRU cache
89 select count(*) > 0 as ok from pg_stat_slru;
95 -- There must be only one record
96 select count(*) = 1 as ok from pg_stat_wal;
102 -- We expect no walreceiver running in this test
103 select count(*) = 0 as ok from pg_stat_wal_receiver;
109 -- This is to record the prevailing planner enable_foo settings during
110 -- a regression test run.
111 select name, setting from pg_settings where name like 'enable%';
113 --------------------------------+---------
114 enable_async_append | on
115 enable_bitmapscan | on
116 enable_gathermerge | on
119 enable_incremental_sort | on
120 enable_indexonlyscan | on
121 enable_indexscan | on
124 enable_mergejoin | on
126 enable_parallel_append | on
127 enable_parallel_hash | on
128 enable_partition_pruning | on
129 enable_partitionwise_aggregate | off
130 enable_partitionwise_join | off
131 enable_presorted_aggregate | on
137 -- There are always wait event descriptions for various types.
138 select type, count(*) > 0 as ok FROM pg_wait_events
139 group by type order by type COLLATE "C";
153 -- Test that the pg_timezone_names and pg_timezone_abbrevs views are
154 -- more-or-less working. We can't test their contents in any great detail
155 -- without the outputs changing anytime IANA updates the underlying data,
156 -- but it seems reasonable to expect at least one entry per major meridian.
157 -- (At the time of writing, the actual counts are around 38 because of
158 -- zones using fractional GMT offsets, so this is a pretty loose test.)
159 select count(distinct utc_offset) >= 24 as ok from pg_timezone_names;
165 select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
171 -- Let's check the non-default timezone abbreviation sets, too
172 set timezone_abbreviations = 'Australia';
173 select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
179 set timezone_abbreviations = 'India';
180 select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;