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

Function cursor_to_xml

src/backend/utils/adt/xml.c:2582–2621  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2580
2581
2582Datum
2583cursor_to_xml(PG_FUNCTION_ARGS)
2584{
2585 char *name = text_to_cstring(PG_GETARG_TEXT_PP(0));
2586 int32 count = PG_GETARG_INT32(1);
2587 bool nulls = PG_GETARG_BOOL(2);
2588 bool tableforest = PG_GETARG_BOOL(3);
2589 const char *targetns = text_to_cstring(PG_GETARG_TEXT_PP(4));
2590
2591 StringInfoData result;
2592 Portal portal;
2593 uint64 i;
2594
2595 initStringInfo(&result);
2596
2597 if (!tableforest)
2598 {
2599 xmldata_root_element_start(&result, "table", NULL, targetns, true);
2600 appendStringInfoChar(&result, '\n');
2601 }
2602
2603 SPI_connect();
2604 portal = SPI_cursor_find(name);
2605 if (portal == NULL)
2606 ereport(ERROR,
2607 (errcode(ERRCODE_UNDEFINED_CURSOR),
2608 errmsg("cursor \"%s\" does not exist", name)));
2609
2610 SPI_cursor_fetch(portal, true, count);
2611 for (i = 0; i < SPI_processed; i++)
2612 SPI_sql_row_to_xmlelement(i, &result, NULL, nulls,
2613 tableforest, targetns, true);
2614
2615 SPI_finish();
2616
2617 if (!tableforest)
2618 xmldata_root_element_end(&result, "table");
2619
2620 PG_RETURN_XML_P(stringinfo_to_xmltype(&result));
2621}
2622
2623
2624/*

Callers

nothing calls this directly

Calls 13

text_to_cstringFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoCharFunction · 0.85
SPI_connectFunction · 0.85
SPI_cursor_findFunction · 0.85
SPI_cursor_fetchFunction · 0.85
SPI_finishFunction · 0.85
xmldata_root_element_endFunction · 0.85
stringinfo_to_xmltypeFunction · 0.85
errcodeFunction · 0.50

Tested by

no test coverage detected