summaryrefslogtreecommitdiff
path: root/src/backend/tsearch
diff options
context:
space:
mode:
authorTom Lane2020-07-24 19:26:51 +0000
committerTom Lane2020-07-24 19:26:51 +0000
commit2f2007fbb255be178aca586780967f43885203a7 (patch)
treef8b550822ccb33b1a63acc292556c7ee2ae90683 /src/backend/tsearch
parent25244b8972a34b838c4033fe9efc1d31cba9d0e3 (diff)
Fix assorted bugs by changing TS_execute's callback API to ternary logic.
Text search sometimes failed to find valid matches, for instance '!crew:A'::tsquery might fail to locate 'crew:1B'::tsvector during an index search. The root of the issue is that TS_execute's callback functions were not changed to use ternary (yes/no/maybe) reporting when we made the search logic itself do so. It's somewhat annoying to break that API, but on the other hand we now see that any code using plain boolean logic is almost certainly broken since the addition of phrase search. There seem to be very few outside callers of this code anyway, so we'll just break them intentionally to get them to adapt. This allows removal of tsginidx.c's private re-implementation of TS_execute, since that's now entirely duplicative. It's also no longer necessary to avoid use of CALC_NOT in tsgistidx.c, since the underlying callbacks can now do something reasonable. Back-patch into v13. We can't change this in stable branches, but it seems not quite too late to fix it in v13. Tom Lane and Pavel Borisov Discussion: https://postgr.es/m/CALT9ZEE-aLotzBg-pOp2GFTesGWVYzXA3=mZKzRDa_OKnLF7Mg@mail.gmail.com
Diffstat (limited to 'src/backend/tsearch')
-rw-r--r--src/backend/tsearch/wparser_def.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/tsearch/wparser_def.c b/src/backend/tsearch/wparser_def.c
index fda35abc741..76b6f9aef03 100644
--- a/src/backend/tsearch/wparser_def.c
+++ b/src/backend/tsearch/wparser_def.c
@@ -1962,7 +1962,7 @@ typedef struct
/*
* TS_execute callback for matching a tsquery operand to headline words
*/
-static bool
+static TSTernaryValue
checkcondition_HL(void *opaque, QueryOperand *val, ExecPhraseData *data)
{
hlCheck *checkval = (hlCheck *) opaque;
@@ -1975,7 +1975,7 @@ checkcondition_HL(void *opaque, QueryOperand *val, ExecPhraseData *data)
{
/* if data == NULL, don't need to report positions */
if (!data)
- return true;
+ return TS_YES;
if (!data->pos)
{
@@ -1992,9 +1992,9 @@ checkcondition_HL(void *opaque, QueryOperand *val, ExecPhraseData *data)
}
if (data && data->npos > 0)
- return true;
+ return TS_YES;
- return false;
+ return TS_NO;
}
/*