Flush Memoize cache when non-key parameters change, take 2
David Rowley <drowley@postgresql.org>
Flush Memoize cache when non-key parameters change, take 2 It's possible that a subplan below a Memoize node contains a parameter from above the Memoize node. If this parameter changes then cache entries may become out-dated due to the new parameter value. Previously Memoize was mistakenly not aware of this. We fix this here by flushing the cache whenever a parameter that's not part of the cache key changes. Bug: #17213 Reported by: Elvis Pranskevichus Author: David Rowley Discussion: https://postgr.es/m/17213-988ed34b225a2862@postgresql.org Backpatch-through: 14, where Memoize was added
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/executor/nodeMemoize.c | modified | +38 −0 |
| src/backend/nodes/bitmapset.c | modified | +2 −0 |
| src/backend/nodes/copyfuncs.c | modified | +1 −0 |
| src/backend/nodes/outfuncs.c | modified | +1 −0 |
| src/backend/nodes/readfuncs.c | modified | +1 −0 |
| src/backend/optimizer/plan/createplan.c | modified | +7 −3 |
| src/backend/optimizer/util/clauses.c | modified | +31 −0 |
| src/include/nodes/execnodes.h | modified | +2 −0 |
| src/include/nodes/plannodes.h | modified | +1 −0 |
| src/include/optimizer/clauses.h | modified | +2 −0 |
| src/test/regress/expected/memoize.out | modified | +39 −0 |
| src/test/regress/sql/memoize.sql | modified | +20 −0 |
Discussion
- BUG #17213: Wrong result from a query involving Merge Semi Join and Memoize 10 messages · 2021-10-04 → 2021-11-24