[icinga-checkins] icinga.org: icinga2/master: ido-pgsql: Use timestamp without time zone in from_unixtime and to_timestamp functions

git at icinga.org git at icinga.org
Fri Nov 18 11:41:44 CET 2016


Module: icinga2
Branch: master
Commit: 69d3016beff218901324cc5bae5fe9e5ca13cec3
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=69d3016beff218901324cc5bae5fe9e5ca13cec3

Author: Eric Lippmann <eric.lippmann at netways.de>
Date:   Thu Nov 17 12:41:12 2016 +0100

ido-pgsql: Use timestamp without time zone in from_unixtime and to_timestamp functions

refs #13221

---

 lib/db_ido_pgsql/schema/pgsql.sql |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/db_ido_pgsql/schema/pgsql.sql b/lib/db_ido_pgsql/schema/pgsql.sql
index 5601a1f..e082ae3 100644
--- a/lib/db_ido_pgsql/schema/pgsql.sql
+++ b/lib/db_ido_pgsql/schema/pgsql.sql
@@ -10,12 +10,14 @@
 -- Functions
 --
 
-CREATE OR REPLACE FUNCTION from_unixtime(bigint) RETURNS timestamp with time zone AS '
-         SELECT to_timestamp($1) AS result
-' LANGUAGE sql;
-
-CREATE OR REPLACE FUNCTION unix_timestamp(timestamp with time zone) RETURNS bigint AS '
-        SELECT EXTRACT(EPOCH FROM $1)::bigint AS result;
+DROP FUNCTION IF EXISTS from_unixtime(bigint);
+CREATE FUNCTION from_unixtime(bigint) RETURNS timestamp AS $$
+  SELECT to_timestamp($1) AT TIME ZONE 'UTC' AS result
+$$ LANGUAGE sql;
+
+DROP FUNCTION IF EXISTS unix_timestamp(timestamp WITH TIME ZONE);
+CREATE OR REPLACE FUNCTION unix_timestamp(timestamp) RETURNS bigint AS '
+  SELECT CAST(EXTRACT(EPOCH FROM $1) AS bigint) AS result;
 ' LANGUAGE sql;
 
 



More information about the icinga-checkins mailing list