バージョンごとのドキュメント一覧

pg_amcheck

pg_amcheck <refpurpose>checks for corruption in one or more <productname>PostgreSQL</productname> databases</refpurpose> — 一つ以上のPostgreSQLデータベースに破損がないかどうかを検査する

概要

pg_amcheck [option...] [dbname]

説明

<title>Description</title>

<application>pg_amcheck</application> supports running <xref linkend="amcheck"/>'s corruption checking functions against one or more databases, with options to select which schemas, tables and indexes to check, which kinds of checking to perform, and whether to perform the checks in parallel, and if so, the number of parallel connections to establish and use. pg_amcheckは、一つ以上のデータベースに対して、どのスキーマ、テーブル、インデックスを検査すべきか、どの種類の検査を実行するか、検査を並列に行うかどうか、並列に行うなら並列接続をいくつ確立するかを指定してamcheckの破損検査関数を実行します。

Only ordinary and toast table relations, materialized views, sequences, and btree indexes are currently supported. Other relation types are silently skipped. 通常のテーブルリレーションとTOASTテーブルリレーション、マテリアライズドビュー、シーケンスとBツリーインデックスのみが今のところサポートされています。 他のリレーションタイプは暗黙のうちにスキップされます。

If <literal>dbname</literal> is specified, it should be the name of a single database to check, and no other database selection options should be present. Otherwise, if any database selection options are present, all matching databases will be checked. If no such options are present, the default database will be checked. Database selection options include <option>&#45;-all</option>, <option>&#45;-database</option> and <option>&#45;-exclude-database</option>. They also include <option>&#45;-relation</option>, <option>&#45;-exclude-relation</option>, <option>&#45;-table</option>, <option>&#45;-exclude-table</option>, <option>&#45;-index</option>, and <option>&#45;-exclude-index</option>, but only when such options are used with a three-part pattern (e.g. <option>mydb*.myschema*.myrel*</option>). Finally, they include <option>&#45;-schema</option> and <option>&#45;-exclude-schema</option> when such options are used with a two-part pattern (e.g. <option>mydb*.myschema*</option>). dbnameを指定するときは、検査すべき単一のデータベース名であるべきで、他のデータベースを選択するオプションは指定すべきではありません。 そうではなくてデータベースの選択オプションが指定されていると、一致するデータベースがすべて検査されます。 オプションを指定しない場合は、デフォルトのデータベースが検査されます。 データベース選択オプションには次のものが含まれます。 --all--database--exclude-database。 また、次のオプションも含まれます。 --relation--exclude-relation--table--exclude-table--index--exclude-index。 しかし、これらのオプションは、3つの部分からなるパターン(つまりmydb*.myschema*.myrel*)を指定したときにのみ使用できます。 最後に、2つの部分からなるパターン(つまりmydb*.myschema*)を指定した時に使用できる--schema--exclude-schemaがあります。

<replaceable>dbname</replaceable> can also be a <link linkend="libpq-connstring">connection string</link>. dbnameは、接続文字列でも構いません。

オプション

<title>Options</title>

The following command-line options control what is checked: 以下のコマンドラインオプションは、何を検査するかを制御します。

-a
--all

Check all databases, except for any excluded via <option>&#45;-exclude-database</option>. --exclude-databaseで除外したものを除くすべてのデータベースを検査します。

-d pattern
--database=pattern

Check databases matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>, except for any excluded by <option>&#45;-exclude-database</option>. This option can be specified more than once. --exclude-databaseで除外したものを除き、指定したパターンにマッチするデータベースを検査します。 このオプションは2回以上指定できます。

-D pattern
--exclude-database=pattern

Exclude databases matching the given <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>. This option can be specified more than once. 与えられたパターンにマッチするデータベースを除外します。 このオプションは2回以上指定できます。

-i pattern
--index=pattern

Check indexes matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>, unless they are otherwise excluded. This option can be specified more than once. 除外されていない限り、指定したパターンにマッチするインデックスを検査します。 このオプションは2回以上指定できます。

This is similar to the <option>&#45;-relation</option> option, except that it applies only to indexes, not to other relation types. これは、インデックスにのみ適用され、他のリレーションタイプには適用されないことを除いて--relationオプションに類似しています。

-I pattern
--exclude-index=pattern

