diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-06 22:33:43 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-04-06 22:33:43 +0000 |
commit | f02a82b6adad1af75499c4ac7221bbd94e3c4fbf (patch) | |
tree | d15b0a2a52d95e046bb3945f4487982943ed211e /src/backend/access/gist | |
parent | 146c83c045625d6f0072dd96045ebbc54582be05 (diff) | |
download | postgresql-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/access/gist')
-rw-r--r-- | src/backend/access/gist/gistget.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index f1d2c777c2f..226812322aa 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.64 2007/01/20 18:43:35 neilc Exp $ + * $PostgreSQL: pgsql/src/backend/access/gist/gistget.c,v 1.65 2007/04/06 22:33:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -381,37 +381,45 @@ gistindex_keytest(IndexTuple tuple, if (key->sk_flags & SK_ISNULL) { /* - * is the compared-to datum NULL? on non-leaf page it's possible - * to have nulls in childs :( + * 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. */ - if (isNull || !GistPageIsLeaf(p)) - return true; - return false; + Assert( key->sk_flags & SK_SEARCHNULL ); + + if ( GistPageIsLeaf(p) && !isNull ) + return false; } else if (isNull) + { return false; + } + else + { - gistdentryinit(giststate, key->sk_attno - 1, &de, - datum, r, p, offset, - FALSE, isNull); + gistdentryinit(giststate, key->sk_attno - 1, &de, + datum, r, p, offset, + FALSE, isNull); - /* - * Call the Consistent function to evaluate the test. The arguments - * are the index datum (as a GISTENTRY*), the comparison datum, and - * the comparison operator's strategy number and subtype from pg_amop. - * - * (Presently there's no need to pass the subtype since it'll always - * be zero, but might as well pass it for possible future use.) - */ - test = FunctionCall4(&key->sk_func, - PointerGetDatum(&de), - key->sk_argument, - Int32GetDatum(key->sk_strategy), - ObjectIdGetDatum(key->sk_subtype)); - - if (!DatumGetBool(test)) - return false; + /* + * Call the Consistent function to evaluate the test. The arguments + * are the index datum (as a GISTENTRY*), the comparison datum, and + * the comparison operator's strategy number and subtype from pg_amop. + * + * (Presently there's no need to pass the subtype since it'll always + * be zero, but might as well pass it for possible future use.) + */ + test = FunctionCall4(&key->sk_func, + PointerGetDatum(&de), + key->sk_argument, + Int32GetDatum(key->sk_strategy), + ObjectIdGetDatum(key->sk_subtype)); + + if (!DatumGetBool(test)) + return false; + } keySize--; key++; |