|
7 | 7 | * Portions Copyright (c) 1994, Regents of the University of California
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.82 2003/08/08 21:41:51 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.83 2003/10/18 16:52:15 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -493,8 +493,8 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
|
493 | 493 | * If rtindex is 0, we build Params to represent the sub-select outputs.
|
494 | 494 | * The paramids of the Params created are returned in the *righthandIds list.
|
495 | 495 | *
|
496 |
| - * If rtindex is not 0, we build Vars using that rtindex as varno. The |
497 |
| - * Vars themselves are returned in *righthandIds (this is a bit of a type |
| 496 | + * If rtindex is not 0, we build Vars using that rtindex as varno. Copies |
| 497 | + * of the Var nodes are returned in *righthandIds (this is a bit of a type |
498 | 498 | * cheat, but we can get away with it).
|
499 | 499 | */
|
500 | 500 | static List *
|
@@ -525,8 +525,11 @@ convert_sublink_opers(List *lefthand, List *operOids,
|
525 | 525 | te->resdom->restype,
|
526 | 526 | te->resdom->restypmod,
|
527 | 527 | 0);
|
528 |
| - /* Record it for caller */ |
529 |
| - *righthandIds = lappend(*righthandIds, rightop); |
| 528 | + /* |
| 529 | + * Copy it for caller. NB: we need a copy to avoid having |
| 530 | + * doubly-linked substructure in the modified parse tree. |
| 531 | + */ |
| 532 | + *righthandIds = lappend(*righthandIds, copyObject(rightop)); |
530 | 533 | }
|
531 | 534 | else
|
532 | 535 | {
|
@@ -735,7 +738,7 @@ convert_IN_to_join(Query *parse, SubLink *sublink)
|
735 | 738 |
|
736 | 739 | /*
|
737 | 740 | * Build the result qual expressions. As a side effect,
|
738 |
| - * ininfo->sub_targetlist is filled with a list of the Vars |
| 741 | + * ininfo->sub_targetlist is filled with a list of Vars |
739 | 742 | * representing the subselect outputs.
|
740 | 743 | */
|
741 | 744 | exprs = convert_sublink_opers(sublink->lefthand,
|
|
0 commit comments