1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Installing Procedural Languages</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="Procedural Languages"
16
HREF="xplang.html"><LINK
18
TITLE="Procedural Languages"
19
HREF="xplang.html"><LINK
21
TITLE="PL/pgSQL - SQL Procedural Language"
22
HREF="plpgsql.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="Procedural Languages"
66
TITLE="Procedural Languages"
74
>Chapter 38. Procedural Languages</TD
80
TITLE="Procedural Languages"
89
TITLE="PL/pgSQL - SQL Procedural Language"
104
NAME="XPLANG-INSTALL"
105
>38.1. Installing Procedural Languages</A
108
> A procedural language must be <SPAN
112
database where it is to be used. But procedural languages installed in
116
> are automatically available in all
117
subsequently created databases, since their entries in
121
> will be copied by <TT
125
So the database administrator can
126
decide which languages are available in which databases and can make
127
some languages available by default if he chooses.
130
> For the languages supplied with the standard distribution, it is
131
only necessary to execute <TT
133
>CREATE EXTENSION</TT
140
> to install the language into the
141
current database. Alternatively, the program <A
142
HREF="app-createlang.html"
147
> can be used to do this from the shell
148
command line. For example, to install the language
158
CLASS="PROGRAMLISTING"
159
>createlang plperl template1</PRE
161
The manual procedure described below is only recommended for
162
installing languages that have not been packaged as extensions.
168
> Manual Procedural Language Installation
172
> A procedural language is installed in a database in five steps,
173
which must be carried out by a database superuser. In most cases
174
the required SQL commands should be packaged as the installation script
180
>CREATE EXTENSION</TT
182
used to execute them.
189
NAME="XPLANG-INSTALL-CR1"
192
> The shared object for the language handler must be compiled and
193
installed into an appropriate library directory. This works in the same
194
way as building and installing modules with regular user-defined C
195
functions does; see <A
196
HREF="xfunc-c.html#DFUNC"
198
>. Often, the language
199
handler will depend on an external library that provides the actual
200
programming language engine; if so, that must be installed as well.
206
NAME="XPLANG-INSTALL-CR2"
209
> The handler must be declared with the command
215
>handler_function_name</I
218
RETURNS language_handler
222
>path-to-shared-object</I
227
The special return type of <TT
229
>language_handler</TT
231
the database system that this function does not return one of
235
> data types and is not directly usable
245
NAME="XPLANG-INSTALL-CR3"
248
> Optionally, the language handler can provide an <SPAN
252
handler function that executes anonymous code blocks
257
written in this language. If an inline handler function
258
is provided by the language, declare it with a command like
264
>inline_function_name</I
271
>path-to-shared-object</I
281
NAME="XPLANG-INSTALL-CR4"
284
> Optionally, the language handler can provide a <SPAN
288
function that checks a function definition for correctness without
289
actually executing it. The validator function is called by
293
> if it exists. If a validator function
294
is provided by the language, declare it with a command like
300
>validator_function_name</I
307
>path-to-shared-object</I
310
LANGUAGE C STRICT;</PRE
317
NAME="XPLANG-INSTALL-CR5"
320
> Finally, the PL must be declared with the command
338
>handler_function_name</I
346
>inline_function_name</I
355
>validator_function_name</I
360
The optional key word <TT
364
the language does not grant access to data that the user would
365
not otherwise have. Trusted languages are designed for ordinary
366
database users (those without superuser privilege) and allows them
367
to safely create functions and trigger
368
procedures. Since PL functions are executed inside the database
372
> flag should only be given
373
for languages that do not allow access to database server
374
internals or the file system. The languages
387
are considered trusted; the languages
400
are designed to provide unlimited functionality and should
414
HREF="xplang-install.html#XPLANG-INSTALL-EXAMPLE"
416
> shows how the manual
417
installation procedure would work with the language
426
NAME="XPLANG-INSTALL-EXAMPLE"
430
>Example 38-1. Manual Installation of <SPAN
436
> The following command tells the database server where to find the
437
shared object for the <SPAN
444
CLASS="PROGRAMLISTING"
445
>CREATE FUNCTION plperl_call_handler() RETURNS language_handler AS
446
'$libdir/plperl' LANGUAGE C;</PRE
453
> has an inline handler function
454
and a validator function, so we declare those too:
457
CLASS="PROGRAMLISTING"
458
>CREATE FUNCTION plperl_inline_handler(internal) RETURNS void AS
459
'$libdir/plperl' LANGUAGE C;
461
CREATE FUNCTION plperl_validator(oid) RETURNS void AS
462
'$libdir/plperl' LANGUAGE C STRICT;</PRE
468
CLASS="PROGRAMLISTING"
469
>CREATE TRUSTED PROCEDURAL LANGUAGE plperl
470
HANDLER plperl_call_handler
471
INLINE plperl_inline_handler
472
VALIDATOR plperl_validator;</PRE
474
then defines that the previously declared functions
475
should be invoked for functions and trigger procedures where the
476
language attribute is <TT
487
the handler for the <SPAN
491
is built and installed into the <SPAN
495
directory; furthermore, the <SPAN
499
itself is installed in all databases.
503
> support is configured in, the handlers for
510
> are built and installed
511
in the library directory, but the language itself is not installed in any
520
handlers are built and installed if Perl support is configured, and the
524
> handler is installed if Python support is
525
configured, but these languages are not installed by default.
533
SUMMARY="Footer navigation table"
572
>Procedural Languages</TD
592
> Procedural Language</TD
b'\\ No newline at end of file'