-
-
Notifications
You must be signed in to change notification settings - Fork 295
Description
Currently, the SPI connection uses SPI_connect()
to establish a connection.
https://github.com/tcdi/pgx/blob/7163fe2437f8305b57e461697005d48de3526bbb/pgx/src/spi.rs#L213-L218
By default, calls to SPI_commit
and SPI_rollback
on a connection opened with SPI_connect
result in an immediate error (panic). That prevents us from rolling back transactions started through pgx::Spi
without a panic.
From the Postgres docs there is a function SPI_connect_ext
that takes an option SPI_OPT_NONATOMIC
to enable SPI_commit
/SPI_rollback
and is otherwise equivalent to SPI_connect
.
Here's the relevant excerpt:
SPI_OPT_NONATOMIC
Sets the SPI connection to be nonatomic, which means that transaction control calls (SPI_commit, SPI_rollback) are allowed. Otherwise, calling those functions will result in an immediate error.
As far as I can tell, it's a strict superset of functionality. What do you think about enabling nonatomic by default on SPI connections?