summaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistget.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-01-01 21:53:49 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-01-01 21:53:49 +0000
commit29c4ad98293e3c5cb3fcdd413a3f4904efff8762 (patch)
tree4e4eeea2655e87eca4d3d0dd97f3e2b7d5f1e032 /src/backend/access/gist/gistget.c
parent15faca259651c065bb20e746777f5fb9eb9d50a1 (diff)
downloadpostgresql-29c4ad98293e3c5cb3fcdd413a3f4904efff8762.tar.gz
Support "x IS NOT NULL" clauses as indexscan conditions. This turns out
to be just a minor extension of the previous patch that made "x IS NULL" indexable, because we can treat the IS NOT NULL condition as if it were "x < NULL" or "x > NULL" (depending on the index's NULLS FIRST/LAST option), just like IS NULL is treated like "x = NULL". Aside from any possible usefulness in its own right, this is an important improvement for index-optimized MAX/MIN aggregates: it is now reliably possible to get a column's min or max value cheaply, even when there are a lot of nulls cluttering the interesting end of the index.
Diffstat (limited to 'src/backend/access/gist/gistget.c')
-rw-r--r--src/backend/access/gist/gistget.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c
index a094495b8a..98104a7a9f 100644
--- a/src/backend/access/gist/gistget.c
+++ b/src/backend/access/gist/gistget.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.82 2009/10/08 22:34:57 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.83 2010/01/01 21:53:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -413,14 +413,20 @@ gistindex_keytest(IndexTuple tuple,
{
/*
* On non-leaf page we can't conclude that child hasn't NULL
- * values because of assumption in GiST: uinon (VAL, NULL) is VAL
- * But if on non-leaf page key IS NULL then all childs has NULL.
+ * values because of assumption in GiST: union (VAL, NULL) is VAL.
+ * But if on non-leaf page key IS NULL, then all children are NULL.
*/
-
- Assert(key->sk_flags & SK_SEARCHNULL);
-
- if (GistPageIsLeaf(p) && !isNull)
- return false;
+ if (key->sk_flags & SK_SEARCHNULL)
+ {
+ if (GistPageIsLeaf(p) && !isNull)
+ return false;
+ }
+ else
+ {
+ Assert(key->sk_flags & SK_SEARCHNOTNULL);
+ if (isNull)
+ return false;
+ }
}
else if (isNull)
{