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

Function PLy_spi_execute_fetch_result

src/pl/plpython/plpy_spi.c:371–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371static PyObject *
372PLy_spi_execute_fetch_result(SPITupleTable *tuptable, uint64 rows, int status)
373{
374 PLyResultObject *result;
375 PLyExecutionContext *exec_ctx = PLy_current_execution_context();
376 volatile MemoryContext oldcontext;
377
378
379#ifdef FAULT_INJECTOR
380 if (rows >= 10000 && rows <= 1000000)
381 {
382 if (FaultInjector_InjectFaultIfSet("executor_run_high_processed",
383 DDLNotSpecified,
384 "" /* databaseName */,
385 "" /* tableName */) == FaultInjectorTypeSkip)
386 {
387 /*
388 * For testing purposes, pretend that we have already processed
389 * almost 2^32 rows.
390 */
391 rows = UINT_MAX - 10;
392 }
393 }
394#endif /* FAULT_INJECTOR */
395
396 result = (PLyResultObject *) PLy_result_new();
397 if (!result)
398 {
399 SPI_freetuptable(tuptable);
400 return NULL;
401 }
402 Py_DECREF(result->status);
403 result->status = PyInt_FromLong(status);
404
405 if (status > 0 && tuptable == NULL)
406 {
407 Py_DECREF(result->nrows);
408 result->nrows = PyLong_FromUnsignedLongLong(rows);
409 }
410 else if (status > 0 && tuptable != NULL)
411 {
412 PLyDatumToOb ininfo;
413 MemoryContext cxt;
414
415 Py_DECREF(result->nrows);
416 result->nrows = PyLong_FromUnsignedLongLong(rows);
417
418 cxt = AllocSetContextCreate(CurrentMemoryContext,
419 "PL/Python temp context",
420 ALLOCSET_DEFAULT_SIZES);
421
422 /* Initialize for converting result tuples to Python */
423 PLy_input_setup_func(&ininfo, cxt, RECORDOID, -1,
424 exec_ctx->curr_proc);
425
426 oldcontext = CurrentMemoryContext;
427 PG_TRY();
428 {

Callers 2

PLy_spi_execute_planFunction · 0.85
PLy_spi_execute_queryFunction · 0.85

Calls 10

PLy_result_newFunction · 0.85
SPI_freetuptableFunction · 0.85
PLy_input_setup_funcFunction · 0.85
PLy_input_setup_tupleFunction · 0.85
PLy_input_from_tupleFunction · 0.85
MemoryContextSwitchToFunction · 0.85
CreateTupleDescCopyFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected