2000-01-05 07:06:23 +01:00
|
|
|
--
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
-- INTERVAL
|
2000-01-05 07:06:23 +01:00
|
|
|
--
|
2000-11-06 17:03:47 +01:00
|
|
|
SET DATESTYLE = DEFAULT;
|
|
|
|
-- check acceptance of "time zone style"
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '01:00' AS "One hour";
|
|
|
|
One hour
|
2000-11-06 17:03:47 +01:00
|
|
|
----------
|
2001-01-18 08:22:43 +01:00
|
|
|
01:00
|
2000-11-06 17:03:47 +01:00
|
|
|
(1 row)
|
|
|
|
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '+02:00' AS "Two hours";
|
|
|
|
Two hours
|
|
|
|
-----------
|
2001-01-18 08:22:43 +01:00
|
|
|
02:00
|
2000-11-06 17:03:47 +01:00
|
|
|
(1 row)
|
|
|
|
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '-08:00' AS "Eight hours";
|
|
|
|
Eight hours
|
|
|
|
-------------
|
2000-11-06 17:03:47 +01:00
|
|
|
-08:00
|
|
|
|
(1 row)
|
|
|
|
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '-05' AS "Five hours";
|
|
|
|
Five hours
|
|
|
|
------------
|
|
|
|
-05:00
|
2000-11-06 17:03:47 +01:00
|
|
|
(1 row)
|
|
|
|
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '-1 +02:03' AS "22 hours ago...";
|
|
|
|
22 hours ago...
|
|
|
|
-----------------
|
2000-11-06 17:03:47 +01:00
|
|
|
-21:57
|
|
|
|
(1 row)
|
|
|
|
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '-1 days +02:03' AS "22 hours ago...";
|
|
|
|
22 hours ago...
|
|
|
|
-----------------
|
2000-11-06 17:03:47 +01:00
|
|
|
-21:57
|
|
|
|
(1 row)
|
|
|
|
|
2000-11-11 20:56:43 +01:00
|
|
|
SELECT INTERVAL '10 years -11 month -12 days +13:14' AS "9 years...";
|
2001-01-18 08:22:43 +01:00
|
|
|
9 years...
|
|
|
|
-------------------------------
|
|
|
|
9 years 1 mon -11 days -10:46
|
2000-11-06 17:03:47 +01:00
|
|
|
(1 row)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
CREATE TABLE INTERVAL_TBL (f1 interval);
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 1 minute');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 5 hour');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 10 day');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 34 year');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 3 months');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 14 seconds ago');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('1 day 2 hours 3 minutes 4 seconds');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('6 years');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months');
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('5 months 12 hours');
|
|
|
|
-- badly formatted interval
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('badly formatted interval');
|
|
|
|
ERROR: Bad interval external representation 'badly formatted interval'
|
|
|
|
INSERT INTO INTERVAL_TBL (f1) VALUES ('@ 30 eons ago');
|
|
|
|
ERROR: Bad interval external representation '@ 30 eons ago'
|
|
|
|
-- test interval operators
|
|
|
|
SELECT '' AS ten, INTERVAL_TBL.*;
|
2001-01-18 08:22:43 +01:00
|
|
|
ten | f1
|
|
|
|
-----+----------------
|
|
|
|
| 00:01
|
|
|
|
| 05:00
|
|
|
|
| 10 days
|
|
|
|
| 34 years
|
|
|
|
| 3 mons
|
2000-11-06 17:03:47 +01:00
|
|
|
| -00:00:14
|
2001-01-18 08:22:43 +01:00
|
|
|
| 1 day 02:03:04
|
|
|
|
| 6 years
|
|
|
|
| 5 mons
|
|
|
|
| 5 mons 12:00
|
1997-04-27 05:57:34 +02:00
|
|
|
(10 rows)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT '' AS nine, INTERVAL_TBL.*
|
|
|
|
WHERE INTERVAL_TBL.f1 <> interval '@ 10 days';
|
2001-01-18 08:22:43 +01:00
|
|
|
nine | f1
|
|
|
|
------+----------------
|
|
|
|
| 00:01
|
|
|
|
| 05:00
|
|
|
|
| 34 years
|
|
|
|
| 3 mons
|
2000-11-06 17:03:47 +01:00
|
|
|
| -00:00:14
|
2001-01-18 08:22:43 +01:00
|
|
|
| 1 day 02:03:04
|
|
|
|
| 6 years
|
|
|
|
| 5 mons
|
|
|
|
| 5 mons 12:00
|
1997-04-27 05:57:34 +02:00
|
|
|
(9 rows)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT '' AS three, INTERVAL_TBL.*
|
|
|
|
WHERE INTERVAL_TBL.f1 <= interval '@ 5 hours';
|
2000-11-06 17:03:47 +01:00
|
|
|
three | f1
|
|
|
|
-------+-----------
|
2001-01-18 08:22:43 +01:00
|
|
|
| 00:01
|
|
|
|
| 05:00
|
2000-11-06 17:03:47 +01:00
|
|
|
| -00:00:14
|
1997-04-27 05:57:34 +02:00
|
|
|
(3 rows)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT '' AS three, INTERVAL_TBL.*
|
|
|
|
WHERE INTERVAL_TBL.f1 < interval '@ 1 day';
|
2000-11-06 17:03:47 +01:00
|
|
|
three | f1
|
|
|
|
-------+-----------
|
2001-01-18 08:22:43 +01:00
|
|
|
| 00:01
|
|
|
|
| 05:00
|
2000-11-06 17:03:47 +01:00
|
|
|
| -00:00:14
|
1997-04-27 05:57:34 +02:00
|
|
|
(3 rows)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT '' AS one, INTERVAL_TBL.*
|
|
|
|
WHERE INTERVAL_TBL.f1 = interval '@ 34 years';
|
2001-01-18 08:22:43 +01:00
|
|
|
one | f1
|
|
|
|
-----+----------
|
|
|
|
| 34 years
|
1997-04-27 05:57:34 +02:00
|
|
|
(1 row)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT '' AS five, INTERVAL_TBL.*
|
|
|
|
WHERE INTERVAL_TBL.f1 >= interval '@ 1 month';
|
2001-01-18 08:22:43 +01:00
|
|
|
five | f1
|
|
|
|
------+--------------
|
|
|
|
| 34 years
|
|
|
|
| 3 mons
|
|
|
|
| 6 years
|
|
|
|
| 5 mons
|
|
|
|
| 5 mons 12:00
|
1997-04-27 05:57:34 +02:00
|
|
|
(5 rows)
|
|
|
|
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
SELECT '' AS nine, INTERVAL_TBL.*
|
|
|
|
WHERE INTERVAL_TBL.f1 > interval '@ 3 seconds ago';
|
2001-01-18 08:22:43 +01:00
|
|
|
nine | f1
|
|
|
|
------+----------------
|
|
|
|
| 00:01
|
|
|
|
| 05:00
|
|
|
|
| 10 days
|
|
|
|
| 34 years
|
|
|
|
| 3 mons
|
|
|
|
| 1 day 02:03:04
|
|
|
|
| 6 years
|
|
|
|
| 5 mons
|
|
|
|
| 5 mons 12:00
|
1997-04-27 05:57:34 +02:00
|
|
|
(9 rows)
|
|
|
|
|
2000-01-05 07:06:23 +01:00
|
|
|
SELECT '' AS fortyfive, r1.*, r2.*
|
All regression tests pass except for rules.sql (unrelated).
Implement "date/time grand unification".
Transform datetime and timespan into timestamp and interval.
Deprecate datetime and timespan, though translate to new types in gram.y.
Transform all datetime and timespan catalog entries into new types.
Make "INTERVAL" reserved word allowed as a column identifier in gram.y.
Remove dt.h, dt.c files, and retarget datetime.h, datetime.c as utility
routines for all date/time types.
date.{h,c} now deals with date, time types.
timestamp.{h,c} now deals with timestamp, interval types.
nabstime.{h,c} now deals with abstime, reltime, tinterval types.
Make NUMERIC a known native type for purposes of type coersion. Not tested.
2000-02-16 18:27:27 +01:00
|
|
|
FROM INTERVAL_TBL r1, INTERVAL_TBL r2
|
1997-05-09 05:26:56 +02:00
|
|
|
WHERE r1.f1 > r2.f1
|
|
|
|
ORDER BY r1.f1, r2.f1;
|
2001-01-18 08:22:43 +01:00
|
|
|
fortyfive | f1 | f1
|
|
|
|
-----------+----------------+----------------
|
|
|
|
| 00:01 | -00:00:14
|
|
|
|
| 05:00 | -00:00:14
|
|
|
|
| 05:00 | 00:01
|
|
|
|
| 1 day 02:03:04 | -00:00:14
|
|
|
|
| 1 day 02:03:04 | 00:01
|
|
|
|
| 1 day 02:03:04 | 05:00
|
|
|
|
| 10 days | -00:00:14
|
|
|
|
| 10 days | 00:01
|
|
|
|
| 10 days | 05:00
|
|
|
|
| 10 days | 1 day 02:03:04
|
|
|
|
| 3 mons | -00:00:14
|
|
|
|
| 3 mons | 00:01
|
|
|
|
| 3 mons | 05:00
|
|
|
|
| 3 mons | 1 day 02:03:04
|
|
|
|
| 3 mons | 10 days
|
|
|
|
| 5 mons | -00:00:14
|
|
|
|
| 5 mons | 00:01
|
|
|
|
| 5 mons | 05:00
|
|
|
|
| 5 mons | 1 day 02:03:04
|
|
|
|
| 5 mons | 10 days
|
|
|
|
| 5 mons | 3 mons
|
|
|
|
| 5 mons 12:00 | -00:00:14
|
|
|
|
| 5 mons 12:00 | 00:01
|
|
|
|
| 5 mons 12:00 | 05:00
|
|
|
|
| 5 mons 12:00 | 1 day 02:03:04
|
|
|
|
| 5 mons 12:00 | 10 days
|
|
|
|
| 5 mons 12:00 | 3 mons
|
|
|
|
| 5 mons 12:00 | 5 mons
|
|
|
|
| 6 years | -00:00:14
|
|
|
|
| 6 years | 00:01
|
|
|
|
| 6 years | 05:00
|
|
|
|
| 6 years | 1 day 02:03:04
|
|
|
|
| 6 years | 10 days
|
|
|
|
| 6 years | 3 mons
|
|
|
|
| 6 years | 5 mons
|
|
|
|
| 6 years | 5 mons 12:00
|
|
|
|
| 34 years | -00:00:14
|
|
|
|
| 34 years | 00:01
|
|
|
|
| 34 years | 05:00
|
|
|
|
| 34 years | 1 day 02:03:04
|
|
|
|
| 34 years | 10 days
|
|
|
|
| 34 years | 3 mons
|
|
|
|
| 34 years | 5 mons
|
|
|
|
| 34 years | 5 mons 12:00
|
|
|
|
| 34 years | 6 years
|
1997-04-27 05:57:34 +02:00
|
|
|
(45 rows)
|
|
|
|
|
2000-11-06 17:03:47 +01:00
|
|
|
SET DATESTYLE = 'postgres';
|
|
|
|
SELECT '' AS ten, INTERVAL_TBL.*;
|
|
|
|
ten | f1
|
|
|
|
-----+-------------------------------
|
|
|
|
| @ 1 min
|
|
|
|
| @ 5 hours
|
|
|
|
| @ 10 days
|
|
|
|
| @ 34 years
|
|
|
|
| @ 3 mons
|
|
|
|
| @ 14 secs ago
|
|
|
|
| @ 1 day 2 hours 3 mins 4 secs
|
|
|
|
| @ 6 years
|
|
|
|
| @ 5 mons
|
|
|
|
| @ 5 mons 12 hours
|
|
|
|
(10 rows)
|
|
|
|
|