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

# SPI\_finish(3)

disconnect a C function from the SPI manager

## NAME

SPI\_finish - disconnect a C function from the SPI manager

## SYNOPSIS

```
int SPI_finish(void)
```

## DESCRIPTION

**SPI\_finish** closes an existing connection to the SPI manager. You must call this function after completing the SPI operations needed during your C function's current invocation. You do not need to worry about making this happen, however, if you abort the transaction via elog(ERROR). In that case SPI will clean itself up automatically.

## RETURN VALUE

SPI\_OK\_FINISH

if properly disconnected

SPI\_ERROR\_UNCONNECTED

if called from an unconnected C function
