]> begriffs open source - ai-pg/blob - full-docs/txt/pgsurgery.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / pgsurgery.txt
1
2 F.34. pg_surgery — perform low-level surgery on relation data #
3
4    F.34.1. Functions
5    F.34.2. Authors
6
7    The pg_surgery module provides various functions to perform surgery on
8    a damaged relation. These functions are unsafe by design and using them
9    may corrupt (or further corrupt) your database. For example, these
10    functions can easily be used to make a table inconsistent with its own
11    indexes, to cause UNIQUE or FOREIGN KEY constraint violations, or even
12    to make tuples visible which, when read, will cause a database server
13    crash. They should be used with great caution and only as a last
14    resort.
15
16 F.34.1. Functions #
17
18    heap_force_kill(regclass, tid[]) returns void
19           heap_force_kill marks “used” line pointers as “dead” without
20           examining the tuples. The intended use of this function is to
21           forcibly remove tuples that are not otherwise accessible. For
22           example:
23
24 test=> select * from t1 where ctid = '(0, 1)';
25 ERROR:  could not access status of transaction 4007513275
26 DETAIL:  Could not open file "pg_xact/0EED": No such file or directory.
27
28 test=# select heap_force_kill('t1'::regclass, ARRAY['(0, 1)']::tid[]);
29  heap_force_kill
30 -----------------
31
32 (1 row)
33
34 test=# select * from t1 where ctid = '(0, 1)';
35 (0 rows)
36
37
38    heap_force_freeze(regclass, tid[]) returns void
39           heap_force_freeze marks tuples as frozen without examining the
40           tuple data. The intended use of this function is to make
41           accessible tuples which are inaccessible due to corrupted
42           visibility information, or which prevent the table from being
43           successfully vacuumed due to corrupted visibility information.
44           For example:
45
46 test=> vacuum t1;
47 ERROR:  found xmin 507 from before relfrozenxid 515
48 CONTEXT:  while scanning block 0 of relation "public.t1"
49
50 test=# select ctid from t1 where xmin = 507;
51  ctid
52 -------
53  (0,3)
54 (1 row)
55
56 test=# select heap_force_freeze('t1'::regclass, ARRAY['(0, 3)']::tid[]);
57  heap_force_freeze
58 -------------------
59
60 (1 row)
61
62 test=# select ctid from t1 where xmin = 2;
63  ctid
64 -------
65  (0,3)
66 (1 row)
67
68
69 F.34.2. Authors #
70
71    Ashutosh Sharma <ashu.coek88@gmail.com>