Merge branch 'bugfix/postgres-5896'

fixes #5896
fixes #6351
fixes #6350
This commit is contained in:
Marius Hein 2014-09-01 10:00:33 +02:00
commit 7bb5ff2c30
7 changed files with 40 additions and 11 deletions

View File

@ -4,6 +4,7 @@
// namespace Icinga\Application\Controllers; // namespace Icinga\Application\Controllers;
use Icinga\Logger\Logger;
use Icinga\Web\Controller\ActionController; use Icinga\Web\Controller\ActionController;
use Icinga\Application\Icinga; use Icinga\Application\Icinga;
@ -21,6 +22,10 @@ class ErrorController extends ActionController
{ {
$error = $this->_getParam('error_handler'); $error = $this->_getParam('error_handler');
$exception = $error->exception; $exception = $error->exception;
Logger::error($exception);
Logger::error('Stacktrace: %s', $exception->getTraceAsString());
switch ($error->type) { switch ($error->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:

View File

@ -89,6 +89,17 @@ class DbQuery extends SimpleQuery
public function getSelectQuery() public function getSelectQuery()
{ {
$select = $this->dbSelect(); $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); $select->columns($this->columns);
$this->applyFilterSql($select); $this->applyFilterSql($select);
@ -102,6 +113,7 @@ class DbQuery extends SimpleQuery
); );
} }
} }
return $select; return $select;
} }

View File

@ -51,10 +51,12 @@ class CommandQuery extends IdoQuery
{ {
$this->select->join( $this->select->join(
array('cnc' => $this->prefix . 'contact_notificationcommands'), array('cnc' => $this->prefix . 'contact_notificationcommands'),
'cnc.command_object_id = co.object_id' 'cnc.command_object_id = co.object_id',
array()
)->join( )->join(
array('con' => $this->prefix . 'contacts'), array('con' => $this->prefix . 'contacts'),
'con.contact_id = cnc.contact_id' 'con.contact_id = cnc.contact_id',
array()
); );
} }
} }

View File

@ -23,8 +23,8 @@ class DowntimeQuery extends IdoQuery
'downtime_triggered_by_id' => 'sd.triggered_by_id', 'downtime_triggered_by_id' => 'sd.triggered_by_id',
'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', 'downtime_scheduled_start' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)',
'downtime_scheduled_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_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_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 THEN UNIX_TIMESTAMP(sd.scheduled_end_time) ELSE UNIX_TIMESTAMP(sd.trigger_time) + sd.duration 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_duration' => 'sd.duration',
'downtime_is_in_effect' => 'sd.is_in_effect', 'downtime_is_in_effect' => 'sd.is_in_effect',
'downtime_internal_id' => 'sd.internal_downtime_id', 'downtime_internal_id' => 'sd.internal_downtime_id',

View File

@ -4,6 +4,7 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query; namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use Icinga\Logger\Logger;
use Zend_Db_Select; use Zend_Db_Select;
class GroupSummaryQuery extends IdoQuery 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); $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( $this->joinedVirtualTables = array(
'servicestatussummary' => true, 'servicestatussummary' => true,
'hoststatussummary' => true 'hoststatussummary' => true

View File

@ -85,7 +85,8 @@ class NotificationhistoryQuery extends IdoQuery
$this->select->group('n.object_id') $this->select->group('n.object_id')
->group('n.start_time') ->group('n.start_time')
->group('n.output') ->group('n.output')
->group('n.state'); ->group('n.state')
->group('o.objecttype_id');
} }
$this->joinedVirtualTables = array('history' => true); $this->joinedVirtualTables = array('history' => true);

View File

@ -487,10 +487,10 @@ class StatusQuery extends IdoQuery
{ {
$sub = '(SELECT' $sub = '(SELECT'
. ' lc.object_id,' . ' 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 = 1 THEN '[' || 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 = 2 THEN '[' || 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 = 3 THEN '[' || 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 = 4 THEN '[' || c.author_name || '] ' || c.comment_data ELSE NULL END AS last_ack_data"
. ' FROM icinga_comments c' . ' FROM icinga_comments c'
. ' JOIN (SELECT' . ' JOIN (SELECT'
. ' MAX(comment_id) as comment_id,' . ' MAX(comment_id) as comment_id,'
@ -499,7 +499,8 @@ class StatusQuery extends IdoQuery
. ' FROM icinga_comments' . ' FROM icinga_comments'
. ' WHERE entry_type = 1 OR entry_type = 4' . ' WHERE entry_type = 1 OR entry_type = 4'
. ' GROUP BY object_id, entry_type' . ' 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); return new Zend_Db_Expr($sub);
} }