Exclude indexes matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>. This option can be specified more than once. 与えられたパターンにマッチするインデックスを除外します。 このオプションは2回以上指定できます。

This is similar to the <option>&#45;-exclude-relation</option> option, except that it applies only to indexes, not other relation types. これは、インデックスにのみ適用され、他のリレーションタイプには適用されないことを除いて--exclude-relationオプションに類似しています。

-r pattern
--relation=pattern

Check relations matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>, unless they are otherwise excluded. This option can be specified more than once. 除外されていない限り、パターンにマッチするリレーションを検査します。 このオプションは2回以上指定できます。

Patterns may be unqualified, e.g. <literal>myrel*</literal>, or they may be schema-qualified, e.g. <literal>myschema*.myrel*</literal> or database-qualified and schema-qualified, e.g. <literal>mydb*.myschema*.myrel*</literal>. A database-qualified pattern will add matching databases to the list of databases to be checked. パターンはたとえばmyrel*のように修飾されていなくても、myschema*.myrel*のようにスキーマ修飾されていても、mydb*.myschema*.myrel*のようにデータベース及びスキーマ修飾されていても構いません。 データベース修飾パターンは、マッチするデータベースを検査対象のデータベースのリストに追加します。

-R pattern
--exclude-relation=pattern

Exclude relations matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>. This option can be specified more than once. 指定されたパターンにマッチするリレーションを除外します。 このオプションは2回以上指定できます。

As with <option>&#45;-relation</option>, the <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link> may be unqualified, schema-qualified, or database- and schema-qualified. --relationにおけるのと同様、パターンは修飾なし、スキーマ修飾、スキーマとデータベース修飾のどれでも構いません。

-s pattern
--schema=pattern

Check tables and indexes in schemas matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>, unless they are otherwise excluded. This option can be specified more than once. 除外されていない限り、指定したパターンにマッチするスキーマ内のテーブルとインデックスを検査します。 このオプションは2回以上指定できます。

To select only tables in schemas matching a particular pattern, consider using something like <literal>&#45;-table=SCHEMAPAT.* &#45;-no-dependent-indexes</literal>. To select only indexes, consider using something like <literal>&#45;-index=SCHEMAPAT.*</literal>. 特定のパターンにマッチするスキーマ内のテーブルだけを選択するには、--table=SCHEMAPAT.* --no-dependent-indexesのような使い方を考慮してください。 インデックスのみを選択するには、--index=SCHEMAPAT.*のような使い方を考慮してください。

A schema pattern may be database-qualified. For example, you may write <literal>&#45;-schema=mydb*.myschema*</literal> to select schemas matching <literal>myschema*</literal> in databases matching <literal>mydb*</literal>. スキーマパターンはデータベース修飾でも構いません。 たとえば、mydb*にマッチするデータベース内のmyschema*にマッチするスキーマを選択するには、--schema=mydb*.myschema*のように書くことができます。

-S pattern
--exclude-schema=pattern

Exclude tables and indexes in schemas matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>. This option can be specified more than once. 指定したパターンにマッチするスキーマ内のテーブルとインデックスを除外します。 このオプションは2回以上指定できます。

As with <option>&#45;-schema</option>, the pattern may be database-qualified. --schemaと同様、パターンはデータベース修飾でも構いません。

-t pattern
--table=pattern

Check tables matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>, unless they are otherwise excluded. This option can be specified more than once. 除外されていない限り、指定したパターンにマッチするスキーマ内のテーブルを検査します。 このオプションは2回以上指定できます。

This is similar to the <option>&#45;-relation</option> option, except that it applies only to tables, materialized views, and sequences, not to indexes. これは、テーブル、マテリアライズドビュー、シーケンスにのみ適用され、インデックスには適用されないことを除いて--relationオプションに類似しています。

-T pattern
--exclude-table=pattern

Exclude tables matching the specified <link linkend="app-psql-patterns"><replaceable class="parameter">pattern</replaceable></link>. This option can be specified more than once. 指定したパターンにマッチするテーブルを除外します。 このオプションは2回以上指定できます。

This is similar to the <option>&#45;-exclude-relation</option> option, except that it applies only to tables, materialized views, and sequences, not to indexes. これは、テーブル、マテリアライズドビュー、シーケンスにのみ適用され、インデックスには適用されないことを除いて--exclude-relationオプションに類似しています。

