for (i = 0; i < ndim; i++)
{ /* PG_USED_FOR_ASSERTS_ONLY prevents variable-isn't-read warnings */
int32 sum PG_USED_FOR_ASSERTS_ONLY;
if (pg_add_s32_overflow(dims[i], lb[i], &sum))
ereturn(escontext, false,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array lower bound is too large: %d",
lb[i])));
}
returntrue;
}
/* *Computeranges(sub-arraydimensions)foranarrayslice * *Weassumecallerhasvalidatedsliceendpoints,sooverflowisimpossible
*/ void
mda_get_range(int n, int *span, constint *st, constint *endp)
{ int i;
for (i = 0; i < n; i++)
span[i] = endp[i] - st[i] + 1;
}
/* *Computeproductsofarraydimensions,ie,scalefactorsforsubscripts * *Weassumecallerhasvalidateddimensions,sooverflowisimpossible
*/ void
mda_get_prod(int n, constint *range, int *prod)
{ int i;
prod[n - 1] = 1; for (i = n - 2; i >= 0; i--)
prod[i] = prod[i + 1] * range[i + 1];
}
/* *Fromproductsofwhole-arraydimensionsandspansofasub-array, *computeoffsetdistancesneededtostepthroughsubarraywithinarray * *Weassumecallerhasvalidateddimensions,sooverflowisimpossible
*/ void
mda_get_offset_values(int n, int *dist, constint *prod, constint *span)
{ int i,
j;
dist[n - 1] = 0; for (j = n - 2; j >= 0; j--)
{
dist[j] = prod[j] - 1; for (i = j + 1; i < n; i++)
dist[j] -= (span[i] - 1) * prod[i];
}
}
/* *Generatesthetuplethatislexicographicallyonegreaterthanthecurrent *n-tuplein"curr",withtherestrictionthatthei-thelementof"curr"is *lessthanthei-thelementof"span". * *Returns-1ifnonexttupleexists,elsethesubscriptposition(0..n-1) *correspondingtothedimensiontoadvancealong. * *Weassumecallerhasvalidateddimensions,sooverflowisimpossible
*/ int
mda_next_tuple(int n, int *curr, constint *span)
{ int i;
if (n <= 0) return -1;
curr[n - 1] = (curr[n - 1] + 1) % span[n - 1]; for (i = n - 1; i && curr[i] == 0; i--)
curr[i - 1] = (curr[i - 1] + 1) % span[i - 1];
if (i) return i; if (curr[0]) return0;
return -1;
}
/* *ArrayGetIntegerTypmods:verifythatargumentisa1-Dcstringarray, *andgetthecontentsconvertedtointegers.Returnsapalloc'darray *andplacesthelengthat*n.
*/
int32 *
ArrayGetIntegerTypmods(ArrayType *arr, int *n)
{
int32 *result;
Datum *elem_values; int i;
if (ARR_ELEMTYPE(arr) != CSTRINGOID)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
errmsg("typmod array must be type cstring[]")));
if (ARR_NDIM(arr) != 1)
ereport(ERROR,
(errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
errmsg("typmod array must be one-dimensional")));
if (array_contains_nulls(arr))
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("typmod array must not contain nulls")));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.