| 497 | } |
| 498 | |
| 499 | PyObject * |
| 500 | PLy_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 | |
| 546 | PyObject * |
| 547 | PLy_rollback(PyObject *self, PyObject *args) |
nothing calls this directly
no test coverage detected