提交 7931bfa7 编写于 作者: T Tom Lane

Make eval_const_expressions simplify FieldSelect from a whole-row Var

into an ordinary one-field Var.  Per example from Chris Mungall.
上级 2a1ef30b
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.131 2003/03/10 03:53:50 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.132 2003/03/14 00:55:17 tgl Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -1497,6 +1497,28 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
newcoalesce->args = newargs;
return (Node *) newcoalesce;
}
if (IsA(node, FieldSelect))
{
/*
* We can optimize field selection from a whole-row Var into a
* simple Var. (This case won't be generated directly by the
* parser, because ParseComplexProjection short-circuits it.
* But it can arise while simplifying functions.) If the argument
* isn't a whole-row Var, just fall through to do generic processing.
*/
FieldSelect *fselect = (FieldSelect *) node;
Var *argvar = (Var *) fselect->arg;
if (argvar && IsA(argvar, Var) &&
argvar->varattno == InvalidAttrNumber)
{
return (Node *) makeVar(argvar->varno,
fselect->fieldnum,
fselect->resulttype,
fselect->resulttypmod,
argvar->varlevelsup);
}
}
/*
* For any node type not handled above, we recurse using
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册