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?
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?
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');
select pg_truncate_visibility_map('test_foreign_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');
+select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where relname = 'regular_table'));
truncate regular_table;
select count(*) > 0 from pg_visibility('regular_table');
+select count(*) > 0 from pg_visibility((select reltoastrelid from pg_class where relname = 'regular_table'));
create materialized view matview_visibility_test as select * from regular_table;
vacuum matview_visibility_test;
select pgstattuple('test_partitioned_index');
ERROR: "test_partitioned_index" (partitioned index) is not supported
select pgstattuple_approx('test_partitioned');
-ERROR: "test_partitioned" is not a table or materialized view
+ERROR: "test_partitioned" is not a table, materialized view, or TOAST table
select pg_relpages('test_partitioned');
ERROR: "test_partitioned" is not a table, index, materialized view, sequence, or TOAST table
select pgstatindex('test_partitioned');
select pgstattuple('test_view');
ERROR: "test_view" (view) is not supported
select pgstattuple_approx('test_view');
-ERROR: "test_view" is not a table or materialized view
+ERROR: "test_view" is not a table, materialized view, or TOAST table
select pg_relpages('test_view');
ERROR: "test_view" is not a table, index, materialized view, sequence, or TOAST table
select pgstatindex('test_view');
select pgstattuple('test_foreign_table');
ERROR: "test_foreign_table" (foreign table) is not supported
select pgstattuple_approx('test_foreign_table');
-ERROR: "test_foreign_table" is not a table or materialized view
+ERROR: "test_foreign_table" is not a table, materialized view, or TOAST table
select pg_relpages('test_foreign_table');
ERROR: "test_foreign_table" is not a table, index, materialized view, sequence, or TOAST table
select pgstatindex('test_foreign_table');
0
(1 row)
+-- toast tables should work
+select pgstattuple((select reltoastrelid from pg_class where relname = 'test'));
+ pgstattuple
+---------------------
+ (0,0,0,0,0,0,0,0,0)
+(1 row)
+
+select pgstattuple_approx((select reltoastrelid from pg_class where relname = 'test'));
+ pgstattuple_approx
+-----------------------
+ (0,0,0,0,0,0,0,0,0,0)
+(1 row)
+
+select pg_relpages((select reltoastrelid from pg_class where relname = 'test'));
+ pg_relpages
+-------------
+ 0
+(1 row)
+
-- not for the index calls though, of course
select pgstatindex('test_partition');
ERROR: relation "test_partition" is not a btree index
errmsg("cannot access temporary tables of other sessions")));
/*
- * We support only ordinary relations and materialised views, because we
- * depend on the visibility map and free space map for our estimates about
- * unscanned pages.
+ * We support only relation kinds with a visibility map and a free space
+ * map.
*/
if (!(rel->rd_rel->relkind == RELKIND_RELATION ||
- rel->rd_rel->relkind == RELKIND_MATVIEW))
+ rel->rd_rel->relkind == RELKIND_MATVIEW ||
+ rel->rd_rel->relkind == RELKIND_TOASTVALUE))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
- errmsg("\"%s\" is not a table or materialized view",
+ errmsg("\"%s\" is not a table, materialized view, or TOAST table",
RelationGetRelationName(rel))));
if (rel->rd_rel->relam != HEAP_TABLE_AM_OID)
select pgstattuple_approx('test_partition');
select pg_relpages('test_partition');
+-- toast tables should work
+select pgstattuple((select reltoastrelid from pg_class where relname = 'test'));
+select pgstattuple_approx((select reltoastrelid from pg_class where relname = 'test'));
+select pg_relpages((select reltoastrelid from pg_class where relname = 'test'));
+
-- not for the index calls though, of course
select pgstatindex('test_partition');
select pgstatginindex('test_partition');