PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pg_aggregate.h File Reference
#include "catalog/genbki.h"
#include "catalog/pg_aggregate_d.h"
#include "catalog/objectaddress.h"
#include "nodes/pg_list.h"
Include dependency graph for pg_aggregate.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BEGIN_CATALOG_STRUCT CATALOG (pg_aggregate, 2600, AggregateRelationId)
 
 DECLARE_TOAST (pg_aggregate, 4159, 4160)
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_aggregate_fnoid_index, 2650, AggregateFnoidIndexId, pg_aggregate, btree(aggfnoid oid_ops))
 
 MAKE_SYSCACHE (AGGFNOID, pg_aggregate_fnoid_index, 16)
 
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)
 

Variables

END_CATALOG_STRUCT typedef FormData_pg_aggregate * Form_pg_aggregate
 
 FormData_pg_aggregate
 

Function Documentation

◆ AggregateCreate()

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

Definition at line 46 of file pg_aggregate.c.

78{
82 bool nulls[Natts_pg_aggregate];
85 Form_pg_proc proc;
86 Oid transfn;
87 Oid finalfn = InvalidOid; /* can be omitted */
88 Oid combinefn = InvalidOid; /* can be omitted */
89 Oid serialfn = InvalidOid; /* can be omitted */
90 Oid deserialfn = InvalidOid; /* can be omitted */
91 Oid mtransfn = InvalidOid; /* can be omitted */
92 Oid minvtransfn = InvalidOid; /* can be omitted */
93 Oid mfinalfn = InvalidOid; /* can be omitted */
94 Oid sortop = InvalidOid; /* can be omitted */
95 Oid *aggArgTypes = parameterTypes->values;
96 bool mtransIsStrict = false;
97 Oid rettype;
100 int nargs_transfn;
101 int nargs_finalfn;
102 Oid procOid;
103 TupleDesc tupDesc;
104 char *detailmsg;
105 int i;
108 ObjectAddresses *addrs;
110
111 /* sanity checks (caller should have caught these) */
112 if (!aggName)
113 elog(ERROR, "no aggregate name supplied");
114
115 if (!aggtransfnName)
116 elog(ERROR, "aggregate must have a transition function");
117
119 elog(ERROR, "incorrect number of direct arguments for aggregate");
120
121 /*
122 * Aggregates can have at most FUNC_MAX_ARGS-1 args, else the transfn
123 * and/or finalfn will be unrepresentable in pg_proc. We must check now
124 * to protect fixed-size arrays here and possibly in called functions.
125 */
129 errmsg_plural("aggregates cannot have more than %d argument",
130 "aggregates cannot have more than %d arguments",
131 FUNC_MAX_ARGS - 1,
132 FUNC_MAX_ARGS - 1)));
133
134 /*
135 * If transtype is polymorphic, must have polymorphic argument also; else
136 * we will have no way to deduce the actual transtype.
137 */
140 numArgs);
141 if (detailmsg)
144 errmsg("cannot determine transition data type"),
145 errdetail_internal("%s", detailmsg)));
146
147 /*
148 * Likewise for moving-aggregate transtype, if any
149 */
151 {
154 numArgs);
155 if (detailmsg)
158 errmsg("cannot determine transition data type"),
159 errdetail_internal("%s", detailmsg)));
160 }
161
162 /*
163 * An ordered-set aggregate that is VARIADIC must be VARIADIC ANY. In
164 * principle we could support regular variadic types, but it would make
165 * things much more complicated because we'd have to assemble the correct
166 * subsets of arguments into array values. Since no standard aggregates
167 * have use for such a case, we aren't bothering for now.
168 */
173 errmsg("a variadic ordered-set aggregate must use VARIADIC type ANY")));
174
175 /*
176 * If it's a hypothetical-set aggregate, there must be at least as many
177 * direct arguments as aggregated ones, and the last N direct arguments
178 * must match the aggregated ones in type. (We have to check this again
179 * when the aggregate is called, in case ANY is involved, but it makes
180 * sense to reject the aggregate definition now if the declared arg types
181 * don't match up.) It's unconditionally OK if numDirectArgs == numArgs,
182 * indicating that the grammar merged identical VARIADIC entries from both
183 * lists. Otherwise, if the agg is VARIADIC, then we had VARIADIC only on
184 * the aggregated side, which is not OK. Otherwise, insist on the last N
185 * parameter types on each side matching exactly.
186 */
189 {
191
196 numAggregatedArgs * sizeof(Oid)) != 0)
199 errmsg("a hypothetical-set aggregate must have direct arguments matching its aggregated arguments")));
200 }
201
202 /*
203 * Find the transfn. For ordinary aggs, it takes the transtype plus all
204 * aggregate arguments. For ordered-set aggs, it takes the transtype plus
205 * all aggregated args, but not direct args. However, we have to treat
206 * specially the case where a trailing VARIADIC item is considered to
207 * cover both direct and aggregated args.
208 */
210 {
213 else
214 {
215 /* special case with VARIADIC last arg */
217 nargs_transfn = 2;
218 }
219 fnArgs[0] = aggTransType;
221 (nargs_transfn - 1) * sizeof(Oid));
222 }
223 else
224 {
226 fnArgs[0] = aggTransType;
227 memcpy(fnArgs + 1, aggArgTypes, numArgs * sizeof(Oid));
228 }
231 &rettype);
232
233 /*
234 * Return type of transfn (possibly after refinement by
235 * enforce_generic_type_consistency, if transtype isn't polymorphic) must
236 * exactly match declared transtype.
237 *
238 * In the non-polymorphic-transtype case, it might be okay to allow a
239 * rettype that's binary-coercible to transtype, but I'm not quite
240 * convinced that it's either safe or useful. When transtype is
241 * polymorphic we *must* demand exact equality.
242 */
243 if (rettype != aggTransType)
246 errmsg("return type of transition function %s is not %s",
249
251 if (!HeapTupleIsValid(tup))
252 elog(ERROR, "cache lookup failed for function %u", transfn);
253 proc = (Form_pg_proc) GETSTRUCT(tup);
254
255 /*
256 * If the transfn is strict and the initval is NULL, make sure first input
257 * type and transtype are the same (or at least binary-compatible), so
258 * that it's OK to use the first input value as the initial transValue.
259 */
260 if (proc->proisstrict && agginitval == NULL)
261 {
262 if (numArgs < 1 ||
266 errmsg("must not omit initial value when transition function is strict and transition type is not compatible with input type")));
267 }
268
270
271 /* handle moving-aggregate transfn, if supplied */
272 if (aggmtransfnName)
273 {
274 /*
275 * The arguments are the same as for the regular transfn, except that
276 * the transition data type might be different. So re-use the fnArgs
277 * values set up above, except for that one.
278 */
281
284 &rettype);
285
286 /* As above, return type must exactly match declared mtranstype. */
287 if (rettype != aggmTransType)
290 errmsg("return type of transition function %s is not %s",
293
295 if (!HeapTupleIsValid(tup))
296 elog(ERROR, "cache lookup failed for function %u", mtransfn);
297 proc = (Form_pg_proc) GETSTRUCT(tup);
298
299 /*
300 * If the mtransfn is strict and the minitval is NULL, check first
301 * input type and mtranstype are binary-compatible.
302 */
303 if (proc->proisstrict && aggminitval == NULL)
304 {
305 if (numArgs < 1 ||
309 errmsg("must not omit initial value when transition function is strict and transition type is not compatible with input type")));
310 }
311
312 /* Remember if mtransfn is strict; we may need this below */
313 mtransIsStrict = proc->proisstrict;
314
316 }
317
318 /* handle minvtransfn, if supplied */
320 {
321 /*
322 * This must have the same number of arguments with the same types as
323 * the forward transition function, so just re-use the fnArgs data.
324 */
326
329 &rettype);
330
331 /* As above, return type must exactly match declared mtranstype. */
332 if (rettype != aggmTransType)
335 errmsg("return type of inverse transition function %s is not %s",
338
340 if (!HeapTupleIsValid(tup))
341 elog(ERROR, "cache lookup failed for function %u", minvtransfn);
342 proc = (Form_pg_proc) GETSTRUCT(tup);
343
344 /*
345 * We require the strictness settings of the forward and inverse
346 * transition functions to agree. This saves having to handle
347 * assorted special cases at execution time.
348 */
349 if (proc->proisstrict != mtransIsStrict)
352 errmsg("strictness of aggregate's forward and inverse transition functions must match")));
353
355 }
356
357 /* handle finalfn, if supplied */
358 if (aggfinalfnName)
359 {
360 /*
361 * If finalfnExtraArgs is specified, the transfn takes the transtype
362 * plus all args; otherwise, it just takes the transtype plus any
363 * direct args. (Non-direct args are useless at runtime, and are
364 * actually passed as NULLs, but we may need them in the function
365 * signature to allow resolution of a polymorphic agg's result type.)
366 */
368
369 fnArgs[0] = aggTransType;
370 memcpy(fnArgs + 1, aggArgTypes, numArgs * sizeof(Oid));
373 else
374 {
377 {
378 /* variadic argument doesn't affect finalfn */
380 }
381 }
382
385 &finaltype);
386
387 /*
388 * When finalfnExtraArgs is specified, the finalfn will certainly be
389 * passed at least one null argument, so complain if it's strict.
390 * Nothing bad would happen at runtime (you'd just get a null result),
391 * but it's surely not what the user wants, so let's complain now.
392 */
393 if (finalfnExtraArgs && func_strict(finalfn))
396 errmsg("final function with extra arguments must not be declared STRICT")));
397 }
398 else
399 {
400 /*
401 * If no finalfn, aggregate result type is type of the state value
402 */
404 }
406
407 /* handle the combinefn, if supplied */
409 {
411
412 /*
413 * Combine function must have 2 arguments, each of which is the trans
414 * type. VARIADIC doesn't affect it.
415 */
416 fnArgs[0] = aggTransType;
417 fnArgs[1] = aggTransType;
418
421 &combineType);
422
423 /* Ensure the return type matches the aggregate's trans type */
427 errmsg("return type of combine function %s is not %s",
430
431 /*
432 * A combine function to combine INTERNAL states must accept nulls and
433 * ensure that the returned state is in the correct memory context. We
434 * cannot directly check the latter, but we can check the former.
435 */
439 errmsg("combine function with transition type %s must not be declared STRICT",
441 }
442
443 /*
444 * Validate the serialization function, if present.
445 */
446 if (aggserialfnName)
447 {
448 /* signature is always serialize(internal) returns bytea */
449 fnArgs[0] = INTERNALOID;
450
453 &rettype);
454
455 if (rettype != BYTEAOID)
458 errmsg("return type of serialization function %s is not %s",
461 }
462
463 /*
464 * Validate the deserialization function, if present.
465 */
467 {
468 /* signature is always deserialize(bytea, internal) returns internal */
469 fnArgs[0] = BYTEAOID;
470 fnArgs[1] = INTERNALOID; /* dummy argument for type safety */
471
474 &rettype);
475
476 if (rettype != INTERNALOID)
479 errmsg("return type of deserialization function %s is not %s",
482 }
483
484 /*
485 * If finaltype (i.e. aggregate return type) is polymorphic, inputs must
486 * be polymorphic also, else parser will fail to deduce result type.
487 * (Note: given the previous test on transtype and inputs, this cannot
488 * happen, unless someone has snuck a finalfn definition into the catalogs
489 * that itself violates the rule against polymorphic result with no
490 * polymorphic input.)
491 */
494 numArgs);
495 if (detailmsg)
498 errmsg("cannot determine result data type"),
499 errdetail_internal("%s", detailmsg)));
500
501 /*
502 * Also, the return type can't be INTERNAL unless there's at least one
503 * INTERNAL argument. This is the same type-safety restriction we enforce
504 * for regular functions, but at the level of aggregates. We must test
505 * this explicitly because we allow INTERNAL as the transtype.
506 */
509 numArgs);
510 if (detailmsg)
513 errmsg("unsafe use of pseudo-type \"internal\""),
514 errdetail_internal("%s", detailmsg)));
515
516 /*
517 * If a moving-aggregate implementation is supplied, look up its finalfn
518 * if any, and check that the implied aggregate result type matches the
519 * plain implementation.
520 */
522 {
523 /* handle finalfn, if supplied */
524 if (aggmfinalfnName)
525 {
526 /*
527 * The arguments are figured the same way as for the regular
528 * finalfn, but using aggmTransType and mfinalfnExtraArgs.
529 */
531
533 memcpy(fnArgs + 1, aggArgTypes, numArgs * sizeof(Oid));
536 else
537 {
540 {
541 /* variadic argument doesn't affect finalfn */
543 }
544 }
545
548 &rettype);
549
550 /* As above, check strictness if mfinalfnExtraArgs is given */
554 errmsg("final function with extra arguments must not be declared STRICT")));
555 }
556 else
557 {
558 /*
559 * If no finalfn, aggregate result type is type of the state value
560 */
561 rettype = aggmTransType;
562 }
563 Assert(OidIsValid(rettype));
564 if (rettype != finaltype)
567 errmsg("moving-aggregate implementation returns type %s, but plain implementation returns type %s",
568 format_type_be(rettype),
570 }
571
572 /* handle sortop, if supplied */
573 if (aggsortopName)
574 {
575 if (numArgs != 1)
578 errmsg("sort operator can only be specified for single-argument aggregates")));
581 false, -1);
582 }
583
584 /*
585 * permission checks on used types
586 */
587 for (i = 0; i < numArgs; i++)
588 {
590 if (aclresult != ACLCHECK_OK)
592 }
593
595 if (aclresult != ACLCHECK_OK)
597
599 {
601 if (aclresult != ACLCHECK_OK)
603 }
604
606 if (aclresult != ACLCHECK_OK)
608
609
610 /*
611 * Everything looks okay. Try to create the pg_proc entry for the
612 * aggregate. (This could fail if there's already a conflicting entry.)
613 */
614
617 replace, /* maybe replacement */
618 false, /* doesn't return a set */
619 finaltype, /* returnType */
620 GetUserId(), /* proowner */
621 INTERNALlanguageId, /* languageObjectId */
622 InvalidOid, /* no validator */
623 "aggregate_dummy", /* placeholder (no such proc) */
624 NULL, /* probin */
625 NULL, /* prosqlbody */
627 false, /* security invoker (currently not
628 * definable for agg) */
629 false, /* isLeakProof */
630 false, /* isStrict (not needed for agg) */
631 PROVOLATILE_IMMUTABLE, /* volatility (not needed
632 * for agg) */
634 parameterTypes, /* paramTypes */
635 allParameterTypes, /* allParamTypes */
636 parameterModes, /* parameterModes */
637 parameterNames, /* parameterNames */
638 parameterDefaults, /* parameterDefaults */
639 PointerGetDatum(NULL), /* trftypes */
640 NIL, /* trfoids */
641 PointerGetDatum(NULL), /* proconfig */
642 InvalidOid, /* no prosupport */
643 1, /* procost */
644 0); /* prorows */
645 procOid = myself.objectId;
646
647 /*
648 * Okay to create the pg_aggregate entry.
649 */
651 tupDesc = aggdesc->rd_att;
652
653 /* initialize nulls and values */
654 for (i = 0; i < Natts_pg_aggregate; i++)
655 {
656 nulls[i] = false;
657 values[i] = (Datum) 0;
658 replaces[i] = true;
659 }
680 if (agginitval)
682 else
683 nulls[Anum_pg_aggregate_agginitval - 1] = true;
684 if (aggminitval)
686 else
687 nulls[Anum_pg_aggregate_aggminitval - 1] = true;
688
689 if (replace)
691 else
692 oldtup = NULL;
693
695 {
697
698 /*
699 * If we're replacing an existing entry, we need to validate that
700 * we're not changing anything that would break callers. Specifically
701 * we must not change aggkind or aggnumdirectargs, which affect how an
702 * aggregate call is treated in parse analysis.
703 */
704 if (aggKind != oldagg->aggkind)
707 errmsg("cannot change routine kind"),
708 (oldagg->aggkind == AGGKIND_NORMAL ?
709 errdetail("\"%s\" is an ordinary aggregate function.", aggName) :
711 errdetail("\"%s\" is an ordered-set aggregate.", aggName) :
713 errdetail("\"%s\" is a hypothetical-set aggregate.", aggName) :
714 0)));
715 if (numDirectArgs != oldagg->aggnumdirectargs)
718 errmsg("cannot change number of direct arguments of an aggregate function")));
719
723
724 tup = heap_modify_tuple(oldtup, tupDesc, values, nulls, replaces);
725 CatalogTupleUpdate(aggdesc, &tup->t_self, tup);
727 }
728 else
729 {
730 tup = heap_form_tuple(tupDesc, values, nulls);
732 }
733
735
736 /*
737 * Create dependencies for the aggregate (above and beyond those already
738 * made by ProcedureCreate). Note: we don't need an explicit dependency
739 * on aggTransType since we depend on it indirectly through transfn.
740 * Likewise for aggmTransType using the mtransfn, if it exists.
741 *
742 * If we're replacing an existing definition, ProcedureCreate deleted all
743 * our existing dependencies, so we have to do the same things here either
744 * way.
745 */
746
747 addrs = new_object_addresses();
748
749 /* Depends on transition function */
752
753 /* Depends on final function, if any */
754 if (OidIsValid(finalfn))
755 {
758 }
759
760 /* Depends on combine function, if any */
762 {
765 }
766
767 /* Depends on serialization function, if any */
768 if (OidIsValid(serialfn))
769 {
772 }
773
774 /* Depends on deserialization function, if any */
775 if (OidIsValid(deserialfn))
776 {
779 }
780
781 /* Depends on forward transition function, if any */
782 if (OidIsValid(mtransfn))
783 {
786 }
787
788 /* Depends on inverse transition function, if any */
790 {
793 }
794
795 /* Depends on final function, if any */
796 if (OidIsValid(mfinalfn))
797 {
800 }
801
802 /* Depends on sort operator, if any */
803 if (OidIsValid(sortop))
804 {
807 }
808
811 return myself;
812}
AclResult
Definition acl.h:183
@ ACLCHECK_OK
Definition acl.h:184
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition aclchk.c:3902
void aclcheck_error_type(AclResult aclerr, Oid typeOid)
Definition aclchk.c:2997
static Datum values[MAXATTR]
Definition bootstrap.c:190
#define CStringGetTextDatum(s)
Definition builtins.h:98
#define Assert(condition)
Definition c.h:1002
#define OidIsValid(objectId)
Definition c.h:917
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void free_object_addresses(ObjectAddresses *addrs)
@ DEPENDENCY_NORMAL
Definition dependency.h:33
int errcode(int sqlerrcode)
Definition elog.c:875
int int errdetail_internal(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
#define ereport(elevel,...)
Definition elog.h:152
char * format_type_be(Oid type_oid)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
Definition heaptuple.c:1118
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition heaptuple.c:1025
#define HeapTupleIsValid(tuple)
Definition htup.h:78
static void * GETSTRUCT(const HeapTupleData *tuple)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
Definition indexing.c:313
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition indexing.c:233
int i
Definition isn.c:77
#define RowExclusiveLock
Definition lockdefs.h:38
bool func_strict(Oid funcid)
Definition lsyscache.c:2075
Oid GetUserId(void)
Definition miscinit.c:470
char * NameListToString(const List *names)
Definition namespace.c:3666
static char * errmsg
#define ObjectAddressSet(addr, class_id, object_id)
char * check_valid_internal_signature(Oid ret_type, const Oid *declared_arg_types, int nargs)
char * check_valid_polymorphic_signature(Oid ret_type, const Oid *declared_arg_types, int nargs)
bool IsBinaryCoercible(Oid srctype, Oid targettype)
Oid LookupOperName(ParseState *pstate, List *opername, Oid oprleft, Oid oprright, bool noError, int location)
Definition parse_oper.c:102
#define ACL_USAGE
Definition parsenodes.h:84
static Oid lookup_agg_function(List *fnName, int nargs, Oid *input_types, Oid variadicArgType, Oid *rettype)
END_CATALOG_STRUCT typedef FormData_pg_aggregate * Form_pg_aggregate
#define FUNC_MAX_ARGS
#define NIL
Definition pg_list.h:68
ObjectAddress ProcedureCreate(const char *procedureName, Oid procNamespace, bool replace, bool returnsSet, Oid returnType, Oid proowner, Oid languageObjectId, Oid languageValidator, const char *prosrc, const char *probin, Node *prosqlbody, char prokind, bool security_definer, bool isLeakProof, bool isStrict, char volatility, char parallel, oidvector *parameterTypes, Datum allParameterTypes, Datum parameterModes, Datum parameterNames, List *parameterDefaults, Datum trftypes, List *trfoids, Datum proconfig, Oid prosupport, float4 procost, float4 prorows)
Definition pg_proc.c:99
END_CATALOG_STRUCT typedef FormData_pg_proc * Form_pg_proc
Definition pg_proc.h:140
static Datum Int16GetDatum(int16 X)
Definition postgres.h:172
static Datum BoolGetDatum(bool X)
Definition postgres.h:112
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
uint64_t Datum
Definition postgres.h:70
static Datum Int32GetDatum(int32 X)
Definition postgres.h:212
#define PointerGetDatum(X)
Definition postgres.h:354
static Datum CharGetDatum(char X)
Definition postgres.h:132
#define InvalidOid
unsigned int Oid
static int fb(int x)
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition c.h:881
void ReleaseSysCache(HeapTuple tuple)
Definition syscache.c:265
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Definition syscache.c:221
void table_close(Relation relation, LOCKMODE lockmode)
Definition table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition table.c:40

References ACL_USAGE, aclcheck_error_type(), ACLCHECK_OK, add_exact_object_address(), Assert, BoolGetDatum(), CatalogTupleInsert(), CatalogTupleUpdate(), CharGetDatum(), check_valid_internal_signature(), check_valid_polymorphic_signature(), CStringGetTextDatum, DEPENDENCY_NORMAL, elog, ereport, errcode(), errdetail(), errdetail_internal(), errmsg, errmsg_plural(), ERROR, fb(), Form_pg_aggregate, Form_pg_proc, format_type_be(), free_object_addresses(), FUNC_MAX_ARGS, func_strict(), GETSTRUCT(), GetUserId(), heap_form_tuple(), heap_modify_tuple(), HeapTupleIsValid, i, Int16GetDatum(), Int32GetDatum(), InvalidOid, IsBinaryCoercible(), lookup_agg_function(), LookupOperName(), memcpy(), NameListToString(), new_object_addresses(), NIL, object_aclcheck(), ObjectAddressSet, ObjectIdGetDatum(), OidIsValid, PointerGetDatum, ProcedureCreate(), record_object_address_dependencies(), ReleaseSysCache(), RowExclusiveLock, SearchSysCache1(), table_close(), table_open(), oidvector::values, and values.

Referenced by DefineAggregate().

◆ CATALOG()

BEGIN_CATALOG_STRUCT CATALOG ( pg_aggregate  ,
2600  ,
AggregateRelationId   
)

Definition at line 34 of file pg_aggregate.h.

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
Oid regproc
Definition c.h:792
int16_t int16
Definition c.h:678
int32_t int32
Definition c.h:679
#define BKI_LOOKUP(catalog)
Definition genbki.h:65
#define BKI_DEFAULT(value)
Definition genbki.h:54
#define BKI_LOOKUP_OPT(catalog)
Definition genbki.h:66
FormData_pg_aggregate
Definition c.h:835

References BKI_DEFAULT, BKI_LOOKUP, BKI_LOOKUP_OPT, and fb().

◆ DECLARE_TOAST()

DECLARE_TOAST ( pg_aggregate  ,
4159  ,
4160   
)

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_aggregate_fnoid_index  ,
2650  ,
AggregateFnoidIndexId  ,
pg_aggregate  ,
btree(aggfnoid oid_ops)   
)

◆ MAKE_SYSCACHE()

MAKE_SYSCACHE ( AGGFNOID  ,
pg_aggregate_fnoid_index  ,
16   
)

Variable Documentation

◆ Form_pg_aggregate

◆ FormData_pg_aggregate

FormData_pg_aggregate

Definition at line 104 of file pg_aggregate.h.