12inline pg_exception::pg_exception(::MemoryContext mcxt) : mcxt(mcxt) {
13 ::CurrentMemoryContext = error_cxt =
14 memory_context(std::move(alloc_set_memory_context(top_memory_context())));
15 error = ffi_guard{::CopyErrorData}();
16 ::CurrentMemoryContext = mcxt;
17 ffi_guard{::FlushErrorState}();
20inline pg_exception::~pg_exception() { memory_context(error_cxt).delete_context(); }
22[[noreturn]]
inline void pg_exception::rethrow() {
27 auto *cb =
static_cast<::MemoryContextCallback *
>(
28 ffi_guard{::MemoryContextAlloc}(::ErrorContext,
sizeof(::MemoryContextCallback)));
29 cb->func = [](
void *arg) { ::MemoryContextDelete(
static_cast<::MemoryContext
>(arg)); };
31 ::MemoryContextRegisterResetCallback(::ErrorContext, cb);
32 ::ReThrowError(error);
33 __builtin_unreachable();