Module: check_mk
Branch: master
Commit: 26c5243209c0555956334e57374a68b9d228b3a6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=26c5243209c055…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Feb 1 13:47:53 2018 +0100
Avoid exception for non-existent columns.
Change-Id: I271a11d832304d02028fcd5593a82142fe5abe57
---
livestatus/src/TableEventConsole.cc | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/livestatus/src/TableEventConsole.cc b/livestatus/src/TableEventConsole.cc
index 140af75..7b13eae 100644
--- a/livestatus/src/TableEventConsole.cc
+++ b/livestatus/src/TableEventConsole.cc
@@ -70,15 +70,20 @@ private:
// Initially we consider all columns used in the query...
auto all = _query->allColumns();
// ... then we add some special columns which we might need irrespective
- // of the actual query (see receiveReply, isAuthorizedForEvent, and
- // isAuthorizedForEventViaContactGroups below)...
- for (const auto &name : {"event_host", //
- "event_contact_groups_precedence", //
- "event_contact_groups"}) {
- if (auto col = _table.column(name)) {
+ // of the actual query...
+ static std::unordered_set<std::string> special_columns{
+ // see receiveReply
+ "event_host",
+ // see isAuthorizedForEvent
+ "event_contact_groups_precedence",
+ // see isAuthorizedForEventViaContactGroups
+ "event_contact_groups"};
+ _table.any_column([&](const auto &col) {
+ if (special_columns.find(col->name()) != special_columns.end()) {
all.insert(col);
}
- }
+ return false;
+ });
// .. and then we ignore all host-related columns, they are implicitly
// joined later via ECRow._host later.
for (const auto &c : all) {