Fix the plan-invalidation mechanism to treat regclass constants that refer to
Tom Lane <tgl@sss.pgh.pa.us>
Fix the plan-invalidation mechanism to treat regclass constants that refer to
a relation as a reason to invalidate a plan when the relation changes. This
handles scenarios such as dropping/recreating a sequence that is referenced by
nextval('seq') in a cached plan. Rather than teach plancache.c all about
digging through plan trees to find regclass Consts, we charge the planner's
setrefs.c with making a list of the relation OIDs on which each plan depends.
That way the list can be built cheaply during a plan tree traversal that has
to happen anyway. Per bug #3662 and subsequent discussion.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/nodes/copyfuncs.c | modified | +2 −1 |
| src/backend/nodes/outfuncs.c | modified | +3 −1 |
| src/backend/optimizer/plan/planner.c | modified | +5 −2 |
| src/backend/optimizer/plan/setrefs.c | modified | +167 −78 |
| src/backend/utils/cache/plancache.c | modified | +6 −15 |
| src/include/nodes/plannodes.h | modified | +3 −1 |
| src/include/nodes/relation.h | modified | +3 −1 |
| src/include/optimizer/planmain.h | modified | +3 −2 |
| src/test/regress/expected/plancache.out | modified | +17 −0 |
| src/test/regress/sql/plancache.sql | modified | +14 −0 |