Server Programming Interface (SPI)
A set of interface functions for executing SQL commands inside C functions
The Server Programming Interface
(SPI
) is a set of interface functions for executing SQL commands inside C functions which run in the PostgreSQL server context.
For an interface for embedding SQL commands into external C programs, see ECPG.
SPI
was added in PostgreSQL 6.2.
Source code
SPI
is mainly located in: src/backend/executor/spi.c.
Change history
Work-in-progress
- PostgreSQL 14
- PostgreSQL 10
- following functions removed and replaced by no-op macros (commit 1833f1a1):
SPI_push()
SPI_pop()
SPI_restore_connection()
- following functions removed and replaced by no-op macros (commit 1833f1a1):
- PostgreSQL 8.3
- following functions added (commit 66888f74):
SPI_prepare_cursor()
SPI_scroll_cursor_fetch()
SPI_scroll_cursor_move()
- following functions added (commit 66888f74):
- PostgreSQL 8.2
- following return codes added (commit ea2e2635):
SPI_OK_INSERT_RETURNING
SPI_OK_UPDATE_RETURNING
SPI_OK_DELETE_RETURNING
- following return codes added (commit ea2e2635):
- PostgreSQL 8.0
- following functions added (commit 65a0db19):
SPI_getargtypeid()
SPI_getargcount()
SPI_is_cursor_plan()
- following functions added (commit 65a0db19):
- PostgreSQL 7.2
- PostgreSQL 6.2
- added (commit 0d0254d1)
References
- PostgreSQL documentation: Server Programming Interface