Make use of plancache module for SPI plans. In particular, since plpgsql
Tom Lane <tgl@sss.pgh.pa.us>
Make use of plancache module for SPI plans. In particular, since plpgsql uses SPI plans, this finally fixes the ancient gotcha that you can't drop and recreate a temp table used by a plpgsql function. Along the way, clean up SPI's API a little bit by declaring SPI plan pointers as "SPIPlanPtr" instead of "void *". This is cosmetic but helps to forestall simple programming mistakes. (I have changed some but not all of the callers to match; there are still some "void *"'s in contrib and the PL's. This is intentional so that we can see if anyone's compiler complains about it.)
Files
| Path | Change | +/− |
|---|---|---|
| contrib/spi/refint.c | modified | +5 −5 |
| contrib/spi/timetravel.c | modified | +2 −2 |
| doc/src/sgml/spi.sgml | modified | +62 −38 |
| src/backend/executor/spi.c | modified | +282 −120 |
| src/backend/utils/adt/ri_triggers.c | modified | +28 −30 |
| src/backend/utils/adt/ruleutils.c | modified | +5 −5 |
| src/backend/utils/adt/xml.c | modified | +3 −3 |
| src/backend/utils/cache/plancache.c | modified | +12 −12 |
| src/include/executor/spi.h | modified | +21 −13 |
| src/include/executor/spi_priv.h | modified | +39 −20 |
| src/include/utils/plancache.h | modified | +2 −1 |
| src/pl/plpgsql/src/pl_exec.c | modified | +87 −32 |
| src/pl/plpgsql/src/plpgsql.h | modified | +4 −3 |
| src/test/regress/expected/plancache.out | modified | +61 −0 |
| src/test/regress/regress.c | modified | +3 −3 |
| src/test/regress/sql/plancache.sql | modified | +40 −0 |