Modify the relcache to record the temp status of both local and nonlocal
Tom Lane <tgl@sss.pgh.pa.us>
Modify the relcache to record the temp status of both local and nonlocal temp relations; this is no more expensive than before, now that we have pg_class.relistemp. Insert tests into bufmgr.c to prevent attempting to fetch pages from nonlocal temp relations. This provides a low-level defense against bugs-of-omission allowing temp pages to be loaded into shared buffers, as in the contrib/pgstattuple problem reported by Stuart Bishop. While at it, tweak a bunch of places to use new relcache tests (instead of expensive probes into pg_namespace) to detect local or nonlocal temp tables.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/catalog/index.c | modified | +2 −2 |
| src/backend/catalog/namespace.c | modified | +4 −1 |
| src/backend/catalog/toasting.c | modified | +2 −2 |
| src/backend/commands/analyze.c | modified | +2 −2 |
| src/backend/commands/cluster.c | modified | +4 −4 |
| src/backend/commands/copy.c | modified | +2 −3 |
| src/backend/commands/indexcmds.c | modified | +4 −3 |
| src/backend/commands/tablecmds.c | modified | +9 −10 |
| src/backend/commands/vacuum.c | modified | +2 −2 |
| src/backend/optimizer/prep/prepunion.c | modified | +11 −9 |
| src/backend/postmaster/autovacuum.c | modified | +8 −8 |
| src/backend/storage/buffer/bufmgr.c | modified | +19 −1 |
| src/backend/utils/cache/relcache.c | modified | +10 −6 |
| src/include/utils/rel.h | modified | +13 −3 |