提交 87b97b94 编写于 作者: K Kuien Liu

Remove dead code in outfuncs.c (#714)

The reason to remove them is because: print_variable_fields is initialized
to true, and only set to false in outfuncs_workfile_mgr_init() function.
But outfuncs_workfile_mgr_init() is never called. So we can remove all of:
print_variable_fields, outfuncs_workfile_mgr_init(), outfuncs_workfile_mgr_end(),
and all the if() tests depending on print_variable_fields.

Co-authored-by: Kuien Liu and Heikki Linnakangas
上级 96d1f4a0
......@@ -142,13 +142,6 @@
static void _outNode(StringInfo str, void *obj);
/* When serializing a plan for workfile caching, we want to leave out
* all variable fields by setting this to false */
static bool print_variable_fields = true;
/* rtable needed when serializing for workfile caching */
static List *range_table = NULL;
/*
* _outToken
* Convert an ordinary string (eg, an identifier) into a form that
......@@ -338,16 +331,13 @@ _outPlannedStmt(StringInfo str, PlannedStmt *node)
static void
_outPlanInfo(StringInfo str, Plan *node)
{
if (print_variable_fields)
{
WRITE_INT_FIELD(plan_node_id);
WRITE_INT_FIELD(plan_parent_node_id);
WRITE_INT_FIELD(plan_node_id);
WRITE_INT_FIELD(plan_parent_node_id);
WRITE_FLOAT_FIELD(startup_cost, "%.2f");
WRITE_FLOAT_FIELD(total_cost, "%.2f");
WRITE_FLOAT_FIELD(plan_rows, "%.0f");
WRITE_INT_FIELD(plan_width);
}
WRITE_FLOAT_FIELD(startup_cost, "%.2f");
WRITE_FLOAT_FIELD(total_cost, "%.2f");
WRITE_FLOAT_FIELD(plan_rows, "%.0f");
WRITE_INT_FIELD(plan_width);
WRITE_NODE_FIELD(targetlist);
WRITE_NODE_FIELD(qual);
......@@ -357,23 +347,17 @@ _outPlanInfo(StringInfo str, Plan *node)
WRITE_INT_FIELD(nParamExec);
if (print_variable_fields)
{
WRITE_NODE_FIELD(flow);
WRITE_ENUM_FIELD(dispatch, DispatchMethod);
WRITE_INT_FIELD(nMotionNodes);
WRITE_INT_FIELD(nInitPlans);
WRITE_NODE_FIELD(sliceTable);
}
WRITE_NODE_FIELD(flow);
WRITE_ENUM_FIELD(dispatch, DispatchMethod);
WRITE_INT_FIELD(nMotionNodes);
WRITE_INT_FIELD(nInitPlans);
WRITE_NODE_FIELD(sliceTable);
WRITE_NODE_FIELD(lefttree);
WRITE_NODE_FIELD(righttree);
WRITE_NODE_FIELD(initPlan);
if (print_variable_fields)
{
WRITE_UINT64_FIELD(operatorMemKB);
}
WRITE_UINT64_FIELD(operatorMemKB);
}
#endif /* COMPILING_BINARY_FUNCS */
......@@ -385,30 +369,7 @@ _outScanInfo(StringInfo str, Scan *node)
{
_outPlanInfo(str, (Plan *) node);
if (print_variable_fields)
{
WRITE_UINT_FIELD(scanrelid);
}
else
{
/*
* Serializing for workfile caching.
* Instead of outputing rtable indices, serialize the actual rtable entry
*/
Assert(range_table != NULL);
RangeTblEntry *rte = rt_fetch(node->scanrelid, range_table);
/*
* Serialize all rtable entries except for subquery type.
* For subquery scan, the rtable entry contains the entire plan of the
* subquery, but this is serialized elsewhere in outSubqueryScan, no
* need to duplicate it here
*/
if (rte->rtekind != RTE_SUBQUERY)
{
_outNode(str,rte);
}
}
WRITE_UINT_FIELD(scanrelid);
WRITE_INT_FIELD(partIndex);
WRITE_INT_FIELD(partIndexPrintable);
......@@ -794,11 +755,8 @@ _outAgg(StringInfo str, Agg *node)
for (i = 0; i < node->numCols; i++)
appendStringInfo(str, " %u", node->grpOperators[i]);
if (print_variable_fields)
{
WRITE_LONG_FIELD(numGroups);
WRITE_INT_FIELD(transSpace);
}
WRITE_LONG_FIELD(numGroups);
WRITE_INT_FIELD(transSpace);
WRITE_INT_FIELD(numNullCols);
WRITE_UINT64_FIELD(inputGrouping);
WRITE_UINT64_FIELD(grouping);
......@@ -1182,18 +1140,12 @@ _outVar(StringInfo str, Var *node)
{
WRITE_NODE_TYPE("VAR");
if (print_variable_fields)
{
WRITE_UINT_FIELD(varno);
}
WRITE_UINT_FIELD(varno);
WRITE_INT_FIELD(varattno);
WRITE_OID_FIELD(vartype);
WRITE_INT_FIELD(vartypmod);
WRITE_UINT_FIELD(varlevelsup);
if (print_variable_fields)
{
WRITE_UINT_FIELD(varnoold);
}
WRITE_UINT_FIELD(varnoold);
WRITE_INT_FIELD(varoattno);
}
......@@ -5132,35 +5084,6 @@ _outNode(StringInfo str, void *obj)
}
}
/*
* Initialize global variables for serializing a plan for the workfile manager.
* The serialized form of a plan for workfile manager does not include some
* variable fields such as costs and node ids.
* In addition, range table pointers are replaced with Oids where applicable.
*/
void
outfuncs_workfile_mgr_init(List *rtable)
{
Assert(NULL == range_table);
Assert(print_variable_fields);
range_table = rtable;
print_variable_fields = false;
}
/*
* Reset global variables to their default values at the end of serializing
* a plan for the workfile manager.
*/
void
outfuncs_workfile_mgr_end()
{
Assert(range_table != NULL);
Assert(!print_variable_fields);
print_variable_fields = true;
range_table = NULL;
}
/*
* nodeToString -
* returns the ascii representation of the Node as a palloc'd string
......
......@@ -198,14 +198,9 @@ bool WorkfileQueryspace_AddWorkfile(void);
void WorkfileQueryspace_SubtractWorkfile(int32 nFiles);
/* Serialization functions */
void outfuncs_workfile_mgr_init(List *rtable);
void outfuncs_workfile_mgr_end(void);
void outfast_workfile_mgr_init(List *rtable);
void outfast_workfile_mgr_end(void);
/* Debugging functions */
void workfile_mgr_print_set(workfile_set *work_set);
/* Workfile error reporting */
typedef enum WorkfileError
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册