aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/path/indxpath.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-04-06 22:33:43 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-04-06 22:33:43 +0000
commitf02a82b6adad1af75499c4ac7221bbd94e3c4fbf (patch)
treed15b0a2a52d95e046bb3945f4487982943ed211e /src/backend/optimizer/path/indxpath.c
parent146c83c045625d6f0072dd96045ebbc54582be05 (diff)
downloadpostgresql-f02a82b6adad1af75499c4ac7221bbd94e3c4fbf.tar.gz
postgresql-f02a82b6adad1af75499c4ac7221bbd94e3c4fbf.zip
Make 'col IS NULL' clauses be indexable conditions.
Teodor Sigaev, with some kibitzing from Tom Lane.
Diffstat (limited to 'src/backend/optimizer/path/indxpath.c')
-rw-r--r--src/backend/optimizer/path/indxpath.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c
index 7197658ae9b..176f2a66387 100644
--- a/src/backend/optimizer/path/indxpath.c
+++ b/src/backend/optimizer/path/indxpath.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.218 2007/03/21 22:18:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.219 2007/04/06 22:33:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1050,6 +1050,7 @@ match_clause_to_indexcol(IndexOptInfo *index,
* Clause must be a binary opclause, or possibly a ScalarArrayOpExpr
* (which is always binary, by definition). Or it could be a
* RowCompareExpr, which we pass off to match_rowcompare_to_indexcol().
+ * Or, if the index supports it, we can handle IS NULL clauses.
*/
if (is_opclause(clause))
{
@@ -1083,6 +1084,15 @@ match_clause_to_indexcol(IndexOptInfo *index,
(RowCompareExpr *) clause,
outer_relids);
}
+ else if (index->amsearchnulls && IsA(clause, NullTest))
+ {
+ NullTest *nt = (NullTest *) clause;
+
+ if (nt->nulltesttype == IS_NULL &&
+ match_index_to_operand((Node *) nt->arg, indexcol, index))
+ return true;
+ return false;
+ }
else
return false;
@@ -2102,8 +2112,8 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
}
/*
- * Else it must be an opclause (usual case), ScalarArrayOp, or
- * RowCompare
+ * Else it must be an opclause (usual case), ScalarArrayOp,
+ * RowCompare, or NullTest
*/
if (is_opclause(clause))
{
@@ -2123,6 +2133,16 @@ expand_indexqual_conditions(IndexOptInfo *index, List *clausegroups)
index,
indexcol));
}
+ else if (IsA(clause, NullTest))
+ {
+ Assert(index->amsearchnulls);
+ resultquals = lappend(resultquals,
+ make_restrictinfo(clause,
+ true,
+ false,
+ false,
+ NULL));
+ }
else
elog(ERROR, "unsupported indexqual type: %d",
(int) nodeTag(clause));