1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +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:
Tom Lane
2007-11-08 19:25:37 +00:00
parent f1528b5154
commit 1be0601681
4 changed files with 50 additions and 23 deletions

View File

@ -11,7 +11,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.87 2007/11/02 18:54:15 tgl Exp $
* $PostgreSQL: pgsql/src/backend/optimizer/path/pathkeys.c,v 1.88 2007/11/08 19:25:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -292,13 +292,14 @@ make_pathkey_from_sortinfo(PlannerInfo *root,
if (exprType((Node *) expr) != opcintype &&
!IsPolymorphicType(opcintype))
{
/* Strip any existing RelabelType, and add a new one */
/* Strip any existing RelabelType, and add a new one if needed */
while (expr && IsA(expr, RelabelType))
expr = (Expr *) ((RelabelType *) expr)->arg;
expr = (Expr *) makeRelabelType(expr,
opcintype,
-1,
COERCE_DONTCARE);
if (exprType((Node *) expr) != opcintype)
expr = (Expr *) makeRelabelType(expr,
opcintype,
-1,
COERCE_DONTCARE);
}
/* Now find or create a matching EquivalenceClass */