488 HeapTupleData tmptup,
491 bool needsep =
false;
494 sep = use_line_feeds ?
",\n " :
",";
496 td = DatumGetHeapTupleHeader(composite);
499 tupType = HeapTupleHeaderGetTypeId(td);
500 tupTypmod = HeapTupleHeaderGetTypMod(td);
501 tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
504 tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
508 appendStringInfoChar(result,
'{');
510 for (i = 0; i < tupdesc->natts; i++)
517 Form_pg_attribute att = TupleDescAttr(tupdesc, i);
519 if (att->attisdropped)
523 appendStringInfoString(result, sep);
526 attname = NameStr(att->attname);
527 escape_json(result, attname);
528 appendStringInfoChar(result,
':');
530 val = heap_getattr(tuple, i + 1, tupdesc, &isnull);
535 outfuncoid = InvalidOid;
540 datum_to_json(val, isnull, result, tcategory, outfuncoid,
false);
543 appendStringInfoChar(result,
'}');
544 ReleaseTupleDesc(tupdesc);
static void json_categorize_type(Oid typoid, JsonTypeCategory *tcategory, Oid *outfuncoid)
static void datum_to_json(Datum val, bool is_null, StringInfo result, JsonTypeCategory tcategory, Oid outfuncoid, bool key_scalar)