mirror of
https://github.com/postgres/postgres.git
synced 2025-04-29 13:56:47 +03:00
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.
This commit is contained in:
parent
f1d0269861
commit
5d1af6aee3
@ -11,7 +11,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.55 2003/12/03 17:45:07 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.56 2004/04/07 17:42:28 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -757,6 +757,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
|
|||||||
List *retval = NIL;
|
List *retval = NIL;
|
||||||
int retvallen = 0;
|
int retvallen = 0;
|
||||||
int outer_query_keys = length(root->query_pathkeys);
|
int outer_query_keys = length(root->query_pathkeys);
|
||||||
|
List *sub_tlist = rel->subplan->targetlist;
|
||||||
List *l;
|
List *l;
|
||||||
|
|
||||||
foreach(l, subquery->query_pathkeys)
|
foreach(l, subquery->query_pathkeys)
|
||||||
@ -789,7 +790,7 @@ build_subquery_pathkeys(Query *root, RelOptInfo *rel, Query *subquery)
|
|||||||
Node *sub_key = sub_item->key;
|
Node *sub_key = sub_item->key;
|
||||||
List *k;
|
List *k;
|
||||||
|
|
||||||
foreach(k, subquery->targetList)
|
foreach(k, sub_tlist)
|
||||||
{
|
{
|
||||||
TargetEntry *tle = (TargetEntry *) lfirst(k);
|
TargetEntry *tle = (TargetEntry *) lfirst(k);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user