diff options
Diffstat (limited to 'src/backend/utils/adt')
-rw-r--r-- | src/backend/utils/adt/selfuncs.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 8bc26cb6e97..56e3a085974 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.264 2009/12/29 20:11:45 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.265 2010/01/01 21:53:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -5614,7 +5614,7 @@ btcostestimate(PG_FUNCTION_ARGS) int indexcol; bool eqQualHere; bool found_saop; - bool found_null_op; + bool found_is_null_op; double num_sa_scans; ListCell *l; @@ -5639,7 +5639,7 @@ btcostestimate(PG_FUNCTION_ARGS) indexcol = 0; eqQualHere = false; found_saop = false; - found_null_op = false; + found_is_null_op = false; num_sa_scans = 1; foreach(l, indexQuals) { @@ -5680,12 +5680,14 @@ btcostestimate(PG_FUNCTION_ARGS) { NullTest *nt = (NullTest *) clause; - Assert(nt->nulltesttype == IS_NULL); leftop = (Node *) nt->arg; rightop = NULL; clause_op = InvalidOid; - found_null_op = true; - is_null_op = true; + if (nt->nulltesttype == IS_NULL) + { + found_is_null_op = true; + is_null_op = true; + } } else { @@ -5725,12 +5727,7 @@ btcostestimate(PG_FUNCTION_ARGS) } } /* check for equality operator */ - if (is_null_op) - { - /* IS NULL is like = for purposes of selectivity determination */ - eqQualHere = true; - } - else + if (OidIsValid(clause_op)) { op_strategy = get_op_opfamily_strategy(clause_op, index->opfamily[indexcol]); @@ -5738,6 +5735,11 @@ btcostestimate(PG_FUNCTION_ARGS) if (op_strategy == BTEqualStrategyNumber) eqQualHere = true; } + else if (is_null_op) + { + /* IS NULL is like = for purposes of selectivity determination */ + eqQualHere = true; + } /* count up number of SA scans induced by indexBoundQuals only */ if (IsA(clause, ScalarArrayOpExpr)) { @@ -5760,7 +5762,7 @@ btcostestimate(PG_FUNCTION_ARGS) indexcol == index->ncolumns - 1 && eqQualHere && !found_saop && - !found_null_op) + !found_is_null_op) numIndexTuples = 1.0; else { |