mirror of
https://github.com/postgres/postgres.git
synced 2025-07-17 06:41:09 +03:00
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.
This commit is contained in:
@ -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))
|
||||
|
Reference in New Issue
Block a user