PageRenderTime 79ms CodeModel.GetById 26ms RepoModel.GetById 5ms app.codeStats 0ms

/src/include/catalog/pg_aggregate.h

https://bitbucket.org/gencer/postgres
C Header | 298 lines | 185 code | 34 blank | 79 comment | 1 complexity | f9cd4abdd05580384c2664d0d344eff7 MD5 | raw file
Possible License(s): AGPL-3.0
  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. * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
  9. * Portions Copyright (c) 1994, Regents of the University of California
  10. *
  11. * src/include/catalog/pg_aggregate.h
  12. *
  13. * NOTES
  14. * the genbki.pl script reads this file and generates .bki
  15. * information from the DATA() statements.
  16. *
  17. *-------------------------------------------------------------------------
  18. */
  19. #ifndef PG_AGGREGATE_H
  20. #define PG_AGGREGATE_H
  21. #include "catalog/genbki.h"
  22. #include "nodes/pg_list.h"
  23. /* ----------------------------------------------------------------
  24. * pg_aggregate definition.
  25. *
  26. * cpp turns this into typedef struct FormData_pg_aggregate
  27. *
  28. * aggfnoid pg_proc OID of the aggregate itself
  29. * aggkind aggregate kind, see AGGKIND_ categories below
  30. * aggnumdirectargs number of arguments that are "direct" arguments
  31. * aggtransfn transition function
  32. * aggfinalfn final function (0 if none)
  33. * aggsortop associated sort operator (0 if none)
  34. * aggtranstype type of aggregate's transition (state) data
  35. * aggtransspace estimated size of state data (0 for default estimate)
  36. * agginitval initial value for transition state (can be NULL)
  37. * ----------------------------------------------------------------
  38. */
  39. #define AggregateRelationId 2600
  40. CATALOG(pg_aggregate,2600) BKI_WITHOUT_OIDS
  41. {
  42. regproc aggfnoid;
  43. char aggkind;
  44. int16 aggnumdirectargs;
  45. regproc aggtransfn;
  46. regproc aggfinalfn;
  47. Oid aggsortop;
  48. Oid aggtranstype;
  49. int32 aggtransspace;
  50. #ifdef CATALOG_VARLEN /* variable-length fields start here */
  51. text agginitval;
  52. #endif
  53. } FormData_pg_aggregate;
  54. /* ----------------
  55. * Form_pg_aggregate corresponds to a pointer to a tuple with
  56. * the format of pg_aggregate relation.
  57. * ----------------
  58. */
  59. typedef FormData_pg_aggregate *Form_pg_aggregate;
  60. /* ----------------
  61. * compiler constants for pg_aggregate
  62. * ----------------
  63. */
  64. #define Natts_pg_aggregate 9
  65. #define Anum_pg_aggregate_aggfnoid 1
  66. #define Anum_pg_aggregate_aggkind 2
  67. #define Anum_pg_aggregate_aggnumdirectargs 3
  68. #define Anum_pg_aggregate_aggtransfn 4
  69. #define Anum_pg_aggregate_aggfinalfn 5
  70. #define Anum_pg_aggregate_aggsortop 6
  71. #define Anum_pg_aggregate_aggtranstype 7
  72. #define Anum_pg_aggregate_aggtransspace 8
  73. #define Anum_pg_aggregate_agginitval 9
  74. /*
  75. * Symbolic values for aggkind column. We distinguish normal aggregates
  76. * from ordered-set aggregates (which have two sets of arguments, namely
  77. * direct and aggregated arguments) and from hypothetical-set aggregates
  78. * (which are a subclass of ordered-set aggregates in which the last
  79. * direct arguments have to match up in number and datatypes with the
  80. * aggregated arguments).
  81. */
  82. #define AGGKIND_NORMAL 'n'
  83. #define AGGKIND_ORDERED_SET 'o'
  84. #define AGGKIND_HYPOTHETICAL 'h'
  85. /* Use this macro to test for "ordered-set agg including hypothetical case" */
  86. #define AGGKIND_IS_ORDERED_SET(kind) ((kind) != AGGKIND_NORMAL)
  87. /* ----------------
  88. * initial contents of pg_aggregate
  89. * ---------------
  90. */
  91. /* avg */
  92. DATA(insert ( 2100 n 0 int8_avg_accum numeric_avg 0 2281 128 _null_ ));
  93. DATA(insert ( 2101 n 0 int4_avg_accum int8_avg 0 1016 0 "{0,0}" ));
  94. DATA(insert ( 2102 n 0 int2_avg_accum int8_avg 0 1016 0 "{0,0}" ));
  95. DATA(insert ( 2103 n 0 numeric_avg_accum numeric_avg 0 2281 128 _null_ ));
  96. DATA(insert ( 2104 n 0 float4_accum float8_avg 0 1022 0 "{0,0,0}" ));
  97. DATA(insert ( 2105 n 0 float8_accum float8_avg 0 1022 0 "{0,0,0}" ));
  98. DATA(insert ( 2106 n 0 interval_accum interval_avg 0 1187 0 "{0 second,0 second}" ));
  99. /* sum */
  100. DATA(insert ( 2107 n 0 int8_avg_accum numeric_sum 0 2281 128 _null_ ));
  101. DATA(insert ( 2108 n 0 int4_sum - 0 20 0 _null_ ));
  102. DATA(insert ( 2109 n 0 int2_sum - 0 20 0 _null_ ));
  103. DATA(insert ( 2110 n 0 float4pl - 0 700 0 _null_ ));
  104. DATA(insert ( 2111 n 0 float8pl - 0 701 0 _null_ ));
  105. DATA(insert ( 2112 n 0 cash_pl - 0 790 0 _null_ ));
  106. DATA(insert ( 2113 n 0 interval_pl - 0 1186 0 _null_ ));
  107. DATA(insert ( 2114 n 0 numeric_avg_accum numeric_sum 0 2281 128 _null_ ));
  108. /* max */
  109. DATA(insert ( 2115 n 0 int8larger - 413 20 0 _null_ ));
  110. DATA(insert ( 2116 n 0 int4larger - 521 23 0 _null_ ));
  111. DATA(insert ( 2117 n 0 int2larger - 520 21 0 _null_ ));
  112. DATA(insert ( 2118 n 0 oidlarger - 610 26 0 _null_ ));
  113. DATA(insert ( 2119 n 0 float4larger - 623 700 0 _null_ ));
  114. DATA(insert ( 2120 n 0 float8larger - 674 701 0 _null_ ));
  115. DATA(insert ( 2121 n 0 int4larger - 563 702 0 _null_ ));
  116. DATA(insert ( 2122 n 0 date_larger - 1097 1082 0 _null_ ));
  117. DATA(insert ( 2123 n 0 time_larger - 1112 1083 0 _null_ ));
  118. DATA(insert ( 2124 n 0 timetz_larger - 1554 1266 0 _null_ ));
  119. DATA(insert ( 2125 n 0 cashlarger - 903 790 0 _null_ ));
  120. DATA(insert ( 2126 n 0 timestamp_larger - 2064 1114 0 _null_ ));
  121. DATA(insert ( 2127 n 0 timestamptz_larger - 1324 1184 0 _null_ ));
  122. DATA(insert ( 2128 n 0 interval_larger - 1334 1186 0 _null_ ));
  123. DATA(insert ( 2129 n 0 text_larger - 666 25 0 _null_ ));
  124. DATA(insert ( 2130 n 0 numeric_larger - 1756 1700 0 _null_ ));
  125. DATA(insert ( 2050 n 0 array_larger - 1073 2277 0 _null_ ));
  126. DATA(insert ( 2244 n 0 bpchar_larger - 1060 1042 0 _null_ ));
  127. DATA(insert ( 2797 n 0 tidlarger - 2800 27 0 _null_ ));
  128. DATA(insert ( 3526 n 0 enum_larger - 3519 3500 0 _null_ ));
  129. /* min */
  130. DATA(insert ( 2131 n 0 int8smaller - 412 20 0 _null_ ));
  131. DATA(insert ( 2132 n 0 int4smaller - 97 23 0 _null_ ));
  132. DATA(insert ( 2133 n 0 int2smaller - 95 21 0 _null_ ));
  133. DATA(insert ( 2134 n 0 oidsmaller - 609 26 0 _null_ ));
  134. DATA(insert ( 2135 n 0 float4smaller - 622 700 0 _null_ ));
  135. DATA(insert ( 2136 n 0 float8smaller - 672 701 0 _null_ ));
  136. DATA(insert ( 2137 n 0 int4smaller - 562 702 0 _null_ ));
  137. DATA(insert ( 2138 n 0 date_smaller - 1095 1082 0 _null_ ));
  138. DATA(insert ( 2139 n 0 time_smaller - 1110 1083 0 _null_ ));
  139. DATA(insert ( 2140 n 0 timetz_smaller - 1552 1266 0 _null_ ));
  140. DATA(insert ( 2141 n 0 cashsmaller - 902 790 0 _null_ ));
  141. DATA(insert ( 2142 n 0 timestamp_smaller - 2062 1114 0 _null_ ));
  142. DATA(insert ( 2143 n 0 timestamptz_smaller - 1322 1184 0 _null_ ));
  143. DATA(insert ( 2144 n 0 interval_smaller - 1332 1186 0 _null_ ));
  144. DATA(insert ( 2145 n 0 text_smaller - 664 25 0 _null_ ));
  145. DATA(insert ( 2146 n 0 numeric_smaller - 1754 1700 0 _null_ ));
  146. DATA(insert ( 2051 n 0 array_smaller - 1072 2277 0 _null_ ));
  147. DATA(insert ( 2245 n 0 bpchar_smaller - 1058 1042 0 _null_ ));
  148. DATA(insert ( 2798 n 0 tidsmaller - 2799 27 0 _null_ ));
  149. DATA(insert ( 3527 n 0 enum_smaller - 3518 3500 0 _null_ ));
  150. /* count */
  151. DATA(insert ( 2147 n 0 int8inc_any - 0 20 0 "0" ));
  152. DATA(insert ( 2803 n 0 int8inc - 0 20 0 "0" ));
  153. /* var_pop */
  154. DATA(insert ( 2718 n 0 int8_accum numeric_var_pop 0 2281 128 _null_ ));
  155. DATA(insert ( 2719 n 0 int4_accum numeric_var_pop 0 2281 128 _null_ ));
  156. DATA(insert ( 2720 n 0 int2_accum numeric_var_pop 0 2281 128 _null_ ));
  157. DATA(insert ( 2721 n 0 float4_accum float8_var_pop 0 1022 0 "{0,0,0}" ));
  158. DATA(insert ( 2722 n 0 float8_accum float8_var_pop 0 1022 0 "{0,0,0}" ));
  159. DATA(insert ( 2723 n 0 numeric_accum numeric_var_pop 0 2281 128 _null_ ));
  160. /* var_samp */
  161. DATA(insert ( 2641 n 0 int8_accum numeric_var_samp 0 2281 128 _null_ ));
  162. DATA(insert ( 2642 n 0 int4_accum numeric_var_samp 0 2281 128 _null_ ));
  163. DATA(insert ( 2643 n 0 int2_accum numeric_var_samp 0 2281 128 _null_ ));
  164. DATA(insert ( 2644 n 0 float4_accum float8_var_samp 0 1022 0 "{0,0,0}" ));
  165. DATA(insert ( 2645 n 0 float8_accum float8_var_samp 0 1022 0 "{0,0,0}" ));
  166. DATA(insert ( 2646 n 0 numeric_accum numeric_var_samp 0 2281 128 _null_ ));
  167. /* variance: historical Postgres syntax for var_samp */
  168. DATA(insert ( 2148 n 0 int8_accum numeric_var_samp 0 2281 128 _null_ ));
  169. DATA(insert ( 2149 n 0 int4_accum numeric_var_samp 0 2281 128 _null_ ));
  170. DATA(insert ( 2150 n 0 int2_accum numeric_var_samp 0 2281 128 _null_ ));
  171. DATA(insert ( 2151 n 0 float4_accum float8_var_samp 0 1022 0 "{0,0,0}" ));
  172. DATA(insert ( 2152 n 0 float8_accum float8_var_samp 0 1022 0 "{0,0,0}" ));
  173. DATA(insert ( 2153 n 0 numeric_accum numeric_var_samp 0 2281 128 _null_ ));
  174. /* stddev_pop */
  175. DATA(insert ( 2724 n 0 int8_accum numeric_stddev_pop 0 2281 128 _null_ ));
  176. DATA(insert ( 2725 n 0 int4_accum numeric_stddev_pop 0 2281 128 _null_ ));
  177. DATA(insert ( 2726 n 0 int2_accum numeric_stddev_pop 0 2281 128 _null_ ));
  178. DATA(insert ( 2727 n 0 float4_accum float8_stddev_pop 0 1022 0 "{0,0,0}" ));
  179. DATA(insert ( 2728 n 0 float8_accum float8_stddev_pop 0 1022 0 "{0,0,0}" ));
  180. DATA(insert ( 2729 n 0 numeric_accum numeric_stddev_pop 0 2281 128 _null_ ));
  181. /* stddev_samp */
  182. DATA(insert ( 2712 n 0 int8_accum numeric_stddev_samp 0 2281 128 _null_ ));
  183. DATA(insert ( 2713 n 0 int4_accum numeric_stddev_samp 0 2281 128 _null_ ));
  184. DATA(insert ( 2714 n 0 int2_accum numeric_stddev_samp 0 2281 128 _null_ ));
  185. DATA(insert ( 2715 n 0 float4_accum float8_stddev_samp 0 1022 0 "{0,0,0}" ));
  186. DATA(insert ( 2716 n 0 float8_accum float8_stddev_samp 0 1022 0 "{0,0,0}" ));
  187. DATA(insert ( 2717 n 0 numeric_accum numeric_stddev_samp 0 2281 128 _null_ ));
  188. /* stddev: historical Postgres syntax for stddev_samp */
  189. DATA(insert ( 2154 n 0 int8_accum numeric_stddev_samp 0 2281 128 _null_ ));
  190. DATA(insert ( 2155 n 0 int4_accum numeric_stddev_samp 0 2281 128 _null_ ));
  191. DATA(insert ( 2156 n 0 int2_accum numeric_stddev_samp 0 2281 128 _null_ ));
  192. DATA(insert ( 2157 n 0 float4_accum float8_stddev_samp 0 1022 0 "{0,0,0}" ));
  193. DATA(insert ( 2158 n 0 float8_accum float8_stddev_samp 0 1022 0 "{0,0,0}" ));
  194. DATA(insert ( 2159 n 0 numeric_accum numeric_stddev_samp 0 2281 128 _null_ ));
  195. /* SQL2003 binary regression aggregates */
  196. DATA(insert ( 2818 n 0 int8inc_float8_float8 - 0 20 0 "0" ));
  197. DATA(insert ( 2819 n 0 float8_regr_accum float8_regr_sxx 0 1022 0 "{0,0,0,0,0,0}" ));
  198. DATA(insert ( 2820 n 0 float8_regr_accum float8_regr_syy 0 1022 0 "{0,0,0,0,0,0}" ));
  199. DATA(insert ( 2821 n 0 float8_regr_accum float8_regr_sxy 0 1022 0 "{0,0,0,0,0,0}" ));
  200. DATA(insert ( 2822 n 0 float8_regr_accum float8_regr_avgx 0 1022 0 "{0,0,0,0,0,0}" ));
  201. DATA(insert ( 2823 n 0 float8_regr_accum float8_regr_avgy 0 1022 0 "{0,0,0,0,0,0}" ));
  202. DATA(insert ( 2824 n 0 float8_regr_accum float8_regr_r2 0 1022 0 "{0,0,0,0,0,0}" ));
  203. DATA(insert ( 2825 n 0 float8_regr_accum float8_regr_slope 0 1022 0 "{0,0,0,0,0,0}" ));
  204. DATA(insert ( 2826 n 0 float8_regr_accum float8_regr_intercept 0 1022 0 "{0,0,0,0,0,0}" ));
  205. DATA(insert ( 2827 n 0 float8_regr_accum float8_covar_pop 0 1022 0 "{0,0,0,0,0,0}" ));
  206. DATA(insert ( 2828 n 0 float8_regr_accum float8_covar_samp 0 1022 0 "{0,0,0,0,0,0}" ));
  207. DATA(insert ( 2829 n 0 float8_regr_accum float8_corr 0 1022 0 "{0,0,0,0,0,0}" ));
  208. /* boolean-and and boolean-or */
  209. DATA(insert ( 2517 n 0 booland_statefunc - 58 16 0 _null_ ));
  210. DATA(insert ( 2518 n 0 boolor_statefunc - 59 16 0 _null_ ));
  211. DATA(insert ( 2519 n 0 booland_statefunc - 58 16 0 _null_ ));
  212. /* bitwise integer */
  213. DATA(insert ( 2236 n 0 int2and - 0 21 0 _null_ ));
  214. DATA(insert ( 2237 n 0 int2or - 0 21 0 _null_ ));
  215. DATA(insert ( 2238 n 0 int4and - 0 23 0 _null_ ));
  216. DATA(insert ( 2239 n 0 int4or - 0 23 0 _null_ ));
  217. DATA(insert ( 2240 n 0 int8and - 0 20 0 _null_ ));
  218. DATA(insert ( 2241 n 0 int8or - 0 20 0 _null_ ));
  219. DATA(insert ( 2242 n 0 bitand - 0 1560 0 _null_ ));
  220. DATA(insert ( 2243 n 0 bitor - 0 1560 0 _null_ ));
  221. /* xml */
  222. DATA(insert ( 2901 n 0 xmlconcat2 - 0 142 0 _null_ ));
  223. /* array */
  224. DATA(insert ( 2335 n 0 array_agg_transfn array_agg_finalfn 0 2281 0 _null_ ));
  225. /* text */
  226. DATA(insert ( 3538 n 0 string_agg_transfn string_agg_finalfn 0 2281 0 _null_ ));
  227. /* bytea */
  228. DATA(insert ( 3545 n 0 bytea_string_agg_transfn bytea_string_agg_finalfn 0 2281 0 _null_ ));
  229. /* json */
  230. DATA(insert ( 3175 n 0 json_agg_transfn json_agg_finalfn 0 2281 0 _null_ ));
  231. DATA(insert ( 3197 n 0 json_object_agg_transfn json_object_agg_finalfn 0 2281 0 _null_ ));
  232. /* ordered-set and hypothetical-set aggregates */
  233. DATA(insert ( 3972 o 1 ordered_set_transition percentile_disc_final 0 2281 0 _null_ ));
  234. DATA(insert ( 3974 o 1 ordered_set_transition percentile_cont_float8_final 0 2281 0 _null_ ));
  235. DATA(insert ( 3976 o 1 ordered_set_transition percentile_cont_interval_final 0 2281 0 _null_ ));
  236. DATA(insert ( 3978 o 1 ordered_set_transition percentile_disc_multi_final 0 2281 0 _null_ ));
  237. DATA(insert ( 3980 o 1 ordered_set_transition percentile_cont_float8_multi_final 0 2281 0 _null_ ));
  238. DATA(insert ( 3982 o 1 ordered_set_transition percentile_cont_interval_multi_final 0 2281 0 _null_ ));
  239. DATA(insert ( 3984 o 0 ordered_set_transition mode_final 0 2281 0 _null_ ));
  240. DATA(insert ( 3986 h 1 ordered_set_transition_multi rank_final 0 2281 0 _null_ ));
  241. DATA(insert ( 3988 h 1 ordered_set_transition_multi percent_rank_final 0 2281 0 _null_ ));
  242. DATA(insert ( 3990 h 1 ordered_set_transition_multi cume_dist_final 0 2281 0 _null_ ));
  243. DATA(insert ( 3992 h 1 ordered_set_transition_multi dense_rank_final 0 2281 0 _null_ ));
  244. /*
  245. * prototypes for functions in pg_aggregate.c
  246. */
  247. extern Oid AggregateCreate(const char *aggName,
  248. Oid aggNamespace,
  249. char aggKind,
  250. int numArgs,
  251. int numDirectArgs,
  252. oidvector *parameterTypes,
  253. Datum allParameterTypes,
  254. Datum parameterModes,
  255. Datum parameterNames,
  256. List *parameterDefaults,
  257. Oid variadicArgType,
  258. List *aggtransfnName,
  259. List *aggfinalfnName,
  260. List *aggsortopName,
  261. Oid aggTransType,
  262. int32 aggTransSpace,
  263. const char *agginitval);
  264. #endif /* PG_AGGREGATE_H */