*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.100 2009/06/11 14:48:59 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/joinrels.c,v 1.101 2009/07/19 20:32:48 tgl Exp $
*
*-------------------------------------------------------------------------
*/
{
SpecialJoinInfo *match_sjinfo;
bool reversed;
+ bool unique_ified;
bool is_valid_inner;
ListCell *l;
*/
match_sjinfo = NULL;
reversed = false;
+ unique_ified = false;
is_valid_inner = true;
foreach(l, root->join_info_list)
return false; /* invalid join path */
match_sjinfo = sjinfo;
reversed = false;
+ unique_ified = true;
}
else if (sjinfo->jointype == JOIN_SEMI &&
bms_equal(sjinfo->syn_righthand, rel1->relids) &&
return false; /* invalid join path */
match_sjinfo = sjinfo;
reversed = true;
+ unique_ified = true;
}
else
{
}
}
- /* Fail if violated some SJ's RHS and didn't match to another SJ */
- if (match_sjinfo == NULL && !is_valid_inner)
+ /*
+ * Fail if violated some SJ's RHS and didn't match to another SJ.
+ * However, "matching" to a semijoin we are implementing by
+ * unique-ification doesn't count (think: it's really an inner join).
+ */
+ if (!is_valid_inner &&
+ (match_sjinfo == NULL || unique_ified))
return false; /* invalid join path */
/* Otherwise, it's a valid join */
1
(1 row)
+-- try that with GEQO too
+begin;
+set geqo = on;
+set geqo_threshold = 2;
+select count(*) from tenk1 x where
+ x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
+ x.unique1 = 0 and
+ x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
+ count
+-------
+ 1
+(1 row)
+
+rollback;
--
-- Clean up
--
x.unique1 = 0 and
x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
+-- try that with GEQO too
+begin;
+set geqo = on;
+set geqo_threshold = 2;
+select count(*) from tenk1 x where
+ x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
+ x.unique1 = 0 and
+ x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
+rollback;
+
--
-- Clean up