summaryrefslogtreecommitdiff
path: root/src/test/regress
diff options
context:
space:
mode:
authorRobert Haas2011-08-30 15:34:29 +0000
committerRobert Haas2011-08-30 15:38:42 +0000
commit8a3d33c8e6c681d512f79af4a521ee0c02befcef (patch)
treef85ddcc351946c777225a19c578d2c52254c5d61 /src/test/regress
parenteab2ef6164ae2d0e5a72501de9c09474fd94a394 (diff)
Fix parsing of time string followed by yesterday/today/tomorrow.
Previously, 'yesterday 04:00:00'::timestamp didn't do the same thing as '04:00:00 yesterday'::timestamp, and the return value from the latter was midnight rather than the specified time. Dean Rasheed, with some stylistic changes
Diffstat (limited to 'src/test/regress')
-rw-r--r--src/test/regress/expected/horology.out78
-rw-r--r--src/test/regress/sql/horology.sql13
2 files changed, 91 insertions, 0 deletions
diff --git a/src/test/regress/expected/horology.out b/src/test/regress/expected/horology.out
index b13f7d7c5b5..8526765967c 100644
--- a/src/test/regress/expected/horology.out
+++ b/src/test/regress/expected/horology.out
@@ -388,12 +388,48 @@ SELECT (timestamp without time zone 'today' = (timestamp without time zone 'tomo
t
(1 row)
+SELECT (timestamp without time zone 'today 10:30' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp without time zone '10:30 today' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True";
+ True
+------
+ t
+(1 row)
+
SELECT (timestamp without time zone 'tomorrow' = (timestamp without time zone 'yesterday' + interval '2 days')) as "True";
True
------
t
(1 row)
+SELECT (timestamp without time zone 'tomorrow 16:00:00' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp without time zone '16:00:00 tomorrow' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp without time zone 'yesterday 12:34:56' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp without time zone '12:34:56 yesterday' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True";
+ True
+------
+ t
+(1 row)
+
SELECT (timestamp without time zone 'tomorrow' > 'now') as "True";
True
------
@@ -603,12 +639,54 @@ SELECT (timestamp with time zone 'today' = (timestamp with time zone 'tomorrow'
t
(1 row)
+SELECT (timestamp with time zone 'today 10:30+05' = timestamptz(date 'today', time with time zone '10:30 +05')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp with time zone '10:30+05 today' = timestamptz(date 'today', time with time zone '10:30 +05')) as "True";
+ True
+------
+ t
+(1 row)
+
SELECT (timestamp with time zone 'tomorrow' = (timestamp with time zone 'yesterday' + interval '2 days')) as "True";
True
------
t
(1 row)
+SELECT (timestamp with time zone 'tomorrow 10:30+05' = (timestamp with time zone 'today 10:30+05' + interval '1 day')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp with time zone '10:30+05 tomorrow' = (timestamp with time zone 'today 10:30+05' + interval '1 day')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp with time zone 'yesterday 12:34:56-7' = timestamptz(date 'yesterday', time with time zone '12:34:56-7')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp with time zone '12:34:56 yesterday -7' = timestamptz(date 'yesterday', time with time zone '12:34:56-7')) as "True";
+ True
+------
+ t
+(1 row)
+
+SELECT (timestamp with time zone '12:34:56-7 yesterday' = timestamptz(date 'yesterday', time with time zone '12:34:56-7')) as "True";
+ True
+------
+ t
+(1 row)
+
SELECT (timestamp with time zone 'tomorrow' > 'now') as "True";
True
------
diff --git a/src/test/regress/sql/horology.sql b/src/test/regress/sql/horology.sql
index 97ff9f20c79..e9981e586a5 100644
--- a/src/test/regress/sql/horology.sql
+++ b/src/test/regress/sql/horology.sql
@@ -91,7 +91,13 @@ SELECT timestamp without time zone '12/31/294276' - timestamp without time zone
-- So, just try to test parser and hope for the best - thomas 97/04/26
SELECT (timestamp without time zone 'today' = (timestamp without time zone 'yesterday' + interval '1 day')) as "True";
SELECT (timestamp without time zone 'today' = (timestamp without time zone 'tomorrow' - interval '1 day')) as "True";
+SELECT (timestamp without time zone 'today 10:30' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True";
+SELECT (timestamp without time zone '10:30 today' = (timestamp without time zone 'yesterday' + interval '1 day 10 hr 30 min')) as "True";
SELECT (timestamp without time zone 'tomorrow' = (timestamp without time zone 'yesterday' + interval '2 days')) as "True";
+SELECT (timestamp without time zone 'tomorrow 16:00:00' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True";
+SELECT (timestamp without time zone '16:00:00 tomorrow' = (timestamp without time zone 'today' + interval '1 day 16 hours')) as "True";
+SELECT (timestamp without time zone 'yesterday 12:34:56' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True";
+SELECT (timestamp without time zone '12:34:56 yesterday' = (timestamp without time zone 'tomorrow' - interval '2 days - 12:34:56')) as "True";
SELECT (timestamp without time zone 'tomorrow' > 'now') as "True";
-- Convert from date and time to timestamp
@@ -112,7 +118,14 @@ SELECT timestamp with time zone '1999-12-01' + interval '1 month - 1 second' AS
SELECT (timestamp with time zone 'today' = (timestamp with time zone 'yesterday' + interval '1 day')) as "True";
SELECT (timestamp with time zone 'today' = (timestamp with time zone 'tomorrow' - interval '1 day')) as "True";
+SELECT (timestamp with time zone 'today 10:30+05' = timestamptz(date 'today', time with time zone '10:30 +05')) as "True";
+SELECT (timestamp with time zone '10:30+05 today' = timestamptz(date 'today', time with time zone '10:30 +05')) as "True";
SELECT (timestamp with time zone 'tomorrow' = (timestamp with time zone 'yesterday' + interval '2 days')) as "True";
+SELECT (timestamp with time zone 'tomorrow 10:30+05' = (timestamp with time zone 'today 10:30+05' + interval '1 day')) as "True";
+SELECT (timestamp with time zone '10:30+05 tomorrow' = (timestamp with time zone 'today 10:30+05' + interval '1 day')) as "True";
+SELECT (timestamp with time zone 'yesterday 12:34:56-7' = timestamptz(date 'yesterday', time with time zone '12:34:56-7')) as "True";
+SELECT (timestamp with time zone '12:34:56 yesterday -7' = timestamptz(date 'yesterday', time with time zone '12:34:56-7')) as "True";
+SELECT (timestamp with time zone '12:34:56-7 yesterday' = timestamptz(date 'yesterday', time with time zone '12:34:56-7')) as "True";
SELECT (timestamp with time zone 'tomorrow' > 'now') as "True";
-- timestamp with time zone, interval arithmetic around DST change