aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistscan.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/gistscan.c
parent15faca259651c065bb20e746777f5fb9eb9d50a1 (diff)
downloadpostgresql-29c4ad98293e3c5cb3fcdd413a3f4904efff8762.tar.gz
postgresql-29c4ad98293e3c5cb3fcdd413a3f4904efff8762.zip
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/gistscan.c')
-rw-r--r--src/backend/access/gist/gistscan.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c
index aed3e95b4e3..dd43036524a 100644
--- a/src/backend/access/gist/gistscan.c
+++ b/src/backend/access/gist/gistscan.c
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.76 2009/06/11 14:48:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/gist/gistscan.c,v 1.77 2010/01/01 21:53:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -92,15 +92,18 @@ gistrescan(PG_FUNCTION_ARGS)
* field.
*
* Next, if any of keys is a NULL and that key is not marked with
- * SK_SEARCHNULL then nothing can be found.
+ * SK_SEARCHNULL/SK_SEARCHNOTNULL then nothing can be found (ie,
+ * we assume all indexable operators are strict).
*/
for (i = 0; i < scan->numberOfKeys; i++)
{
- scan->keyData[i].sk_func = so->giststate->consistentFn[scan->keyData[i].sk_attno - 1];
+ ScanKey skey = &(scan->keyData[i]);
- if (scan->keyData[i].sk_flags & SK_ISNULL)
+ skey->sk_func = so->giststate->consistentFn[skey->sk_attno - 1];
+
+ if (skey->sk_flags & SK_ISNULL)
{
- if ((scan->keyData[i].sk_flags & SK_SEARCHNULL) == 0)
+ if (!(skey->sk_flags & (SK_SEARCHNULL | SK_SEARCHNOTNULL)))
so->qual_ok = false;
}
}