

Chapter 49. Procedural Languages

Postgres supports the definition of procedural languages. In the case of a function or trigger procedure defined in a procedural language, the database has no built-in knowledge about how to interpret the function's source text. Instead, the task is passed to a handler that knows the details of the language. The handler itself is a special programming language function compiled into a shared object and loaded on demand.


Installing Procedural Languages

Procedural Language Installation

A procedural language is installed in the database in three steps. (For the languages supplied with the standard distribution, the shell script createlang can be used instead of carrying out the details manually.)


  2. The handler must be declared with the command

    CREATE FUNCTION handler_function_name ()
    The special return type of OPAQUE tells the database that this function does not return one of the defined SQL datatypes and is not directly usable in SQL statements.
  3. The PL must be declared with the command

        HANDLER handler_function_name
        LANCOMPILER 'description';
    The optional keyword TRUSTED tells whether ordinary database users that have no superuser privileges should be allowed to use this language to create functions and trigger procedures. Since PL functions are executed inside the database backend, the TRUSTED flag should only be given for languages that don't allow access to database backends internals or the filesystem. The languages PL/pgSQL and PL/Tcl are known to be trusted.



    CREATE FUNCTION plpgsql_call_handler () RETURNS OPAQUE AS
  2. The command

        HANDLER plpgsql_call_handler




Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group