aboutsummaryrefslogtreecommitdiff
path: root/src/test/regress/sql/pagefuncs.sql
blob: 12d32eeae473e3d9c741b8a745a1ea3dbc333003 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
--
-- 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
SELECT pg_relation_check_pages('pg_class', 'main'); -- error
RESET ROLE;
DROP ROLE regress_pgfunc_user;

-- NULL and simple sanity checks
SELECT pg_relation_check_pages(NULL); -- empty result
SELECT pg_relation_check_pages(NULL, NULL); -- empty result
SELECT pg_relation_check_pages('pg_class', 'invalid_fork'); -- error

-- 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');
SELECT pg_relation_check_pages('pgfunc_test_ind');
DROP TABLE pgfunc_test_tab;

CREATE MATERIALIZED VIEW pgfunc_test_matview AS SELECT 1;
SELECT pg_relation_check_pages('pgfunc_test_matview');
DROP MATERIALIZED VIEW pgfunc_test_matview;
CREATE SEQUENCE pgfunc_test_seq;
SELECT pg_relation_check_pages('pgfunc_test_seq');
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');
DROP TABLE pgfunc_test_temp;
CREATE VIEW pgfunc_test_view AS SELECT 1;
SELECT pg_relation_check_pages('pgfunc_test_view');
DROP VIEW pgfunc_test_view;