From 5cabcfccce4b8b826c9b30828f3012b7926a6946 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 26 Aug 2002 17:54:02 +0000 Subject: 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. --- src/backend/utils/adt/timestamp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/backend/utils/adt/timestamp.c') diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 5be34e6199..1b2553ec94 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.69 2002/08/04 06:44:47 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.70 2002/08/26 17:53:59 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -24,6 +24,7 @@ #include "access/hash.h" #include "access/xact.h" +#include "catalog/pg_type.h" #include "miscadmin.h" #include "utils/array.h" #include "utils/builtins.h" @@ -1917,7 +1918,7 @@ interval_accum(PG_FUNCTION_ARGS) /* We assume the input is array of interval */ deconstruct_array(transarray, - false, 12, 'd', + INTERVALOID, 12, false, 'd', &transdatums, &ndatums); if (ndatums != 2) elog(ERROR, "interval_accum: expected 2-element interval array"); @@ -1943,7 +1944,7 @@ interval_accum(PG_FUNCTION_ARGS) transdatums[1] = IntervalPGetDatum(&N); result = construct_array(transdatums, 2, - false, 12, 'd'); + INTERVALOID, 12, false, 'd'); PG_RETURN_ARRAYTYPE_P(result); } @@ -1959,7 +1960,7 @@ interval_avg(PG_FUNCTION_ARGS) /* We assume the input is array of interval */ deconstruct_array(transarray, - false, 12, 'd', + INTERVALOID, 12, false, 'd', &transdatums, &ndatums); if (ndatums != 2) elog(ERROR, "interval_avg: expected 2-element interval array"); -- cgit v1.2.1