summaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/float.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-26 17:54:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-26 17:54:02 +0000
commit5cabcfccce4b8b826c9b30828f3012b7926a6946 (patch)
tree3e14c0710a45b4195734dd3189eb89eac4969073 /src/backend/utils/adt/float.c
parent8009c275925dda90f1275ba70f5c2a63abaa520b (diff)
downloadpostgresql-5cabcfccce4b8b826c9b30828f3012b7926a6946.tar.gz
Modify array operations to include array's element type OID in the
array header, and to compute sizing and alignment of array elements the same way normal tuple access operations do --- viz, using the tupmacs.h macros att_addlength and att_align. This makes the world safe for arrays of cstrings or intervals, and should make it much easier to write array-type-polymorphic functions; as examples see the cleanups of array_out and contrib/array_iterator. By Joe Conway and Tom Lane.
Diffstat (limited to 'src/backend/utils/adt/float.c')
-rw-r--r--src/backend/utils/adt/float.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c
index 84233ebd1c..5edea787af 100644
--- a/src/backend/utils/adt/float.c
+++ b/src/backend/utils/adt/float.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.79 2002/06/20 20:29:37 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.80 2002/08/26 17:53:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,6 +61,7 @@
#include <ieeefp.h>
#endif
+#include "catalog/pg_type.h"
#include "fmgr.h"
#include "utils/array.h"
#include "utils/builtins.h"
@@ -1480,9 +1481,9 @@ check_float8_array(ArrayType *transarray, const char *caller)
* don't need to use deconstruct_array() since the array data is just
* going to look like a C array of 3 float8 values.
*/
- if (ARR_SIZE(transarray) != (ARR_OVERHEAD(1) + 3 * sizeof(float8)) ||
- ARR_NDIM(transarray) != 1 ||
- ARR_DIMS(transarray)[0] != 3)
+ if (ARR_NDIM(transarray) != 1 ||
+ ARR_DIMS(transarray)[0] != 3 ||
+ ARR_ELEMTYPE(transarray) != FLOAT8OID)
elog(ERROR, "%s: expected 3-element float8 array", caller);
return (float8 *) ARR_DATA_PTR(transarray);
}
@@ -1513,7 +1514,8 @@ float8_accum(PG_FUNCTION_ARGS)
transdatums[2] = Float8GetDatumFast(sumX2);
result = construct_array(transdatums, 3,
- false /* float8 byval */ , sizeof(float8), 'd');
+ FLOAT8OID,
+ sizeof(float8), false /*float8 byval*/, 'd');
PG_RETURN_ARRAYTYPE_P(result);
}
@@ -1548,7 +1550,8 @@ float4_accum(PG_FUNCTION_ARGS)
transdatums[2] = Float8GetDatumFast(sumX2);
result = construct_array(transdatums, 3,
- false /* float8 byval */ , sizeof(float8), 'd');
+ FLOAT8OID,
+ sizeof(float8), false /*float8 byval*/, 'd');
PG_RETURN_ARRAYTYPE_P(result);
}