| 369 | } |
| 370 | |
| 371 | static PyObject * |
| 372 | PLy_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 | { |
no test coverage detected