Module: check_mk
Branch: master
Commit: 0a0265a98e5e432e345f369b2c3355c0d058e7be
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0a0265a98e5e43…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon Dec 4 13:23:58 2017 +0100
Fixed string value restrictions for disjunctions.
Change-Id: I232117d7f354935e4608651c77fabfb19cd53f8f
---
livestatus/src/OringFilter.cc | 17 +++++++++++++++++
livestatus/src/OringFilter.h | 2 ++
2 files changed, 19 insertions(+)
diff --git a/livestatus/src/OringFilter.cc b/livestatus/src/OringFilter.cc
index 3223f73..275540c 100644
--- a/livestatus/src/OringFilter.cc
+++ b/livestatus/src/OringFilter.cc
@@ -42,6 +42,23 @@ bool OringFilter::accepts(Row row, const contact *auth_user,
return false;
}
+const std::string *OringFilter::stringValueRestrictionFor(
+ const std::string &column_name) const {
+ const std::string *restriction = nullptr;
+ for (const auto &filter : _subfilters) {
+ if (auto current = filter->stringValueRestrictionFor(column_name)) {
+ if (restriction == nullptr) {
+ restriction = current; // First restriction? Take it.
+ } else if (*restriction != *current) {
+ return nullptr; // Different restrictions? Give up.
+ }
+ } else {
+ return nullptr; // No restriction for subfilter? Give up.
+ }
+ }
+ return restriction;
+}
+
void OringFilter::findIntLimits(const std::string &colum_nname, int *lower,
int *upper,
std::chrono::seconds timezone_offset) const {
diff --git a/livestatus/src/OringFilter.h b/livestatus/src/OringFilter.h
index 2641e7b..52d1696 100644
--- a/livestatus/src/OringFilter.h
+++ b/livestatus/src/OringFilter.h
@@ -44,6 +44,8 @@ public:
void accept(FilterVisitor &v) const override;
bool accepts(Row row, const contact *auth_user,
std::chrono::seconds timezone_offset) const override;
+ const std::string *stringValueRestrictionFor(
+ const std::string &column_name) const override;
void findIntLimits(const std::string &colum_nname, int *lower, int *upper,
std::chrono::seconds timezone_offset) const override;
bool optimizeBitmask(const std::string &column_name, uint32_t *mask,