Skip to content

Commit 5d1af6a

Browse files
committed
build_subquery_pathkeys() was examining wrong copy of subquery target list,
causing it to fail to recognize the output ordering of subqueries that contain set operations (UNION/INTERSECT/EXPECT). Per example from Karel Zak.
1 parent f1d0269 commit 5d1af6a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/optimizer/path/pathkeys.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.55 2003/12/03 17:45:07 tgl Exp $
14+
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.56 2004/04/07 17:42:28 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -757,6 +757,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
757757
List *retval = NIL;
758758
int retvallen = 0;
759759
int outer_query_keys = length(root->query_pathkeys);
760+
List *sub_tlist = rel->subplan->targetlist;
760761
List *l;
761762

762763
foreach(l, subquery->query_pathkeys)
@@ -789,7 +790,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
789790
Node *sub_key = sub_item->key;
790791
List *k;
791792

792-
foreach(k, subquery->targetList)
793+
foreach(k, sub_tlist)
793794
{
794795
TargetEntry *tle = (TargetEntry *) lfirst(k);
795796

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy