diff options
| author | Tom Lane | 2007-11-08 21:49:48 +0000 |
|---|---|---|
| committer | Tom Lane | 2007-11-08 21:49:48 +0000 |
| commit | c291203ca3cde3b10e7a8962df2c1ccc737a9e6f (patch) | |
| tree | 2fef9ed8d4bbd9b725b4f857918ea98cf85bbc09 /src/include/optimizer | |
| parent | 1be0601681197fe79a2d2d403c518e7aeff1788a (diff) | |
Fix EquivalenceClass code to handle volatile sort expressions in a more
predictable manner; in particular that if you say ORDER BY output-column-ref,
it will in fact sort by that specific column even if there are multiple
syntactic matches. An example is
SELECT random() AS a, random() AS b FROM ... ORDER BY b, a;
While the use-case for this might be a bit debatable, it worked as expected
in earlier releases, so we should preserve the behavior for 8.3. Per my
recent proposal.
While at it, fix convert_subquery_pathkeys() to handle RelabelType stripping
in both directions; it needs this for the same reasons make_sort_from_pathkeys
does.
Diffstat (limited to 'src/include/optimizer')
| -rw-r--r-- | src/include/optimizer/paths.h | 5 | ||||
| -rw-r--r-- | src/include/optimizer/tlist.h | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index cbde0c7b9a5..cf589b48af7 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.99 2007/09/26 18:51:51 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/paths.h,v 1.100 2007/11/08 21:49:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -115,7 +115,8 @@ extern void reconsider_outer_join_clauses(PlannerInfo *root); extern EquivalenceClass *get_eclass_for_sort_expr(PlannerInfo *root, Expr *expr, Oid expr_datatype, - List *opfamilies); + List *opfamilies, + Index sortref); extern void generate_base_implied_equalities(PlannerInfo *root); extern List *generate_join_implied_equalities(PlannerInfo *root, RelOptInfo *joinrel, diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index bb127cbce2b..515339363ab 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/tlist.h,v 1.46 2007/11/08 19:25:37 tgl Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/tlist.h,v 1.47 2007/11/08 21:49:48 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,8 @@ extern TargetEntry *tlist_member_ignore_relabel(Node *node, List *targetlist); extern List *flatten_tlist(List *tlist); extern List *add_to_flat_tlist(List *tlist, List *vars); +extern TargetEntry *get_sortgroupref_tle(Index sortref, + List *targetList); extern TargetEntry *get_sortgroupclause_tle(SortClause *sortClause, List *targetList); extern Node *get_sortgroupclause_expr(SortClause *sortClause, |
