September 4, 2025: PostgreSQL 18 RC 1 Released!
DocumentationPostgreSQL devel (2025年09月20日 21:25:11 - git commit e1d917182c1)
Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: 18 / devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2 / 8.1 / 8.0 / 7.4
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.
SPI_connect
Prev Up 45.1. Interface Functions Home Next

SPI_connect

SPI_connect, SPI_connect_ext — connect a C function to the SPI manager

Synopsis

int SPI_connect(void)
int SPI_connect_ext(int options)

Description

SPI_connect opens a connection from a C function invocation to the SPI manager. You must call this function if you want to execute commands through SPI. Some utility SPI functions can be called from unconnected C functions.

SPI_connect_ext does the same but has an argument that allows passing option flags. Currently, the following option values are available:

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.

SPI_connect() is equivalent to SPI_connect_ext(0).

Return Value

SPI_OK_CONNECT

on success

The fact that these functions return int not void is historical. All failure cases are reported via ereport or elog. (In versions before PostgreSQL v10, some but not all failures would be reported with a result value of SPI_ERROR_CONNECT.)


Prev Up Next
45.1. Interface Functions Home SPI_finish

AltStyle によって変換されたページ (->オリジナル) /