diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-01-20 20:45:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-01-20 20:45:41 +0000 |
commit | f41803bb39bc2949db200116a609fd242d0ec221 (patch) | |
tree | 2c81bcf712ab8b46133c2f50bbee34b2b3ea7129 /src/backend/nodes/print.c | |
parent | 2b7334d4877ba445003f96b0bb7eed4e7078a39b (diff) | |
download | postgresql-f41803bb39bc2949db200116a609fd242d0ec221.tar.gz postgresql-f41803bb39bc2949db200116a609fd242d0ec221.zip |
Refactor planner's pathkeys data structure to create a separate, explicit
representation of equivalence classes of variables. This is an extensive
rewrite, but it brings a number of benefits:
* planner no longer fails in the presence of "incomplete" operator families
that don't offer operators for every possible combination of datatypes.
* avoid generating and then discarding redundant equality clauses.
* remove bogus assumption that derived equalities always use operators
named "=".
* mergejoins can work with a variety of sort orders (e.g., descending) now,
instead of tying each mergejoinable operator to exactly one sort order.
* better recognition of redundant sort columns.
* can make use of equalities appearing underneath an outer join.
Diffstat (limited to 'src/backend/nodes/print.c')
-rw-r--r-- | src/backend/nodes/print.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 1a7e1afb71e..e50ebf2bb55 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.82 2007/01/05 22:19:30 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/nodes/print.c,v 1.83 2007/01/20 20:45:38 tgl Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -404,7 +404,7 @@ print_expr(Node *expr, List *rtable) /* * print_pathkeys - - * pathkeys list of list of PathKeyItems + * pathkeys list of PathKeys */ void print_pathkeys(List *pathkeys, List *rtable) @@ -414,17 +414,26 @@ print_pathkeys(List *pathkeys, List *rtable) printf("("); foreach(i, pathkeys) { - List *pathkey = (List *) lfirst(i); + PathKey *pathkey = (PathKey *) lfirst(i); + EquivalenceClass *eclass; ListCell *k; + bool first = true; + + eclass = pathkey->pk_eclass; + /* chase up, in case pathkey is non-canonical */ + while (eclass->ec_merged) + eclass = eclass->ec_merged; printf("("); - foreach(k, pathkey) + foreach(k, eclass->ec_members) { - PathKeyItem *item = (PathKeyItem *) lfirst(k); + EquivalenceMember *mem = (EquivalenceMember *) lfirst(k); - print_expr(item->key, rtable); - if (lnext(k)) + if (first) + first = false; + else printf(", "); + print_expr((Node *) mem->em_expr, rtable); } printf(")"); if (lnext(i)) |