]> granicus.if.org Git - postgresql/blob - src/include/catalog/pg_aggregate.h
Fix final function for cash avg() aggregate.
[postgresql] / src / include / catalog / pg_aggregate.h
1 /*-------------------------------------------------------------------------
2  *
3  * pg_aggregate.h--
4  *        definition of the system "aggregate" relation (pg_aggregate)
5  *        along with the relation's initial contents.
6  *
7  *
8  * Copyright (c) 1994, Regents of the University of California
9  *
10  * $Id: pg_aggregate.h,v 1.12 1997/10/15 01:08:25 thomas Exp $
11  *
12  * NOTES
13  *        the genbki.sh script reads this file and generates .bki
14  *        information from the DATA() statements.
15  *
16  *-------------------------------------------------------------------------
17  */
18 #ifndef PG_AGGREGATE_H
19 #define PG_AGGREGATE_H
20
21 /* ----------------
22  *              postgres.h contains the system type definitions and the
23  *              CATALOG(), BOOTSTRAP and DATA() sugar words so this file
24  *              can be read by both genbki.sh and the C compiler.
25  * ----------------
26  */
27
28 /* ----------------------------------------------------------------
29  *              pg_aggregate definition.
30  *
31  *              cpp turns this into typedef struct FormData_pg_aggregate
32  *
33  *      aggname                         name of the aggregate
34  *      aggtransfn1                     transition function 1
35  *      aggtransfn2                     transition function 2
36  *      aggfinalfn                      final function
37  *      aggbasetype                     type of data on which aggregate operates
38  *      aggtranstype1           output types for transition func 1
39  *      aggtranstype2           output types for transition func 2
40  *      aggfinaltype            output type for final function
41  *      agginitval1                     initial aggregate value
42  *      agginitval2                     initial value for transition state 2
43  * ----------------------------------------------------------------
44  */
45 CATALOG(pg_aggregate)
46 {
47         NameData        aggname;
48         Oid                     aggowner;
49         regproc         aggtransfn1;
50         regproc         aggtransfn2;
51         regproc         aggfinalfn;
52         Oid                     aggbasetype;
53         Oid                     aggtranstype1;
54         Oid                     aggtranstype2;
55         Oid                     aggfinaltype;
56         text            agginitval1;    /* VARIABLE LENGTH FIELD */
57         text            agginitval2;    /* VARIABLE LENGTH FIELD */
58 } FormData_pg_aggregate;
59
60 /* ----------------
61  *              Form_pg_aggregate corresponds to a pointer to a tuple with
62  *              the format of pg_aggregate relation.
63  * ----------------
64  */
65 typedef FormData_pg_aggregate *Form_pg_aggregate;
66
67 /* ----------------
68  *              compiler constants for pg_aggregate
69  * ----------------
70  */
71
72 #define Natts_pg_aggregate                              11
73 #define Anum_pg_aggregate_aggname               1
74 #define Anum_pg_aggregate_aggowner              2
75 #define Anum_pg_aggregate_aggtransfn1   3
76 #define Anum_pg_aggregate_aggtransfn2   4
77 #define Anum_pg_aggregate_aggfinalfn    5
78 #define Anum_pg_aggregate_aggbasetype   6
79 #define Anum_pg_aggregate_aggtranstype1 7
80 #define Anum_pg_aggregate_aggtranstype2 8
81 #define Anum_pg_aggregate_aggfinaltype  9
82 #define Anum_pg_aggregate_agginitval1   10
83 #define Anum_pg_aggregate_agginitval2   11
84
85
86 /* ----------------
87  * initial contents of pg_aggregate
88  * ---------------
89  */
90
91 DATA(insert OID = 0 ( avg       PGUID int4pl      int4inc   int4div         23   23   23   23 _null_ 0 ));
92 DATA(insert OID = 0 ( avg       PGUID int2pl      int2inc   int2div         21   21   21   21 _null_ 0 ));
93 DATA(insert OID = 0 ( avg       PGUID float4pl    float4inc float4div      700  700  700  700 _null_ 0.0 ));
94 DATA(insert OID = 0 ( avg       PGUID float8pl    float8inc float8div      701  701  701  701 _null_ 0.0 ));
95 DATA(insert OID = 0 ( avg       PGUID cash_pl     float8inc cash_div_flt8  790  790  701  790 _null_ 0.0 ));
96 DATA(insert OID = 0 ( avg       PGUID timespan_pl float8inc timespan_div  1186 1186  701 1186 _null_ 0.0 ));
97
98 DATA(insert OID = 0 ( sum       PGUID int4pl            - -   23   23 0   23 _null_ _null_ ));
99 DATA(insert OID = 0 ( sum       PGUID int2pl            - -   21   21 0   21 _null_ _null_ ));
100 DATA(insert OID = 0 ( sum       PGUID float4pl          - -  700  700 0  700 _null_ _null_ ));
101 DATA(insert OID = 0 ( sum       PGUID float8pl          - -  701  701 0  701 _null_ _null_ ));
102 DATA(insert OID = 0 ( sum       PGUID cash_pl           - -  790  790 0  790 _null_ _null_ ));
103 DATA(insert OID = 0 ( sum       PGUID timespan_pl       - -  1186 1186 0 1186 _null_ _null_ ));
104
105 DATA(insert OID = 0 ( max       PGUID int4larger          - -   23       23 0   23 _null_ _null_ ));
106 DATA(insert OID = 0 ( max       PGUID int2larger          - -   21       21 0   21 _null_ _null_ ));
107 DATA(insert OID = 0 ( max       PGUID float4larger        - -  700      700 0  700 _null_ _null_ ));
108 DATA(insert OID = 0 ( max       PGUID float8larger        - -  701      701 0  701 _null_ _null_ ));
109 DATA(insert OID = 0 ( max       PGUID int4larger          - -  702      702 0  702 _null_ _null_ ));
110 DATA(insert OID = 0 ( max       PGUID date_larger         - - 1082 1082 0 1082 _null_ _null_ ));
111 DATA(insert OID = 0 ( max       PGUID float8larger        - - 1084 1084 0 1084 _null_ _null_ ));
112 DATA(insert OID = 0 ( max       PGUID cashlarger          - -  790      790 0  790 _null_ _null_ ));
113 DATA(insert OID = 0 ( max       PGUID datetime_larger - - 1184 1184 0 1184 _null_ _null_ ));
114 DATA(insert OID = 0 ( max       PGUID timespan_larger - - 1186 1186 0 1186 _null_ _null_ ));
115
116 DATA(insert OID = 0 ( min       PGUID int4smaller          - -   23   23 0       23 _null_ _null_ ));
117 DATA(insert OID = 0 ( min       PGUID int2smaller          - -   21   21 0       21 _null_ _null_ ));
118 DATA(insert OID = 0 ( min       PGUID float4smaller    - -      700  700 0      700 _null_ _null_ ));
119 DATA(insert OID = 0 ( min       PGUID float8smaller    - -      701  701 0      701 _null_ _null_ ));
120 DATA(insert OID = 0 ( min       PGUID int4smaller          - -  702  702 0      702 _null_ _null_ ));
121 DATA(insert OID = 0 ( min       PGUID date_smaller         - - 1082 1082 0 1082 _null_ _null_ ));
122 DATA(insert OID = 0 ( min       PGUID float8smaller    - - 1084 1084 0 1084 _null_ _null_ ));
123 DATA(insert OID = 0 ( min       PGUID cashsmaller          - -  790  790 0      790 _null_ _null_ ));
124 DATA(insert OID = 0 ( min       PGUID datetime_smaller - - 1184 1184 0 1184 _null_ _null_ ));
125 DATA(insert OID = 0 ( min       PGUID timespan_smaller - - 1186 1186 0 1186 _null_ _null_ ));
126
127 DATA(insert OID = 0 ( count PGUID - int4inc - 0 0 23 23 _null_ 0 ));
128
129 /*
130  * prototypes for functions in pg_aggregate.c
131  */
132 extern void
133 AggregateCreate(char *aggName,
134                                 char *aggtransfn1Name,
135                                 char *aggtransfn2Name,
136                                 char *aggfinalfnName,
137                                 char *aggbasetypeName,
138                                 char *aggtransfn1typeName,
139                                 char *aggtransfn2typeName,
140                                 char *agginitval1,
141                                 char *agginitval2);
142 extern char *
143 AggNameGetInitVal(char *aggName, Oid basetype,
144                                   int xfuncno, bool *isNull);
145
146 #endif                                                  /* PG_AGGREGATE_H */