-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharchive-module-callbacks.html
More file actions
129 lines (123 loc) · 13 KB
/
archive-module-callbacks.html
File metadata and controls
129 lines (123 loc) · 13 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?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>49.2. アーカイブモジュールコールバック</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="archive-module-init.html" title="49.1. 初期化関数" /><link rel="next" href="oauth-validators.html" title="第50章 OAuth検証器モジュール" /><meta name="viewport" content="width=device-width,initial-scale=1.0" /></head><body id="docContent" class="container-fluid col-10"><div class="other_version"><a href="https://www.postgresql.jp/document/">バージョンごとのドキュメント一覧</a></div><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="4" align="center"><a accesskey="h" href="index.html">PostgreSQL 18.3文書</a></th></tr><tr><td width="10%" align="left"></td><td width="10%" align="left"></td><td width="60%" align="center"><a href="archive-modules.html" title="第49章 アーカイブモジュール">第49章 アーカイブモジュール</a></td><td width="20%" align="right"><div class="actions"><a class="issue" title="github" href="https://github.com/pgsql-jp/jpug-doc/issues/new?template=bug_report.yml&what-happened=version 18.3 : archive-module-callbacks.html">誤訳等の報告
</a></div></td></tr><tr><td width="10%" align="left"><a accesskey="p" href="archive-module-init.html" title="49.1. 初期化関数">前へ</a> </td><td width="10%" align="left"><a accesskey="u" href="archive-modules.html" title="第49章 アーカイブモジュール">上へ</a></td><td width="60%" align="center">49.2. アーカイブモジュールコールバック</td><td width="20%" align="right"> <a accesskey="n" href="oauth-validators.html" title="第50章 OAuth検証器モジュール">次へ</a></td></tr></table><hr /></div><div class="sect1" id="ARCHIVE-MODULE-CALLBACKS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">49.2. アーカイブモジュールコールバック <a href="#ARCHIVE-MODULE-CALLBACKS" class="id_link">#</a></h2></div></div></div><span class="original">
<title>Archive Module Callbacks</title>
</span><p>
<span class="original">
The archive callbacks define the actual archiving behavior of the module.
The server will call them as required to process each individual WAL file.
</span>
アーカイブコールバックは、モジュールの実際のアーカイブ動作を定義します。
サーバは、個々のWALファイルを処理するために必要に応じてこれらを呼び出します。
</p><div class="sect2" id="ARCHIVE-MODULE-STARTUP"><div class="titlepage"><div><div><h3 class="title">49.2.1. スタートアップコールバック <a href="#ARCHIVE-MODULE-STARTUP" class="id_link">#</a></h3></div></div></div><span class="original">
<title>Startup Callback</title>
</span><p>
<span class="original">
The <function>startup_cb</function> callback is called shortly after the
module is loaded. This callback can be used to perform any additional
initialization required. If the archive module has any state, it can use
<structfield>state->private_data</structfield> to store it.
</span>
<code class="function">startup_cb</code>コールバックは、モジュールがロードされた直後に呼び出されます。
このコールバックは、必要な追加の初期化を実行するために使用できます。
アーカイブモジュールに状態がある場合は、<code class="structfield">state->private_data</code>を使用して保存できます。
</p><pre class="programlisting">
typedef void (*ArchiveStartupCB) (ArchiveModuleState *state);
</pre><p>
</p></div><div class="sect2" id="ARCHIVE-MODULE-CHECK"><div class="titlepage"><div><div><h3 class="title">49.2.2. チェックコールバック <a href="#ARCHIVE-MODULE-CHECK" class="id_link">#</a></h3></div></div></div><span class="original">
<title>Check Callback</title>
</span><p>
<span class="original">
The <function>check_configured_cb</function> callback is called to determine
whether the module is fully configured and ready to accept WAL files (e.g.,
its configuration parameters are set to valid values). If no
<function>check_configured_cb</function> is defined, the server always
assumes the module is configured.
</span>
<code class="function">check_configured_cb</code>コールバックは、モジュールが完全に設定されていて、WALファイルを受け入れる準備ができているかどうかを判断するために呼び出されます(たとえば、構成パラメータが適切な値に設定されているかどうかを判断します)。
<code class="function">check_configured_cb</code>が定義されていない場合、サーバは常にモジュールが設定されていると想定します。
</p><pre class="programlisting">
typedef bool (*ArchiveCheckConfiguredCB) (ArchiveModuleState *state);
</pre><p>
<span class="original">
If <literal>true</literal> is returned, the server will proceed with
archiving the file by calling the <function>archive_file_cb</function>
callback. If <literal>false</literal> is returned, archiving will not
proceed, and the archiver will emit the following message to the server log:
</span>
<code class="literal">true</code>が返された場合、サーバは<code class="function">archive_file_cb</code>コールバックを呼び出してファイルのアーカイブを続行します。
<code class="literal">false</code>が返された場合、アーカイブは続行されず、アーカイバはサーバログに次のメッセージを出力します:
</p><pre class="screen">
WARNING: archive_mode enabled, yet archiving is not configured
</pre><p>
<span class="original">
In the latter case, the server will periodically call this function, and
archiving will proceed only when it returns <literal>true</literal>.
</span>
後者の場合、サーバは定期的にこの関数を呼び出し、<code class="literal">true</code>が返された場合のみアーカイブが続行されます。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
When returning <literal>false</literal>, it may be useful to append some
additional information to the generic warning message. To do that, provide
a message to the <function>arch_module_check_errdetail</function> macro
before returning <literal>false</literal>. Like
<function>errdetail()</function>, this macro accepts a format string
followed by an optional list of arguments. The resulting string will be
emitted as the <literal>DETAIL</literal> line of the warning message.
</span>
<code class="literal">false</code>を返すときに、一般的な警告メッセージに追加情報を加えると便利な場合があります。
そのためには、<code class="literal">false</code>を返す前に<code class="function">arch_module_check_errdetail</code>マクロにメッセージを指定します。
<code class="function">errdetail()</code>と同様に、このマクロはフォーマット文字列とそれに続くオプショナルリストの引数を受け入れます。
結果の文字列は警告メッセージの<code class="literal">DETAIL</code>行として出力されます。
</p></div></div><div class="sect2" id="ARCHIVE-MODULE-ARCHIVE"><div class="titlepage"><div><div><h3 class="title">49.2.3. アーカイブコールバック <a href="#ARCHIVE-MODULE-ARCHIVE" class="id_link">#</a></h3></div></div></div><span class="original">
<title>Archive Callback</title>
</span><p>
<span class="original">
The <function>archive_file_cb</function> callback is called to archive a
single WAL file.
</span>
<code class="function">archive_file_cb</code>コールバックは、単一のWALファイルをアーカイブするために呼び出されます。
</p><pre class="programlisting">
typedef bool (*ArchiveFileCB) (ArchiveModuleState *state, const char *file, const char *path);
</pre><p>
<span class="original">
If <literal>true</literal> is returned, the server proceeds as if the file
was successfully archived, which may include recycling or removing the
original WAL file. If <literal>false</literal> is returned or an error is thrown, the server will
keep the original WAL file and retry archiving later.
<replaceable>file</replaceable> will contain just the file name of the WAL
file to archive, while <replaceable>path</replaceable> contains the full
path of the WAL file (including the file name).
</span>
<code class="literal">true</code>が返された場合、サーバはファイルが正常にアーカイブされたかのように処理を進めます。
これには元のWALファイルのリサイクルまたは削除が含まれる場合があります。
<code class="literal">false</code>が返されたかエラーが生じた場合には、サーバは元のWALファイルを保持し、後でアーカイブを再試行します。
<em class="replaceable"><code>file</code></em>にはアーカイブするWALファイルのファイル名だけが含まれ、<em class="replaceable"><code>path</code></em>にはWALファイルのフルパス(ファイル名を含む)が含まれます。
<em class="replaceable"><code>file</code></em>にはアーカイブするWALファイルのファイル名だけが含まれ、<em class="replaceable"><code>path</code></em>にはWALファイルのフルパス(ファイル名を含む)が含まれます。
</p><div class="note"><h3 class="title">注記</h3><p>
<span class="original">
The <function>archive_file_cb</function> callback is called in a
short-lived memory context that will be reset between invocations. If you
need longer-lived storage, create a memory context in the module's
<function>startup_cb</function> callback.
</span>
<code class="function">archive_file_cb</code>コールバックは、呼び出し毎にリセットされる存続期間の短いメモリコンテキストで、呼び出されます。
存続期間の長いストレージが必要な場合は、モジュールの<code class="function">startup_cb</code>コールバックにメモリコンテキストを作成します。
</p></div></div><div class="sect2" id="ARCHIVE-MODULE-SHUTDOWN"><div class="titlepage"><div><div><h3 class="title">49.2.4. シャットダウンコールバック <a href="#ARCHIVE-MODULE-SHUTDOWN" class="id_link">#</a></h3></div></div></div><span class="original">
<title>Shutdown Callback</title>
</span><p>
<span class="original">
The <function>shutdown_cb</function> callback is called when the archiver
process exits (e.g., after an error) or the value of
<xref linkend="guc-archive-library"/> changes. If no
<function>shutdown_cb</function> is defined, no special action is taken in
these situations. If the archive module has any state, this callback should
free it to avoid leaks.
</span>
<code class="function">shutdown_cb</code>コールバックは、アーカイバプロセスが終了するとき(たとえばエラー後など)、または<a class="xref" href="runtime-config-wal.html#GUC-ARCHIVE-LIBRARY">archive_library</a>の値が変更されたときに呼び出されます。
<code class="function">shutdown_cb</code>が定義されていない場合、これらの状況では特別な処理は行われません。
アーカイブモジュールが何らかの状態を持っている場合、このコールバックはメモリリークを防ぐためにそれを解放すべきです。
</p><pre class="programlisting">
typedef void (*ArchiveShutdownCB) (ArchiveModuleState *state);
</pre><p>
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="archive-module-init.html" title="49.1. 初期化関数">前へ</a> </td><td width="20%" align="center"><a accesskey="u" href="archive-modules.html" title="第49章 アーカイブモジュール">上へ</a></td><td width="40%" align="right"> <a accesskey="n" href="oauth-validators.html" title="第50章 OAuth検証器モジュール">次へ</a></td></tr><tr><td width="40%" align="left" valign="top">49.1. 初期化関数 </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.3文書">ホーム</a></td><td width="40%" align="right" valign="top"> 第50章 OAuth検証器モジュール</td></tr></table></div></body></html>