1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-21 00:42:43 +03:00

Replace TS_execute's TS_EXEC_CALC_NOT flag with TS_EXEC_SKIP_NOT.

It's fairly silly that ignoring NOT subexpressions is TS_execute's
default behavior.  It's wrong on its face and it encourages errors
of omission.  Moreover, the only two remaining callers that aren't
specifying CALC_NOT are in ts_headline calculations, and it's very
arguable that those are bugs: if you've specified "!foo" in your
query, why would you want to get a headline that includes "foo"?

Hence, rip that out and change the default behavior to be to calculate
NOT accurately.  As a concession to the slim chance that there is still
somebody somewhere who needs the incorrect behavior, provide a new
SKIP_NOT flag to explicitly request that.

Back-patch into v13, mainly because it seems better to change this
at the same time as the previous commit's rejiggering of TS_execute
related APIs.  Any outside callers affected by this change are
probably also affected by that one.

Discussion: https://postgr.es/m/CALT9ZEE-aLotzBg-pOp2GFTesGWVYzXA3=mZKzRDa_OKnLF7Mg@mail.gmail.com
This commit is contained in:
Tom Lane
2020-07-24 15:43:56 -04:00
parent 2f2007fbb2
commit 79d6d1a277
5 changed files with 14 additions and 12 deletions

View File

@@ -1627,9 +1627,9 @@ TS_phrase_execute(QueryItem *curitem, void *arg, uint32 flags,
* We need not touch data->width, since a NOT operation does not
* change the match width.
*/
if (!(flags & TS_EXEC_CALC_NOT))
if (flags & TS_EXEC_SKIP_NOT)
{
/* without CALC_NOT, report NOT as "match everywhere" */
/* with SKIP_NOT, report NOT as "match everywhere" */
Assert(data->npos == 0 && !data->negate);
data->negate = true;
return TS_YES;
@@ -1875,7 +1875,7 @@ TS_execute_recurse(QueryItem *curitem, void *arg, uint32 flags,
switch (curitem->qoperator.oper)
{
case OP_NOT:
if (!(flags & TS_EXEC_CALC_NOT))
if (flags & TS_EXEC_SKIP_NOT)
return TS_YES;
switch (TS_execute_recurse(curitem + 1, arg, flags, chkcond))
{
@@ -2038,7 +2038,7 @@ ts_match_vq(PG_FUNCTION_ARGS)
chkval.operand = GETOPERAND(query);
result = TS_execute(GETQUERY(query),
&chkval,
TS_EXEC_CALC_NOT,
TS_EXEC_EMPTY,
checkcondition_str);
PG_FREE_IF_COPY(val, 0);