1-- 2-- Test assorted system views 3-- 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 9-- through the SRF. 10 11select count(*) >= 0 as ok from pg_available_extension_versions; 12 13select count(*) >= 0 as ok from pg_available_extensions; 14 15-- The entire output of pg_backend_memory_contexts is not stable, 16-- we test only the existance and basic condition of TopMemoryContext. 17select name, ident, parent, level, total_bytes >= free_bytes 18 from pg_backend_memory_contexts where level = 0; 19 20-- At introduction, pg_config had 23 entries; it may grow 21select count(*) > 20 as ok from pg_config; 22 23-- We expect no cursors in this test; see also portals.sql 24select count(*) = 0 as ok from pg_cursors; 25 26select count(*) >= 0 as ok from pg_file_settings; 27 28-- There will surely be at least one rule 29select count(*) > 0 as ok from pg_hba_file_rules; 30 31-- There will surely be at least one active lock 32select count(*) > 0 as ok from pg_locks; 33 34-- We expect no prepared statements in this test; see also prepare.sql 35select count(*) = 0 as ok from pg_prepared_statements; 36 37-- See also prepared_xacts.sql 38select count(*) >= 0 as ok from pg_prepared_xacts; 39 40-- There must be only one record 41select count(*) = 1 as ok from pg_stat_wal; 42 43-- We expect no walreceiver running in this test 44select count(*) = 0 as ok from pg_stat_wal_receiver; 45 46-- This is to record the prevailing planner enable_foo settings during 47-- a regression test run. 48select name, setting from pg_settings where name like 'enable%'; 49 50-- Test that the pg_timezone_names and pg_timezone_abbrevs views are 51-- more-or-less working. We can't test their contents in any great detail 52-- without the outputs changing anytime IANA updates the underlying data, 53-- but it seems reasonable to expect at least one entry per major meridian. 54-- (At the time of writing, the actual counts are around 38 because of 55-- zones using fractional GMT offsets, so this is a pretty loose test.) 56select count(distinct utc_offset) >= 24 as ok from pg_timezone_names; 57select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs; 58-- Let's check the non-default timezone abbreviation sets, too 59set timezone_abbreviations = 'Australia'; 60select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs; 61set timezone_abbreviations = 'India'; 62select count(distinct utc_offset) >= 24 as ok from pg_timezone_abbrevs; 63