Database Reference
In-Depth Information
int32 sum = 0;
bool not_null = false;
// variables for "deconstructed" array
Datum *datums;
bool *nulls;
int count;
// for for loop
int i;
input_array = PG_GETARG_ARRAYTYPE_P(0);
// check that we do indeed have a
one-dimensional int array
Assert( ARR_ELEMTYPE(input_array) ==
INT4OID );
if ( ARR_NDIM(input_array) > 1)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("1-dimensional array
needed")));
deconstruct_array( input_array, //
one-dimensional array
INT4OID, // of
integers
4, // size of
integer in bytes
true, // int4 is
pass-by value
'i', //
alignment type is 'i'
&datums, &nulls, &count);
// result here
for(i=0;i<count;i++) {
// first check and ignore null elements
Search WWH ::




Custom Search