summaryrefslogtreecommitdiff
path: root/src/backend/optimizer/plan/planmain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-09-23 23:50:47 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-09-23 23:50:47 +0000
commit730e2ffebc98977366ec717a0f89345425e02eb1 (patch)
tree7ac97764d3e565d7e9a67969d1e742dde6c8856f /src/backend/optimizer/plan/planmain.c
parent783af51cb1fc27218bec7137c7a138eefb1d76e4 (diff)
Back-patch code to deduce implied equalities from transitivity of
mergejoin clauses, and add these equalities to the given WHERE clauses. This is necessary to ensure that sort keys we think are equivalent really are equivalent as soon as their rels have been joined. Without this, 7.0 may create an incorrect mergejoin plan.
Diffstat (limited to 'src/backend/optimizer/plan/planmain.c')
-rw-r--r--src/backend/optimizer/plan/planmain.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c
index 0e05c945380..5e0619a3d8d 100644
--- a/src/backend/optimizer/plan/planmain.c
+++ b/src/backend/optimizer/plan/planmain.c
@@ -14,7 +14,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.55 2000/04/12 17:15:22 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.55.2.1 2000/09/23 23:50:47 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -184,7 +184,7 @@ subplanner(Query *root,
* base_rel_list as relation references are found (e.g., in the
* qualification, the targetlist, etc.). Restrict and join clauses
* are added to appropriate lists belonging to the mentioned
- * relations, and we also build lists of equijoined keys for pathkey
+ * relations. We also build lists of equijoined keys for pathkey
* construction.
*/
root->base_rel_list = NIL;
@@ -193,9 +193,19 @@ subplanner(Query *root,
make_var_only_tlist(root, flat_tlist);
add_restrict_and_join_to_rels(root, qual);
+
+ /*
+ * Make sure we have RelOptInfo nodes for all relations used.
+ */
add_missing_rels_to_query(root);
/*
+ * Use the completed lists of equijoined keys to deduce any implied
+ * but unstated equalities (for example, A=B and B=C imply A=C).
+ */
+ generate_implied_equalities(root);
+
+ /*
* We should now have all the pathkey equivalence sets built, so it's
* now possible to convert the requested query_pathkeys to canonical
* form.