From 836616b937889db46500e5791de075247386be2d Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Fri, 25 Feb 2022 21:34:29 -0500 Subject: Tagcache Don't create filters when parsing a logical OR if possible search clauses are converted to filters once a logical OR is added to the mix (CLAUSE1|CLAUSE2 & CLAUS3)) if CLAUSE1,2 are database non-numeric tags they get made into filters but the logical OR gets carried to the next CLAUSE Rather than trying to figure this out just keep all clauses around a logical OR Change-Id: I03e064e7f897033c5d47d78a1d34238217cde485 --- apps/tagcache.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'apps') diff --git a/apps/tagcache.c b/apps/tagcache.c index fc06005c1d..9719e4e651 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -1495,8 +1495,9 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs, struct tagcache_search_clause *clause) { int i; + int clause_count = tcs->clause_count; - if (tcs->clause_count >= TAGCACHE_MAX_CLAUSES) + if (clause_count >= TAGCACHE_MAX_CLAUSES) { logf("Too many clauses"); return false; @@ -1504,13 +1505,19 @@ bool tagcache_search_add_clause(struct tagcache_search *tcs, if (clause->type != clause_logical_or) { - /* Check if there is already a similar filter in present (filters are - * much faster than clauses). - */ - for (i = 0; i < tcs->filter_count; i++) + /* BUGFIX OR'd clauses seem to be mishandled once made into a filter */ + if (clause_count <= 1 || tcs->clause[clause_count - 1]->type != clause_logical_or) { - if (tcs->filter_tag[i] == clause->tag) - return true; + /* Check if there is already a similar filter in present (filters are + * much faster than clauses). + */ + for (i = 0; i < tcs->filter_count; i++) + { + if (tcs->filter_tag[i] == clause->tag) + { + return true; + } + } } if (!TAGCACHE_IS_NUMERIC(clause->tag) && tcs->idxfd[clause->tag] < 0) -- cgit v1.2.3