37 for (i = n - 1; i >= 0; i--)
39 offset += (indx[
i] - lb[
i]) * scale;
55 for (i = 0; i < n; i++)
56 lin += tup[i] * scale[i];
80 #define MaxArraySize ((Size) (MaxAllocSize / sizeof(Datum)))
85 for (i = 0; i < ndim; i++)
92 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
93 errmsg(
"array size exceeds the maximum allowed (%d)",
96 prod = (int64) ret *(int64) dims[
i];
99 if ((int64) ret != prod)
101 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
102 errmsg(
"array size exceeds the maximum allowed (%d)",
103 (
int) MaxArraySize)));
108 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
109 errmsg(
"array size exceeds the maximum allowed (%d)",
124 for (i = 0; i < n; i++)
125 span[i] = endp[i] - st[i] + 1;
139 for (i = n - 2; i >= 0; i--)
140 prod[i] = prod[i + 1] * range[i + 1];
156 for (j = n - 2; j >= 0; j--)
158 dist[j] = prod[j] - 1;
159 for (i = j + 1; i < n; i++)
160 dist[j] -= (span[i] - 1) * prod[
i];
182 curr[n - 1] = (curr[n - 1] + 1) % span[n - 1];
183 for (i = n - 1; i && curr[
i] == 0; i--)
184 curr[i - 1] = (curr[i - 1] + 1) % span[i - 1];
208 (
errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
209 errmsg(
"typmod array must be type cstring[]")));
213 (
errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
214 errmsg(
"typmod array must be one-dimensional")));
218 (
errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
219 errmsg(
"typmod array must not contain nulls")));
224 &elem_values,
NULL, n);
228 for (i = 0; i < *n; i++)
230 sizeof(
int32),
'\0');
static struct cvec * range(struct vars *v, celt a, celt b, int cases)
int ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx)
void mda_get_prod(int n, const int *range, int *prod)
int32 * ArrayGetIntegerTypmods(ArrayType *arr, int *n)
int ArrayGetNItems(int ndim, const int *dims)
int errcode(int sqlerrcode)
void pfree(void *pointer)
#define DatumGetCString(X)
#define ereport(elevel, rest)
void mda_get_offset_values(int n, int *dist, const int *prod, const int *span)
void mda_get_range(int n, int *span, const int *st, const int *endp)
#define Assert(condition)
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
int mda_next_tuple(int n, int *curr, const int *span)
int errmsg(const char *fmt,...)
bool array_contains_nulls(ArrayType *array)
int32 pg_atoi(const char *s, int size, int c)
int ArrayGetOffset0(int n, const int *tup, const int *scale)