Commit efcc7572 authored by Peter Eisentraut's avatar Peter Eisentraut

Clean up date_part tests a bit

Some tests for timestamp and timestamptz were in the date.sql test
file.  Move them to their appropriate files, or drop tests cases that
were already present there.
parent f37fec83
......@@ -971,18 +971,6 @@ SELECT EXTRACT(EPOCH FROM DATE '1970-01-01'); -- 0
0
(1 row)
SELECT EXTRACT(EPOCH FROM TIMESTAMP '1970-01-01'); -- 0
date_part
-----------
0
(1 row)
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '1970-01-01+00'); -- 0
date_part
-----------
0
(1 row)
--
-- century
--
......@@ -1137,22 +1125,6 @@ SELECT EXTRACT(DECADE FROM DATE '0012-12-31 BC'); -- -2
-2
(1 row)
--
-- some other types:
--
-- on a timestamp.
SELECT EXTRACT(CENTURY FROM NOW())>=21 AS True; -- true
true
------
t
(1 row)
SELECT EXTRACT(CENTURY FROM TIMESTAMP '1970-03-20 04:30:00.00000'); -- 20
date_part
-----------
20
(1 row)
--
-- all possible fields
--
......@@ -1370,7 +1342,7 @@ select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'
(1 row)
--
-- oscillating fields from non-finite date/timestamptz:
-- oscillating fields from non-finite date:
--
SELECT EXTRACT(HOUR FROM DATE 'infinity'); -- NULL
date_part
......@@ -1384,30 +1356,6 @@ SELECT EXTRACT(HOUR FROM DATE '-infinity'); -- NULL
(1 row)
SELECT EXTRACT(HOUR FROM TIMESTAMP 'infinity'); -- NULL
date_part
-----------
(1 row)
SELECT EXTRACT(HOUR FROM TIMESTAMP '-infinity'); -- NULL
date_part
-----------
(1 row)
SELECT EXTRACT(HOUR FROM TIMESTAMPTZ 'infinity'); -- NULL
date_part
-----------
(1 row)
SELECT EXTRACT(HOUR FROM TIMESTAMPTZ '-infinity'); -- NULL
date_part
-----------
(1 row)
-- all possible fields
SELECT EXTRACT(MICROSECONDS FROM DATE 'infinity'); -- NULL
date_part
......@@ -1500,7 +1448,7 @@ SELECT EXTRACT(TIMEZONE_H FROM DATE 'infinity'); -- NULL
(1 row)
--
-- monotonic fields from non-finite date/timestamptz:
-- monotonic fields from non-finite date:
--
SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity
date_part
......@@ -1514,30 +1462,6 @@ SELECT EXTRACT(EPOCH FROM DATE '-infinity'); -- -Infinity
-Infinity
(1 row)
SELECT EXTRACT(EPOCH FROM TIMESTAMP 'infinity'); -- Infinity
date_part
-----------
Infinity
(1 row)
SELECT EXTRACT(EPOCH FROM TIMESTAMP '-infinity'); -- -Infinity
date_part
-----------
-Infinity
(1 row)
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ 'infinity'); -- Infinity
date_part
-----------
Infinity
(1 row)
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '-infinity'); -- -Infinity
date_part
-----------
-Infinity
(1 row)
-- all possible fields
SELECT EXTRACT(YEAR FROM DATE 'infinity'); -- Infinity
date_part
......
This diff is collapsed.
This diff is collapsed.
......@@ -239,8 +239,6 @@ SELECT f1 as "date",
-- epoch
--
SELECT EXTRACT(EPOCH FROM DATE '1970-01-01'); -- 0
SELECT EXTRACT(EPOCH FROM TIMESTAMP '1970-01-01'); -- 0
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '1970-01-01+00'); -- 0
--
-- century
--
......@@ -276,12 +274,6 @@ SELECT EXTRACT(DECADE FROM DATE '0002-12-31 BC'); -- -1
SELECT EXTRACT(DECADE FROM DATE '0011-01-01 BC'); -- -1
SELECT EXTRACT(DECADE FROM DATE '0012-12-31 BC'); -- -2
--
-- some other types:
--
-- on a timestamp.
SELECT EXTRACT(CENTURY FROM NOW())>=21 AS True; -- true
SELECT EXTRACT(CENTURY FROM TIMESTAMP '1970-03-20 04:30:00.00000'); -- 20
--
-- all possible fields
--
SELECT EXTRACT(MICROSECONDS FROM DATE '2020-08-11');
......@@ -327,14 +319,10 @@ select 'infinity'::date > 'today'::date as t;
select '-infinity'::date < 'today'::date as t;
select isfinite('infinity'::date), isfinite('-infinity'::date), isfinite('today'::date);
--
-- oscillating fields from non-finite date/timestamptz:
-- oscillating fields from non-finite date:
--
SELECT EXTRACT(HOUR FROM DATE 'infinity'); -- NULL
SELECT EXTRACT(HOUR FROM DATE '-infinity'); -- NULL
SELECT EXTRACT(HOUR FROM TIMESTAMP 'infinity'); -- NULL
SELECT EXTRACT(HOUR FROM TIMESTAMP '-infinity'); -- NULL
SELECT EXTRACT(HOUR FROM TIMESTAMPTZ 'infinity'); -- NULL
SELECT EXTRACT(HOUR FROM TIMESTAMPTZ '-infinity'); -- NULL
-- all possible fields
SELECT EXTRACT(MICROSECONDS FROM DATE 'infinity'); -- NULL
SELECT EXTRACT(MILLISECONDS FROM DATE 'infinity'); -- NULL
......@@ -352,14 +340,10 @@ SELECT EXTRACT(TIMEZONE FROM DATE 'infinity'); -- NULL
SELECT EXTRACT(TIMEZONE_M FROM DATE 'infinity'); -- NULL
SELECT EXTRACT(TIMEZONE_H FROM DATE 'infinity'); -- NULL
--
-- monotonic fields from non-finite date/timestamptz:
-- monotonic fields from non-finite date:
--
SELECT EXTRACT(EPOCH FROM DATE 'infinity'); -- Infinity
SELECT EXTRACT(EPOCH FROM DATE '-infinity'); -- -Infinity
SELECT EXTRACT(EPOCH FROM TIMESTAMP 'infinity'); -- Infinity
SELECT EXTRACT(EPOCH FROM TIMESTAMP '-infinity'); -- -Infinity
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ 'infinity'); -- Infinity
SELECT EXTRACT(EPOCH FROM TIMESTAMPTZ '-infinity'); -- -Infinity
-- all possible fields
SELECT EXTRACT(YEAR FROM DATE 'infinity'); -- Infinity
SELECT EXTRACT(DECADE FROM DATE 'infinity'); -- Infinity
......
......@@ -256,7 +256,8 @@ SELECT d1 as "timestamp",
date_part( 'decade', d1) AS decade,
date_part( 'century', d1) AS century,
date_part( 'millennium', d1) AS millennium,
round(date_part( 'julian', d1)) AS julian
round(date_part( 'julian', d1)) AS julian,
date_part( 'epoch', d1) AS epoch
FROM TIMESTAMP_TBL;
-- TO_CHAR()
......
......@@ -262,7 +262,8 @@ SELECT d1 as timestamptz,
date_part( 'decade', d1) AS decade,
date_part( 'century', d1) AS century,
date_part( 'millennium', d1) AS millennium,
round(date_part( 'julian', d1)) AS julian
round(date_part( 'julian', d1)) AS julian,
date_part( 'epoch', d1) AS epoch
FROM TIMESTAMPTZ_TBL;
SELECT d1 as timestamptz,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment