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

Function array_fill

src/backend/utils/adt/arrayfuncs.c:5914–5947  ·  view source on GitHub ↗

* array_fill * Create and fill array with default lower bounds. */

Source from the content-addressed store, hash-verified

5912 * Create and fill array with default lower bounds.
5913 */
5914Datum
5915array_fill(PG_FUNCTION_ARGS)
5916{
5917 ArrayType *dims;
5918 ArrayType *result;
5919 Oid elmtype;
5920 Datum value;
5921 bool isnull;
5922
5923 if (PG_ARGISNULL(1))
5924 ereport(ERROR,
5925 (errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
5926 errmsg("dimension array or low bound array cannot be null")));
5927
5928 dims = PG_GETARG_ARRAYTYPE_P(1);
5929
5930 if (!PG_ARGISNULL(0))
5931 {
5932 value = PG_GETARG_DATUM(0);
5933 isnull = false;
5934 }
5935 else
5936 {
5937 value = 0;
5938 isnull = true;
5939 }
5940
5941 elmtype = get_fn_expr_argtype(fcinfo->flinfo, 0);
5942 if (!OidIsValid(elmtype))
5943 elog(ERROR, "could not determine data type of input");
5944
5945 result = array_fill_internal(dims, NULL, value, isnull, elmtype, fcinfo);
5946 PG_RETURN_ARRAYTYPE_P(result);
5947}
5948
5949static ArrayType *
5950create_array_envelope(int ndims, int *dimv, int *lbsv, int nbytes,

Callers

nothing calls this directly

Calls 4

get_fn_expr_argtypeFunction · 0.85
array_fill_internalFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected