Skip to content

Commit e472ce9

Browse files
committed
Add integrity-checking functions to pg_visibility.
The new pg_check_visible() and pg_check_frozen() functions can be used to verify that the visibility map bits for a relation's data pages match the actual state of the tuples on those pages. Amit Kapila and Robert Haas, reviewed (in earlier versions) by Andres Freund. Additional testing help by Thomas Munro.
1 parent 38e9f90 commit e472ce9

File tree

7 files changed

+376
-4
lines changed

7 files changed

+376
-4
lines changed

contrib/pg_visibility/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MODULE_big = pg_visibility
44
OBJS = pg_visibility.o $(WIN32RES)
55

66
EXTENSION = pg_visibility
7-
DATA = pg_visibility--1.0.sql
7+
DATA = pg_visibility--1.1.sql pg_visibility--1.0--1.1.sql
88
PGFILEDESC = "pg_visibility - page visibility information"
99

1010
ifdef USE_PGXS
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/* contrib/pg_visibility/pg_visibility--1.0--1.1.sql */
2+
3+
-- complain if script is sourced in psql, rather than via ALTER EXTENSION
4+
\echo Use "ALTER EXTENSION pg_visibility UPDATE TO '1.1'" to load this file. \quit
5+
6+
CREATE FUNCTION pg_check_frozen(regclass, t_ctid OUT tid)
7+
RETURNS SETOF tid
8+
AS 'MODULE_PATHNAME', 'pg_check_frozen'
9+
LANGUAGE C STRICT;
10+
11+
CREATE FUNCTION pg_check_visible(regclass, t_ctid OUT tid)
12+
RETURNS SETOF tid
13+
AS 'MODULE_PATHNAME', 'pg_check_visible'
14+
LANGUAGE C STRICT;
15+
16+
REVOKE ALL ON FUNCTION pg_check_frozen(regclass) FROM PUBLIC;
17+
REVOKE ALL ON FUNCTION pg_check_visible(regclass) FROM PUBLIC;

contrib/pg_visibility/pg_visibility--1.0.sql renamed to contrib/pg_visibility/pg_visibility--1.1.sql

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* contrib/pg_visibility/pg_visibility--1.0.sql */
1+
/* contrib/pg_visibility/pg_visibility--1.1.sql */
22

33
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
44
\echo Use "CREATE EXTENSION pg_visibility" to load this file. \quit
@@ -44,9 +44,24 @@ RETURNS record
4444
AS 'MODULE_PATHNAME', 'pg_visibility_map_summary'
4545
LANGUAGE C STRICT;
4646

47+
-- Show tupleids of non-frozen tuples if any in all_frozen pages
48+
-- for a relation.
49+
CREATE FUNCTION pg_check_frozen(regclass, t_ctid OUT tid)
50+
RETURNS SETOF tid
51+
AS 'MODULE_PATHNAME', 'pg_check_frozen'
52+
LANGUAGE C STRICT;
53+
54+
-- Show tupleids of dead tuples if any in all_visible pages for a relation.
55+
CREATE FUNCTION pg_check_visible(regclass, t_ctid OUT tid)
56+
RETURNS SETOF tid
57+
AS 'MODULE_PATHNAME', 'pg_check_visible'
58+
LANGUAGE C STRICT;
59+
4760
-- Don't want these to be available to public.
4861
REVOKE ALL ON FUNCTION pg_visibility_map(regclass, bigint) FROM PUBLIC;
4962
REVOKE ALL ON FUNCTION pg_visibility(regclass, bigint) FROM PUBLIC;
5063
REVOKE ALL ON FUNCTION pg_visibility_map(regclass) FROM PUBLIC;
5164
REVOKE ALL ON FUNCTION pg_visibility(regclass) FROM PUBLIC;
5265
REVOKE ALL ON FUNCTION pg_visibility_map_summary(regclass) FROM PUBLIC;
66+
REVOKE ALL ON FUNCTION pg_check_frozen(regclass) FROM PUBLIC;
67+
REVOKE ALL ON FUNCTION pg_check_visible(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