1SPI_SAVEPLAN(3) PostgreSQL 12.6 Documentation SPI_SAVEPLAN(3)
2
3
4
6 SPI_saveplan - save a prepared statement
7
9 SPIPlanPtr SPI_saveplan(SPIPlanPtr plan)
10
12 SPI_saveplan copies a passed statement (prepared by SPI_prepare) into
13 memory that will not be freed by SPI_finish nor by the transaction
14 manager, and returns a pointer to the copied statement. This gives you
15 the ability to reuse prepared statements in the subsequent invocations
16 of your C function in the current session.
17
19 SPIPlanPtr plan
20 the prepared statement to be saved
21
23 Pointer to the copied statement; or NULL if unsuccessful. On error,
24 SPI_result is set thus:
25
26 SPI_ERROR_ARGUMENT
27 if plan is NULL or invalid
28
29 SPI_ERROR_UNCONNECTED
30 if called from an unconnected C function
31
33 The originally passed-in statement is not freed, so you might wish to
34 do SPI_freeplan on it to avoid leaking memory until SPI_finish.
35
36 In most cases, SPI_keepplan is preferred to this function, since it
37 accomplishes largely the same result without needing to physically copy
38 the prepared statement's data structures.
39
40
41
42PostgreSQL 12.6 2021 SPI_SAVEPLAN(3)