mirror of
https://github.com/postgres/postgres.git
synced 2025-08-08 06:02:22 +03:00
Add relkind checks to certain contrib modules
The contrib extensions pageinspect, pg_visibility and pgstattuple only work against regular relations which have storage. They don't work against foreign tables, partitioned (parent) tables, views, et al. Add checks to the user-callable functions to return a useful error message to the user if they mistakenly pass an invalid relation to a function which doesn't accept that kind of relation. In passing, improve some of the existing checks to use ereport() instead of elog(), add a function to consolidate common checks where appropriate, and add some regression tests. Author: Amit Langote, with various changes by me Reviewed by: Michael Paquier and Corey Huinker Discussion: https://postgr.es/m/ab91fd9d-4751-ee77-c87b-4dd704c1e59c@lab.ntt.co.jp
This commit is contained in:
@@ -71,3 +71,12 @@ SELECT * FROM fsm_page_contents(get_raw_page('test1', 'fsm', 0));
|
||||
(1 row)
|
||||
|
||||
DROP TABLE test1;
|
||||
-- check that using any of these functions with a partitioned table would fail
|
||||
create table test_partitioned (a int) partition by range (a);
|
||||
select get_raw_page('test_partitioned', 0); -- error about partitioned table
|
||||
ERROR: cannot get raw page from partitioned table "test_partitioned"
|
||||
-- a regular table which is a member of a partition set should work though
|
||||
create table test_part1 partition of test_partitioned for values from ( 1 ) to (100);
|
||||
select get_raw_page('test_part1', 0); -- get farther and error about empty table
|
||||
ERROR: block number 0 is out of range for relation "test_part1"
|
||||
drop table test_partitioned;
|
||||
|
Reference in New Issue
Block a user