]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/jit-extensibility.html
PG 18 docs from https://ftp.postgresql.org/pub/source/v18.0/postgresql-18.0-docs...
[ai-pg] / full-docs / src / sgml / html / jit-extensibility.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!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>30.4. Extensibility</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="jit-configuration.html" title="30.3. Configuration" /><link rel="next" href="regress.html" title="Chapter 31. Regression Tests" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">30.4. Extensibility</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="jit-configuration.html" title="30.3. Configuration">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="jit.html" title="Chapter 30. Just-in-Time Compilation (JIT)">Up</a></td><th width="60%" align="center">Chapter 30. Just-in-Time Compilation (<acronym class="acronym">JIT</acronym>)</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="regress.html" title="Chapter 31. Regression Tests">Next</a></td></tr></table><hr /></div><div class="sect1" id="JIT-EXTENSIBILITY"><div class="titlepage"><div><div><h2 class="title" style="clear: both">30.4. Extensibility <a href="#JIT-EXTENSIBILITY" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="jit-extensibility.html#JIT-EXTENSIBILITY-BITCODE">30.4.1. Inlining Support for Extensions</a></span></dt><dt><span class="sect2"><a href="jit-extensibility.html#JIT-PLUGGABLE">30.4.2. Pluggable <acronym class="acronym">JIT</acronym> Providers</a></span></dt></dl></div><div class="sect2" id="JIT-EXTENSIBILITY-BITCODE"><div class="titlepage"><div><div><h3 class="title">30.4.1. Inlining Support for Extensions <a href="#JIT-EXTENSIBILITY-BITCODE" class="id_link">#</a></h3></div></div></div><p>
3     <span class="productname">PostgreSQL</span>'s <acronym class="acronym">JIT</acronym>
4     implementation can inline the bodies of functions
5     of types <code class="literal">C</code> and <code class="literal">internal</code>, as well as
6     operators based on such functions.  To do so for functions in extensions,
7     the definitions of those functions need to be made available.
8     When using <a class="link" href="extend-pgxs.html" title="36.18. Extension Building Infrastructure">PGXS</a> to build an extension
9     against a server that has been compiled with LLVM JIT support, the
10     relevant files will be built and installed automatically.
11    </p><p>
12     The relevant files have to be installed into
13     <code class="filename">$pkglibdir/bitcode/$extension/</code> and a summary of them
14     into <code class="filename">$pkglibdir/bitcode/$extension.index.bc</code>, where
15     <code class="literal">$pkglibdir</code> is the directory returned by
16     <code class="literal">pg_config --pkglibdir</code> and <code class="literal">$extension</code>
17     is the base name of the extension's shared library.
18
19     </p><div class="note"><h3 class="title">Note</h3><p>
20       For functions built into <span class="productname">PostgreSQL</span> itself,
21       the bitcode is installed into
22       <code class="literal">$pkglibdir/bitcode/postgres</code>.
23      </p></div><p>
24    </p></div><div class="sect2" id="JIT-PLUGGABLE"><div class="titlepage"><div><div><h3 class="title">30.4.2. Pluggable <acronym class="acronym">JIT</acronym> Providers <a href="#JIT-PLUGGABLE" class="id_link">#</a></h3></div></div></div><p>
25     <span class="productname">PostgreSQL</span> provides a <acronym class="acronym">JIT</acronym>
26     implementation based on <span class="productname">LLVM</span>.  The interface to
27     the <acronym class="acronym">JIT</acronym> provider is pluggable and the provider can be
28     changed without recompiling (although currently, the build process only
29     provides inlining support data for <span class="productname">LLVM</span>).
30     The active provider is chosen via the setting
31     <a class="xref" href="runtime-config-client.html#GUC-JIT-PROVIDER">jit_provider</a>.
32    </p><div class="sect3" id="JIT-PLUGGABLE-PROVIDER-INTERFACE"><div class="titlepage"><div><div><h4 class="title">30.4.2.1. <acronym class="acronym">JIT</acronym> Provider Interface <a href="#JIT-PLUGGABLE-PROVIDER-INTERFACE" class="id_link">#</a></h4></div></div></div><p>
33      A <acronym class="acronym">JIT</acronym> provider is loaded by dynamically loading the
34      named shared library. The normal library search path is used to locate
35      the library. To provide the required <acronym class="acronym">JIT</acronym> provider
36      callbacks and to indicate that the library is actually a
37      <acronym class="acronym">JIT</acronym> provider, it needs to provide a C function named
38      <code class="function">_PG_jit_provider_init</code>. This function is passed a
39      struct that needs to be filled with the callback function pointers for
40      individual actions:
41 </p><pre class="programlisting">
42 struct JitProviderCallbacks
43 {
44     JitProviderResetAfterErrorCB reset_after_error;
45     JitProviderReleaseContextCB release_context;
46     JitProviderCompileExprCB compile_expr;
47 };
48
49 extern void _PG_jit_provider_init(JitProviderCallbacks *cb);
50 </pre><p>
51     </p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="jit-configuration.html" title="30.3. Configuration">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="jit.html" title="Chapter 30. Just-in-Time Compilation (JIT)">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="regress.html" title="Chapter 31. Regression Tests">Next</a></td></tr><tr><td width="40%" align="left" valign="top">30.3. Configuration </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> Chapter 31. Regression Tests</td></tr></table></div></body></html>