Postgresql 中文操作指南
Appendix F. Additional Supplied Modules and Extensions
Table of Contents
本附录和下一附录包含有关 PostgreSQL 发行版 contrib 目录中发现的可选组件的信息。其中包括移植工具、分析实用程序和不属于 PostgreSQL 核心系统的插件功能。它们主要是独立的,因为它们针对有限的受众或过于实验性,而无法成为主源码树的一部分。这并不妨碍它们的有用性。
This appendix and the next one contain information on the optional components found in the contrib directory of the PostgreSQL distribution. These include porting tools, analysis utilities, and plug-in features that are not part of the core PostgreSQL system. They are separate mainly because they address a limited audience or are too experimental to be part of the main source tree. This does not preclude their usefulness.
本附录涵盖 contrib 中发现的扩展和其他服务器插件模块库。 Appendix G 涵盖实用程序程序。
This appendix covers extensions and other server plug-in module libraries found in contrib. Appendix G covers utility programs.
如果从源代码包进行构建,除非构建了“world”目标,否则这些可选组件不会自动构建(参见 Step 2 )。可以通过运行以下命令来构建并安装所有这些组件:
When building from the source distribution, these optional components are not built automatically, unless you build the "world" target (see Step 2). You can build and install all of them by running:
make
make install
在已配置源代码树的 contrib 目录中;或者,若要仅构建并安装选定模块,请在该模块的子目录中执行相同的操作。许多模块都有回归测试,可以通过运行以下命令执行这些测试:
in the contrib directory of a configured source tree; or to build and install just one selected module, do the same in that module’s subdirectory. Many of the modules have regression tests, which can be executed by running:
make check
在安装之前或
before installation or
make installcheck
在运行 PostgreSQL 服务器后运行。
once you have a PostgreSQL server running.
如果您正在使用 PostgreSQL 的预封装版本,则这些组件通常可作为 postgresql-contrib 等单独子包提供。
If you are using a pre-packaged version of PostgreSQL, these components are typically made available as a separate subpackage, such as postgresql-contrib.
许多组件提供打包为 extensions 之中的新用户自定义函数、操作符或类型。为使用这些扩展之一,在安装代码后,您需要在数据库系统中注册新的 SQL 对象。这是通过执行 CREATE EXTENSION 命令完成的。在新的数据库中,您可以简单执行
Many components supply new user-defined functions, operators, or types, packaged as extensions. To make use of one of these extensions, after you have installed the code you need to register the new SQL objects in the database system. This is done by executing a CREATE EXTENSION command. In a fresh database, you can simply do
CREATE EXTENSION extension_name;
此命令仅在当前数据库中注册新 SQL 对象,因此您需要在希望使用扩展程序功能的每个数据库中运行它。或者,在数据库 template1 中运行它,以便默认情况下将扩展复制到随后创建的数据库中。
This command registers the new SQL objects in the current database only, so you need to run it in every database in which you want the extension’s facilities to be available. Alternatively, run it in database template1 so that the extension will be copied into subsequently-created databases by default.
对于所有扩展,除非扩展被视为“受信任”的,否则 CREATE EXTENSION 命令必须由数据库超级用户运行。受信任的扩展可以由任何在当前数据库上具有 CREATE 权限的用户运行。以下部分会将受信任的扩展识别出来。通常,受信任的扩展是对外部数据库功能无法提供访问权限的扩展。
For all extensions, the CREATE EXTENSION command must be run by a database superuser, unless the extension is considered “trusted”. Trusted extensions can be run by any user who has CREATE privilege on the current database. Extensions that are trusted are identified as such in the sections that follow. Generally, trusted extensions are ones that cannot provide access to outside-the-database functionality.
默认安装中受信任的扩展有:
The following extensions are trusted in a default installation:
许多扩展允许您在选定的模式中安装自己的对象。要做到这一点,需要将 SCHEMA _schema_name_ 添加到 CREATE EXTENSION 命令中。默认情况下,这些对象将放在当前创建目标模式中,后者又默认为 public 。
Many extensions allow you to install their objects in a schema of your choice. To do that, add SCHEMA _schema_name_ to the CREATE EXTENSION command. By default, the objects will be placed in your current creation target schema, which in turn defaults to public.
但是,请注意,一些组件从这个意义上讲不是“扩展”,但它们会通过其他方式加载到服务器中,例如通过 shared_preload_libraries 。有关详细信息,请参见每个组件的文档。
Note, however, that some of these components are not “extensions” in this sense, but are loaded into the server in some other way, for instance by way of shared_preload_libraries. See the documentation of each component for details.