aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/joinpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-01-05 23:25:36 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-01-05 23:25:36 +0000
commit90f4c2d960a3f3b9d51d8349119f0fbb4c35fc9b (patch)
tree88f8e96f26083306f7523bd9c81394cc07246afa /src/backend/optimizer/path/joinpath.c
parentd86d51a95810caebcea587498068ff32fe28293e (diff)
downloadpostgresql-90f4c2d960a3f3b9d51d8349119f0fbb4c35fc9b.tar.gz
postgresql-90f4c2d960a3f3b9d51d8349119f0fbb4c35fc9b.zip
Add support for doing FULL JOIN ON FALSE. While this is really a rather
peculiar variant of UNION ALL, and so wouldn't likely get written directly as-is, it's possible for it to arise as a result of simplification of less-obviously-silly queries. In particular, now that we can do flattening of subqueries that have constant outputs and are underneath an outer join, it's possible for the case to result from simplification of queries of the type exhibited in bug #5263. Back-patch to 8.4 to avoid a functionality regression for this type of query.
Diffstat (limited to 'src/backend/optimizer/path/joinpath.c')
-rw-r--r--src/backend/optimizer/path/joinpath.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c
index f69ffbed7a8..2e208cb6210 100644
--- a/src/backend/optimizer/path/joinpath.c
+++ b/src/backend/optimizer/path/joinpath.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.128 2010/01/02 16:57:46 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/joinpath.c,v 1.129 2010/01/05 23:25:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1184,10 +1184,18 @@ select_mergejoin_clauses(PlannerInfo *root,
if (isouterjoin && restrictinfo->is_pushed_down)
continue;
+ /* Check that clause is a mergeable operator clause */
if (!restrictinfo->can_join ||
restrictinfo->mergeopfamilies == NIL)
{
- have_nonmergeable_joinclause = true;
+ /*
+ * The executor can handle extra joinquals that are constants,
+ * but not anything else, when doing right/full merge join. (The
+ * reason to support constants is so we can do FULL JOIN ON
+ * FALSE.)
+ */
+ if (!restrictinfo->clause || !IsA(restrictinfo->clause, Const))
+ have_nonmergeable_joinclause = true;
continue; /* not mergejoinable */
}