@@ -736,20 +736,66 @@ SELECT '' as "54", d1 as timestamp,
736736--
737737-- abstime, reltime arithmetic
738738--
739- SELECT '' AS four, f1 AS abstime,
740- date_part('year', f1) AS year, date_part('month', f1) AS month,
741- date_part('day',f1) AS day, date_part('hour', f1) AS hour,
742- date_part('minute', f1) AS minute, date_part('second', f1) AS second
743- FROM ABSTIME_TBL
744- WHERE isfinite(f1) and f1 <> abstime 'current'
745- ORDER BY abstime;
746- four | abstime | year | month | day | hour | minute | second
747- ------+------------------------------+------+-------+-----+------+--------+--------
748- | Sat May 10 23:59:12 1947 PST | 1947 | 5 | 10 | 23 | 59 | 12
749- | epoch | 1969 | 12 | 31 | 16 | 0 | 0
750- | Sun Jan 14 03:14:21 1973 PST | 1973 | 1 | 14 | 3 | 14 | 21
751- | Mon May 01 00:30:30 1995 PDT | 1995 | 5 | 1 | 0 | 30 | 30
752- (4 rows)
739+ SELECT '' AS ten, ABSTIME_TBL.f1 AS abstime, RELTIME_TBL.f1 AS reltime
740+ WHERE (ABSTIME_TBL.f1 + RELTIME_TBL.f1)
741+ < abstime 'Jan 14 14:00:00 1971'
742+ ORDER BY abstime, reltime;
743+ ten | abstime | reltime
744+ -----+------------------------------+---------------
745+ | Sat May 10 23:59:12 1947 PST | @ 14 secs ago
746+ | Sat May 10 23:59:12 1947 PST | @ 1 min
747+ | Sat May 10 23:59:12 1947 PST | @ 5 hours
748+ | Sat May 10 23:59:12 1947 PST | @ 10 days
749+ | Sat May 10 23:59:12 1947 PST | @ 3 mons
750+ | epoch | @ 14 secs ago
751+ | epoch | @ 1 min
752+ | epoch | @ 5 hours
753+ | epoch | @ 10 days
754+ | epoch | @ 3 mons
755+ (10 rows)
756+
757+ -- these four queries should return the same answer
758+ -- the "infinity" and "-infinity" tuples in ABSTIME_TBL cannot be added and
759+ -- therefore, should not show up in the results.
760+ SELECT '' AS three, ABSTIME_TBL.*
761+ WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year') -- +3 years
762+ < abstime 'Jan 14 14:00:00 1977';
763+ three | f1
764+ -------+------------------------------
765+ | Sun Jan 14 03:14:21 1973 PST
766+ | epoch
767+ | Sat May 10 23:59:12 1947 PST
768+ (3 rows)
769+
770+ SELECT '' AS three, ABSTIME_TBL.*
771+ WHERE (ABSTIME_TBL.f1 + reltime '@ 3 year ago') -- -3 years
772+ < abstime 'Jan 14 14:00:00 1971';
773+ three | f1
774+ -------+------------------------------
775+ | Sun Jan 14 03:14:21 1973 PST
776+ | epoch
777+ | Sat May 10 23:59:12 1947 PST
778+ (3 rows)
779+
780+ SELECT '' AS three, ABSTIME_TBL.*
781+ WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year') -- -(+3) years
782+ < abstime 'Jan 14 14:00:00 1971';
783+ three | f1
784+ -------+------------------------------
785+ | Sun Jan 14 03:14:21 1973 PST
786+ | epoch
787+ | Sat May 10 23:59:12 1947 PST
788+ (3 rows)
789+
790+ SELECT '' AS three, ABSTIME_TBL.*
791+ WHERE (ABSTIME_TBL.f1 - reltime '@ 3 year ago') -- -(-3) years
792+ < abstime 'Jan 14 14:00:00 1977';
793+ three | f1
794+ -------+------------------------------
795+ | Sun Jan 14 03:14:21 1973 PST
796+ | epoch
797+ | Sat May 10 23:59:12 1947 PST
798+ (3 rows)
753799
754800--
755801-- Conversions