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

Function print_literal

contrib/test_decoding/test_decoding.c:471–514  ·  view source on GitHub ↗

* Print literal `outputstr' already represented as string of type `typid' * into stringbuf `s'. * * Some builtin types aren't quoted, the rest is quoted. Escaping is done as * if standard_conforming_strings were enabled. */

Source from the content-addressed store, hash-verified

469 * if standard_conforming_strings were enabled.
470 */
471static void
472print_literal(StringInfo s, Oid typid, char *outputstr)
473{
474 const char *valptr;
475
476 switch (typid)
477 {
478 case INT2OID:
479 case INT4OID:
480 case INT8OID:
481 case OIDOID:
482 case FLOAT4OID:
483 case FLOAT8OID:
484 case NUMERICOID:
485 /* NB: We don't care about Inf, NaN et al. */
486 appendStringInfoString(s, outputstr);
487 break;
488
489 case BITOID:
490 case VARBITOID:
491 appendStringInfo(s, "B'%s'", outputstr);
492 break;
493
494 case BOOLOID:
495 if (strcmp(outputstr, "t") == 0)
496 appendStringInfoString(s, "true");
497 else
498 appendStringInfoString(s, "false");
499 break;
500
501 default:
502 appendStringInfoChar(s, '\'');
503 for (valptr = outputstr; *valptr; valptr++)
504 {
505 char ch = *valptr;
506
507 if (SQL_STR_DOUBLE(ch, false))
508 appendStringInfoChar(s, ch);
509 appendStringInfoChar(s, ch);
510 }
511 appendStringInfoChar(s, '\'');
512 break;
513 }
514}
515
516/* print the tuple 'tuple' into the StringInfo s */
517static void

Callers 1

tuple_to_stringinfoFunction · 0.85

Calls 3

appendStringInfoStringFunction · 0.85
appendStringInfoFunction · 0.85
appendStringInfoCharFunction · 0.85

Tested by

no test coverage detected