codekingpro/portable-devtools
115k
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!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 — perform low-level surgery on relation data</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 — obtain tuple-level statistics" /><link rel="next" href="pgtrgm.html" title="F.35. pg_trgm — support for similarity of text using trigram matching" /></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 — perform low-level surgery on relation data</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgstattuple.html" title="F.33. pgstattuple — obtain tuple-level statistics">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules and Extensions</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgtrgm.html" title="F.35. pg_trgm — support for similarity of text using trigram matching">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 — perform low-level surgery on relation data <a href="#PGSURGERY" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="pgsurgery.html#PGSURGERY-FUNCS">F.34.1. Functions</a></span></dt><dt><span class="sect2"><a href="pgsurgery.html#PGSURGERY-AUTHORS">F.34.2. Authors</a></span></dt></dl></div><a id="id-1.11.7.44.2" class="indexterm"></a><p>3 The <code class="filename">pg_surgery</code> module provides various functions to4 perform surgery on a damaged relation. These functions are unsafe by design5 and using them may corrupt (or further corrupt) your database. For example,6 these functions can easily be used to make a table inconsistent with its7 own indexes, to cause <code class="literal">UNIQUE</code> or8 <code class="literal">FOREIGN KEY</code> constraint violations, or even to make9 tuples visible which, when read, will cause a database server crash.10 They should be used with great caution and only as a last resort.11 </p><div class="sect2" id="PGSURGERY-FUNCS"><div class="titlepage"><div><div><h3 class="title">F.34.1. Functions <a href="#PGSURGERY-FUNCS" class="id_link">#</a></h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">12 <code class="function">heap_force_kill(regclass, tid[]) returns void</code>13 </span></dt><dd><p>14 <code class="function">heap_force_kill</code> marks <span class="quote">“<span class="quote">used</span>”</span> line15 pointers as <span class="quote">“<span class="quote">dead</span>”</span> without examining the tuples. The16 intended use of this function is to forcibly remove tuples that are not17 otherwise accessible. For example:18</p><pre class="programlisting">19test=> select * from t1 where ctid = '(0, 1)';20ERROR: could not access status of transaction 400751327521DETAIL: Could not open file "pg_xact/0EED": No such file or directory.22 23test=# select heap_force_kill('t1'::regclass, ARRAY['(0, 1)']::tid[]);24 heap_force_kill25-----------------26 27(1 row)28 29test=# select * from t1 where ctid = '(0, 1)';30(0 rows)31 32</pre><p>33 </p></dd><dt><span class="term">34 <code class="function">heap_force_freeze(regclass, tid[]) returns void</code>35 </span></dt><dd><p>36 <code class="function">heap_force_freeze</code> marks tuples as frozen without37 examining the tuple data. The intended use of this function is to38 make accessible tuples which are inaccessible due to corrupted39 visibility information, or which prevent the table from being40 successfully vacuumed due to corrupted visibility information.41 For example:42</p><pre class="programlisting">43test=> vacuum t1;44ERROR: found xmin 507 from before relfrozenxid 51545CONTEXT: while scanning block 0 of relation "public.t1"46 47test=# select ctid from t1 where xmin = 507;48 ctid49-------50 (0,3)51(1 row)52 53test=# select heap_force_freeze('t1'::regclass, ARRAY['(0, 3)']::tid[]);54 heap_force_freeze55-------------------56 57(1 row)58 59test=# select ctid from t1 where xmin = 2;60 ctid61-------62 (0,3)63(1 row)64 65</pre><p>66 </p></dd></dl></div></div><div class="sect2" id="PGSURGERY-AUTHORS"><div class="titlepage"><div><div><h3 class="title">F.34.2. Authors <a href="#PGSURGERY-AUTHORS" class="id_link">#</a></h3></div></div></div><p>67 Ashutosh Sharma <code class="email"><<a class="email" href="mailto:ashu.coek88@gmail.com">ashu.coek88@gmail.com</a>></code>68 </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 — obtain tuple-level statistics">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules and Extensions">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgtrgm.html" title="F.35. pg_trgm — support for similarity of text using trigram matching">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.33. pgstattuple — obtain tuple-level statistics </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.35. pg_trgm —69 support for similarity of text using trigram matching</td></tr></table></div></body></html>