1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Change the name of the Result Cache node to Memoize

"Result Cache" was never a great name for this node, but nobody managed
to come up with another name that anyone liked enough.  That was until
David Johnston mentioned "Node Memoization", which Tom Lane revised to
just "Memoize".  People seem to like "Memoize", so let's do the rename.

Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/20210708165145.GG1176@momjian.us
Backpatch-through: 14, where Result Cache was introduced
This commit is contained in:
David Rowley
2021-07-14 12:43:58 +12:00
parent d68a003912
commit 83f4fcc655
43 changed files with 594 additions and 605 deletions

View File

@@ -92,9 +92,8 @@ static Result *create_group_result_plan(PlannerInfo *root,
static ProjectSet *create_project_set_plan(PlannerInfo *root, ProjectSetPath *best_path);
static Material *create_material_plan(PlannerInfo *root, MaterialPath *best_path,
int flags);
static ResultCache *create_resultcache_plan(PlannerInfo *root,
ResultCachePath *best_path,
int flags);
static Memoize *create_memoize_plan(PlannerInfo *root, MemoizePath *best_path,
int flags);
static Plan *create_unique_plan(PlannerInfo *root, UniquePath *best_path,
int flags);
static Gather *create_gather_plan(PlannerInfo *root, GatherPath *best_path);
@@ -278,11 +277,9 @@ static Sort *make_sort_from_groupcols(List *groupcls,
AttrNumber *grpColIdx,
Plan *lefttree);
static Material *make_material(Plan *lefttree);
static ResultCache *make_resultcache(Plan *lefttree, Oid *hashoperators,
Oid *collations,
List *param_exprs,
bool singlerow,
uint32 est_entries);
static Memoize *make_memoize(Plan *lefttree, Oid *hashoperators,
Oid *collations, List *param_exprs,
bool singlerow, uint32 est_entries);
static WindowAgg *make_windowagg(List *tlist, Index winref,
int partNumCols, AttrNumber *partColIdx, Oid *partOperators, Oid *partCollations,
int ordNumCols, AttrNumber *ordColIdx, Oid *ordOperators, Oid *ordCollations,
@@ -459,10 +456,10 @@ create_plan_recurse(PlannerInfo *root, Path *best_path, int flags)
(MaterialPath *) best_path,
flags);
break;
case T_ResultCache:
plan = (Plan *) create_resultcache_plan(root,
(ResultCachePath *) best_path,
flags);
case T_Memoize:
plan = (Plan *) create_memoize_plan(root,
(MemoizePath *) best_path,
flags);
break;
case T_Unique:
if (IsA(best_path, UpperUniquePath))
@@ -1578,16 +1575,16 @@ create_material_plan(PlannerInfo *root, MaterialPath *best_path, int flags)
}
/*
* create_resultcache_plan
* Create a ResultCache plan for 'best_path' and (recursively) plans
* for its subpaths.
* create_memoize_plan
* Create a Memoize plan for 'best_path' and (recursively) plans for its
* subpaths.
*
* Returns a Plan node.
*/
static ResultCache *
create_resultcache_plan(PlannerInfo *root, ResultCachePath *best_path, int flags)
static Memoize *
create_memoize_plan(PlannerInfo *root, MemoizePath *best_path, int flags)
{
ResultCache *plan;
Memoize *plan;
Plan *subplan;
Oid *operators;
Oid *collations;
@@ -1619,8 +1616,8 @@ create_resultcache_plan(PlannerInfo *root, ResultCachePath *best_path, int flags
i++;
}
plan = make_resultcache(subplan, operators, collations, param_exprs,
best_path->singlerow, best_path->est_entries);
plan = make_memoize(subplan, operators, collations, param_exprs,
best_path->singlerow, best_path->est_entries);
copy_generic_path_info(&plan->plan, (Path *) best_path);
@@ -6417,11 +6414,11 @@ materialize_finished_plan(Plan *subplan)
return matplan;
}
static ResultCache *
make_resultcache(Plan *lefttree, Oid *hashoperators, Oid *collations,
List *param_exprs, bool singlerow, uint32 est_entries)
static Memoize *
make_memoize(Plan *lefttree, Oid *hashoperators, Oid *collations,
List *param_exprs, bool singlerow, uint32 est_entries)
{
ResultCache *node = makeNode(ResultCache);
Memoize *node = makeNode(Memoize);
Plan *plan = &node->plan;
plan->targetlist = lefttree->targetlist;
@@ -7035,7 +7032,7 @@ is_projection_capable_path(Path *path)
{
case T_Hash:
case T_Material:
case T_ResultCache:
case T_Memoize:
case T_Sort:
case T_IncrementalSort:
case T_Unique:
@@ -7085,7 +7082,7 @@ is_projection_capable_plan(Plan *plan)
{
case T_Hash:
case T_Material:
case T_ResultCache:
case T_Memoize:
case T_Sort:
case T_Unique:
case T_SetOp:

View File

@@ -78,7 +78,7 @@ static bool check_equivalence_delay(PlannerInfo *root,
static bool check_redundant_nullability_qual(PlannerInfo *root, Node *clause);
static void check_mergejoinable(RestrictInfo *restrictinfo);
static void check_hashjoinable(RestrictInfo *restrictinfo);
static void check_resultcacheable(RestrictInfo *restrictinfo);
static void check_memoizable(RestrictInfo *restrictinfo);
/*****************************************************************************
@@ -2212,10 +2212,10 @@ distribute_restrictinfo_to_rels(PlannerInfo *root,
/*
* Likewise, check if the clause is suitable to be used with a
* Result Cache node to cache inner tuples during a parameterized
* Memoize node to cache inner tuples during a parameterized
* nested loop.
*/
check_resultcacheable(restrictinfo);
check_memoizable(restrictinfo);
/*
* Add clause to the join lists of all the relevant relations.
@@ -2459,7 +2459,7 @@ build_implied_join_equality(PlannerInfo *root,
/* Set mergejoinability/hashjoinability flags */
check_mergejoinable(restrictinfo);
check_hashjoinable(restrictinfo);
check_resultcacheable(restrictinfo);
check_memoizable(restrictinfo);
return restrictinfo;
}
@@ -2709,13 +2709,13 @@ check_hashjoinable(RestrictInfo *restrictinfo)
}
/*
* check_resultcacheable
* If the restrictinfo's clause is suitable to be used for a Result Cache
* node, set the hasheqoperator to the hash equality operator that will be
* needed during caching.
* check_memoizable
* If the restrictinfo's clause is suitable to be used for a Memoize node,
* set the hasheqoperator to the hash equality operator that will be needed
* during caching.
*/
static void
check_resultcacheable(RestrictInfo *restrictinfo)
check_memoizable(RestrictInfo *restrictinfo)
{
TypeCacheEntry *typentry;
Expr *clause = restrictinfo->clause;

View File

@@ -752,19 +752,19 @@ set_plan_refs(PlannerInfo *root, Plan *plan, int rtoffset)
set_hash_references(root, plan, rtoffset);
break;
case T_ResultCache:
case T_Memoize:
{
ResultCache *rcplan = (ResultCache *) plan;
Memoize *mplan = (Memoize *) plan;
/*
* Result Cache does not evaluate its targetlist. It just
* uses the same targetlist from its outer subnode.
* Memoize does not evaluate its targetlist. It just uses the
* same targetlist from its outer subnode.
*/
set_dummy_tlist_references(plan, rtoffset);
rcplan->param_exprs = fix_scan_list(root, rcplan->param_exprs,
rtoffset,
NUM_EXEC_TLIST(plan));
mplan->param_exprs = fix_scan_list(root, mplan->param_exprs,
rtoffset,
NUM_EXEC_TLIST(plan));
break;
}

View File

@@ -2745,8 +2745,8 @@ finalize_plan(PlannerInfo *root, Plan *plan,
/* rescan_param does *not* get added to scan_params */
break;
case T_ResultCache:
finalize_primnode((Node *) ((ResultCache *) plan)->param_exprs,
case T_Memoize:
finalize_primnode((Node *) ((Memoize *) plan)->param_exprs,
&context);
break;