aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/selfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils/adt/selfuncs.c')
-rw-r--r--src/backend/utils/adt/selfuncs.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 0fcfdcbf322..56248a93b6a 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.214.2.5 2007/05/05 17:05:55 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.214.2.6 2007/08/31 23:35:29 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1386,11 +1386,24 @@ booltestsel(PlannerInfo *root, BoolTestType booltesttype, Node *arg,
*/
Selectivity
nulltestsel(PlannerInfo *root, NullTestType nulltesttype,
- Node *arg, int varRelid)
+ Node *arg, int varRelid, JoinType jointype)
{
VariableStatData vardata;
double selec;
+ /*
+ * Special hack: an IS NULL test being applied at an outer join should not
+ * be taken at face value, since it's very likely being used to select the
+ * outer-side rows that don't have a match, and thus its selectivity has
+ * nothing whatever to do with the statistics of the original table
+ * column. We do not have nearly enough context here to determine its
+ * true selectivity, so for the moment punt and guess at 0.5. Eventually
+ * the planner should be made to provide enough info about the clause's
+ * context to let us do better.
+ */
+ if (IS_OUTER_JOIN(jointype) && nulltesttype == IS_NULL)
+ return (Selectivity) 0.5;
+
examine_variable(root, arg, varRelid, &vardata);
if (HeapTupleIsValid(vardata.statsTuple))