must be carried out by a database superuser. In most cases
the required SQL commands should be packaged as the installation script
of an <quote>extension</quote>, so that <command>CREATE EXTENSION</command> can be
used to execute them.
</para>
<step performance="required" id="xplang-install-cr1">
<para>
The shared object for the language handler must be compiled and
installed into an appropriate library directory. This works in the same
way as building and installing modules with regular user-defined C
functions does; see <xref linkend="dfunc"/>. Often, the language
handler will depend on an external library that provides the actual
programming language engine; if so, that must be installed as well.
</para>
</step>
<step performance="required" id="xplang-install-cr2">
<para>
The handler must be declared with the command
<synopsis>
CREATE FUNCTION <replaceable>handler_function_name</replaceable>()
RETURNS language_handler
AS '<replaceable>path-to-shared-object</replaceable>'
LANGUAGE C;
</synopsis>
The special return type of <type>language_handler</type> tells
the database system that this function does not return one of
the defined <acronym>SQL</acronym> data types and is not directly usable
in <acronym>SQL</acronym> statements.
</para>
</step>
<step performance="optional" id="xplang-install-cr3">
<para>
Optionally, the language handler can provide an <quote>inline</quote>
handler function that executes anonymous code blocks
(<link linkend="sql-do"><command>DO</command></link> commands)
written in this language. If an inline handler function
is provided by the language, declare it with a command like
<synopsis>
CREATE FUNCTION <replaceable>inline_function_name</replaceable>(internal)
RETURNS void
AS '<replaceable>path-to-shared-object</replaceable>'
LANGUAGE C;
</synopsis>
</para>
</step>
<step performance="optional" id="xplang-install-cr4">
<para>
Optionally, the language handler can provide a <quote>validator</quote>
function that checks a function definition for correctness without
actually executing it. The validator 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