]> granicus.if.org Git - icinga2/commitdiff
ido-pgsql: Use timestamp without time zone in from_unixtime and to_timestamp functions
authorEric Lippmann <eric.lippmann@netways.de>
Thu, 17 Nov 2016 11:41:12 +0000 (12:41 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Fri, 18 Nov 2016 10:11:50 +0000 (11:11 +0100)
refs #13221

lib/db_ido_pgsql/schema/pgsql.sql

index 5601a1fa7c16038b9762f926df287a0912c3a92a..e082ae3b5b9631c1dbb32c7ff62a21ff7136b45e 100644 (file)
 -- 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;