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

# SPI\_prepare\_extended(3)

prepare a statement, without executing it yet

## NAME

SPI\_prepare\_extended - prepare a statement, without executing it yet

## SYNOPSIS

```
SPIPlanPtr SPI_prepare_extended(const char * command,
                                const SPIPrepareOptions * options)
```

## DESCRIPTION

**SPI\_prepare\_extended** creates and returns a prepared statement for the specified command, but doesn't execute the command. This function is equivalent to **SPI\_prepare**, with the addition that the caller can specify options to control the parsing of external parameter references, as well as other facets of query parsing and planning.

## ARGUMENTS

const char \* *command*

command string

const SPIPrepareOptions \* *options*

struct containing optional arguments

Callers should always zero out the entire *options* struct, then fill whichever fields they want to set. This ensures forward compatibility of code, since any fields that are added to the struct in future will be defined to behave backwards-compatibly if they are zero. The currently available *options* fields are:

ParserSetupHook *parserSetup*

Parser hook setup function

void \* *parserSetupArg*

pass-through argument for *parserSetup*

RawParseMode *parseMode*

mode for raw parsing; RAW\_PARSE\_DEFAULT (zero) produces default behavior

int *cursorOptions*

integer bit mask of cursor options; zero produces default behavior

## RETURN VALUE

**SPI\_prepare\_extended** has the same return conventions as **SPI\_prepare**.
