3.2. pg_aggregate

pg_aggregate stores information about aggregate functions. An aggregate function is a function that operates on a set of values (typically one column from each row that matches a query condition) and returns a single value computed from all these values. Typical aggregate functions are sum, count, and max.

Table 3-2. pg_aggregate Columns

NameTypeReferencesDescription
aggnamename Name of the aggregate function
aggownerint4pg_shadow.usesysidOwner (creator) of the aggregate function
aggtransfnregproc (function) Transition function
aggfinalfnregproc (function) Final function
aggbasetypeoidpg_type.oidThe input datatype for this aggregate function
aggtranstypeoidpg_type.oidThe type of the aggregate function's internal transition (state) data
aggfinaltypeoidpg_type.oidThe type of the result
agginitvaltext  The initial value of the transition state. This is a text field which will be cast to the type of aggtranstype.

New aggregate functions are registered with the CREATE AGGREGATE command. See the Programmer's Guide for more information about writing aggregate functions and the meaning of the transition functions, etc.

An aggregate function is identified through name and argument type. Hence aggname and aggbasetype are the composite primary key.