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

32.4. 拡張性 #

<title>Extensibility</title>

32.4.1. 拡張のためのインライン展開サポート #

<title>Inlining Support for Extensions</title>

<productname>PostgreSQL</productname>'s <acronym>JIT</acronym> implementation can inline the bodies of functions of types <literal>C</literal> and <literal>internal</literal>, as well as operators based on such functions. To do so for functions in extensions, the definitions of those functions need to be made available. When using <link linkend="extend-pgxs">PGXS</link> to build an extension against a server that has been compiled with LLVM JIT support, the relevant files will be built and installed automatically. PostgreSQLJIT実装は、Cinternal型の関数の本体をインライン展開できます。そうした関数に基づく演算子も同様です。 拡張の関数に同じことを行うには、関数の定義が入手可能である必要があります。 LLVM JITサポートがコンパイルされているサーバに対してPGXSを使って拡張をビルドする際に、関連するファイルは自動的にビルドされ、インストールされます。

The relevant files have to be installed into <filename>$pkglibdir/bitcode/$extension/</filename> and a summary of them into <filename>$pkglibdir/bitcode/$extension.index.bc</filename>, where <literal>$pkglibdir</literal> is the directory returned by <literal>pg_config &#45;-pkglibdir</literal> and <literal>$extension</literal> is the base name of the extension's shared library. 関連するファイルは$pkglibdir/bitcode/$extension/に、そのサマリは$pkglibdir/bitcode/$extension.index.bcにインストールされなければなりません。 ここで、$pkglibdirは、pg_config --pkglibdirが返すディレクトリで、$extensionは拡張の共有ライブラリのベース名です。

注記

For functions built into <productname>PostgreSQL</productname> itself, the bitcode is installed into <literal>$pkglibdir/bitcode/postgres</literal>. PostgreSQL自身に組み込まれた関数については、ビットコードが$pkglibdir/bitcode/postgresにインストールされます。

32.4.2. プラグ可能JITプロバイダ #

<title>Pluggable <acronym>JIT</acronym> Providers</title>

<productname>PostgreSQL</productname> provides a <acronym>JIT</acronym> implementation based on <productname>LLVM</productname>. The interface to the <acronym>JIT</acronym> provider is pluggable and the provider can be changed without recompiling (although currently, the build process only provides inlining support data for <productname>LLVM</productname>). The active provider is chosen via the setting <xref linkend="guc-jit-provider"/>. PostgreSQLLLVMに基づいたJIT実装を提供します。 JITプロバイダのインタフェースはプラグ可能で、プロバイダは再コンパイルすることなく変更できます。(ただし今のところ、ビルドプロセスはLLVM用のインライン展開サポートデータのみを提供しています。) 有効なプロバイダはjit_providerの設定で選択できます。

32.4.2.1. JITプロバイダインタフェース #

<title><acronym>JIT</acronym> Provider Interface</title>

A <acronym>JIT</acronym> provider is loaded by dynamically loading the named shared library. The normal library search path is used to locate the library. To provide the required <acronym>JIT</acronym> provider callbacks and to indicate that the library is actually a <acronym>JIT</acronym> provider, it needs to provide a C function named <function>_PG_jit_provider_init</function>. This function is passed a struct that needs to be filled with the callback function pointers for individual actions: 名前付きの共有ライブラリをロードすることにより、JITは動的にロードされます。 ライブラリを特定するために通常のライブラリサーチパスが使用されます。 必要なJITプロバイダコールバックを提供し、かつそのライブラリが実際にJITプロバイダであることを示すために、_PG_jit_provider_initという名前のC関数を提供する必要があります。 この関数には構造体が渡され、その構造体には各々の動作用のコールバック関数へのポインタが設定される必要があります。

struct JitProviderCallbacks
{
    JitProviderResetAfterErrorCB reset_after_error;
    JitProviderReleaseContextCB release_context;
    JitProviderCompileExprCB compile_expr;
};

extern void _PG_jit_provider_init(JitProviderCallbacks *cb);