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 type, name, ident, level, total_bytes >= free_bytes
25 from pg_backend_memory_contexts where level = 1;
26 type | name | ident | level | ?column?
27 ----------+------------------+-------+-------+----------
28 AllocSet | TopMemoryContext | | 1 | t
31 -- We can exercise some MemoryContext type stats functions. Most of the
32 -- column values are too platform-dependant to display.
33 -- Ensure stats from the bump allocator look sane. Bump isn't a commonly
34 -- used context, but it is used in tuplesort.c, so open a cursor to keep
35 -- the tuplesort alive long enough for us to query the context stats.
37 declare cur cursor for select left(a,10), b
38 from (values(repeat('a', 512 * 1024),1),(repeat('b', 512),2)) v(a,b)
46 select type, name, total_bytes > 0, total_nblocks, free_bytes > 0, free_chunks
47 from pg_backend_memory_contexts where name = 'Caller tuples';
48 type | name | ?column? | total_nblocks | ?column? | free_chunks
49 ------+---------------+----------+---------------+----------+-------------
50 Bump | Caller tuples | t | 2 | t | 0
54 -- Further sanity checks on pg_backend_memory_contexts. We expect
55 -- CacheMemoryContext to have multiple children. Ensure that's the case.
57 select * from pg_backend_memory_contexts
60 from contexts c1, contexts c2
61 where c2.name = 'CacheMemoryContext'
62 and c1.path[c2.level] = c2.path[c2.level];
68 -- At introduction, pg_config had 23 entries; it may grow
69 select count(*) > 20 as ok from pg_config;
75 -- We expect no cursors in this test; see also portals.sql
76 select count(*) = 0 as ok from pg_cursors;
82 select count(*) >= 0 as ok from pg_file_settings;
88 -- There will surely be at least one rule, with no errors.
89 select count(*) > 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err
90 from pg_hba_file_rules;
96 -- There may be no rules, and there should be no errors.
97 select count(*) >= 0 as ok, count(*) FILTER (WHERE error IS NOT NULL) = 0 AS no_err
98 from pg_ident_file_mappings;
104 -- There will surely be at least one active lock
105 select count(*) > 0 as ok from pg_locks;
111 -- We expect no prepared statements in this test; see also prepare.sql
112 select count(*) = 0 as ok from pg_prepared_statements;
118 -- See also prepared_xacts.sql
119 select count(*) >= 0 as ok from pg_prepared_xacts;
125 -- There will surely be at least one SLRU cache
126 select count(*) > 0 as ok from pg_stat_slru;
132 -- There must be only one record
133 select count(*) = 1 as ok from pg_stat_wal;
139 -- We expect no walreceiver running in this test
140 select count(*) = 0 as ok from pg_stat_wal_receiver;
146 -- This is to record the prevailing planner enable_foo settings during
147 -- a regression test run.
148 select name, setting from pg_settings where name like 'enable%';
150 --------------------------------+---------
151 enable_async_append | on
152 enable_bitmapscan | on
153 enable_distinct_reordering | on
154 enable_gathermerge | on
155 enable_group_by_reordering | on
158 enable_incremental_sort | on
159 enable_indexonlyscan | on
160 enable_indexscan | on
163 enable_mergejoin | on
165 enable_parallel_append | on
166 enable_parallel_hash | on
167 enable_partition_pruning | on
168 enable_partitionwise_aggregate | off
169 enable_partitionwise_join | off
170 enable_presorted_aggregate | on
176 -- There are always wait event descriptions for various types. InjectionPoint
177 -- may be present or absent, depending on history since last postmaster start.
178 select type, count(*) > 0 as ok FROM pg_wait_events
179 where type <> 'InjectionPoint' group by type order by type COLLATE "C";
193 -- Test that the pg_timezone_names and pg_timezone_abbrevs views are
194 -- more-or-less working. We can't test their contents in any great detail
195 -- without the outputs changing anytime IANA updates the underlying data,
196 -- but it seems reasonable to expect at least one entry per major meridian.
197 -- (At the time of writing, the actual counts are around 38 because of
198 -- zones using fractional GMT offsets, so this is a pretty loose test.)
199 select count(distinct utc_offset) >= 24 as ok from pg_timezone_names;
205 select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
211 -- Let's check the non-default timezone abbreviation sets, too
212 set timezone_abbreviations = 'Australia';
213 select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;
219 set timezone_abbreviations = 'India';
220 select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs;