aboutsummaryrefslogtreecommitdiff
path: root/src/include/utils/numeric.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-07-17 03:05:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-07-17 03:05:41 +0000
commitbec98a31c55a4f799b398d01541e68d7c086bb81 (patch)
tree14924bb5da2bc0a0f9bfac1aa5b32256fd996b9c /src/include/utils/numeric.h
parent139f19c30221968e7d3bf64fe303cb41517e4601 (diff)
downloadpostgresql-bec98a31c55a4f799b398d01541e68d7c086bb81.tar.gz
postgresql-bec98a31c55a4f799b398d01541e68d7c086bb81.zip
Revise aggregate functions per earlier discussions in pghackers.
There's now only one transition value and transition function. NULL handling in aggregates is a lot cleaner. Also, use Numeric accumulators instead of integer accumulators for sum/avg on integer datatypes --- this avoids overflow at the cost of being a little slower. Implement VARIANCE() and STDDEV() aggregates in the standard backend. Also, enable new LIKE selectivity estimators by default. Unrelated change, but as long as I had to force initdb anyway...
Diffstat (limited to 'src/include/utils/numeric.h')
-rw-r--r--src/include/utils/numeric.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h
index 1a0dd692dbd..8e6412eabee 100644
--- a/src/include/utils/numeric.h
+++ b/src/include/utils/numeric.h
@@ -5,7 +5,7 @@
*
* 1998 Jan Wieck
*
- * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.10 2000/06/13 07:35:31 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/include/utils/numeric.h,v 1.11 2000/07/17 03:05:32 tgl Exp $
*
* ----------
*/
@@ -55,7 +55,7 @@
* all leading and trailing zeroes (except there will be a trailing zero
* in the last byte, if the number of digits is odd). In particular,
* if the value is zero, there will be no digits at all! The weight is
- * arbitrary in this case, but we normally set it to zero.
+ * arbitrary in that case, but we normally set it to zero.
* ----------
*/
typedef struct NumericData
@@ -75,9 +75,11 @@ typedef NumericData *Numeric;
* fmgr interface macros
*/
-#define DatumGetNumeric(X) ((Numeric) PG_DETOAST_DATUM(X))
-#define NumericGetDatum(X) PointerGetDatum(X)
-#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
-#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
+#define DatumGetNumeric(X) ((Numeric) PG_DETOAST_DATUM(X))
+#define DatumGetNumericCopy(X) ((Numeric) PG_DETOAST_DATUM_COPY(X))
+#define NumericGetDatum(X) PointerGetDatum(X)
+#define PG_GETARG_NUMERIC(n) DatumGetNumeric(PG_GETARG_DATUM(n))
+#define PG_GETARG_NUMERIC_COPY(n) DatumGetNumericCopy(PG_GETARG_DATUM(n))
+#define PG_RETURN_NUMERIC(x) return NumericGetDatum(x)
#endif /* _PG_NUMERIC_H_ */