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

Function ReadArrayStr

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

* ReadArrayStr : * parses the array string pointed to by "arrayStr" and converts the values * to internal format. Unspecified elements are initialized to nulls. * The array dimensions must already have been determined. * * Inputs: * arrayStr: the string to parse. * CAUTION: the contents of "arrayStr" will be modified! * origStr: the unmodified input string, used only in error messa

Source from the content-addressed store, hash-verified

721 * nitems elements.
722 */
723static void
724ReadArrayStr(char *arrayStr,
725 const char *origStr,
726 int nitems,
727 int ndim,
728 int *dim,
729 FmgrInfo *inputproc,
730 Oid typioparam,
731 int32 typmod,
732 char typdelim,
733 int typlen,
734 bool typbyval,
735 char typalign,
736 Datum *values,
737 bool *nulls,
738 bool *hasnulls,
739 int32 *nbytes)
740{
741 int i,
742 nest_level = 0;
743 char *srcptr;
744 bool in_quotes = false;
745 bool eoArray = false;
746 bool hasnull;
747 int32 totbytes;
748 int indx[MAXDIM],
749 prod[MAXDIM];
750
751 mda_get_prod(ndim, dim, prod);
752 MemSet(indx, 0, sizeof(indx));
753
754 /* Initialize is-null markers to true */
755 memset(nulls, true, nitems * sizeof(bool));
756
757 /*
758 * We have to remove " and \ characters to create a clean item value to
759 * pass to the datatype input routine. We overwrite each item value
760 * in-place within arrayStr to do this. srcptr is the current scan point,
761 * and dstptr is where we are copying to.
762 *
763 * We also want to suppress leading and trailing unquoted whitespace. We
764 * use the leadingspace flag to suppress leading space. Trailing space is
765 * tracked by using dstendptr to point to the last significant output
766 * character.
767 *
768 * The error checking in this routine is mostly pro-forma, since we expect
769 * that ArrayCount() already validated the string. So we don't bother
770 * with errdetail messages.
771 */
772 srcptr = arrayStr;
773 while (!eoArray)
774 {
775 bool itemdone = false;
776 bool leadingspace = true;
777 bool hasquoting = false;
778 char *itemstart;
779 char *dstptr;
780 char *dstendptr;

Callers 1

array_inFunction · 0.85

Calls 7

mda_get_prodFunction · 0.85
ArrayGetOffset0Function · 0.85
array_isspaceFunction · 0.85
pg_strcasecmpFunction · 0.85
InputFunctionCallFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected