Fix thinko: have trueTriConsistentFn return GIN_TRUE.

While we're at it, also improve comments in ginlogic.c.
This commit is contained in:
Heikki Linnakangas 2014-03-17 17:18:40 +02:00
parent 2bccced110
commit d663d4399e
1 changed files with 21 additions and 14 deletions

View File

@ -3,18 +3,25 @@
* ginlogic.c
* routines for performing binary- and ternary-logic consistent checks.
*
* A GIN operator class provides a consistent function which checks if a
* tuple matches a qual, when the given set of keys are present in the tuple.
* The consistent function is passed a TRUE/FALSE argument for every key,
* indicating if that key is present, and it returns TRUE or FALSE. However,
* a GIN scan can apply various optimizations, if it can determine that an
* item matches or doesn't match, even if it doesn't know if some of the keys
* are present or not. Hence, it's useful to have a ternary-logic consistent
* function, where each key can be TRUE (present), FALSE (not present),
* or MAYBE (don't know if present). This file provides such a ternary-logic
* consistent function, implemented by calling the regular boolean consistent
* function many times, with all the MAYBE arguments set to all combinations
* of TRUE and FALSE.
* A GIN operator class can provide a boolean or ternary consistent
* function, or both. This file provides both boolean and ternary
* interfaces to the rest of the GIN code, even if only one of them is
* implemented by the opclass.
*
* Providing a boolean interface when the opclass implements only the
* ternary function is straightforward - just call the ternary function
* with the check-array as is, and map the GIN_TRUE, GIN_FALSE, GIN_MAYBE
* return codes to TRUE, FALSE and TRUE+recheck, respectively. Providing
* a ternary interface when the opclass only implements a boolean function
* is implemented by calling the boolean function many times, with all the
* MAYBE arguments set to all combinations of TRUE and FALSE (up to a
* certain number of MAYBE arguments).
*
* (A boolean function is enough to determine if an item matches, but a
* GIN scan can apply various optimizations if it can determine that an
* item matches or doesn't match, even if it doesn't know if some of the
* keys are present or not. That's what the ternary consistent function
* is used for.)
*
*
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
@ -43,7 +50,7 @@
#define MAX_MAYBE_ENTRIES 4
/*
* A dummy consistent function for an EVERYTHING key. Just claim it matches.
* Dummy consistent functions for an EVERYTHING key. Just claim it matches.
*/
static bool
trueConsistentFn(GinScanKey key)
@ -54,7 +61,7 @@ trueConsistentFn(GinScanKey key)
static GinLogicValue
trueTriConsistentFn(GinScanKey key)
{
return GIN_MAYBE;
return GIN_TRUE;
}
/*