Function

The Config Load Directory is functions.d. For functions two allowed formats for giving the functions body exist. The usual variant is to give the following YAML structure including the body value. The second variant is to give the following YAML structure as Front Matter (i. e. fenced with --- lines) providing the body as content following the frontmatter. The Examples include both variants.

The recommended practice is to use the Front Matter style while using a filename extension that matches the used language (.pgsql, .sql, .py) to enable syntax highlighting in editors.

name SQL Identifier
Function name
description String
Function description
returns SQL Type
Return type of the function, the value TABLE is special (see return_table)
parameters List [Variable]
parameters the function takes
templates List [SQL Identifier]
list of template names, from which this function derives definitions (see FunctionTpl)
returns_columns List [Parameter]
If the value of return is TABLE (case sensitive), this options defines the columns that are returned
priv_execute List [SQL Identifier]
Role that has the privilege to execute the function
security_definer Bool
If true, the function is executed with the privileges of the owner! Owner has to be given, if this is true
owner SQL Identifier
owner of the function
language String:
language in which the body is written.
variables List [Variable]
Variables
body String
The code of the function (body)

Parameter

name SQL Identifier
Name
type SQL Type
Type
description String
Description

Variable

name SQL Identifier
Name
type SQL Type
Type
description String
Description
default String
Default

Examples

Usual definition using plain YAML
name: f
description: |
 Always returns ``1``
returns: int
body: |

 RETURN 1;
Same function with the function body following a Front Matter
---
name: f
description: |
 Always returns ``1``
returns: int
---

RETURN 1;
Same function written in Python 3
---
name: f
description: |
 Always returns ``1``
returns: int
language: plpython3u
---

return 1