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

Function array_out

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

* array_out : * takes the internal representation of an array and returns a string * containing the array in its external format. */

Source from the content-addressed store, hash-verified

1016 * containing the array in its external format.
1017 */
1018Datum
1019array_out(PG_FUNCTION_ARGS)
1020{
1021 AnyArrayType *v = PG_GETARG_ANY_ARRAY_P(0);
1022 Oid element_type = AARR_ELEMTYPE(v);
1023 int typlen;
1024 bool typbyval;
1025 char typalign;
1026 char typdelim;
1027 char *p,
1028 *tmp,
1029 *retval,
1030 **values,
1031 dims_str[(MAXDIM * 33) + 2];
1032
1033 /*
1034 * 33 per dim since we assume 15 digits per number + ':' +'[]'
1035 *
1036 * +2 allows for assignment operator + trailing null
1037 */
1038 bool *needquotes,
1039 needdims = false;
1040 size_t overall_length;
1041 int nitems,
1042 i,
1043 j,
1044 k,
1045 indx[MAXDIM];
1046 int ndim,
1047 *dims,
1048 *lb;
1049 array_iter iter;
1050 ArrayMetaState *my_extra;
1051
1052 /*
1053 * We arrange to look up info about element type, including its output
1054 * conversion proc, only once per series of calls, assuming the element
1055 * type doesn't change underneath us.
1056 */
1057 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
1058 if (my_extra == NULL)
1059 {
1060 fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
1061 sizeof(ArrayMetaState));
1062 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
1063 my_extra->element_type = ~element_type;
1064 }
1065
1066 if (my_extra->element_type != element_type)
1067 {
1068 /*
1069 * Get info about element type, including its output conversion proc
1070 */
1071 get_type_io_data(element_type, IOFunc_output,
1072 &my_extra->typlen, &my_extra->typbyval,
1073 &my_extra->typalign, &my_extra->typdelim,
1074 &my_extra->typioparam, &my_extra->typiofunc);
1075 fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,

Callers 2

anyarray_outFunction · 0.85
anycompatiblearray_outFunction · 0.85

Calls 12

MemoryContextAllocFunction · 0.85
get_type_io_dataFunction · 0.85
fmgr_info_cxtFunction · 0.85
ArrayGetNItemsFunction · 0.85
array_iter_setupFunction · 0.85
array_iter_nextFunction · 0.85
OutputFunctionCallFunction · 0.85
pg_strcasecmpFunction · 0.85
array_isspaceFunction · 0.85
pstrdupFunction · 0.50
pallocFunction · 0.50
pfreeFunction · 0.50

Tested by

no test coverage detected