pgsql: New contrib module, pg_surgery, with heap surgery functions. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: New contrib module, pg_surgery, with heap surgery functions.
Date
Msg-id E1kGONd-0003Mg-Ms@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
New contrib module, pg_surgery, with heap surgery functions.

Sometimes it happens that the visibility information for a tuple
becomes corrupted, either due to bugs in the database software or
external factors. Provide a function heap_force_kill() that can
be used to truncate such dead tuples to dead line pointers, and
a function heap_force_freeze() that can be used to overwrite the
visibility information in such a way that the tuple becomes
all-visible.

These functions are unsafe, in that you can easily use them to
corrupt a database that was not previously corrupted, and you can
use them to further corrupt an already-corrupted database or to
destroy data. The documentation accordingly cautions against
casual use. However, in some cases they permit recovery of data
that would otherwise be very difficult to recover, or to allow a
system to continue to function when it would otherwise be difficult
to do so.

Because we may want to add other functions for performing other
kinds of surgery in the future, the new contrib module is called
pg_surgery rather than something specific to these functions. I
proposed back-patching this so that it could be more easily used
by people running existing releases who are facing these kinds of
problems, but that proposal did not attract enough support, so
no back-patch for now.

Ashutosh Sharma, reviewed and tested by Andrey M. Borodin,
M. Beena Emerson, Masahiko Sawada, Rajkumar Raghuwanshi,
Asim Praveen, and Mark Dilger, and somewhat revised by me.

Discussion: http://postgr.es/m/CA+TgmoZW1fsU-QUNCRUQMGUygBDPVeOTLCqRdQZch=EYZnctSA@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/34a947ca13e52389eb3e81f1ceb38e592ad53110

Modified Files
--------------
contrib/Makefile                             |   1 +
contrib/pg_surgery/.gitignore                |   4 +
contrib/pg_surgery/Makefile                  |  23 ++
contrib/pg_surgery/expected/heap_surgery.out | 180 +++++++++++
contrib/pg_surgery/heap_surgery.c            | 428 +++++++++++++++++++++++++++
contrib/pg_surgery/pg_surgery--1.0.sql       |  18 ++
contrib/pg_surgery/pg_surgery.control        |   5 +
contrib/pg_surgery/sql/heap_surgery.sql      |  91 ++++++
doc/src/sgml/contrib.sgml                    |   1 +
doc/src/sgml/filelist.sgml                   |   1 +
doc/src/sgml/pgsurgery.sgml                  | 107 +++++++
src/tools/pgindent/typedefs.list             |   1 +
12 files changed, 860 insertions(+)


pgsql-committers by date:

Previous
From: Peter Eisentraut
Date:
Subject: pgsql: Remove unused parameter
Next
From: Tom Lane
Date:
Subject: pgsql: Use _exit(2) for SIGQUIT during ProcessStartupPacket, too.