]> begriffs open source - ai-pg/blob - full-docs/txt/jit-extensibility.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / jit-extensibility.txt
1
2 30.4. Extensibility #
3
4    30.4.1. Inlining Support for Extensions
5    30.4.2. Pluggable JIT Providers
6
7 30.4.1. Inlining Support for Extensions #
8
9    PostgreSQL's JIT implementation can inline the bodies of functions of
10    types C and internal, as well as operators based on such functions. To
11    do so for functions in extensions, the definitions of those functions
12    need to be made available. When using PGXS to build an extension
13    against a server that has been compiled with LLVM JIT support, the
14    relevant files will be built and installed automatically.
15
16    The relevant files have to be installed into
17    $pkglibdir/bitcode/$extension/ and a summary of them into
18    $pkglibdir/bitcode/$extension.index.bc, where $pkglibdir is the
19    directory returned by pg_config --pkglibdir and $extension is the base
20    name of the extension's shared library.
21
22 Note
23
24    For functions built into PostgreSQL itself, the bitcode is installed
25    into $pkglibdir/bitcode/postgres.
26
27 30.4.2. Pluggable JIT Providers #
28
29    PostgreSQL provides a JIT implementation based on LLVM. The interface
30    to the JIT provider is pluggable and the provider can be changed
31    without recompiling (although currently, the build process only
32    provides inlining support data for LLVM). The active provider is chosen
33    via the setting jit_provider.
34
35 30.4.2.1. JIT Provider Interface #
36
37    A JIT provider is loaded by dynamically loading the named shared
38    library. The normal library search path is used to locate the library.
39    To provide the required JIT provider callbacks and to indicate that the
40    library is actually a JIT provider, it needs to provide a C function
41    named _PG_jit_provider_init. This function is passed a struct that
42    needs to be filled with the callback function pointers for individual
43    actions:
44 struct JitProviderCallbacks
45 {
46     JitProviderResetAfterErrorCB reset_after_error;
47     JitProviderReleaseContextCB release_context;
48     JitProviderCompileExprCB compile_expr;
49 };
50
51 extern void _PG_jit_provider_init(JitProviderCallbacks *cb);