Skip to content

Commit

Permalink
ido-pgsql: Use timestamp without time zone in from_unixtime and to_ti…
Browse files Browse the repository at this point in the history
…mestamp functions

refs #13221
  • Loading branch information
lippserd committed Nov 17, 2016
1 parent 4051664 commit 3e06801
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/db_ido_pgsql/schema/pgsql.sql
Expand Up @@ -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;


Expand Down

0 comments on commit 3e06801

Please sign in to comment.