Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/xplang.sgml`
ed4a76f0f67f3d45341434214f3a7a75cd0065c2132f2bf60000000100000861
 function is called by
      <command>CREATE FUNCTION</command> if it exists.  If a validator function
      is provided by the language, declare it with a command like
<synopsis>
CREATE FUNCTION <replaceable>validator_function_name</replaceable>(oid)
    RETURNS void
    AS '<replaceable>path-to-shared-object</replaceable>'
    LANGUAGE C STRICT;
</synopsis>
     </para>
    </step>

    <step performance="required" id="xplang-install-cr5">
     <para>
      Finally, the PL must be declared with the command
<synopsis>
CREATE <optional>TRUSTED</optional> LANGUAGE <replaceable>language_name</replaceable>
    HANDLER <replaceable>handler_function_name</replaceable>
    <optional>INLINE <replaceable>inline_function_name</replaceable></optional>
    <optional>VALIDATOR <replaceable>validator_function_name</replaceable></optional> ;
</synopsis>
      The optional key word <literal>TRUSTED</literal> specifies that
      the language does not grant access to data that the user would
      not otherwise have.  Trusted languages are designed for ordinary
      database users (those without superuser privilege) and allows them
      to safely create functions and
      procedures. Since PL functions are executed inside the database
      server, the <literal>TRUSTED</literal> flag should only be given
      for languages that do not allow access to database server
      internals or the file system. The languages
      <application>PL/pgSQL</application>,
      <application>PL/Tcl</application>, and
      <application>PL/Perl</application>
      are considered trusted; the languages
      <application>PL/TclU</application>,
      <application>PL/PerlU</application>, and
      <application>PL/PythonU</application>
      are designed to provide unlimited functionality and should
      <emphasis>not</emphasis> be marked trusted.
     </para>
    </step>
   </procedure>

   <para>
    <xref linkend="xplang-install-example"/> shows how the manual
    installation procedure would work with the language
    <application>PL/Perl</application>.
   </para>

   <example id="xplang-install-example">
    <title>Manual Installation

Title: Declaring Procedural Languages in PostgreSQL
Summary
This section describes the final steps in manually installing a procedural language in PostgreSQL. It explains how to declare a validator function and the procedural language itself using SQL commands. The CREATE LANGUAGE command is detailed, including optional parameters for specifying handler, inline, and validator functions. The text also discusses the TRUSTED keyword, which is used to indicate languages that don't grant extra access privileges. It provides examples of trusted languages (PL/pgSQL, PL/Tcl, PL/Perl) and untrusted languages (PL/TclU, PL/PerlU, PL/PythonU), emphasizing the importance of only marking genuinely safe languages as trusted.