2 $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_language.sgml,v 1.18 2001/10/26 21:17:03 tgl Exp $
6 <refentry id="SQL-CREATELANGUAGE">
8 <date>2001-09-05</date>
12 <refentrytitle id="sql-createlanguage-title">CREATE LANGUAGE</refentrytitle>
13 <refmiscinfo>SQL - Language Statements</refmiscinfo>
17 <refname>CREATE LANGUAGE</refname>
18 <refpurpose>define a new procedural language</refpurpose>
23 CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="parameter">langname</replaceable>
24 HANDLER <replaceable class="parameter">call_handler</replaceable>
28 <refsect1 id="sql-createlanguage-description">
29 <title>Description</title>
32 Using <command>CREATE LANGUAGE</command>, a
33 <productname>PostgreSQL</productname> user can register a new
34 procedural language with a <productname>PostgreSQL</productname>
35 database. Subsequently, functions and trigger procedures can be
36 defined in this new language. The user must have the
37 <productname>PostgreSQL</productname> superuser privilege to
38 register a new language.
42 <command>CREATE LANGUAGE</command> effectively associates the
43 language name with a call handler that is responsible for executing
44 functions written in the language. Refer to the
45 <citetitle>Programmer's Guide</citetitle> for more information
46 about language call handlers.
50 Note that procedural languages are local to individual databases.
51 To make a language available in all databases by default, it should
52 be installed into the <literal>template1</literal> database.
56 <refsect1 id="sql-createlanguage-parameters">
57 <title>Parameters</title>
61 <term><literal>TRUSTED</literal></term>
65 <literal>TRUSTED</literal> specifies that the call handler for
66 the language is safe, that is, it does not offer an
67 unprivileged user any functionality to bypass access
68 restrictions. If this keyword is omitted when registering the
69 language, only users with the
70 <productname>PostgreSQL</productname> superuser privilege can
71 use this language to create new functions.
77 <term><literal>PROCEDURAL</literal></term>
87 <term><replaceable class="parameter">langname</replaceable></term>
91 The name of the new procedural language. The language name is
92 case insensitive. A procedural language cannot override one of
93 the built-in languages of <productname>PostgreSQL</productname>.
97 For backward compatibility, the name may be enclosed by single
104 <term><literal>HANDLER</literal> <replaceable class="parameter">call_handler</replaceable></term>
108 <replaceable class="parameter">call_handler</replaceable> is
109 the name of a previously registered function that will be
110 called to execute the procedural language functions. The call
111 handler for a procedural language must be written in a compiled
112 language such as C with version 1 call convention and
113 registered with <productname>PostgreSQL</productname> as a
114 function taking no arguments and returning the
115 <type>opaque</type> type, a placeholder for unspecified or
123 <refsect1 id="sql-createlanguage-diagnostics">
124 <title>Diagnostics</title>
140 This message is returned if the language is successfully
151 ERROR: PL handler function <replaceable class="parameter">funcname</replaceable>() doesn't exist
159 This error is returned if the function <replaceable
160 class="parameter">funcname</replaceable>() is not found.
167 <refsect1 id="sql-createlanguage-notes">
171 This command normally should not be executed directly by users.
172 For the procedural languages supplied in the
173 <productname>PostgreSQL</productname> distribution, the <xref
174 linkend="app-createlang"> script should be used, which will also
175 install the correct call handler. (<command>createlang</command>
176 will call <command>CREATE LANGUAGE</command> internally.)
180 Use the <xref linkend="sql-createfunction"> command to create a new
185 Use <xref linkend="sql-droplanguage">, or better yet the <xref
186 linkend="app-droplang"> script, to drop procedural languages.
190 The system catalog <classname>pg_language</classname> records
191 information about the currently installed procedural languages.
195 Attribute | Type | Modifier
196 ---------------+---------+----------
199 lanpltrusted | boolean |
200 lanplcallfoid | oid |
203 lanname | lanispl | lanpltrusted | lanplcallfoid | lancompiler
204 -------------+---------+--------------+---------------+-------------
205 internal | f | f | 0 | n/a
206 C | f | f | 0 | /bin/cc
207 sql | f | f | 0 | postgres
212 At present, the definition of a procedural language cannot be
213 changed once it has been created.
217 <refsect1 id="sql-createlanguage-examples">
218 <title>Examples</title>
221 The following two commands executed in sequence will register a new
222 procedural language and the associated call handler.
224 CREATE FUNCTION plsample_call_handler () RETURNS opaque
225 AS '$libdir/plsample'
227 CREATE LANGUAGE plsample
228 HANDLER plsample_call_handler;
233 <refsect1 id="sql-createlanguage-compat">
234 <title>Compatibility</title>
237 <command>CREATE LANGUAGE</command> is a
238 <productname>PostgreSQL</productname> extension.
243 <title>History</title>
246 The <command>CREATE LANGUAGE</command> command first appeared in
247 <productname>PostgreSQL</productname> 6.3.
252 <title>See Also</title>
255 <simplelist type="inline">
256 <member><xref linkend="app-createlang"></member>
257 <member><xref linkend="sql-createfunction"></member>
258 <member><xref linkend="app-droplang"></member>
259 <member><xref linkend="sql-droplanguage"></member>
260 <member><citetitle>PostgreSQL Programmer's Guide</citetitle></member>
266 <!-- Keep this comment at the end of the file
271 sgml-minimize-attributes:nil
272 sgml-always-quote-attributes:t
275 sgml-parent-document:nil
276 sgml-default-dtd-file:"../reference.ced"
277 sgml-exposed-tags:nil
278 sgml-local-catalogs:"/usr/lib/sgml/catalog"
279 sgml-local-ecat-files:nil