---
name: "SPI_connect_ext"
section: "3"
platform: "linux"
package: "postgresql"
version: "18.6-4"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/SPI_connect"
---

# SPI\_connect\_ext(3)

connect a C function to the SPI manager

Part of [SPI\_connect(3)](/SPI_connect/3.md).

## NAME

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.)
