Skip to content

Commit d663d43

Browse files
committed
Fix thinko: have trueTriConsistentFn return GIN_TRUE.
While we're at it, also improve comments in ginlogic.c.
1 parent 2bccced commit d663d43

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/backend/access/gin/ginlogic.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,25 @@
33
* ginlogic.c
44
* routines for performing binary- and ternary-logic consistent checks.
55
*
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.)
1825
*
1926
*
2027
* Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
@@ -43,7 +50,7 @@
4350
#define MAX_MAYBE_ENTRIES 4
4451

4552
/*
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.
4754
*/
4855
static bool
4956
trueConsistentFn(GinScanKey key)
@@ -54,7 +61,7 @@ trueConsistentFn(GinScanKey key)
5461
static GinLogicValue
5562
trueTriConsistentFn(GinScanKey key)
5663
{
57-
return GIN_MAYBE;
64+
return GIN_TRUE;
5865
}
5966

6067
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy