mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21:12 +03:00
Rethink representation of PathTargets.
In commit 19a541143a
I did not make PathTarget a subtype of Node,
and embedded a RelOptInfo's reltarget directly into it rather than having
a separately-allocated Node. In hindsight that was misguided
micro-optimization, enabled by the fact that at that point we didn't have
any Paths with custom PathTargets. Now that PathTarget processing has
been fleshed out some more, it's easier to see that it's better to have
PathTarget as an indepedent Node type, even if it does cost us one more
palloc to create a RelOptInfo. So change it while we still can.
This commit just changes the representation, without doing anything more
interesting than that.
This commit is contained in:
@ -1598,22 +1598,8 @@ _outPathInfo(StringInfo str, const Path *node)
|
||||
WRITE_ENUM_FIELD(pathtype, NodeTag);
|
||||
appendStringInfoString(str, " :parent_relids ");
|
||||
_outBitmapset(str, node->parent->relids);
|
||||
if (node->pathtarget != &(node->parent->reltarget))
|
||||
{
|
||||
WRITE_NODE_FIELD(pathtarget->exprs);
|
||||
if (node->pathtarget->sortgrouprefs)
|
||||
{
|
||||
int i;
|
||||
|
||||
appendStringInfoString(str, " :pathtarget->sortgrouprefs");
|
||||
for (i = 0; i < list_length(node->pathtarget->exprs); i++)
|
||||
appendStringInfo(str, " %u",
|
||||
node->pathtarget->sortgrouprefs[i]);
|
||||
}
|
||||
WRITE_FLOAT_FIELD(pathtarget->cost.startup, "%.2f");
|
||||
WRITE_FLOAT_FIELD(pathtarget->cost.per_tuple, "%.2f");
|
||||
WRITE_INT_FIELD(pathtarget->width);
|
||||
}
|
||||
if (node->pathtarget != node->parent->reltarget)
|
||||
WRITE_NODE_FIELD(pathtarget);
|
||||
appendStringInfoString(str, " :required_outer ");
|
||||
if (node->param_info)
|
||||
_outBitmapset(str, node->param_info->ppi_req_outer);
|
||||
@ -2094,11 +2080,7 @@ _outRelOptInfo(StringInfo str, const RelOptInfo *node)
|
||||
WRITE_BOOL_FIELD(consider_startup);
|
||||
WRITE_BOOL_FIELD(consider_param_startup);
|
||||
WRITE_BOOL_FIELD(consider_parallel);
|
||||
WRITE_NODE_FIELD(reltarget.exprs);
|
||||
/* reltarget.sortgrouprefs is never interesting, at present anyway */
|
||||
WRITE_FLOAT_FIELD(reltarget.cost.startup, "%.2f");
|
||||
WRITE_FLOAT_FIELD(reltarget.cost.per_tuple, "%.2f");
|
||||
WRITE_INT_FIELD(reltarget.width);
|
||||
WRITE_NODE_FIELD(reltarget);
|
||||
WRITE_NODE_FIELD(pathlist);
|
||||
WRITE_NODE_FIELD(ppilist);
|
||||
WRITE_NODE_FIELD(partial_pathlist);
|
||||
@ -2201,6 +2183,25 @@ _outPathKey(StringInfo str, const PathKey *node)
|
||||
WRITE_BOOL_FIELD(pk_nulls_first);
|
||||
}
|
||||
|
||||
static void
|
||||
_outPathTarget(StringInfo str, const PathTarget *node)
|
||||
{
|
||||
WRITE_NODE_TYPE("PATHTARGET");
|
||||
|
||||
WRITE_NODE_FIELD(exprs);
|
||||
if (node->sortgrouprefs)
|
||||
{
|
||||
int i;
|
||||
|
||||
appendStringInfoString(str, " :sortgrouprefs");
|
||||
for (i = 0; i < list_length(node->exprs); i++)
|
||||
appendStringInfo(str, " %u", node->sortgrouprefs[i]);
|
||||
}
|
||||
WRITE_FLOAT_FIELD(cost.startup, "%.2f");
|
||||
WRITE_FLOAT_FIELD(cost.per_tuple, "%.2f");
|
||||
WRITE_INT_FIELD(width);
|
||||
}
|
||||
|
||||
static void
|
||||
_outParamPathInfo(StringInfo str, const ParamPathInfo *node)
|
||||
{
|
||||
@ -3612,6 +3613,9 @@ _outNode(StringInfo str, const void *obj)
|
||||
case T_PathKey:
|
||||
_outPathKey(str, obj);
|
||||
break;
|
||||
case T_PathTarget:
|
||||
_outPathTarget(str, obj);
|
||||
break;
|
||||
case T_ParamPathInfo:
|
||||
_outParamPathInfo(str, obj);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user