Seth Woolley's Man Viewer

create_language(7) - CREATE LANGUAGE - define a new procedural language - man 7 create_language

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

CREATE LANGUAGE(7)               SQL Commands               CREATE LANGUAGE(7)



NAME
       CREATE LANGUAGE - define a new procedural language


SYNOPSIS
       CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name
           HANDLER call_handler [ VALIDATOR valfunction ]


DESCRIPTION
       Using  CREATE LANGUAGE, a PostgreSQL user can register a new procedural
       language with a PostgreSQL database. Subsequently, functions and  trig-
       ger  procedures can be defined in(1,8) this new language. The user must have
       the PostgreSQL superuser privilege to register a new language.

       CREATE LANGUAGE effectively associates the language name  with  a  call
       handler that is responsible for executing functions written in(1,8) the lan-
       guage. Refer to the section called ``User-Defined  Functions''  in(1,8)  the
       documentation for more information about language call handlers.

       Note  that  procedural languages are local to individual databases.  To
       make a language available in(1,8) all databases by  default,  it  should  be
       installed into the template1 database.

PARAMETERS
       TRUSTED
              TRUSTED  specifies  that  the  call  handler for the language is
              safe, that is, it does not offer an unprivileged user any  func-
              tionality  to  bypass  access(2,5)  restrictions. If this key word is
              omitted when registering the language, only users(1,5) with the Post-
              greSQL  superuser  privilege can use this language to create new
              functions.

       PROCEDURAL
              This is a noise word.

       name   The name of the new procedural language. The  language  name  is
              case insensitive. The name must be unique among the languages in(1,8)
              the database.

              For backward compatibility, the name may be enclosed  by  single
              quotes.

       HANDLER call_handler
              call_handler  is  the  name  of a previously registered function
              that will be called to execute  the  procedural  language  func-
              tions.  The call handler for a procedural language must be writ-
              ten in(1,8) a compiled language such as C with version(1,3,5) 1 call conven-
              tion  and  registered  with  PostgreSQL  as a function taking no
              arguments and returning the language_handler type, a placeholder
              type that is simply used to identify the function as a call han-
              dler.

       VALIDATOR valfunction
              valfunction is the name of a previously registered function that
              will  be  called when a new function in(1,8) the language is created,
              to validate the new function.  If no validator function is spec-
              ified,  then  a new function will not be checked when it is cre-
              ated.  The validator function must take  one  argument  of  type
              oid,  which  will  be the OID of the to-be-created function, and
              will typically return void.

              A validator function would typically inspect the  function  body
              for syntactical correctness, but it can also look(1,8,3 Search::Dict) at other prop-
              erties of the function, for example if(3,n) the language cannot  han-
              dle  certain  argument  types. To signal(2,7) an error(8,n), the validator
              function should use the ereport() function. The return value  of
              the function is ignored.

NOTES
       This  command  normally  should not be executed directly by users.  For
       the procedural languages supplied in(1,8) the PostgreSQL  distribution,  the
       createlang(1)  program should be used, which will also install the cor-
       rect call handler. (createlang will call CREATE LANGUAGE internally.)

       In PostgreSQL versions before 7.3, it was necessary to declare  handler
       functions  as  returning  the placeholder type opaque, rather than lan-
       guage_handler.  To support loading of old dump files,  CREATE  LANGUAGE
       will  accept(2,8) a function declared as returning opaque, but it will issue
       a notice and  change  the  function's  declared  return  type  to  lan-
       guage_handler.

       Use  the  CREATE  FUNCTION [create_function(7)] command to create a new
       function.

       Use DROP LANGUAGE [drop_language(7)], or  better  yet  the  droplang(1)
       program, to drop procedural languages.

       The  system  catalog pg_language (see the chapter called ``System Cata-
       logs'' in(1,8) the documentation) records information  about  the  currently
       installed  languages.  Also  createlang  has  an  option  to  list  the
       installed languages.

       The definition of a procedural language cannot be changed once  it  has
       been created, with the exception of the privileges.

       To  be  able  to  use a procedural language, a user must be granted the
       USAGE privilege. The createlang program  automatically  grants  permis-
       sions to everyone if(3,n) the language is known to be trusted.

EXAMPLES
       The  following  two  commands  executed in(1,8) sequence will register a new
       procedural language and the associated call handler.

       CREATE FUNCTION plsample_call_handler() RETURNS language_handler
           AS '$libdir/plsample'
           LANGUAGE C;
       CREATE LANGUAGE plsample
           HANDLER plsample_call_handler;


COMPATIBILITY
       CREATE LANGUAGE is a PostgreSQL extension.

SEE ALSO
       ALTER  LANGUAGE  [alter_language(7)],  CREATE  FUNCTION   [create_func-
       tion(l)],  DROP  LANGUAGE  [drop_language(l)], GRANT [grant(l)], REVOKE
       [revoke(l)], createlang(1), droplang(1)




SQL - Language Statements         2003-11-02                CREATE LANGUAGE(7)

References for this manual (incoming links)