Skip to content

Latest commit

 

History

History
81 lines (58 loc) · 3.4 KB

functions.md

File metadata and controls

81 lines (58 loc) · 3.4 KB

Function Operations

pgm.createFunction( function_name, function_params, function_options, definition )

Create a new function - postgres docs

Arguments:

  • function_name [Name] - name of the new function

  • function_params [array] - parameters of the new function

    Either array of strings or objects. If array of strings, it is interpreted as is, if array of objects:

    • mode [string] - IN, OUT, INOUT, or VARIADIC
    • name [string] - name of argument
    • type [string] - datatype of argument
    • default [string] - default value of argument
  • function_options [object] - options:

    • returns [string] - returns clause
    • language [string] - language name of function definition
    • replace [boolean] - create or replace function
    • window [boolean] - window function
    • behavior [string] - IMMUTABLE, STABLE, or VOLATILE
    • strict [boolean] - RETURNS NULL/CALLED ON NULL INPUT
    • onNull [string] (deprecated) - alias for strict, also accepts NULL or CALLED
    • parallel [string] - UNSAFE, RESTRICTED, or SAFE
    • cost [number] - estimated execution cost
    • rows [number] - estimated number of result rows
    • comment [string] - comment on function
  • definition [string] - definition of function

Reverse Operation: dropFunction


pgm.dropFunction( function_name, function_params, drop_options )

Drop a function - postgres docs

Arguments:

  • function_name [Name] - name of the function to drop
  • function_params [array] - see
  • drop_options [object] - options:
    • ifExists [boolean] - drops function only if it exists
    • cascade [boolean] - drops also dependent objects

pgm.alterFunction( function_name, function_params, function_options )

Alter a function - postgres docs

Arguments:

  • function_name [Name] - name of the function to drop
  • function_params [array] - see
  • function_options [object] - options:
    • owner [string] - the new owner of the function
    • window [boolean] - window function
    • behavior [string] - IMMUTABLE, STABLE, or VOLATILE
    • strict [boolean] - RETURNS NULL/CALLED ON NULL INPUT
    • onNull [string] (deprecated) - alias for strict, also accepts NULL or CALLED
    • parallel [string] - UNSAFE, RESTRICTED, or SAFE
    • cost [number] - estimated execution cost
    • rows [number] - estimated number of result rows
    • comment [string] - comment on function

pgm.renameFunction( old_function_name, function_params, new_function_name )

Rename a function - postgres docs

Arguments:

  • old_function_name [Name] - old name of the function
  • function_params [array] - see
  • new_function_name [Name] - new name of the function