Skip to content

Commit ba0a198

Browse files
committed
Add pg_visibility contrib module.
This lets you examine the visibility map as well as page-level visibility information. I initially wrote it as a debugging aid, but was encouraged to polish it for commit. Patch by me, reviewed by Masahiko Sawada. Discussion: 56D77803.6080503@BlueTreble.com
1 parent 6f56b41 commit ba0a198

File tree

9 files changed

+544
-0
lines changed

9 files changed

+544
-0
lines changed

contrib/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SUBDIRS = \
3737
pgcrypto \
3838
pgrowlocks \
3939
pgstattuple \
40+
pg_visibility \
4041
postgres_fdw \
4142
seg \
4243
spi \

contrib/pg_visibility/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# contrib/pg_visibility/Makefile
2+
3+
MODULE_big = pg_visibility
4+
OBJS = pg_visibility.o $(WIN32RES)
5+
6+
EXTENSION = pg_visibility
7+
DATA = pg_visibility--1.0.sql
8+
PGFILEDESC = "pg_visibility - page visibility information"
9+
10+
ifdef USE_PGXS
11+
PG_CONFIG = pg_config
12+
PGXS := $(shell $(PG_CONFIG) --pgxs)
13+
include $(PGXS)
14+
else
15+
subdir = contrib/pg_visibility
16+
top_builddir = ../..
17+
include $(top_builddir)/src/Makefile.global
18+
include $(top_srcdir)/contrib/contrib-global.mk
19+
endif
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/* contrib/pg_visibility/pg_visibility--1.0.sql */
2+
3+
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
4+
\echo Use "CREATE EXTENSION pg_visibility" to load this file. \quit
5+
6+
-- Show visibility map information.
7+
CREATE FUNCTION pg_visibility_map(regclass, blkno bigint,
8+
all_visible OUT boolean,
9+
all_frozen OUT boolean)
10+
RETURNS record
11+
AS 'MODULE_PATHNAME', 'pg_visibility_map'
12+
LANGUAGE C STRICT;
13+
14+
-- Show visibility map and page-level visibility information.
15+
CREATE FUNCTION pg_visibility(regclass, blkno bigint,
16+
all_visible OUT boolean,
17+
all_frozen OUT boolean,
18+
pd_all_visible OUT boolean)
19+
RETURNS record
20+
AS 'MODULE_PATHNAME', 'pg_visibility'
21+
LANGUAGE C STRICT;
22+
23+
-- Show visibility map information for each block in a relation.
24+
CREATE FUNCTION pg_visibility_map(regclass, blkno OUT bigint,
25+
all_visible OUT boolean,
26+
all_frozen OUT boolean)
27+
RETURNS SETOF record
28+
AS 'MODULE_PATHNAME', 'pg_visibility_map_rel'
29+
LANGUAGE C STRICT;
30+
31+
-- Show visibility map and page-level visibility information for each block.
32+
CREATE FUNCTION pg_visibility(regclass, blkno OUT bigint,
33+
all_visible OUT boolean,
34+
all_frozen OUT boolean,
35+
pd_all_visible OUT boolean)
36+
RETURNS SETOF record
37+
AS 'MODULE_PATHNAME', 'pg_visibility_rel'
38+
LANGUAGE C STRICT;
39+
40+
-- Show summary of visibility map bits for a relation.
41+
CREATE FUNCTION pg_visibility_map_summary(regclass,
42+
OUT all_visible bigint, OUT all_frozen bigint)
43+
RETURNS record
44+
AS 'MODULE_PATHNAME', 'pg_visibility_map_summary'
45+
LANGUAGE C STRICT;
46+
47+
-- Don't want these to be available to public.
48+
REVOKE ALL ON FUNCTION pg_visibility_map(regclass, bigint) FROM PUBLIC;
49+
REVOKE ALL ON FUNCTION pg_visibility(regclass, bigint) FROM PUBLIC;
50+
REVOKE ALL ON FUNCTION pg_visibility_map(regclass) FROM PUBLIC;
51+
REVOKE ALL ON FUNCTION pg_visibility(regclass) FROM PUBLIC;
52+
REVOKE ALL ON FUNCTION pg_visibility_map_summary(regclass) FROM PUBLIC;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy