diff options
author | Bruce Momjian <bruce@momjian.us> | 1998-07-24 04:03:10 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1998-07-24 04:03:10 +0000 |
commit | 128d827d4bd4334bb0370a52790b3ec0f41eed57 (patch) | |
tree | 66df4c8a403b280266b26c77328df8f465a169b0 /src/backend/optimizer/plan/subselect.c | |
parent | bf00bbb0c4940b80b46b7e5b379cd64184f2262f (diff) | |
download | postgresql-128d827d4bd4334bb0370a52790b3ec0f41eed57.tar.gz postgresql-128d827d4bd4334bb0370a52790b3ec0f41eed57.zip |
I'm sorry, but I think I introduced a little bug with my last patch.
Everyone using an [NOT] EXISTS subquery will have noticed that
already.
The bug is in "subselect.c" in the function "SS_process_sublinks()".
Here the whole function as it *SHOULD BE*:
Stephan
Diffstat (limited to 'src/backend/optimizer/plan/subselect.c')
-rw-r--r-- | src/backend/optimizer/plan/subselect.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index 040c6732ccc..b5e4b1d8c84 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -404,12 +404,20 @@ SS_process_sublinks(Node *expr) ((Expr *) expr)->args = (List *) SS_process_sublinks((Node *) ((Expr *) expr)->args); else if (IsA(expr, SubLink))/* got it! */ - { - lfirst(((Expr *) lfirst(((SubLink *)expr)->oper))->args) = - lfirst(((SubLink *)expr)->lefthand); - + { + /* Hack to make sure expr->oper->args points to the same VAR node + * as expr->lefthand does. Needed for subselects in the havingQual + * when used on views. + * Otherwise aggregate functions will fail later on (at execution + * time!) Reason: The rewite System makes several copies of the + * VAR nodes and in this case it should not do so :-( */ + if(expr->lefthand != NULL) + { + lfirst(((Expr *) lfirst(((SubLink *)expr)->oper))->args) = + lfirst(((SubLink *)expr)->lefthand); + } expr = _make_subplan((SubLink *) expr); - } + } return (expr); } |