postgresql_16:6.10.1.29.4 Notes
PostgreSQL 16 > Server Programming > Server Programming Interface > Interface Functions > SPI_saveplan > Notes
The originally passed-in statement is not freed, so you might wish to do SPI_freeplan on it to avoid leaking memory until SPI_finish.
In most cases, SPI_keepplan is preferred to this function, since it accomplishes largely the same result without needing to physically copy the prepared statement's data structures.