1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

pgstattuple: Have pgstattuple_approx accept TOAST tables

TOAST tables have a visibility map and a free space map, so they can
be supported by pgstattuple_approx just fine.

Add test cases to show how various pgstattuple functions accept TOAST
tables.  Also add similar tests to pg_visibility, which already
accepted TOAST tables correctly but had no test coverage for them.

Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Discussion: https://www.postgresql.org/message-id/flat/27c4496a-02b9-dc87-8f6f-bddbef54e0fe@2ndquadrant.com
This commit is contained in:
Peter Eisentraut
2020-06-30 00:29:35 +02:00
parent ea57e531b9
commit ee0202d552
5 changed files with 52 additions and 12 deletions

View File

@ -102,8 +102,9 @@ ERROR: "test_foreign_table" is not a table, materialized view, or TOAST table
select pg_truncate_visibility_map('test_foreign_table');
ERROR: "test_foreign_table" is not a table, materialized view, or TOAST table
-- check some of the allowed relkinds
create table regular_table (a int);
insert into regular_table values (1), (2);
create table regular_table (a int, b text);
alter table regular_table alter column b set storage external;
insert into regular_table values (1, repeat('one', 1000)), (2, repeat('two', 1000));
vacuum regular_table;
select count(*) > 0 from pg_visibility('regular_table');
?column?
@ -111,6 +112,12 @@ select count(*) > 0 from pg_visibility('regular_table');
t
(1 row)
select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where relname = 'regular_table'));
?column?
----------
t
(1 row)
truncate regular_table;
select count(*) > 0 from pg_visibility('regular_table');
?column?
@ -118,6 +125,12 @@ select count(*) > 0 from pg_visibility('regular_table');
f
(1 row)
select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where relname = 'regular_table'));
?column?
----------
f
(1 row)
create materialized view matview_visibility_test as select * from regular_table;
vacuum matview_visibility_test;
select count(*) > 0 from pg_visibility('matview_visibility_test');