print the tuple 'tuple' into the StringInfo s */
| 515 | |
| 516 | /* print the tuple 'tuple' into the StringInfo s */ |
| 517 | static void |
| 518 | tuple_to_stringinfo(StringInfo s, TupleDesc tupdesc, HeapTuple tuple, bool skip_nulls) |
| 519 | { |
| 520 | int natt; |
| 521 | |
| 522 | /* print all columns individually */ |
| 523 | for (natt = 0; natt < tupdesc->natts; natt++) |
| 524 | { |
| 525 | Form_pg_attribute attr; /* the attribute itself */ |
| 526 | Oid typid; /* type of current attribute */ |
| 527 | Oid typoutput; /* output function */ |
| 528 | bool typisvarlena; |
| 529 | Datum origval; /* possibly toasted Datum */ |
| 530 | bool isnull; /* column is null? */ |
| 531 | |
| 532 | attr = TupleDescAttr(tupdesc, natt); |
| 533 | |
| 534 | /* |
| 535 | * don't print dropped columns, we can't be sure everything is |
| 536 | * available for them |
| 537 | */ |
| 538 | if (attr->attisdropped) |
| 539 | continue; |
| 540 | |
| 541 | /* |
| 542 | * Don't print system columns, oid will already have been printed if |
| 543 | * present. |
| 544 | */ |
| 545 | if (attr->attnum < 0) |
| 546 | continue; |
| 547 | |
| 548 | typid = attr->atttypid; |
| 549 | |
| 550 | /* get Datum from tuple */ |
| 551 | origval = heap_getattr(tuple, natt + 1, tupdesc, &isnull); |
| 552 | |
| 553 | if (isnull && skip_nulls) |
| 554 | continue; |
| 555 | |
| 556 | /* print attribute name */ |
| 557 | appendStringInfoChar(s, ' '); |
| 558 | appendStringInfoString(s, quote_identifier(NameStr(attr->attname))); |
| 559 | |
| 560 | /* print attribute type */ |
| 561 | appendStringInfoChar(s, '['); |
| 562 | appendStringInfoString(s, format_type_be(typid)); |
| 563 | appendStringInfoChar(s, ']'); |
| 564 | |
| 565 | /* query output function */ |
| 566 | getTypeOutputInfo(typid, |
| 567 | &typoutput, &typisvarlena); |
| 568 | |
| 569 | /* print separator */ |
| 570 | appendStringInfoChar(s, ':'); |
| 571 | |
| 572 | /* print data */ |
| 573 | if (isnull) |
| 574 | appendStringInfoString(s, "null"); |
no test coverage detected