Postgresql function part definition and translation

CREATE [ OR REPLACE ] FUNCTION

    Name function name ( [ [ argmode parameter form: IN OUT INOUT VARIADIC defaults to IN ] [ argname parameter name \ column name ] argtype variable type [ { DEFAULT | = }default_expr ] [, ...] default value] )

    [ RETURNS rettype Return value type: If it is an out\inout parameter, it can be omitted, otherwise it is the same as the type of the output result. If there are multiple outputs, it is RECORD. The SETOF modifier indicates that a set of items is returned, and the column type is referenced by table name. column name %TYPE

      | RETURNS TABLE (column_name column_type [, ...] ) ] Another form of statement output

  { LANGUAGE lang_name SQL\C\internal…

    | WINDOW window functions are for C only

| IMMUTABLE CAN NOT MODIFY DATABASE CANNOT LOOK | STABLE is suitable for database lookups | VOLATILE IS UNSTABLE | [NOT] LEAKPROOF SUPERUSER SETTING ONLY

    | CALLED ON NULL INPUT can also be called when some parameters are empty | RETURNS NULL ON NULL INPUT | STRICT returns null if any parameter is null

    | [ EXTERNAL ] SECURITYINVOKER default setting | [ EXTERNAL ] SECURITY DEFINER The user who created it executes

    | COST execution_cost A positive number giving the estimated execution cost of the function in cpu_operator_cost. If the function returns a collection, this is the cost per returned row. If no cost is specified, 1 unit is assumed for C language and intrinsics, and 100 units for other languages. Larger values ​​cause planners to try to avoid evaluating features more often than necessary.

    | ROWS result_rows defaults to 1000 rows, the expected number of rows returned is only allowed if the statement returns a collection

    | SETconfiguration_parameter { TO value | = value | FROM CURRENT } The SET clause sets the parameter when entering the function and restores the previous value when exiting.

    | AS 'definition' description, suitable for $$ quoting otherwise ' and / need to be escaped by typing it twice

    | AS 'obj_file', 'link_symbol' C application

  } ...

[ WITH ( attribute[, ...] ) ] can be put into isStrict isCachable


When replacing a function, there are restrictions on changing the parameter name, you cannot change the name of any parameter that has been assigned, and if there are multiple output parameters, you cannot change the name of the output parameter.

refer to:

https://www.postgresql.org/docs/9.3/static/sql-createfunction.html


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325732195&siteId=291194637
Recommended