From 3b135c6b6f32590f784e8d878c89a9d9de3d2bee Mon Sep 17 00:00:00 2001 From: Matthias Jentsch Date: Thu, 17 Sep 2015 16:03:42 +0200 Subject: [PATCH] Fix PostgreSQL queries that use GROUP BY Add missing instance_id to getGroup query functions to avoid query errors in PostgreSQL. fixes #10160 --- .../library/Monitoring/Backend/Ido/Query/HostcommentQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/HostdowntimeQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/HostnotificationQuery.php | 4 ++++ .../library/Monitoring/Backend/Ido/Query/HoststatusQuery.php | 3 +++ .../Monitoring/Backend/Ido/Query/ServicecommentQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/ServicenotificationQuery.php | 4 ++++ .../Monitoring/Backend/Ido/Query/ServicestatusQuery.php | 3 +++ 8 files changed, 30 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php index 54c675087..2b06a00ef 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentQuery.php @@ -181,6 +181,10 @@ class HostcommentQuery extends IdoQuery if ($this->hasJoinedVirtualTable('hoststatus')) { $group[] = 'hs.hoststatus_id'; } + + if ($this->hasJoinedVirtualTable('instances')) { + $group[] = 'i.instance_id'; + } } return $group; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php index a8ff8355b..c6ffc4aee 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeQuery.php @@ -187,6 +187,10 @@ class HostdowntimeQuery extends IdoQuery if ($this->hasJoinedVirtualTable('hoststatus')) { $group[] = 'hs.hoststatus_id'; } + + if ($this->hasJoinedVirtualTable('instances')) { + $group[] = 'i.instance_id'; + } } return $group; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php index b06e5440b..d18c05408 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php @@ -265,6 +265,10 @@ class HostnotificationQuery extends IdoQuery if ($this->hasJoinedVirtualTable('acknowledgements')) { $group[] = 'a.acknowledgement_id'; } + + if ($this->hasJoinedVirtualTable('instances')) { + $group[] = 'i.instance_id'; + } } return $group; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 7f1066bfc..02a2fb8fb 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -336,6 +336,9 @@ class HoststatusQuery extends IdoQuery $group[] = 'so.object_id'; $group[] = 's.service_id'; break; + case 'instances': + $group[] = 'i.instance_id'; + break; default: continue 2; } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php index 8b2b9e04f..dea7554ba 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentQuery.php @@ -203,6 +203,10 @@ class ServicecommentQuery extends IdoQuery if ($this->hasJoinedVirtualTable('servicestatus')) { $group[] = 'ss.servicestatus_id'; } + + if ($this->hasJoinedVirtualTable('instances')) { + $group[] = 'i.instance_id'; + } } return $group; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php index 18a22ea93..98f12f84d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeQuery.php @@ -210,6 +210,10 @@ class ServicedowntimeQuery extends IdoQuery if ($this->hasJoinedVirtualTable('servicestatus')) { $group[] = 'ss.servicestatus_id'; } + + if ($this->hasJoinedVirtualTable('instances')) { + $group[] = 'i.instance_id'; + } } return $group; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php index 30e4dc7e2..9b8963055 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php @@ -268,6 +268,10 @@ class ServicenotificationQuery extends IdoQuery if ($this->hasJoinedVirtualTable('acknowledgements')) { $group[] = 'a.acknowledgement_id'; } + + if ($this->hasJoinedVirtualTable('instances')) { + $group[] = 'i.instance_id'; + } } return $group; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php index 1c9785548..a4b1d7272 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php @@ -452,6 +452,9 @@ class ServicestatusQuery extends IdoQuery case 'hoststatus': $group[] = 'hs.hoststatus_id'; break; + case 'instances': + $group[] = 'i.instance_id'; + break; case 'servicestatus': $group[] = 'ss.servicestatus_id'; break;