--no-dependent-indexes

By default, if a table is checked, any btree indexes of that table will also be checked, even if they are not explicitly selected by an option such as <literal>&#45;-index</literal> or <literal>&#45;-relation</literal>. This option suppresses that behavior. デフォルトでは、--index--relationオプションで明示的に選択されていなくても、テーブルが検査される際にそのテーブルのBツリーインデックスも検査されます。 このオプションはこの振る舞いを抑止します。

--no-dependent-toast

By default, if a table is checked, its toast table, if any, will also be checked, even if it is not explicitly selected by an option such as <literal>&#45;-table</literal> or <literal>&#45;-relation</literal>. This option suppresses that behavior. デフォルトでは、--table--relationオプションで明示的に選択されていなくても、テーブルが検査される際にそのテーブルのTOASTテーブルも検査されます。 このオプションはこの振る舞いを抑止します。

--no-strict-names

By default, if an argument to <literal>&#45;-database</literal>, <literal>&#45;-table</literal>, <literal>&#45;-index</literal>, or <literal>&#45;-relation</literal> matches no objects, it is a fatal error. This option downgrades that error to a warning. デフォルトでは、--database--table--index--relationへの引数がどのオブジェクトにもマッチしなければ、フェイタルエラーが起こります。 このオプションはそのエラーをワーニングへと格下げします。

The following command-line options control checking of tables: 次のコマンドラインオプションはテーブルの検査を制御します。

--exclude-toast-pointers

By default, whenever a toast pointer is encountered in a table, a lookup is performed to ensure that it references apparently-valid entries in the toast table. These checks can be quite slow, and this option can be used to skip them. デフォルトでは、テーブル中のTOASTポインタに遭遇すると必ずTOASTテーブル中の明らかに有効なエントリを参照していることを確認するために検索が行われます。 このチェックは非常に遅くなることがあり、このオプションはこれを省略するために使うことができます。

--on-error-stop

After reporting all corruptions on the first page of a table where corruption is found, stop processing that table relation and move on to the next table or index. 破損が見つかった最初のテーブルのページに関してすべての破損の報告を行った後そのテーブルリレーションの処理を中断し、次のテーブルあるいはインデックスに進みます。

Note that index checking always stops after the first corrupt page. This option only has meaning relative to table relations. インデックスの検査は、最初の破損したページの後で常に停止することに留意してください。 このオプションは、テーブルリレーションに関してのみ意味があります。

--skip=option

If <literal>all-frozen</literal> is given, table corruption checks will skip over pages in all tables that are marked as all frozen. all-frozenが与えられると、テーブル破損検査は、すべて凍結されていると印が付いたすべてのテーブルの中のページをスキップします。

If <literal>all-visible</literal> is given, table corruption checks will skip over pages in all tables that are marked as all visible. all-visibleが与えられると、テーブル破損検査は、すべて可視と印が付いたすべてのテーブルの中のページをスキップします。

By default, no pages are skipped. This can be specified as <literal>none</literal>, but since this is the default, it need not be mentioned. デフォルトではページをスキップすることはありません。 noneと指定することもできますが、これがデフォルトなのでそのように指定する必要はありません。

--startblock=block

Start checking at the specified block number. An error will occur if the table relation being checked has fewer than this number of blocks. This option does not apply to indexes, and is probably only useful when checking a single table relation. See <literal>&#45;-endblock</literal> for further caveats. 指定したブロック番号から検査を開始します。 検査しているテーブルリレーションのブロック数がこのブロック数よりも小さければエラーが生じます。 このオプションはインデックスには適用されず、おそらく単一のテーブルリレーションを検査するときにのみ意味があるでしょう。 それ以外の警告については--endblockを参照してください。

--endblock=block

End checking at the specified block number. An error will occur if the table relation being checked has fewer than this number of blocks. This option does not apply to indexes, and is probably only useful when checking a single table relation. If both a regular table and a toast table are checked, this option will apply to both, but higher-numbered toast blocks may still be accessed while validating toast pointers, unless that is suppressed using <option>&#45;-exclude-toast-pointers</option>. 指定したブロック番号で検査を終了します。 検査しているテーブルリレーションのブロック数がこのブロック数よりも小さければエラーが生じます。 このオプションはインデックスには適用されず、おそらく単一のテーブルリレーションを検査するときにのみ意味があるでしょう。 通常のテーブルとTOASTテーブルの両方が検査される際にはこのオプションはその両方に適用されますが、--exclude-toast-pointersを使って抑止していない限りTOASTポインタを検証中により大きな番号のTOASTブロックがアクセスされるかも知れません。

The following command-line options control checking of B-tree indexes: 以下のコマンドラインオプションはBツリーインデックスの検査を制御します。

--heapallindexed

For each index checked, verify the presence of all heap tuples as index tuples in the index using <xref linkend="amcheck"/>'s <option>heapallindexed</option> option. 検査しているインデックスごとに、amcheckheapallindexedオプションを使ってすべてのヒープタプルがインデックス中のインデックスタプルとして存在していることを検証します。

--parent-check

For each btree index checked, use <xref linkend="amcheck"/>'s <function>bt_index_parent_check</function> function, which performs additional checks of parent/child relationships during index checking. 検査しているBツリーインデックスごとに、インデックス検査中に親/子関係の追加の検査を行うamcheckbt_index_parent_check関数を使います。

The default is to use <application>amcheck</application>'s <function>bt_index_check</function> function, but note that use of the <option>&#45;-rootdescend</option> option implicitly selects <function>bt_index_parent_check</function>. デフォルトではamcheckbt_index_check関数を使いますが、--rootdescendオプションを使うと暗黙的にbt_index_parent_checkを選択することに注意してください。

--rootdescend

For each index checked, re-find tuples on the leaf level by performing a new search from the root page for each tuple using <xref linkend="amcheck"/>'s <option>rootdescend</option> option. 検査しているインデックスごとに、amcheckrootdescendオプションを使い、各タプルに関してルートページから新たに検索を実施してリーフレベルのタプルを再発見します。

Use of this option implicitly also selects the <option>&#45;-parent-check</option> option. このオプションを使うと--parent-checkオプションも暗黙的に選択します。

This form of verification was originally written to help in the development of btree index features. It may be of limited use or even of no use in helping detect the kinds of corruption that occur in practice. It may also cause corruption checking to take considerably longer and consume considerably more resources on the server. この形式の検証は、元々はBツリーインデックスの機能の開発を支援するために作られました。 実際に発生する類の破損を検出するための支援としては限定的、あるいはまったく無用かも知れません。 また、これは破損検査に要する時間がかなり長くなったり、サーバでかなり多くのリソースを消費する原因になるかも知れません。

警告

The extra checks performed against B-tree indexes when the <option>&#45;-parent-check</option> option or the <option>&#45;-rootdescend</option> option is specified require relatively strong relation-level locks. These checks are the only checks that will block concurrent data modification from <command>INSERT</command>, <command>UPDATE</command>, and <command>DELETE</command> commands. --parent-checkオプション、あるいは--rootdescendオプションが指定された時にBツリーインデックスに対して行われる追加の検査では、比較的強いリレーションレベルのロックが必要です。 この検査だけが、INSERTUPDATEDELETEコマンドによる並行するデータ変更をブロックする検査です。

The following command-line options control the connection to the server: 以下のコマンドラインオプションは、サーバへの接続を制御します。

-h hostname
--host=hostname

Specifies the host name of the machine on which the server is running. If the value begins with a slash, it is used as the directory for the Unix domain socket. サーバが実行中のマシンのホスト名を指定します。 値がスラッシュで始まると、Unixドメインソケットのディレクトリとして使用されます。

-p port
--port=port

Specifies the TCP port or local Unix domain socket file extension on which the server is listening for connections. TCPポートあるいはサーバが接続をリッスンしているマシン上のUnixドメインソケットファイルの拡張子を指定します。

-U
--username=username

User name to connect as. 接続するユーザ名です。

-w
--no-password

Never issue a password prompt. If the server requires password authentication and a password is not available by other means such as a <filename>.pgpass</filename> file, the connection attempt will fail. This option can be useful in batch jobs and scripts where no user is present to enter a password. 決してパスワードプロンプトを表示しません。 サーバがパスワード認証を要求し、パスワードが.pgpassファイルなどの他の方法で提供されない場合は接続の試みは失敗します。 このオプションはパスワードを入力するユーザが存在しないバッチジョブやスクリプトで有用かも知れません。

-W
--password

Force <application>pg_amcheck</application> to prompt for a password before connecting to a database. pg_amcheckがデータベースに接続する前にパスワードのプロンプトを表示することを強制します。

This option is never essential, since <application>pg_amcheck</application> will automatically prompt for a password if the server demands password authentication. However, <application>pg_amcheck</application> will waste a connection attempt finding out that the server wants a password. In some cases it is worth typing <option>-W</option> to avoid the extra connection attempt. サーバがパスワード認証を必要とするときにはpg_amcheckはパスワードを自動的に要求するので、このオプションは絶対に必要というものではありません。 しかし、pg_amcheckはサーバがパスワードを必要としているかどうかを確認するために無駄な接続の試みをします。 ある種の状況では余分な接続の試みを避けるために-Wをタイプする価値があります。

--maintenance-db=dbname

Specifies a database or <link linkend="libpq-connstring">connection string</link> to be used to discover the list of databases to be checked. If neither <option>&#45;-all</option> nor any option including a database pattern is used, no such connection is required and this option does nothing. Otherwise, any connection string parameters other than the database name which are included in the value for this option will also be used when connecting to the databases being checked. If this option is omitted, the default is <literal>postgres</literal> or, if that fails, <literal>template1</literal>. データベースあるいは検査対象データベースのリストを発見するために使われる接続文字列を指定します。 --allあるいはデータベースパターンを含むオプションが使われていなければ、そうした接続は必要ではなく、このオプションは何もしません。 そうでなければ、このオプションの値に含まれるデータベース名が、検査対象のデータベースに接続する際にも使われます。 このオプションが省略されるとデフォルトはpostgres、あるいはそれが失敗すればtemplate1となります。

Other options are also available: 他のオプションも利用可能です。

-e
--echo

Echo to stdout all SQL sent to the server. サーバに送られたすべてのSQLを標準出力にそのまま表示します。

-j num
--jobs=num

Use <replaceable>num</replaceable> concurrent connections to the server, or one per object to be checked, whichever is less. サーバへのnum並列接続か、検査対象オブジェクト1つにつき1本の接続のどちらか少ない方を使います。

The default is to use a single connection. デフォルトでは単一の接続を使います。

-P
--progress

Show progress information. Progress information includes the number of relations for which checking has been completed, and the total size of those relations. It also includes the total number of relations that will eventually be checked, and the estimated size of those relations. 進捗状況の情報を表示します。 進捗状況情報には、検査が完了したリレーションの数と(検査が完了した)リレーションの合計サイズが含まれます。 最終的に検査されるリレーションの全数と(これら(最終的に検査される)の)リレーションのサイズの見積もりも含まれます。

-v
--verbose

Print more messages. In particular, this will print a message for each relation being checked, and will increase the level of detail shown for server errors. より多くのメッセージを表示します。 とりわけ、これは検査している個々のリレーションを表示し、サーバエラーに関しては詳細度のレベルを上げます。

-V
--version

Print the <application>pg_amcheck</application> version and exit. pg_amcheckのバージョンを表示して終了します。

--install-missing
--install-missing=schema

Install any missing extensions that are required to check the database(s). If not yet installed, each extension's objects will be installed into the given <replaceable class="parameter">schema</replaceable>, or if not specified into schema <literal>pg_catalog</literal>. データベースを検査するのに必要な拡張で漏れているものをインストールします。 もしまだインストールされていなければ、各拡張のオブジェクトは与えられたschema、あるいは指定されていなければpg_catalogスキーマにインストールされます。

At present, the only required extension is <xref linkend="amcheck"/>. 今の所唯一必要な拡張はamcheckです。

-?
--help

Show help about <application>pg_amcheck</application> command line arguments, and exit. pg_amcheckコマンド行引数に関するヘルプを表示して終了します。

注釈

<title>Notes</title>

<application>pg_amcheck</application> is designed to work with <productname>PostgreSQL</productname> 14.0 and later. pg_amcheckPostgreSQL 14.0以降で動作するように設計されています。

関連項目

<title>See Also</title> amcheck