Functions

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

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 PostgreSQL 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

static Function.from_map(name, schema, arguments, inobj)

Initialize a function instance from a YAML map

Parameters:
  • name – function name
  • name – schema name
  • arguments – arguments
  • inobj – YAML map of the function
Returns:

function instance

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(obj, *args, **kwargs)

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()

Aggregate Function

Aggregate is derived from Proc and represents a PostgreSQL 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

static Aggregate.from_map(name, schema, arguments, inobj)

Initialize an aggregate instance from a YAML map

Parameters:
  • name – aggregate name
  • name – schema name
  • arguments – arguments
  • inobj – YAML map of the aggregate
Returns:

aggregate instance

Aggregate.to_map(db, no_owner, no_privs)

Convert an agggregate to a YAML-suitable format

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

dictionary

Aggregate.create(obj, *args, **kwargs)

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)

Initalize the dictionary of functions by converting the input map

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