Functions

The function module defines four classes: class Proc derived from DbSchemaObject, classes Function and Aggregate derived from Proc, and class ProcDict derived from DbObjectDict.

Procedure

Class Proc is derived from DbSchemaObject and represents a regular or aggregate function.

class pyrseas.dbobject.function.Proc(name, schema, description, owner, privileges, arguments)

A procedure such as a FUNCTION or an AGGREGATE

Proc.extern_key()

Return the key to be used in external maps for this function

Returns:string
Proc.identifier()

Return a full identifier for a function object

Returns:string

Function

Function is derived from Proc and represents a Postgres user-defined function.

class pyrseas.dbobject.function.Function(name, schema, description, owner, privileges, arguments, language, returns, source, obj_file=None, configuration=None, volatility=None, leakproof=False, strict=False, security_definer=False, cost=0, rows=0, allargs=None, oid=None)

A procedural language function

Function.to_map(db, no_owner, no_privs)

Convert a function to a YAML-suitable format

Parameters:
  • no_owner – exclude function owner information
  • no_privs – exclude privilege information
Returns:

dictionary

Function.create(dbversion=None, newsrc=None, basetype=False, returns=None)

Return SQL statements to CREATE or REPLACE the function

Parameters:newsrc – new source for a changed function
Returns:SQL statements
Function.alter(infunction, dbversion=None, no_owner=False)

Generate SQL to transform an existing function

Parameters:infunction – a YAML map defining the new function
Returns:list of SQL statements

Compares the function to an input function and generates SQL statements to transform it into the one represented by the input.

Function.drop()

Generate SQL to drop the current function

Returns:list of SQL statements

Aggregate Function

Aggregate is derived from Proc and represents a Postgres user-defined aggregate function.

class pyrseas.dbobject.function.Aggregate(name, schema, description, owner, privileges, arguments, sfunc, stype, sspace=0, finalfunc=None, finalfunc_extra=False, initcond=None, sortop=None, msfunc=None, minvfunc=None, mstype=None, msspace=0, mfinalfunc=None, mfinalfunc_extra=False, minitcond=None, kind='normal', combinefunc=None, serialfunc=None, deserialfunc=None, parallel='unsafe', oid=None)

An aggregate function

Aggregate.to_map(db, no_owner, no_privs)

Convert an aggregate to a YAML-suitable format

Parameters:
  • no_owner – exclude aggregate owner information
  • no_privs – exclude privilege information
Returns:

dictionary

Aggregate.create(dbversion=None)

Return SQL statements to CREATE the aggregate

Parameters:dbversion – Posgres version
Returns:SQL statements

Procedure Dictionary

ProcDict is derived from DbObjectDict. It is a dictionary that represents the collection of regular and aggregate functions in a database.

class pyrseas.dbobject.function.ProcDict(dbconn=None)

The collection of regular and aggregate functions in a database

ProcDict.from_map(schema, infuncs)

Initialize the dictionary of functions by converting the input map

Parameters:
  • schema – schema owning the functions
  • infuncs – YAML map defining the functions