PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_aggregate.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * pg_aggregate.h
4 * definition of the "aggregate" system catalog (pg_aggregate)
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/catalog/pg_aggregate.h
11 *
12 * NOTES
13 * The Catalog.pm module reads this file and derives schema
14 * information.
15 *
16 *-------------------------------------------------------------------------
17 */
18#ifndef PG_AGGREGATE_H
19#define PG_AGGREGATE_H
20
21#include "catalog/genbki.h"
22#include "catalog/pg_aggregate_d.h" /* IWYU pragma: export */
23
25#include "nodes/pg_list.h"
26
27/* ----------------------------------------------------------------
28 * pg_aggregate definition.
29 * cpp turns this into typedef struct FormData_pg_aggregate
30 * ----------------------------------------------------------------
31 */
33
35{
36 /* pg_proc OID of the aggregate itself */
37 regproc aggfnoid BKI_LOOKUP(pg_proc);
38
39 /* aggregate kind, see AGGKIND_ categories below */
40 char aggkind BKI_DEFAULT(n);
41
42 /* number of arguments that are "direct" arguments */
44
45 /* transition function */
47
48 /* final function (0 if none) */
50
51 /* combine function (0 if none) */
53
54 /* function to convert transtype to bytea (0 if none) */
56
57 /* function to convert bytea to transtype (0 if none) */
59
60 /* forward function for moving-aggregate mode (0 if none) */
62
63 /* inverse function for moving-aggregate mode (0 if none) */
65
66 /* final function for moving-aggregate mode (0 if none) */
68
69 /* true to pass extra dummy arguments to aggfinalfn */
71
72 /* true to pass extra dummy arguments to aggmfinalfn */
74
75 /* tells whether aggfinalfn modifies transition state */
77
78 /* tells whether aggmfinalfn modifies transition state */
80
81 /* associated sort operator (0 if none) */
83
84 /* type of aggregate's transition (state) data */
85 Oid aggtranstype BKI_LOOKUP(pg_type);
86
87 /* estimated size of state data (0 for default estimate) */
88 int32 aggtransspace BKI_DEFAULT(0);
89
90 /* type of moving-aggregate state data (0 if none) */
92
93 /* estimated size of moving-agg state (0 for default est) */
95
96#ifdef CATALOG_VARLEN /* variable-length fields start here */
97
98 /* initial value for transition state (can be NULL) */
100
101 /* initial value for moving-agg state (can be NULL) */
103#endif
105
107
108/* ----------------
109 * Form_pg_aggregate corresponds to a pointer to a tuple with
110 * the format of pg_aggregate relation.
111 * ----------------
112 */
114
116
118
120
121#ifdef EXPOSE_TO_CLIENT_CODE
122
123/*
124 * Symbolic values for aggkind column. We distinguish normal aggregates
125 * from ordered-set aggregates (which have two sets of arguments, namely
126 * direct and aggregated arguments) and from hypothetical-set aggregates
127 * (which are a subclass of ordered-set aggregates in which the last
128 * direct arguments have to match up in number and datatypes with the
129 * aggregated arguments).
130 */
131#define AGGKIND_NORMAL 'n'
132#define AGGKIND_ORDERED_SET 'o'
133#define AGGKIND_HYPOTHETICAL 'h'
134
135/* Use this macro to test for "ordered-set agg including hypothetical case" */
136#define AGGKIND_IS_ORDERED_SET(kind) ((kind) != AGGKIND_NORMAL)
137
138/*
139 * Symbolic values for aggfinalmodify and aggmfinalmodify columns.
140 * Preferably, finalfns do not modify the transition state value at all,
141 * but in some cases that would cost too much performance. We distinguish
142 * "pure read only" and "trashes it arbitrarily" cases, as well as the
143 * intermediate case where multiple finalfn calls are allowed but the
144 * transfn cannot be applied anymore after the first finalfn call.
145 */
146#define AGGMODIFY_READ_ONLY 'r'
147#define AGGMODIFY_SHAREABLE 's'
148#define AGGMODIFY_READ_WRITE 'w'
149
150#endif /* EXPOSE_TO_CLIENT_CODE */
151
152
153extern ObjectAddress AggregateCreate(const char *aggName,
155 bool replace,
156 char aggKind,
157 int numArgs,
158 int numDirectArgs,
159 oidvector *parameterTypes,
173 bool finalfnExtraArgs,
175 char finalfnModify,
176 char mfinalfnModify,
182 const char *agginitval,
183 const char *aggminitval,
184 char proparallel);
185
186#endif /* PG_AGGREGATE_H */
Oid regproc
Definition c.h:696
int16_t int16
Definition c.h:574
int32_t int32
Definition c.h:575
#define BEGIN_CATALOG_STRUCT
Definition genbki.h:37
#define DECLARE_UNIQUE_INDEX_PKEY(name, oid, oidmacro, tblname, decl)
Definition genbki.h:105
#define BKI_LOOKUP(catalog)
Definition genbki.h:65
#define END_CATALOG_STRUCT
Definition genbki.h:38
#define BKI_DEFAULT(value)
Definition genbki.h:54
#define BKI_LOOKUP_OPT(catalog)
Definition genbki.h:66
#define DECLARE_TOAST(name, toastoid, indexoid)
Definition genbki.h:82
#define CATALOG(name, oid, oidmacro)
Definition genbki.h:42
#define MAKE_SYSCACHE(name, idxname, nbuckets)
Definition genbki.h:146
ObjectAddress AggregateCreate(const char *aggName, Oid aggNamespace, bool replace, char aggKind, int numArgs, int numDirectArgs, oidvector *parameterTypes, Datum allParameterTypes, Datum parameterModes, Datum parameterNames, List *parameterDefaults, Oid variadicArgType, List *aggtransfnName, List *aggfinalfnName, List *aggcombinefnName, List *aggserialfnName, List *aggdeserialfnName, List *aggmtransfnName, List *aggminvtransfnName, List *aggmfinalfnName, bool finalfnExtraArgs, bool mfinalfnExtraArgs, char finalfnModify, char mfinalfnModify, List *aggsortopName, Oid aggTransType, int32 aggTransSpace, Oid aggmTransType, int32 aggmTransSpace, const char *agginitval, const char *aggminitval, char proparallel)
FormData_pg_aggregate
END_CATALOG_STRUCT typedef FormData_pg_aggregate * Form_pg_aggregate
uint64_t Datum
Definition postgres.h:70
unsigned int Oid
static int fb(int x)
Definition pg_list.h:54
Definition c.h:778
Definition c.h:739