Merge branch 'bugfix/postgres-5896'
fixes #5896 fixes #6351 fixes #6350
This commit is contained in:
commit
7bb5ff2c30
|
@ -4,6 +4,7 @@
|
|||
|
||||
// namespace Icinga\Application\Controllers;
|
||||
|
||||
use Icinga\Logger\Logger;
|
||||
use Icinga\Web\Controller\ActionController;
|
||||
use Icinga\Application\Icinga;
|
||||
|
||||
|
@ -21,6 +22,10 @@ class ErrorController extends ActionController
|
|||
{
|
||||
$error = $this->_getParam('error_handler');
|
||||
$exception = $error->exception;
|
||||
|
||||
Logger::error($exception);
|
||||
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
|
||||
|
||||
switch ($error->type) {
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
|
||||
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
|
||||
|
|
|
@ -89,6 +89,17 @@ class DbQuery extends SimpleQuery
|
|||
public function getSelectQuery()
|
||||
{
|
||||
$select = $this->dbSelect();
|
||||
|
||||
// Add order fields to select for postgres distinct queries (#6351)
|
||||
if ($this->hasOrder()
|
||||
&& $this->getDatasource()->getDbType() === 'pgsql'
|
||||
&& $select->getPart(Zend_Db_Select::DISTINCT) === true) {
|
||||
foreach ($this->getOrder() as $fieldAndDirection) {
|
||||
list($alias, $field) = explode('.', $fieldAndDirection[0]);
|
||||
$this->columns[$field] = $fieldAndDirection[0];
|
||||
}
|
||||
}
|
||||
|
||||
$select->columns($this->columns);
|
||||
$this->applyFilterSql($select);
|
||||
|
||||
|
@ -102,6 +113,7 @@ class DbQuery extends SimpleQuery
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $select;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,10 +51,12 @@ class CommandQuery extends IdoQuery
|
|||
{
|
||||
$this->select->join(
|
||||
array('cnc' => $this->prefix . 'contact_notificationcommands'),
|
||||
'cnc.command_object_id = co.object_id'
|
||||
'cnc.command_object_id = co.object_id',
|
||||
array()
|
||||
)->join(
|
||||
array('con' => $this->prefix . 'contacts'),
|
||||
'con.contact_id = cnc.contact_id'
|
||||
'con.contact_id = cnc.contact_id',
|
||||
array()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -23,8 +23,8 @@ class DowntimeQuery extends IdoQuery
|
|||
'downtime_triggered_by_id' => 'sd.triggered_by_id',
|
||||
'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)',
|
||||
'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)',
|
||||
'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN sd.trigger_time != '0000-00-00 00:00:00' then sd.trigger_time ELSE sd.scheduled_start_time END)",
|
||||
'downtime_end' => 'CASE WHEN sd.is_fixed THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration END',
|
||||
'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN UNIX_TIMESTAMP(sd.trigger_time) > 0 then sd.trigger_time ELSE sd.scheduled_start_time END)",
|
||||
'downtime_end' => 'CASE WHEN sd.is_fixed > 0 THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration END',
|
||||
'downtime_duration' => 'sd.duration',
|
||||
'downtime_is_in_effect' => 'sd.is_in_effect',
|
||||
'downtime_internal_id' => 'sd.internal_downtime_id',
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
|
||||
|
||||
use Icinga\Logger\Logger;
|
||||
use Zend_Db_Select;
|
||||
|
||||
class GroupSummaryQuery extends IdoQuery
|
||||
|
@ -69,8 +70,15 @@ class GroupSummaryQuery extends IdoQuery
|
|||
)
|
||||
);
|
||||
|
||||
$groupColumn = 'hostgroup';
|
||||
|
||||
if (in_array('servicegroup', $this->desiredColumns)) {
|
||||
$groupColumn = 'servicegroup';
|
||||
}
|
||||
|
||||
$union = $this->db->select()->union(array($hosts, $services), Zend_Db_Select::SQL_UNION_ALL);
|
||||
$this->select->from(array('statussummary' => $union), '*')->group($columns[0]);
|
||||
$this->select->from(array('statussummary' => $union), array($groupColumn))->group(array($groupColumn));
|
||||
|
||||
$this->joinedVirtualTables = array(
|
||||
'servicestatussummary' => true,
|
||||
'hoststatussummary' => true
|
||||
|
|
|
@ -85,7 +85,8 @@ class NotificationhistoryQuery extends IdoQuery
|
|||
$this->select->group('n.object_id')
|
||||
->group('n.start_time')
|
||||
->group('n.output')
|
||||
->group('n.state');
|
||||
->group('n.state')
|
||||
->group('o.objecttype_id');
|
||||
}
|
||||
|
||||
$this->joinedVirtualTables = array('history' => true);
|
||||
|
|
|
@ -487,10 +487,10 @@ class StatusQuery extends IdoQuery
|
|||
{
|
||||
$sub = '(SELECT'
|
||||
. ' lc.object_id,'
|
||||
. " CASE WHEN lc.entry_type = 1 THEN CONCAT('[' || c.author_name || '] ' || c.comment_data) ELSE NULL END AS last_comment_data,"
|
||||
. " CASE WHEN lc.entry_type = 2 THEN CONCAT('[' || c.author_name || '] ' || c.comment_data) ELSE NULL END AS last_downtime_data,"
|
||||
. " CASE WHEN lc.entry_type = 3 THEN CONCAT('[' || c.author_name || '] ' || c.comment_data) ELSE NULL END AS last_flapping_data,"
|
||||
. " CASE WHEN lc.entry_type = 4 THEN CONCAT('[' || c.author_name || '] ' || c.comment_data) ELSE NULL END AS last_ack_data"
|
||||
. " CASE WHEN lc.entry_type = 1 THEN '[' || c.author_name || '] ' || c.comment_data ELSE NULL END AS last_comment_data,"
|
||||
. " CASE WHEN lc.entry_type = 2 THEN '[' || c.author_name || '] ' || c.comment_data ELSE NULL END AS last_downtime_data,"
|
||||
. " CASE WHEN lc.entry_type = 3 THEN '[' || c.author_name || '] ' || c.comment_data ELSE NULL END AS last_flapping_data,"
|
||||
. " CASE WHEN lc.entry_type = 4 THEN '[' || c.author_name || '] ' || c.comment_data ELSE NULL END AS last_ack_data"
|
||||
. ' FROM icinga_comments c'
|
||||
. ' JOIN (SELECT'
|
||||
. ' MAX(comment_id) as comment_id,'
|
||||
|
@ -499,7 +499,8 @@ class StatusQuery extends IdoQuery
|
|||
. ' FROM icinga_comments'
|
||||
. ' WHERE entry_type = 1 OR entry_type = 4'
|
||||
. ' GROUP BY object_id, entry_type'
|
||||
. ') lc ON lc.comment_id = c.comment_id GROUP BY lc.object_id)';
|
||||
. ') lc ON lc.comment_id = c.comment_id'
|
||||
. ' GROUP BY lc.object_id, lc.entry_type, c.author_name, c.comment_data)';
|
||||
return new Zend_Db_Expr($sub);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue