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
    • following functions added (commits ee895a65 and d5a83d79):
      • SPI_execute_extended()
      • SPI_cursor_parse_open()
  • PostgreSQL 10
    • following functions removed and replaced by no-op macros (commit 1833f1a1):
      • SPI_push()
      • SPI_pop()
      • SPI_restore_connection()
  • PostgreSQL 8.3
    • following functions added (commit 66888f74):
      • SPI_prepare_cursor()
      • SPI_scroll_cursor_fetch()
      • SPI_scroll_cursor_move()
  • PostgreSQL 8.2
    • following return codes added (commit ea2e2635):
      • SPI_OK_INSERT_RETURNING
      • SPI_OK_UPDATE_RETURNING
      • SPI_OK_DELETE_RETURNING
  • PostgreSQL 8.0
    • following functions added (commit 65a0db19):
      • SPI_getargtypeid()
      • SPI_getargcount()
      • SPI_is_cursor_plan()
  • PostgreSQL 7.2
    • following functions added (commit d27f363e):
      • SPI_cursor_open()
      • SPI_cursor_find()
      • SPI_cursor_fetch()
      • SPI_cursor_fetch()
      • SPI_freeplan()
      • SPI_freetuptable()
    • function SPI_copytupledesc() added (commit f59f3c88)
  • PostgreSQL 6.2

Categories

Application interface, PostgreSQL internals

See also

spi, ECPG, worker_spi