-- -- Tests for functions related to relation pages -- -- Restricted to superusers by default CREATE ROLE regress_pgfunc_user; SET ROLE regress_pgfunc_user; SELECT pg_relation_check_pages('pg_class'); -- error ERROR: permission denied for function pg_relation_check_pages SELECT pg_relation_check_pages('pg_class', 'main'); -- error ERROR: permission denied for function pg_relation_check_pages RESET ROLE; DROP ROLE regress_pgfunc_user; -- NULL and simple sanity checks SELECT pg_relation_check_pages(NULL); -- empty result pg_relation_check_pages ------------------------- (0 rows) SELECT pg_relation_check_pages(NULL, NULL); -- empty result pg_relation_check_pages ------------------------- (0 rows) SELECT pg_relation_check_pages('pg_class', 'invalid_fork'); -- error ERROR: invalid fork name HINT: Valid fork names are "main", "fsm", "vm", and "init". -- Relation types that are supported CREATE TABLE pgfunc_test_tab (id int); CREATE INDEX pgfunc_test_ind ON pgfunc_test_tab(id); INSERT INTO pgfunc_test_tab VALUES (generate_series(1,1000)); SELECT pg_relation_check_pages('pgfunc_test_tab'); pg_relation_check_pages ------------------------- (0 rows) SELECT pg_relation_check_pages('pgfunc_test_ind'); pg_relation_check_pages ------------------------- (0 rows) DROP TABLE pgfunc_test_tab; CREATE MATERIALIZED VIEW pgfunc_test_matview AS SELECT 1; SELECT pg_relation_check_pages('pgfunc_test_matview'); pg_relation_check_pages ------------------------- (0 rows) DROP MATERIALIZED VIEW pgfunc_test_matview; CREATE SEQUENCE pgfunc_test_seq; SELECT pg_relation_check_pages('pgfunc_test_seq'); pg_relation_check_pages ------------------------- (0 rows) DROP SEQUENCE pgfunc_test_seq; -- pg_relation_check_pages() returns no results if passed relations that -- do not support the operation, like relations without storage or temporary -- relations. CREATE TEMPORARY TABLE pgfunc_test_temp AS SELECT generate_series(1,10) AS a; SELECT pg_relation_check_pages('pgfunc_test_temp'); pg_relation_check_pages ------------------------- (0 rows) DROP TABLE pgfunc_test_temp; CREATE VIEW pgfunc_test_view AS SELECT 1; SELECT pg_relation_check_pages('pgfunc_test_view'); pg_relation_check_pages ------------------------- (0 rows) DROP VIEW pgfunc_test_view;