1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>F.34. pg_surgery</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="pgstattuple.html" title="F.33. pgstattuple" /><link rel="next" href="pgtrgm.html" title="F.35. pg_trgm" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.34. pg_surgery</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgstattuple.html" title="F.33. pgstattuple">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgtrgm.html" title="F.35. pg_trgm">Next</a></td></tr></table><hr /></div><div class="sect1" id="PGSURGERY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.34. pg_surgery</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="pgsurgery.html#id-1.11.7.43.4">F.34.1. Functions</a></span></dt><dt><span class="sect2"><a href="pgsurgery.html#id-1.11.7.43.5">F.34.2. Authors</a></span></dt></dl></div><a id="id-1.11.7.43.2" class="indexterm"></a><p>
The <code class="filename">pg_surgery</code> module provides various functions to
perform surgery on a damaged relation. These functions are unsafe by design
and using them may corrupt (or further corrupt) your database. For example,
these functions can easily be used to make a table inconsistent with its
own indexes, to cause <code class="literal">UNIQUE</code> or
<code class="literal">FOREIGN KEY</code> constraint violations, or even to make
tuples visible which, when read, will cause a database server crash.
They should be used with great caution and only as a last resort.
</p><div class="sect2" id="id-1.11.7.43.4"><div class="titlepage"><div><div><h3 class="title">F.34.1. Functions</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">
<code class="function">heap_force_kill(regclass, tid[]) returns void</code>
</span></dt><dd><p>
<code class="function">heap_force_kill</code> marks <span class="quote">“<span class="quote">used</span>”</span> line
pointers as <span class="quote">“<span class="quote">dead</span>”</span> without examining the tuples. The
intended use of this function is to forcibly remove tuples that are not
otherwise accessible. For example:
</p><pre class="programlisting">
test=> select * from t1 where ctid = '(0, 1)';
ERROR: could not access status of transaction 4007513275
DETAIL: Could not open file "pg_xact/0EED": No such file or directory.
test=# select heap_force_kill('t1'::regclass, ARRAY['(0, 1)']::tid[]);
heap_force_kill
-----------------
(1 row)
test=# select * from t1 where ctid = '(0, 1)';
(0 rows)
</pre><p>
</p></dd><dt><span class="term">
<code class="function">heap_force_freeze(regclass, tid[]) returns void</code>
</span></dt><dd><p>
<code class="function">heap_force_freeze</code> marks tuples as frozen without
examining the tuple data. The intended use of this function is to
make accessible tuples which are inaccessible due to corrupted
visibility information, or which prevent the table from being
successfully vacuumed due to corrupted visibility information.
For example:
</p><pre class="programlisting">
test=> vacuum t1;
ERROR: found xmin 507 from before relfrozenxid 515
CONTEXT: while scanning block 0 of relation "public.t1"
test=# select ctid from t1 where xmin = 507;
ctid
-------
(0,3)
(1 row)
test=# select heap_force_freeze('t1'::regclass, ARRAY['(0, 3)']::tid[]);
heap_force_freeze
-------------------
(1 row)
test=# select ctid from t1 where xmin = 2;
ctid
-------
(0,3)
(1 row)
</pre><p>
</p></dd></dl></div></div><div class="sect2" id="id-1.11.7.43.5"><div class="titlepage"><div><div><h3 class="title">F.34.2. Authors</h3></div></div></div><p>
Ashutosh Sharma <code class="email"><<a class="email" href="mailto:ashu.coek88@gmail.com">ashu.coek88@gmail.com</a>></code>
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgstattuple.html" title="F.33. pgstattuple">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgtrgm.html" title="F.35. pg_trgm">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.33. pgstattuple </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.35. pg_trgm</td></tr></table></div></body></html>
|