summaryrefslogtreecommitdiff
path: root/src/include/access/skey.h
diff options
context:
space:
mode:
authorTom Lane2010-01-01 21:53:49 +0000
committerTom Lane2010-01-01 21:53:49 +0000
commit29c4ad98293e3c5cb3fcdd413a3f4904efff8762 (patch)
tree4e4eeea2655e87eca4d3d0dd97f3e2b7d5f1e032 /src/include/access/skey.h
parent15faca259651c065bb20e746777f5fb9eb9d50a1 (diff)
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/include/access/skey.h')
-rw-r--r--src/include/access/skey.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/include/access/skey.h b/src/include/access/skey.h
index d295d3d12d5..509e1d08ddb 100644
--- a/src/include/access/skey.h
+++ b/src/include/access/skey.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/skey.h,v 1.37 2009/01/01 17:23:56 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/access/skey.h,v 1.38 2010/01/01 21:53:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -52,11 +52,13 @@ typedef uint16 StrategyNumber;
* the operator. When using a ScanKey in a heap scan, these fields are not
* used and may be set to InvalidStrategy/InvalidOid.
*
- * A ScanKey can also represent a condition "column IS NULL"; this is signaled
- * by the SK_SEARCHNULL flag bit. In this case the argument is always NULL,
+ * A ScanKey can also represent a condition "column IS NULL" or "column
+ * IS NOT NULL"; these cases are signaled by the SK_SEARCHNULL and
+ * SK_SEARCHNOTNULL flag bits respectively. The argument is always NULL,
* and the sk_strategy, sk_subtype, and sk_func fields are not used (unless
- * set by the index AM). Currently, SK_SEARCHNULL is supported only for
- * index scans, not heap scans; and not all index AMs support it.
+ * set by the index AM). Currently, SK_SEARCHNULL and SK_SEARCHNOTNULL are
+ * supported only for index scans, not heap scans; and not all index AMs
+ * support them.
*
* Note: in some places, ScanKeys are used as a convenient representation
* for the invocation of an access method support procedure. In this case
@@ -112,12 +114,13 @@ typedef ScanKeyData *ScanKey;
* bits should be defined here). Bits 16-31 are reserved for use within
* individual index access methods.
*/
-#define SK_ISNULL 0x0001 /* sk_argument is NULL */
-#define SK_UNARY 0x0002 /* unary operator (currently unsupported) */
-#define SK_ROW_HEADER 0x0004 /* row comparison header (see above) */
-#define SK_ROW_MEMBER 0x0008 /* row comparison member (see above) */
-#define SK_ROW_END 0x0010 /* last row comparison member (see above) */
-#define SK_SEARCHNULL 0x0020 /* scankey represents a "col IS NULL" qual */
+#define SK_ISNULL 0x0001 /* sk_argument is NULL */
+#define SK_UNARY 0x0002 /* unary operator (not supported!) */
+#define SK_ROW_HEADER 0x0004 /* row comparison header (see above) */
+#define SK_ROW_MEMBER 0x0008 /* row comparison member (see above) */
+#define SK_ROW_END 0x0010 /* last row comparison member */
+#define SK_SEARCHNULL 0x0020 /* scankey represents "col IS NULL" */
+#define SK_SEARCHNOTNULL 0x0040 /* scankey represents "col IS NOT NULL" */
/*