mirror of
https://github.com/postgres/postgres.git
synced 2025-11-22 12:22:45 +03:00
Last week's patch for make_sort_from_pathkeys wasn't good enough: it has
to be able to discard top-level RelabelType nodes on *both* sides of the equivalence-class-to-target-list comparison, since make_pathkey_from_sortinfo might either add or remove a RelabelType. Also fix the latter to do the removal case cleanly. Per example from Peter.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.74 2007/01/05 22:19:33 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/optimizer/util/tlist.c,v 1.75 2007/11/08 19:25:37 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -44,6 +44,34 @@ tlist_member(Node *node, List *targetlist)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* tlist_member_ignore_relabel
|
||||
* Same as above, except that we ignore top-level RelabelType nodes
|
||||
* while checking for a match. This is needed for some scenarios
|
||||
* involving binary-compatible sort operations.
|
||||
*/
|
||||
TargetEntry *
|
||||
tlist_member_ignore_relabel(Node *node, List *targetlist)
|
||||
{
|
||||
ListCell *temp;
|
||||
|
||||
while (node && IsA(node, RelabelType))
|
||||
node = (Node *) ((RelabelType *) node)->arg;
|
||||
|
||||
foreach(temp, targetlist)
|
||||
{
|
||||
TargetEntry *tlentry = (TargetEntry *) lfirst(temp);
|
||||
Expr *tlexpr = tlentry->expr;
|
||||
|
||||
while (tlexpr && IsA(tlexpr, RelabelType))
|
||||
tlexpr = ((RelabelType *) tlexpr)->arg;
|
||||
|
||||
if (equal(node, tlexpr))
|
||||
return tlentry;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* flatten_tlist
|
||||
* Create a target list that only contains unique variables.
|
||||
|
||||
Reference in New Issue
Block a user