Commit d663d439 authored by Heikki Linnakangas's avatar Heikki Linnakangas

Fix thinko: have trueTriConsistentFn return GIN_TRUE.

While we're at it, also improve comments in ginlogic.c.
parent 2bccced1
...@@ -3,18 +3,25 @@ ...@@ -3,18 +3,25 @@
* ginlogic.c * ginlogic.c
* routines for performing binary- and ternary-logic consistent checks. * routines for performing binary- and ternary-logic consistent checks.
* *
* A GIN operator class provides a consistent function which checks if a * A GIN operator class can provide a boolean or ternary consistent
* tuple matches a qual, when the given set of keys are present in the tuple. * function, or both. This file provides both boolean and ternary
* The consistent function is passed a TRUE/FALSE argument for every key, * interfaces to the rest of the GIN code, even if only one of them is
* indicating if that key is present, and it returns TRUE or FALSE. However, * implemented by the opclass.
* 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 * Providing a boolean interface when the opclass implements only the
* are present or not. Hence, it's useful to have a ternary-logic consistent * ternary function is straightforward - just call the ternary function
* function, where each key can be TRUE (present), FALSE (not present), * with the check-array as is, and map the GIN_TRUE, GIN_FALSE, GIN_MAYBE
* or MAYBE (don't know if present). This file provides such a ternary-logic * return codes to TRUE, FALSE and TRUE+recheck, respectively. Providing
* consistent function, implemented by calling the regular boolean consistent * a ternary interface when the opclass only implements a boolean function
* function many times, with all the MAYBE arguments set to all combinations * is implemented by calling the boolean function many times, with all the
* of TRUE and FALSE. * 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 * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
...@@ -43,7 +50,7 @@ ...@@ -43,7 +50,7 @@
#define MAX_MAYBE_ENTRIES 4 #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 static bool
trueConsistentFn(GinScanKey key) trueConsistentFn(GinScanKey key)
...@@ -54,7 +61,7 @@ trueConsistentFn(GinScanKey key) ...@@ -54,7 +61,7 @@ trueConsistentFn(GinScanKey key)
static GinLogicValue static GinLogicValue
trueTriConsistentFn(GinScanKey key) trueTriConsistentFn(GinScanKey key)
{ {
return GIN_MAYBE; return GIN_TRUE;
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment