Postgresql 中文操作指南
51.1. Initialization Functions #
存档库通过以 archive_library 的名称作为库基本名称动态加载共享库来加载。通常的库搜索路径用于定位库。为了提供所需的存档模块回调并指示该库实际上是一个存档模块,它需要提供一个名为 _PG_archive_module_init 的函数。该函数的结果必须是一个类型为 ArchiveModuleCallbacks 的结构的指针,其中包含核心代码利用存档模块所需知道的所有内容。返回值需要是服务器生命期的,这通常是通过在全局作用域中将其定义为 static const 变量来实现的。
An archive library is loaded by dynamically loading a shared library with the archive_library's name as the library base name. The normal library search path is used to locate the library. To provide the required archive module callbacks and to indicate that the library is actually an archive module, it needs to provide a function named _PG_archive_module_init. The result of the function must be a pointer to a struct of type ArchiveModuleCallbacks, which contains everything that the core code needs to know to make use of the archive module. The return value needs to be of server lifetime, which is typically achieved by defining it as a static const variable in global scope.
typedef struct ArchiveModuleCallbacks
{
ArchiveStartupCB startup_cb;
ArchiveCheckConfiguredCB check_configured_cb;
ArchiveFileCB archive_file_cb;
ArchiveShutdownCB shutdown_cb;
} ArchiveModuleCallbacks;
typedef const ArchiveModuleCallbacks *(*ArchiveModuleInit) (void);
仅需要 archive_file_cb 回调。其他回调是可选的。
Only the archive_file_cb callback is required. The others are optional.