{
    "mode": "man",
    "parameter": "CREATE_LANGUAGE",
    "section": "7",
    "url": "https://www.chedong.com/phpMan.php/man/CREATE_LANGUAGE/7/json",
    "generated": "2026-06-15T13:16:20Z",
    "synopsis": "CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name\nHANDLER callhandler [ INLINE inlinehandler ] [ VALIDATOR valfunction ]\nCREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name",
    "sections": {
        "NAME": {
            "content": "CREATELANGUAGE - define a new procedural language\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name\nHANDLER callhandler [ INLINE inlinehandler ] [ VALIDATOR valfunction ]\nCREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE name\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "CREATE LANGUAGE registers a new procedural language with a PostgreSQL database. Subsequently,\nfunctions and procedures can be defined in this new language.\n\nCREATE LANGUAGE effectively associates the language name with handler function(s) that are\nresponsible for executing functions written in the language. Refer to Chapter 56 for more\ninformation about language handlers.\n\nCREATE OR REPLACE LANGUAGE will either create a new language, or replace an existing\ndefinition. If the language already exists, its parameters are updated according to the\ncommand, but the language's ownership and permissions settings do not change, and any\nexisting functions written in the language are assumed to still be valid.\n\nOne must have the PostgreSQL superuser privilege to register a new language or change an\nexisting language's parameters. However, once the language is created it is valid to assign\nownership of it to a non-superuser, who may then drop it, change its permissions, rename it,\nor assign it to a new owner. (Do not, however, assign ownership of the underlying C functions\nto a non-superuser; that would create a privilege escalation path for that user.)\n\nThe form of CREATE LANGUAGE that does not supply any handler function is obsolete. For\nbackwards compatibility with old dump files, it is interpreted as CREATE EXTENSION. That will\nwork if the language has been packaged into an extension of the same name, which is the\nconventional way to set up procedural languages.\n",
            "subsections": []
        },
        "PARAMETERS": {
            "content": "TRUSTED\nTRUSTED specifies that the language does not grant access to data that the user would not\notherwise have. If this key word is omitted when registering the language, only users\nwith the PostgreSQL superuser privilege can use this language to create new functions.\n\nPROCEDURAL\nThis is a noise word.\n\nname\nThe name of the new procedural language. The name must be unique among the languages in\nthe database.\n\nHANDLER callhandler\ncallhandler is the name of a previously registered function that will be called to\nexecute the procedural language's functions. The call handler for a procedural language\nmust be written in a compiled language such as C with version 1 call convention and\nregistered with PostgreSQL as a function taking no arguments and returning the\nlanguagehandler type, a placeholder type that is simply used to identify the function as\na call handler.\n\nINLINE inlinehandler\ninlinehandler is the name of a previously registered function that will be called to\nexecute an anonymous code block (DO command) in this language. If no inlinehandler\nfunction is specified, the language does not support anonymous code blocks. The handler\nfunction must take one argument of type internal, which will be the DO command's internal\nrepresentation, and it will typically return void. The return value of the handler is\nignored.\n\nVALIDATOR valfunction\nvalfunction is the name of a previously registered function that will be called when a\nnew function in the language is created, to validate the new function. If no validator\nfunction is specified, then a new function will not be checked when it is created. The\nvalidator function must take one argument of type oid, which will be the OID of the\nto-be-created function, and will typically return void.\n\nA validator function would typically inspect the function body for syntactical\ncorrectness, but it can also look at other properties of the function, for example if the\nlanguage cannot handle certain argument types. To signal an error, the validator function\nshould use the ereport() function. The return value of the function is ignored.\n",
            "subsections": []
        },
        "NOTES": {
            "content": "Use DROP LANGUAGE to drop procedural languages.\n\nThe system catalog pglanguage (see Section 52.29) records information about the currently\ninstalled languages. Also, the psql command \\dL lists the installed languages.\n\nTo create functions in a procedural language, a user must have the USAGE privilege for the\nlanguage. By default, USAGE is granted to PUBLIC (i.e., everyone) for trusted languages. This\ncan be revoked if desired.\n\nProcedural languages are local to individual databases. However, a language can be installed\ninto the template1 database, which will cause it to be available automatically in all\nsubsequently-created databases.\n",
            "subsections": []
        },
        "EXAMPLES": {
            "content": "A minimal sequence for creating a new procedural language is:\n\nCREATE FUNCTION plsamplecallhandler() RETURNS languagehandler\nAS '$libdir/plsample'\nLANGUAGE C;\nCREATE LANGUAGE plsample\nHANDLER plsamplecallhandler;\n\nTypically that would be written in an extension's creation script, and users would do this to\ninstall the extension:\n\nCREATE EXTENSION plsample;\n",
            "subsections": []
        },
        "COMPATIBILITY": {
            "content": "CREATE LANGUAGE is a PostgreSQL extension.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "ALTER LANGUAGE (ALTERLANGUAGE(7)), CREATE FUNCTION (CREATEFUNCTION(7)), DROP LANGUAGE\n(DROPLANGUAGE(7)), GRANT(7), REVOKE(7)\n\n\n\nPostgreSQL 14.23                                2026                              CREATE LANGUAGE(7)",
            "subsections": []
        }
    },
    "summary": "CREATELANGUAGE - define a new procedural language",
    "flags": [],
    "examples": [
        "A minimal sequence for creating a new procedural language is:",
        "CREATE FUNCTION plsamplecallhandler() RETURNS languagehandler",
        "AS '$libdir/plsample'",
        "LANGUAGE C;",
        "CREATE LANGUAGE plsample",
        "HANDLER plsamplecallhandler;",
        "Typically that would be written in an extension's creation script, and users would do this to",
        "install the extension:",
        "CREATE EXTENSION plsample;"
    ],
    "see_also": [
        {
            "name": "ALTERLANGUAGE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/ALTERLANGUAGE/7/json"
        },
        {
            "name": "CREATEFUNCTION",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/CREATEFUNCTION/7/json"
        },
        {
            "name": "DROPLANGUAGE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/DROPLANGUAGE/7/json"
        },
        {
            "name": "GRANT",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/GRANT/7/json"
        },
        {
            "name": "REVOKE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/REVOKE/7/json"
        },
        {
            "name": "LANGUAGE",
            "section": "7",
            "url": "https://www.chedong.com/phpMan.php/man/LANGUAGE/7/json"
        }
    ]
}