*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.113 2004/09/27 01:39:02 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.114 2004/12/17 20:58:26 tgl Exp $
*
*-------------------------------------------------------------------------
*/
/* Check for empty array */
if (nitems <= 0)
- PG_RETURN_ARRAYTYPE_P(v);
+ {
+ /* Return empty array */
+ result = (ArrayType *) palloc0(sizeof(ArrayType));
+ result->size = sizeof(ArrayType);
+ result->elemtype = retType;
+ PG_RETURN_ARRAYTYPE_P(result);
+ }
/*
* We arrange to look up info about input and return element types
if (ndims == 0)
{
/* Allocate and initialize 0-D result array */
- nbytes = ARR_OVERHEAD(ndims);
- result = (ArrayType *) palloc(nbytes);
-
- result->size = nbytes;
- result->ndim = ndims;
- result->flags = 0;
+ result = (ArrayType *) palloc0(sizeof(ArrayType));
+ result->size = sizeof(ArrayType);
result->elemtype = elmtype;
-
return result;
}