diff options
| author | David Rowley | 2021-11-24 10:29:14 +0000 |
|---|---|---|
| committer | David Rowley | 2021-11-24 10:29:14 +0000 |
| commit | 411137a429210e432f923264a8e313a9872910ca (patch) | |
| tree | 2f635992ec138d1c68dbc38f77a6bcf3779a3fbd /src/include | |
| parent | fb5961fd13b1262df280e400645bdf4ed192f058 (diff) | |
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/[email protected]
Backpatch-through: 14, where Memoize was added
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/nodes/execnodes.h | 2 | ||||
| -rw-r--r-- | src/include/nodes/plannodes.h | 1 | ||||
| -rw-r--r-- | src/include/optimizer/clauses.h | 2 |
3 files changed, 5 insertions, 0 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index d96ace32e43..ddc35293326 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -2113,6 +2113,8 @@ typedef struct MemoizeState * by bit, false when using hash equality ops */ MemoizeInstrumentation stats; /* execution statistics */ SharedMemoizeInfo *shared_info; /* statistics for parallel workers */ + Bitmapset *keyparamids; /* Param->paramids of expressions belonging to + * param_exprs */ } MemoizeState; /* ---------------- diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index f1328be3549..be3c30704ad 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -804,6 +804,7 @@ typedef struct Memoize uint32 est_entries; /* The maximum number of entries that the * planner expects will fit in the cache, or 0 * if unknown */ + Bitmapset *keyparamids; /* paramids from param_exprs */ } Memoize; /* ---------------- diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index 0673887a852..bc3f3e60d43 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -53,4 +53,6 @@ extern void CommuteOpExpr(OpExpr *clause); extern Query *inline_set_returning_function(PlannerInfo *root, RangeTblEntry *rte); +extern Bitmapset *pull_paramids(Expr *expr); + #endif /* CLAUSES_H */ |
