Datum
_int_contained(PG_FUNCTION_ARGS)
{ /* just reverse the operands and call _int_contains */ return DirectFunctionCall2(_int_contains,
PG_GETARG_DATUM(1),
PG_GETARG_DATUM(0));
}
Datum
_int_contains(PG_FUNCTION_ARGS)
{ /* Force copy so we can modify the arrays in-place */
ArrayType *a = PG_GETARG_ARRAYTYPE_P_COPY(0);
ArrayType *b = PG_GETARG_ARRAYTYPE_P_COPY(1); bool res;
Datum
uniq(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P_COPY(0);
CHECKARRVALID(a); if (ARRNELEMS(a) < 2)
PG_RETURN_POINTER(a);
a = _int_unique(a);
PG_RETURN_POINTER(a);
}
Datum
idx(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P(0);
int32 result;
CHECKARRVALID(a);
result = ARRNELEMS(a); if (result)
result = intarray_match_first(a, PG_GETARG_INT32(1));
PG_FREE_IF_COPY(a, 0);
PG_RETURN_INT32(result);
}
Datum
subarray(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P(0);
int32 start = PG_GETARG_INT32(1);
int32 len = (fcinfo->nargs == 3) ? PG_GETARG_INT32(2) : 0;
int32 end = 0;
int32 c;
ArrayType *result;
start = (start > 0) ? start - 1 : start;
CHECKARRVALID(a); if (ARRISEMPTY(a))
{
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(new_intArrayType(0));
}
c = ARRNELEMS(a);
if (start < 0)
start = c + start;
if (len < 0)
end = c + len; elseif (len == 0)
end = c; else
end = start + len;
if (end > c)
end = c;
if (start < 0)
start = 0;
if (start >= end || end <= 0)
{
PG_FREE_IF_COPY(a, 0);
PG_RETURN_POINTER(new_intArrayType(0));
}
result = intarray_concat_arrays(a, b);
PG_FREE_IF_COPY(a, 0);
PG_FREE_IF_COPY(b, 1);
PG_RETURN_POINTER(result);
}
Datum
intarray_del_elem(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P_COPY(0);
int32 elem = PG_GETARG_INT32(1);
int32 c;
int32 *aa;
int32 n = 0,
i;
CHECKARRVALID(a); if (!ARRISEMPTY(a))
{
c = ARRNELEMS(a);
aa = ARRPTR(a); for (i = 0; i < c; i++)
{ if (aa[i] != elem)
{ if (i > n)
aa[n++] = aa[i]; else
n++;
}
}
a = resize_intArrayType(a, n);
}
PG_RETURN_POINTER(a);
}
Datum
intset_union_elem(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P(0);
ArrayType *result;
result = intarray_add_elem(a, PG_GETARG_INT32(1));
PG_FREE_IF_COPY(a, 0);
QSORT(result, 1);
PG_RETURN_POINTER(_int_unique(result));
}
Datum
intset_subtract(PG_FUNCTION_ARGS)
{
ArrayType *a = PG_GETARG_ARRAYTYPE_P_COPY(0);
ArrayType *b = PG_GETARG_ARRAYTYPE_P_COPY(1);
ArrayType *result;
int32 ca;
int32 cb;
int32 *aa,
*bb,
*r;
int32 n = 0,
i = 0,
k = 0;
CHECKARRVALID(a);
CHECKARRVALID(b);
QSORT(a, 1);
a = _int_unique(a);
ca = ARRNELEMS(a);
QSORT(b, 1);
b = _int_unique(b);
cb = ARRNELEMS(b);
result = new_intArrayType(ca);
aa = ARRPTR(a);
bb = ARRPTR(b);
r = ARRPTR(result); while (i < ca)
{ if (k == cb || aa[i] < bb[k])
r[n++] = aa[i++]; elseif (aa[i] == bb[k])
{
i++;
k++;
} else
k++;
}
result = resize_intArrayType(result, n);
pfree(a);
pfree(b);
PG_RETURN_POINTER(result);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.5 Sekunden
(vorverarbeitet am 2026-08-08)
¤
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.