MCPcopy Create free account
hub / github.com/apache/cloudberry / ArrayCheckBounds

Function ArrayCheckBounds

src/backend/utils/adt/arrayutils.c:121–137  ·  view source on GitHub ↗

* Verify sanity of proposed lower-bound values for an array * * The lower-bound values must not be so large as to cause overflow when * calculating subscripts, e.g. lower bound 2147483640 with length 10 * must be disallowed. We actually insist that dims[i] + lb[i] be * computable without overflow, meaning that an array with last subscript * equal to INT_MAX will be disallowed. * * It is a

Source from the content-addressed store, hash-verified

119 * overflowed (negative) dims[] values have been eliminated.
120 */
121void
122ArrayCheckBounds(int ndim, const int *dims, const int *lb)
123{
124 int i;
125
126 for (i = 0; i < ndim; i++)
127 {
128 /* PG_USED_FOR_ASSERTS_ONLY prevents variable-isn't-read warnings */
129 int32 sum PG_USED_FOR_ASSERTS_ONLY;
130
131 if (pg_add_s32_overflow(dims[i], lb[i], &sum))
132 ereport(ERROR,
133 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
134 errmsg("array lower bound is too large: %d",
135 lb[i])));
136 }
137}
138
139/*
140 * Compute ranges (sub-array dimensions) for an array slice

Callers 10

array_inFunction · 0.85
array_recvFunction · 0.85
array_set_elementFunction · 0.85
array_set_sliceFunction · 0.85
construct_md_arrayFunction · 0.85
makeArrayResultArrFunction · 0.85
array_fill_internalFunction · 0.85
array_catFunction · 0.85
ExecEvalArrayExprFunction · 0.85

Calls 3

pg_add_s32_overflowFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected