|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.131 2003/03/10 03:53:50 tgl Exp $ |
| 11 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.132 2003/03/14 00:55:17 tgl Exp $ |
12 | 12 | *
|
13 | 13 | * HISTORY
|
14 | 14 | * AUTHORDATEMAJOR EVENT
|
@@ -1497,6 +1497,28 @@ eval_const_expressions_mutator(Node *node, List *active_fns)
|
1497 | 1497 | newcoalesce->args=newargs;
|
1498 | 1498 | return (Node*)newcoalesce;
|
1499 | 1499 | }
|
| 1500 | +if (IsA(node,FieldSelect)) |
| 1501 | +{ |
| 1502 | +/* |
| 1503 | + * We can optimize field selection from a whole-row Var into a |
| 1504 | + * simple Var. (This case won't be generated directly by the |
| 1505 | + * parser, because ParseComplexProjection short-circuits it. |
| 1506 | + * But it can arise while simplifying functions.) If the argument |
| 1507 | + * isn't a whole-row Var, just fall through to do generic processing. |
| 1508 | + */ |
| 1509 | +FieldSelect*fselect= (FieldSelect*)node; |
| 1510 | +Var*argvar= (Var*)fselect->arg; |
| 1511 | + |
| 1512 | +if (argvar&&IsA(argvar,Var)&& |
| 1513 | +argvar->varattno==InvalidAttrNumber) |
| 1514 | +{ |
| 1515 | +return (Node*)makeVar(argvar->varno, |
| 1516 | +fselect->fieldnum, |
| 1517 | +fselect->resulttype, |
| 1518 | +fselect->resulttypmod, |
| 1519 | +argvar->varlevelsup); |
| 1520 | +} |
| 1521 | +} |
1500 | 1522 |
|
1501 | 1523 | /*
|
1502 | 1524 | * For any node type not handled above, we recurse using
|
|