diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-11-08 19:25:37 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-11-08 19:25:37 +0000 |
commit | 1be0601681197fe79a2d2d403c518e7aeff1788a (patch) | |
tree | 6d686123b9ca4e5dc70efa9dba364a558ddaa307 /src/backend/optimizer/path/pathkeys.c | |
parent | f1528b5154ed68ec37735e7125732a96aa1758e1 (diff) | |
download | postgresql-1be0601681197fe79a2d2d403c518e7aeff1788a.tar.gz postgresql-1be0601681197fe79a2d2d403c518e7aeff1788a.zip |
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.
Diffstat (limited to 'src/backend/optimizer/path/pathkeys.c')
-rw-r--r-- | src/backend/optimizer/path/pathkeys.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 2ad31203697..f96d7bb5554 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -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 */ |