Skip to content

Function Operations

Operation: createFunction

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

IMPORTANT

Create a new function - postgres docs

Arguments

NameTypeDescription
function_nameNamename of the new function
function_paramsarray[string] array[object]parameters of the new function
function_optionsobjectCheck below for available options
definitionstringdefinition of function

function_params

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

OptionTypeDescription
modestringIN, OUT, INOUT, or VARIADIC
namestringname of argument
typestringdatatype of argument
defaultstringdefault value of argument

function_options

OptionTypeDescription
returnsstringreturns clause
languagestringlanguage name of function definition
replacebooleancreate or replace function
windowbooleanwindow function
behaviorstringIMMUTABLE, STABLE, or VOLATILE
securitystringINVOKER or DEFINER
onNullbooleanRETURNS NULL ON NULL INPUT
parallelstringUNSAFE, RESTRICTED, or SAFE

Reverse Operation: dropFunction

pgm.dropFunction( function_name, function_params, drop_options )

IMPORTANT

Drop a function - postgres docs

Arguments

NameTypeDescription
function_nameNamename of the function to drop
function_paramsarray[string] array[object]parameters of the function
drop_optionsobjectCheck below for available options

drop_options

OptionTypeDescription
ifExistsbooleandrops function only if it exists
cascadebooleandrops also dependent objects

Operation: alterFunction

pgm.renameFunction( old_function_name, function_params, new_function_name )

IMPORTANT

Rename a function - postgres docs

Arguments

NameTypeDescription
old_function_nameNameold name of the function
function_paramsarray[string] array[object]parameters of the function
new_function_nameNamenew name of the function