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

Function array_iterator

contrib/ltree/_ltree_op.c:36–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34#define NEXTVAL(x) ( (ltree*)( (char*)(x) + INTALIGN( VARSIZE(x) ) ) )
35
36static bool
37array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree **found)
38{
39 int num = ArrayGetNItems(ARR_NDIM(la), ARR_DIMS(la));
40 ltree *item = (ltree *) ARR_DATA_PTR(la);
41
42 if (ARR_NDIM(la) > 1)
43 ereport(ERROR,
44 (errcode(ERRCODE_ARRAY_SUBSCRIPT_ERROR),
45 errmsg("array must be one-dimensional")));
46 if (array_contains_nulls(la))
47 ereport(ERROR,
48 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
49 errmsg("array must not contain nulls")));
50
51 if (found)
52 *found = NULL;
53 while (num > 0)
54 {
55 if (DatumGetBool(DirectFunctionCall2(callback,
56 PointerGetDatum(item), PointerGetDatum(param))))
57 {
58
59 if (found)
60 *found = item;
61 return true;
62 }
63 num--;
64 item = NEXTVAL(item);
65 }
66
67 return false;
68}
69
70Datum
71_ltree_isparent(PG_FUNCTION_ARGS)

Callers 9

_ltree_isparentFunction · 0.85
_ltree_risparentFunction · 0.85
_ltq_regexFunction · 0.85
_lt_q_regexFunction · 0.85
_ltxtq_execFunction · 0.85
_ltree_extract_isparentFunction · 0.85
_ltree_extract_risparentFunction · 0.85
_ltq_extract_regexFunction · 0.85
_ltxtq_extract_execFunction · 0.85

Calls 5

ArrayGetNItemsFunction · 0.85
array_contains_nullsFunction · 0.85
DatumGetBoolFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected