PostgreSQL Source Code: src/backend/utils/adt/arrayutils.c File Reference (original) (raw)
Go to the source code of this file.
Functions | |
---|---|
int | ArrayGetOffset (int n, const int *dim, const int *lb, const int *indx) |
int | ArrayGetNItems (int ndim, const int *dims) |
int | ArrayGetNItemsSafe (int ndim, const int *dims, struct Node *escontext) |
void | ArrayCheckBounds (int ndim, const int *dims, const int *lb) |
bool | ArrayCheckBoundsSafe (int ndim, const int *dims, const int *lb, struct Node *escontext) |
void | mda_get_range (int n, int *span, const int *st, const int *endp) |
void | mda_get_prod (int n, const int *range, int *prod) |
void | mda_get_offset_values (int n, int *dist, const int *prod, const int *span) |
int | mda_next_tuple (int n, int *curr, const int *span) |
int32 * | ArrayGetIntegerTypmods (ArrayType *arr, int *n) |
◆ ArrayCheckBounds()
void ArrayCheckBounds | ( | int | ndim, |
---|---|---|---|
const int * | dims, | ||
const int * | lb | ||
) |
Definition at line 117 of file arrayutils.c.
118{
120}
bool ArrayCheckBoundsSafe(int ndim, const int *dims, const int *lb, struct Node *escontext)
References ArrayCheckBoundsSafe().
Referenced by array_cat(), array_fill_internal(), array_recv(), array_set_element(), array_set_element_expanded(), array_set_slice(), construct_md_array(), ExecEvalArrayExpr(), and makeArrayResultArr().
◆ ArrayCheckBoundsSafe()
bool ArrayCheckBoundsSafe | ( | int | ndim, |
---|---|---|---|
const int * | dims, | ||
const int * | lb, | ||
struct Node * | escontext | ||
) |
Definition at line 127 of file arrayutils.c.
129{
130 int i;
131
132 for (i = 0; i < ndim; i++)
133 {
134
136
138 ereturn(escontext, false,
139 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
140 errmsg("array lower bound is too large: %d",
141 lb[i])));
142 }
143
144 return true;
145}
#define PG_USED_FOR_ASSERTS_ONLY
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereturn(context, dummy_value,...)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
References ereturn, errcode(), errmsg(), i, pg_add_s32_overflow(), and PG_USED_FOR_ASSERTS_ONLY.
Referenced by ArrayCheckBounds().
◆ ArrayGetIntegerTypmods()
Definition at line 233 of file arrayutils.c.
234{
236 Datum *elem_values;
237 int i;
238
241 (errcode(ERRCODE_ARRAY_ELEMENT_ERROR),
242 errmsg("typmod array must be type cstring[]")));
243
246 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
247 errmsg("typmod array must be one-dimensional")));
248
251 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
252 errmsg("typmod array must not contain nulls")));
253
255
257
260
261 pfree(elem_values);
262
263 return result;
264}
bool array_contains_nulls(ArrayType *array)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
#define ereport(elevel,...)
void pfree(void *pointer)
int32 pg_strtoint32(const char *s)
static char * DatumGetCString(Datum X)
References ARR_ELEMTYPE, ARR_NDIM, array_contains_nulls(), DatumGetCString(), deconstruct_array_builtin(), ereport, errcode(), errmsg(), ERROR, i, palloc(), pfree(), and pg_strtoint32().
Referenced by anybit_typmodin(), anychar_typmodin(), anytime_typmodin(), anytimestamp_typmodin(), intervaltypmodin(), and numerictypmodin().
◆ ArrayGetNItems()
int ArrayGetNItems | ( | int | ndim, |
---|---|---|---|
const int * | dims | ||
) |
Definition at line 57 of file arrayutils.c.
58{
60}
int ArrayGetNItemsSafe(int ndim, const int *dims, struct Node *escontext)
References ArrayGetNItemsSafe().
Referenced by _arrq_cons(), _lca(), _lt_q_regex(), _ltree_compress(), accumArrayResultArr(), array_cardinality(), array_cat(), array_cmp(), array_contain_compare(), array_contains_nulls(), array_create_iterator(), array_eq(), array_fill_internal(), array_get_slice(), array_insert_slice(), array_iterator(), array_map(), array_out(), array_recv(), array_replace_internal(), array_send(), array_set_element(), array_set_element_expanded(), array_set_slice(), array_slice_size(), array_to_json_internal(), array_to_jsonb_internal(), array_to_text_internal(), array_unnest(), arrq_cons(), clause_is_strict_for(), construct_md_array(), convert_saop_to_hashed_saop_walker(), count_nulls(), deconstruct_array(), do_set_block_offsets(), EA_get_flat_size(), estimate_array_length(), ExecEvalArrayExpr(), ExecEvalHashedScalarArrayOp(), ExecEvalScalarArrayOp(), get_text_array_contents(), getWeights(), hash_array(), hash_array_extended(), is_strict_saop(), lt_q_regex(), makeArrayResultArr(), pg_isolation_test_session_is_blocked(), predicate_classify(), sanity_check_tid_array(), width_bucket_array_fixed(), width_bucket_array_float8(), and width_bucket_array_variable().
◆ ArrayGetNItemsSafe()
int ArrayGetNItemsSafe | ( | int | ndim, |
---|---|---|---|
const int * | dims, | ||
struct Node * | escontext | ||
) |
Definition at line 67 of file arrayutils.c.
68{
70 int i;
71
72 if (ndim <= 0)
73 return 0;
74 ret = 1;
76 {
78
79
80 if (dims[i] < 0)
82 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
83 errmsg("array size exceeds the maximum allowed (%d)",
85
87
88 ret = (int32) prod;
89 if ((int64) ret != prod)
91 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
92 errmsg("array size exceeds the maximum allowed (%d)",
94 }
98 (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
99 errmsg("array size exceeds the maximum allowed (%d)",
101 return (int) ret;
102}
Assert(PointerIsAligned(start, uint64))
References Assert(), ereturn, errcode(), errmsg(), i, and MaxArraySize.
Referenced by ArrayGetNItems().
◆ ArrayGetOffset()
int ArrayGetOffset | ( | int | n, |
---|---|---|---|
const int * | dim, | ||
const int * | lb, | ||
const int * | indx | ||
) |
◆ mda_get_offset_values()
void mda_get_offset_values | ( | int | n, |
---|---|---|---|
int * | dist, | ||
const int * | prod, | ||
const int * | span | ||
) |
◆ mda_get_prod()
void mda_get_prod | ( | int | n, |
---|---|---|---|
const int * | range, | ||
int * | prod | ||
) |
◆ mda_get_range()
void mda_get_range | ( | int | n, |
---|---|---|---|
int * | span, | ||
const int * | st, | ||
const int * | endp | ||
) |
◆ mda_next_tuple()
int mda_next_tuple | ( | int | n, |
---|---|---|---|
int * | curr, | ||
const int * | span | ||
) |
Definition at line 208 of file arrayutils.c.
209{
210 int i;
211
212 if (n <= 0)
213 return -1;
214
215 curr[n - 1] = (curr[n - 1] + 1) % span[n - 1];
216 for (i = n - 1; i && curr[i] == 0; i--)
217 curr[i - 1] = (curr[i - 1] + 1) % span[i - 1];
218
219 if (i)
220 return i;
221 if (curr[0])
222 return 0;
223
224 return -1;
225}
References i.
Referenced by array_extract_slice(), array_insert_slice(), and array_slice_size().