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

Function PLy_commit

src/pl/plpython/plpy_spi.c:499–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499PyObject *
500PLy_commit(PyObject *self, PyObject *args)
501{
502 MemoryContext oldcontext = CurrentMemoryContext;
503 PLyExecutionContext *exec_ctx = PLy_current_execution_context();
504
505 PG_TRY();
506 {
507 SPI_commit();
508
509 /* was cleared at transaction end, reset pointer */
510 exec_ctx->scratch_ctx = NULL;
511 }
512 PG_CATCH();
513 {
514 ErrorData *edata;
515 PLyExceptionEntry *entry;
516 PyObject *exc;
517
518 /* Save error info */
519 MemoryContextSwitchTo(oldcontext);
520 edata = CopyErrorData();
521 FlushErrorState();
522
523 /* was cleared at transaction end, reset pointer */
524 exec_ctx->scratch_ctx = NULL;
525
526 /* Look up the correct exception */
527 entry = hash_search(PLy_spi_exceptions, &(edata->sqlerrcode),
528 HASH_FIND, NULL);
529
530 /*
531 * This could be a custom error code, if that's the case fallback to
532 * SPIError
533 */
534 exc = entry ? entry->exc : PLy_exc_spi_error;
535 /* Make Python raise the exception */
536 PLy_spi_exception_set(exc, edata);
537 FreeErrorData(edata);
538
539 return NULL;
540 }
541 PG_END_TRY();
542
543 Py_RETURN_NONE;
544}
545
546PyObject *
547PLy_rollback(PyObject *self, PyObject *args)

Callers

nothing calls this directly

Calls 8

SPI_commitFunction · 0.85
MemoryContextSwitchToFunction · 0.85
hash_searchFunction · 0.85
PLy_spi_exception_setFunction · 0.85
CopyErrorDataFunction · 0.50
FlushErrorStateFunction · 0.50
FreeErrorDataFunction · 0.50

Tested by

no test coverage detected