4
CREATE TABLE RELTIME_TBL (f1 reltime);
5
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 1 minute');
6
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 5 hour');
7
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 10 day');
8
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 34 year');
9
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 3 months');
10
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 14 seconds ago');
11
-- badly formatted reltimes
12
INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltime');
13
ERROR: invalid input syntax for type reltime: "badly formatted reltime"
14
LINE 1: INSERT INTO RELTIME_TBL (f1) VALUES ('badly formatted reltim...
16
INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
17
ERROR: invalid input syntax for type reltime: "@ 30 eons ago"
18
LINE 1: INSERT INTO RELTIME_TBL (f1) VALUES ('@ 30 eons ago');
20
-- test reltime operators
21
SELECT '' AS six, * FROM RELTIME_TBL;
32
SELECT '' AS five, * FROM RELTIME_TBL
33
WHERE RELTIME_TBL.f1 <> reltime '@ 10 days';
35
------+---------------
43
SELECT '' AS three, * FROM RELTIME_TBL
44
WHERE RELTIME_TBL.f1 <= reltime '@ 5 hours';
46
-------+---------------
52
SELECT '' AS three, * FROM RELTIME_TBL
53
WHERE RELTIME_TBL.f1 < reltime '@ 1 day';
55
-------+---------------
61
SELECT '' AS one, * FROM RELTIME_TBL
62
WHERE RELTIME_TBL.f1 = reltime '@ 34 years';
68
SELECT '' AS two, * FROM RELTIME_TBL
69
WHERE RELTIME_TBL.f1 >= reltime '@ 1 month';
76
SELECT '' AS five, * FROM RELTIME_TBL
77
WHERE RELTIME_TBL.f1 > reltime '@ 3 seconds ago';
87
SELECT '' AS fifteen, r1.*, r2.*
88
FROM RELTIME_TBL r1, RELTIME_TBL r2
90
ORDER BY r1.f1, r2.f1;
92
---------+------------+---------------
93
| @ 1 min | @ 14 secs ago
94
| @ 5 hours | @ 14 secs ago
96
| @ 10 days | @ 14 secs ago
98
| @ 10 days | @ 5 hours
99
| @ 3 mons | @ 14 secs ago
101
| @ 3 mons | @ 5 hours
102
| @ 3 mons | @ 10 days
103
| @ 34 years | @ 14 secs ago
104
| @ 34 years | @ 1 min
105
| @ 34 years | @ 5 hours
106
| @ 34 years | @ 10 days
107
| @ 34 years | @ 3 mons