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

Function array_in

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

* array_in : * converts an array from the external format in "string" to * its internal format. * * return value : * the internal representation of the input array */

Source from the content-addressed store, hash-verified

174 * the internal representation of the input array
175 */
176Datum
177array_in(PG_FUNCTION_ARGS)
178{
179 char *string = PG_GETARG_CSTRING(0); /* external form */
180 Oid element_type = PG_GETARG_OID(1); /* type of an array
181 * element */
182 int32 typmod = PG_GETARG_INT32(2); /* typmod for array elements */
183 int typlen;
184 bool typbyval;
185 char typalign;
186 char typdelim;
187 Oid typioparam;
188 char *string_save,
189 *p;
190 int i,
191 nitems;
192 Datum *dataPtr;
193 bool *nullsPtr;
194 bool hasnulls;
195 int32 nbytes;
196 int32 dataoffset;
197 ArrayType *retval;
198 int ndim,
199 dim[MAXDIM],
200 lBound[MAXDIM];
201 ArrayMetaState *my_extra;
202
203 /*
204 * We arrange to look up info about element type, including its input
205 * conversion proc, only once per series of calls, assuming the element
206 * type doesn't change underneath us.
207 */
208 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
209 if (my_extra == NULL)
210 {
211 fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
212 sizeof(ArrayMetaState));
213 my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
214 my_extra->element_type = ~element_type;
215 }
216
217 if (my_extra->element_type != element_type)
218 {
219 /*
220 * Get info about element type, including its input conversion proc
221 */
222 get_type_io_data(element_type, IOFunc_input,
223 &my_extra->typlen, &my_extra->typbyval,
224 &my_extra->typalign, &my_extra->typdelim,
225 &my_extra->typioparam, &my_extra->typiofunc);
226 fmgr_info_cxt(my_extra->typiofunc, &my_extra->proc,
227 fcinfo->flinfo->fn_mcxt);
228 my_extra->element_type = element_type;
229 }
230 typlen = my_extra->typlen;
231 typbyval = my_extra->typbyval;
232 typalign = my_extra->typalign;
233 typdelim = my_extra->typdelim;

Callers

nothing calls this directly

Calls 15

MemoryContextAllocFunction · 0.85
get_type_io_dataFunction · 0.85
fmgr_info_cxtFunction · 0.85
array_isspaceFunction · 0.85
ArrayCountFunction · 0.85
ArrayGetNItemsFunction · 0.85
ArrayCheckBoundsFunction · 0.85
construct_empty_arrayFunction · 0.85
ReadArrayStrFunction · 0.85
CopyArrayElsFunction · 0.85
pstrdupFunction · 0.50
errcodeFunction · 0.50

Tested by

no test coverage detected