From 09d5ec6b7a097fcc65a32e8c9272440c64b52882 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Fri, 16 Jan 2015 17:05:50 +0100 Subject: [PATCH] postgres: Return 0 if a timestamp looks like the default timestamp The PostgreSQL IDO schema sets the default value for timestamps with time zone to the epoch time w/o giving the time zone +00. Thus default timestamps are always wrong when using a time zone other than 'UTC'. refs #7919 --- .../library/Monitoring/Backend/Ido/Query/IdoQuery.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 0b505cd73..f2e5bd15f 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -323,6 +323,11 @@ abstract class IdoQuery extends DbQuery foreach ($columns as $key => & $value) { $value = preg_replace('/ COLLATE .+$/', '', $value); $value = preg_replace('/inet_aton\(([[:word:].]+)\)/i', '$1::inet - \'0.0.0.0\'', $value); + $value = preg_replace( + '/(UNIX_TIMESTAMP(\((?>[^()]|(?-1))*\)))/i', + 'CASE WHEN ($1 = EXTRACT(TIMEZONE FROM NOW()) * -1) THEN 0 ELSE $1 END', + $value + ); } } }