528{
529 ArrayType *v = DatumGetArrayTypeP(array);
530 Oid element_type = ARR_ELEMTYPE(v);
531 int *dim;
532 int ndim;
533 int nitems;
535 Datum *elements;
536 bool *nulls;
537 int16 typlen;
538 bool typbyval;
539 char typalign;
541 Oid outfuncoid;
542
543 ndim = ARR_NDIM(v);
544 dim = ARR_DIMS(v);
545 nitems = ArrayGetNItems(ndim, dim);
546
547 if (nitems <= 0)
548 {
549 appendStringInfoString(
result,
"[]");
550 return;
551 }
552
553 get_typlenbyvalalign(element_type,
554 &typlen, &typbyval, &typalign);
555
557 &tcategory, &outfuncoid);
558
559 deconstruct_array(v, element_type, typlen, typbyval,
560 typalign, &elements, &nulls,
561 &nitems);
562
564 outfuncoid, use_line_feeds);
565
566 pfree(elements);
567 pfree(nulls);
568}
char result[OUT_DOUBLE_BUFFER_SIZE]
static void json_categorize_type(Oid typoid, JsonTypeCategory *tcategory, Oid *outfuncoid)
static void array_dim_to_json(StringInfo result, int dim, int ndims, int *dims, Datum *vals, bool *nulls, int *valcount, JsonTypeCategory tcategory, Oid outfuncoid, bool use_line_feeds)