From 665557be2707a331493dbacbaaa8324a9ba6c07e Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 9 Dec 2016 11:57:56 +0100 Subject: [PATCH] Support Icinga 2.6 IDO w/ PostgreSQL --- .../Monitoring/Backend/Ido/Query/IdoQuery.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 1bf6c6746..b81adb85d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -655,11 +655,15 @@ abstract class IdoQuery extends DbQuery '(CASE WHEN $1 ~ \'(?:[0-9]{1,3}\\\\.){3}[0-9]{1,3}\' THEN $1::inet - \'0.0.0.0\' ELSE NULL END)', $column ); - $column = preg_replace( - '/UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\))/i', - 'CASE WHEN ($1 < \'1970-01-03 00:00:00+00\'::timestamp with time zone) THEN 0 ELSE UNIX_TIMESTAMP($1) END', - $column - ); + if (version_compare($this->getIdoVersion(), '1.14.2', '>=')) { + $column = str_replace('NOW()', 'localtimestamp', $column); + } else { + $column = preg_replace( + '/UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\))/i', + 'CASE WHEN ($1 < \'1970-01-03 00:00:00+00\'::timestamp with time zone) THEN 0 ELSE UNIX_TIMESTAMP($1) END', + $column + ); + } } } }