]> granicus.if.org Git - postgresql/commitdiff
Fix adjust_semi_join to be more cautious about clauseless joins.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 2 Nov 2010 22:45:44 +0000 (18:45 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 2 Nov 2010 22:45:44 +0000 (18:45 -0400)
It was reporting that these were fully indexed (hence cheap), when of
course they're the exact opposite of that.  I'm not certain if the case
would arise in practice, since a clauseless semijoin is hard to produce
in SQL, but if it did happen we'd make some dumb decisions.

src/backend/optimizer/path/costsize.c

index 6f16eb81dcd30eaa11b0c709d66ef68761a2550a..b27c26154cc8d908e459579af144df8affd9b33c 100644 (file)
@@ -2810,12 +2810,20 @@ adjust_semi_join(PlannerInfo *root, JoinPath *path, SpecialJoinInfo *sjinfo,
         */
        if (indexed_join_quals)
        {
-               List       *nrclauses;
+               if (path->joinrestrictinfo != NIL)
+               {
+                       List       *nrclauses;
 
-               nrclauses = select_nonredundant_join_clauses(root,
-                                                                                                        path->joinrestrictinfo,
-                                                                                                        path->innerjoinpath);
-               *indexed_join_quals = (nrclauses == NIL);
+                       nrclauses = select_nonredundant_join_clauses(root,
+                                                                                                                path->joinrestrictinfo,
+                                                                                                                path->innerjoinpath);
+                       *indexed_join_quals = (nrclauses == NIL);
+               }
+               else
+               {
+                       /* a clauseless join does NOT qualify */
+                       *indexed_join_quals = false;
+               }
        }
 
        return true;