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

Function SPI_cursor_open_with_args

src/backend/executor/spi.c:1499–1543  ·  view source on GitHub ↗

* SPI_cursor_open_with_args() * * Parse and plan a query and open it as a portal. */

Source from the content-addressed store, hash-verified

1497 * Parse and plan a query and open it as a portal.
1498 */
1499Portal
1500SPI_cursor_open_with_args(const char *name,
1501 const char *src,
1502 int nargs, Oid *argtypes,
1503 Datum *Values, const char *Nulls,
1504 bool read_only, int cursorOptions)
1505{
1506 Portal result;
1507 _SPI_plan plan;
1508 ParamListInfo paramLI;
1509
1510 if (src == NULL || nargs < 0)
1511 elog(ERROR, "SPI_cursor_open_with_args called with invalid arguments");
1512
1513 if (nargs > 0 && (argtypes == NULL || Values == NULL))
1514 elog(ERROR, "SPI_cursor_open_with_args called with missing parameters");
1515
1516 SPI_result = _SPI_begin_call(true);
1517 if (SPI_result < 0)
1518 elog(ERROR, "SPI_cursor_open_with_args called while not connected");
1519
1520 memset(&plan, 0, sizeof(_SPI_plan));
1521 plan.magic = _SPI_PLAN_MAGIC;
1522 plan.parse_mode = RAW_PARSE_DEFAULT;
1523 plan.cursor_options = cursorOptions;
1524 plan.nargs = nargs;
1525 plan.argtypes = argtypes;
1526 plan.parserSetup = NULL;
1527 plan.parserSetupArg = NULL;
1528
1529 /* build transient ParamListInfo in executor context */
1530 paramLI = _SPI_convert_params(nargs, argtypes,
1531 Values, Nulls);
1532
1533 _SPI_prepare_plan(src, &plan);
1534
1535 /* We needn't copy the plan; SPI_cursor_open_internal will do so */
1536
1537 result = SPI_cursor_open_internal(name, &plan, paramLI, read_only);
1538
1539 /* And clean up */
1540 _SPI_end_call(true);
1541
1542 return result;
1543}
1544
1545
1546/*

Callers 1

executeFunction · 0.85

Calls 5

_SPI_begin_callFunction · 0.85
_SPI_convert_paramsFunction · 0.85
_SPI_prepare_planFunction · 0.85
SPI_cursor_open_internalFunction · 0.85
_SPI_end_callFunction · 0.85

Tested by

no test coverage detected