3
3
* ginlogic.c
4
4
* routines for performing binary- and ternary-logic consistent checks.
5
5
*
6
- * A GIN operator class provides a consistent function which checks if a
7
- * tuple matches a qual, when the given set of keys are present in the tuple.
8
- * The consistent function is passed a TRUE/FALSE argument for every key,
9
- * indicating if that key is present, and it returns TRUE or FALSE. However,
10
- * a GIN scan can apply various optimizations, if it can determine that an
11
- * item matches or doesn't match, even if it doesn't know if some of the keys
12
- * are present or not. Hence, it's useful to have a ternary-logic consistent
13
- * function, where each key can be TRUE (present), FALSE (not present),
14
- * or MAYBE (don't know if present). This file provides such a ternary-logic
15
- * consistent function, implemented by calling the regular boolean consistent
16
- * function many times, with all the MAYBE arguments set to all combinations
17
- * of TRUE and FALSE.
6
+ * A GIN operator class can provide a boolean or ternary consistent
7
+ * function, or both. This file provides both boolean and ternary
8
+ * interfaces to the rest of the GIN code, even if only one of them is
9
+ * implemented by the opclass.
10
+ *
11
+ * Providing a boolean interface when the opclass implements only the
12
+ * ternary function is straightforward - just call the ternary function
13
+ * with the check-array as is, and map the GIN_TRUE, GIN_FALSE, GIN_MAYBE
14
+ * return codes to TRUE, FALSE and TRUE+recheck, respectively. Providing
15
+ * a ternary interface when the opclass only implements a boolean function
16
+ * is implemented by calling the boolean function many times, with all the
17
+ * MAYBE arguments set to all combinations of TRUE and FALSE (up to a
18
+ * certain number of MAYBE arguments).
19
+ *
20
+ * (A boolean function is enough to determine if an item matches, but a
21
+ * GIN scan can apply various optimizations if it can determine that an
22
+ * item matches or doesn't match, even if it doesn't know if some of the
23
+ * keys are present or not. That's what the ternary consistent function
24
+ * is used for.)
18
25
*
19
26
*
20
27
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
43
50
#define MAX_MAYBE_ENTRIES 4
44
51
45
52
/*
46
- * A dummy consistent function for an EVERYTHING key. Just claim it matches.
53
+ * Dummy consistent functions for an EVERYTHING key. Just claim it matches.
47
54
*/
48
55
static bool
49
56
trueConsistentFn (GinScanKey key )
@@ -54,7 +61,7 @@ trueConsistentFn(GinScanKey key)
54
61
static GinLogicValue
55
62
trueTriConsistentFn (GinScanKey key )
56
63
{
57
- return GIN_MAYBE ;
64
+ return GIN_TRUE ;
58
65
}
59
66
60
67
/*
0 commit comments