|
6 | 6 | *
|
7 | 7 | *
|
8 | 8 | * IDENTIFICATION
|
9 |
| - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.47 1999/06/21 01:26:56 tgl Exp $ |
| 9 | + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.48 1999/07/11 17:54:30 tgl Exp $ |
10 | 10 | *
|
11 | 11 | *-------------------------------------------------------------------------
|
12 | 12 | */
|
@@ -2610,25 +2610,28 @@ RewritePreprocessQuery(Query *parsetree)
|
2610 | 2610 | * target relation. FixNew() depends on it when replacing
|
2611 | 2611 | * *new* references in a rule action by the expressions
|
2612 | 2612 | * from the rewritten query.
|
| 2613 | + * resjunk targets are somewhat arbitrarily given a resno of 0; |
| 2614 | + * this is to prevent FixNew() from matching them to var nodes. |
2613 | 2615 | * ----------
|
2614 | 2616 | */
|
2615 | 2617 | if (parsetree->resultRelation>0)
|
2616 | 2618 | {
|
2617 | 2619 | RangeTblEntry*rte;
|
2618 | 2620 | Relationrd;
|
2619 | 2621 | List*tl;
|
2620 |
| -TargetEntry*tle; |
2621 |
| -intresdomno; |
2622 | 2622 |
|
2623 | 2623 | rte= (RangeTblEntry*)nth(parsetree->resultRelation-1,
|
2624 | 2624 | parsetree->rtable);
|
2625 | 2625 | rd=heap_openr(rte->relname);
|
2626 | 2626 |
|
2627 | 2627 | foreach(tl,parsetree->targetList)
|
2628 | 2628 | {
|
2629 |
| -tle= (TargetEntry*)lfirst(tl); |
2630 |
| -resdomno=attnameAttNum(rd,tle->resdom->resname); |
2631 |
| -tle->resdom->resno=resdomno; |
| 2629 | +TargetEntry*tle= (TargetEntry*)lfirst(tl); |
| 2630 | + |
| 2631 | +if (!tle->resdom->resjunk) |
| 2632 | +tle->resdom->resno=attnameAttNum(rd,tle->resdom->resname); |
| 2633 | +else |
| 2634 | +tle->resdom->resno=0; |
2632 | 2635 | }
|
2633 | 2636 |
|
2634 | 2637 | heap_close(rd);
|
|