Commit 1f075a32 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Add separate regression tests for timetz and the new timestamptz type.

Modify the timestamp test to reflect the "no time zone" behavior of this
 new code; timestamptz resembles the old timestamp code.
parent 44f18333
...@@ -9,11 +9,20 @@ ...@@ -9,11 +9,20 @@
-- daylight savings time right for times prior to Unix epoch (jan 1 1970). -- daylight savings time right for times prior to Unix epoch (jan 1 1970).
-- --
CREATE TABLE ABSTIME_TBL (f1 abstime); CREATE TABLE ABSTIME_TBL (f1 abstime);
BEGIN;
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'current');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
two
-----
2
(1 row)
END;
DELETE FROM ABSTIME_TBL;
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21'); INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
-- was INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now'):
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'current');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
...@@ -32,13 +41,12 @@ SELECT '' AS eight, ABSTIME_TBL.*; ...@@ -32,13 +41,12 @@ SELECT '' AS eight, ABSTIME_TBL.*;
-------+------------------------------ -------+------------------------------
| Sun Jan 14 03:14:21 1973 PST | Sun Jan 14 03:14:21 1973 PST
| Mon May 01 00:30:30 1995 PDT | Mon May 01 00:30:30 1995 PDT
| epoch | Wed Dec 31 16:00:00 1969 PST
| current
| infinity | infinity
| -infinity | -infinity
| Sat May 10 23:59:12 1947 PST | Sat May 10 23:59:12 1947 PST
| invalid | invalid
(8 rows) (7 rows)
SELECT '' AS six, ABSTIME_TBL.* SELECT '' AS six, ABSTIME_TBL.*
WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001'; WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
...@@ -46,7 +54,7 @@ SELECT '' AS six, ABSTIME_TBL.* ...@@ -46,7 +54,7 @@ SELECT '' AS six, ABSTIME_TBL.*
-----+------------------------------ -----+------------------------------
| Sun Jan 14 03:14:21 1973 PST | Sun Jan 14 03:14:21 1973 PST
| Mon May 01 00:30:30 1995 PDT | Mon May 01 00:30:30 1995 PDT
| epoch | Wed Dec 31 16:00:00 1969 PST
| -infinity | -infinity
| Sat May 10 23:59:12 1947 PST | Sat May 10 23:59:12 1947 PST
(5 rows) (5 rows)
...@@ -57,12 +65,11 @@ SELECT '' AS six, ABSTIME_TBL.* ...@@ -57,12 +65,11 @@ SELECT '' AS six, ABSTIME_TBL.*
-----+------------------------------ -----+------------------------------
| Sun Jan 14 03:14:21 1973 PST | Sun Jan 14 03:14:21 1973 PST
| Mon May 01 00:30:30 1995 PDT | Mon May 01 00:30:30 1995 PDT
| epoch | Wed Dec 31 16:00:00 1969 PST
| current
| infinity | infinity
| Sat May 10 23:59:12 1947 PST | Sat May 10 23:59:12 1947 PST
| invalid | invalid
(7 rows) (6 rows)
SELECT '' AS six, ABSTIME_TBL.* SELECT '' AS six, ABSTIME_TBL.*
WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1; WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
...@@ -70,25 +77,17 @@ SELECT '' AS six, ABSTIME_TBL.* ...@@ -70,25 +77,17 @@ SELECT '' AS six, ABSTIME_TBL.*
-----+------------------------------ -----+------------------------------
| Sun Jan 14 03:14:21 1973 PST | Sun Jan 14 03:14:21 1973 PST
| Mon May 01 00:30:30 1995 PDT | Mon May 01 00:30:30 1995 PDT
| epoch | Wed Dec 31 16:00:00 1969 PST
| current
| infinity | infinity
| -infinity | -infinity
| invalid | invalid
(7 rows) (6 rows)
SELECT '' AS one, ABSTIME_TBL.*
WHERE abstime 'current' = ABSTIME_TBL.f1;
one | f1
-----+---------
| current
(1 row)
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE abstime 'epoch' >= ABSTIME_TBL.f1; WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
three | f1 three | f1
-------+------------------------------ -------+------------------------------
| epoch | Wed Dec 31 16:00:00 1969 PST
| -infinity | -infinity
| Sat May 10 23:59:12 1947 PST | Sat May 10 23:59:12 1947 PST
(3 rows) (3 rows)
...@@ -98,7 +97,7 @@ SELECT '' AS four, ABSTIME_TBL.* ...@@ -98,7 +97,7 @@ SELECT '' AS four, ABSTIME_TBL.*
four | f1 four | f1
------+------------------------------ ------+------------------------------
| Sun Jan 14 03:14:21 1973 PST | Sun Jan 14 03:14:21 1973 PST
| epoch | Wed Dec 31 16:00:00 1969 PST
| -infinity | -infinity
| Sat May 10 23:59:12 1947 PST | Sat May 10 23:59:12 1947 PST
(4 rows) (4 rows)
...@@ -110,7 +109,7 @@ SELECT '' AS four, ABSTIME_TBL.* ...@@ -110,7 +109,7 @@ SELECT '' AS four, ABSTIME_TBL.*
------+------------------------------ ------+------------------------------
| Sun Jan 14 03:14:21 1973 PST | Sun Jan 14 03:14:21 1973 PST
| Mon May 01 00:30:30 1995 PDT | Mon May 01 00:30:30 1995 PDT
| epoch | Wed Dec 31 16:00:00 1969 PST
(3 rows) (3 rows)
SELECT '' AS four, f1 AS abstime, SELECT '' AS four, f1 AS abstime,
...@@ -118,12 +117,12 @@ SELECT '' AS four, f1 AS abstime, ...@@ -118,12 +117,12 @@ SELECT '' AS four, f1 AS abstime,
date_part('day',f1) AS day, date_part('hour', f1) AS hour, date_part('day',f1) AS day, date_part('hour', f1) AS hour,
date_part('minute', f1) AS minute, date_part('second', f1) AS second date_part('minute', f1) AS minute, date_part('second', f1) AS second
FROM ABSTIME_TBL FROM ABSTIME_TBL
WHERE isfinite(f1) and f1 <> abstime 'current' WHERE isfinite(f1)
ORDER BY abstime; ORDER BY abstime;
four | abstime | year | month | day | hour | minute | second four | abstime | year | month | day | hour | minute | second
------+------------------------------+------+-------+-----+------+--------+-------- ------+------------------------------+------+-------+-----+------+--------+--------
| Sat May 10 23:59:12 1947 PST | 1947 | 5 | 10 | 23 | 59 | 12 | Sat May 10 23:59:12 1947 PST | 1947 | 5 | 10 | 23 | 59 | 12
| epoch | 1969 | 12 | 31 | 16 | 0 | 0 | Wed Dec 31 16:00:00 1969 PST | 1969 | 12 | 31 | 16 | 0 | 0
| Sun Jan 14 03:14:21 1973 PST | 1973 | 1 | 14 | 3 | 14 | 21 | Sun Jan 14 03:14:21 1973 PST | 1973 | 1 | 14 | 3 | 14 | 21
| Mon May 01 00:30:30 1995 PDT | 1995 | 5 | 1 | 0 | 30 | 30 | Mon May 01 00:30:30 1995 PDT | 1995 | 5 | 1 | 0 | 30 | 30
(4 rows) (4 rows)
......
...@@ -127,7 +127,7 @@ SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest ...@@ -127,7 +127,7 @@ SELECT '' AS thirty, p.f1, l.s, p.f1 ## l.s AS closest
| (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878049,-4.64390243902439) | (-5,-12) | [(10,-10),(-3,-4)] | (-1.60487804878049,-4.64390243902439)
| (10,10) | [(10,-10),(-3,-4)] | (2.39024390243902,-6.48780487804878) | (10,10) | [(10,-10),(-3,-4)] | (2.39024390243902,-6.48780487804878)
| (0,0) | [(-1000000,200),(300000,-40)] | (0.0028402365895872,15.384614860264) | (0,0) | [(-1000000,200),(300000,-40)] | (0.0028402365895872,15.384614860264)
| (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258202,15.3864610140472) | (-10,0) | [(-1000000,200),(300000,-40)] | (-9.99715942258202,15.3864610140473)
| (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812267519,15.3851688427303) | (-3,4) | [(-1000000,200),(300000,-40)] | (-2.99789812267519,15.3851688427303)
| (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221496,15.3836744976925) | (5.1,34.5) | [(-1000000,200),(300000,-40)] | (5.09647083221496,15.3836744976925)
| (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420845634,15.3855375281616) | (-5,-12) | [(-1000000,200),(300000,-40)] | (-4.99494420845634,15.3855375281616)
...@@ -152,7 +152,7 @@ SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL; ...@@ -152,7 +152,7 @@ SELECT '' as six, box(f1) AS box FROM CIRCLE_TBL;
| (2.12132034355964,2.12132034355964),(-2.12132034355964,-2.12132034355964) | (2.12132034355964,2.12132034355964),(-2.12132034355964,-2.12132034355964)
| (71.7106781186548,72.7106781186548),(-69.7106781186548,-68.7106781186548) | (71.7106781186548,72.7106781186548),(-69.7106781186548,-68.7106781186548)
| (4.53553390593274,6.53553390593274),(-2.53553390593274,-0.535533905932738) | (4.53553390593274,6.53553390593274),(-2.53553390593274,-0.535533905932738)
| (3.12132034355964,4.12132034355964),(-1.12132034355964,-0.121320343559643) | (3.12132034355964,4.12132034355964),(-1.12132034355964,-0.121320343559642)
| (107.071067811865,207.071067811865),(92.9289321881345,192.928932188135) | (107.071067811865,207.071067811865),(92.9289321881345,192.928932188135)
| (170.710678118655,70.7106781186548),(29.2893218813452,-70.7106781186548) | (170.710678118655,70.7106781186548),(29.2893218813452,-70.7106781186548)
(6 rows) (6 rows)
...@@ -504,7 +504,7 @@ SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS d ...@@ -504,7 +504,7 @@ SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS d
ORDER BY distance, circle, point using <<; ORDER BY distance, circle, point using <<;
twentyfour | circle | point | distance twentyfour | circle | point | distance
------------+----------------+------------+------------------- ------------+----------------+------------+-------------------
| <(100,0),100> | (5.1,34.5) | 0.976531926977964 | <(100,0),100> | (5.1,34.5) | 0.976531926977965
| <(1,2),3> | (-3,4) | 1.47213595499958 | <(1,2),3> | (-3,4) | 1.47213595499958
| <(0,0),3> | (-3,4) | 2 | <(0,0),3> | (-3,4) | 2
| <(100,0),100> | (-3,4) | 3.07764064044151 | <(100,0),100> | (-3,4) | 3.07764064044151
...@@ -519,7 +519,7 @@ SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS d ...@@ -519,7 +519,7 @@ SELECT '' AS twentyfour, c1.f1 AS circle, p1.f1 AS point, (p1.f1 <-> c1.f1) AS d
| <(0,0),3> | (10,10) | 11.142135623731 | <(0,0),3> | (10,10) | 11.142135623731
| <(1,3),5> | (-5,-12) | 11.1554944214035 | <(1,3),5> | (-5,-12) | 11.1554944214035
| <(1,2),3> | (-5,-12) | 12.2315462117278 | <(1,2),3> | (-5,-12) | 12.2315462117278
| <(1,3),5> | (5.1,34.5) | 26.7657047773224 | <(1,3),5> | (5.1,34.5) | 26.7657047773223
| <(1,2),3> | (5.1,34.5) | 29.757594539282 | <(1,2),3> | (5.1,34.5) | 29.757594539282
| <(0,0),3> | (5.1,34.5) | 31.8749193547455 | <(0,0),3> | (5.1,34.5) | 31.8749193547455
| <(100,200),10> | (5.1,34.5) | 180.778038568384 | <(100,200),10> | (5.1,34.5) | 180.778038568384
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -85,7 +85,8 @@ WHERE p1.oid != p2.oid AND ...@@ -85,7 +85,8 @@ WHERE p1.oid != p2.oid AND
prorettype | prorettype prorettype | prorettype
------------+------------ ------------+------------
25 | 1043 25 | 1043
(1 row) 1114 | 1184
(2 rows)
SELECT DISTINCT p1.proargtypes[0], p2.proargtypes[0] SELECT DISTINCT p1.proargtypes[0], p2.proargtypes[0]
FROM pg_proc AS p1, pg_proc AS p2 FROM pg_proc AS p1, pg_proc AS p2
...@@ -97,8 +98,9 @@ WHERE p1.oid != p2.oid AND ...@@ -97,8 +98,9 @@ WHERE p1.oid != p2.oid AND
proargtypes | proargtypes proargtypes | proargtypes
-------------+------------- -------------+-------------
25 | 1043 25 | 1043
1114 | 1184
1560 | 1562 1560 | 1562
(2 rows) (3 rows)
SELECT DISTINCT p1.proargtypes[1], p2.proargtypes[1] SELECT DISTINCT p1.proargtypes[1], p2.proargtypes[1]
FROM pg_proc AS p1, pg_proc AS p2 FROM pg_proc AS p1, pg_proc AS p2
...@@ -109,8 +111,9 @@ WHERE p1.oid != p2.oid AND ...@@ -109,8 +111,9 @@ WHERE p1.oid != p2.oid AND
(p1.proargtypes[1] < p2.proargtypes[1]); (p1.proargtypes[1] < p2.proargtypes[1]);
proargtypes | proargtypes proargtypes | proargtypes
-------------+------------- -------------+-------------
1114 | 1184
1560 | 1562 1560 | 1562
(1 row) (2 rows)
SELECT DISTINCT p1.proargtypes[2], p2.proargtypes[2] SELECT DISTINCT p1.proargtypes[2], p2.proargtypes[2]
FROM pg_proc AS p1, pg_proc AS p2 FROM pg_proc AS p1, pg_proc AS p2
...@@ -121,7 +124,8 @@ WHERE p1.oid != p2.oid AND ...@@ -121,7 +124,8 @@ WHERE p1.oid != p2.oid AND
(p1.proargtypes[2] < p2.proargtypes[2]); (p1.proargtypes[2] < p2.proargtypes[2]);
proargtypes | proargtypes proargtypes | proargtypes
-------------+------------- -------------+-------------
(0 rows) 1114 | 1184
(1 row)
SELECT DISTINCT p1.proargtypes[3], p2.proargtypes[3] SELECT DISTINCT p1.proargtypes[3], p2.proargtypes[3]
FROM pg_proc AS p1, pg_proc AS p2 FROM pg_proc AS p1, pg_proc AS p2
...@@ -132,7 +136,8 @@ WHERE p1.oid != p2.oid AND ...@@ -132,7 +136,8 @@ WHERE p1.oid != p2.oid AND
(p1.proargtypes[3] < p2.proargtypes[3]); (p1.proargtypes[3] < p2.proargtypes[3]);
proargtypes | proargtypes proargtypes | proargtypes
-------------+------------- -------------+-------------
(0 rows) 1114 | 1184
(1 row)
SELECT DISTINCT p1.proargtypes[4], p2.proargtypes[4] SELECT DISTINCT p1.proargtypes[4], p2.proargtypes[4]
FROM pg_proc AS p1, pg_proc AS p2 FROM pg_proc AS p1, pg_proc AS p2
...@@ -481,7 +486,7 @@ WHERE p1.aggtransfn = p2.oid AND ...@@ -481,7 +486,7 @@ WHERE p1.aggtransfn = p2.oid AND
oid | aggname | oid | proname oid | aggname | oid | proname
-------+---------+-----+------------- -------+---------+-----+-------------
10021 | max | 768 | int4larger 10021 | max | 768 | int4larger
10036 | min | 769 | int4smaller 10037 | min | 769 | int4smaller
(2 rows) (2 rows)
-- Cross-check finalfn (if present) against its entry in pg_proc. -- Cross-check finalfn (if present) against its entry in pg_proc.
......
...@@ -1029,8 +1029,8 @@ SELECT * FROM shoe_ready WHERE total_avail >= 2; ...@@ -1029,8 +1029,8 @@ SELECT * FROM shoe_ready WHERE total_avail >= 2;
UPDATE shoelace_data SET sl_avail = 6 WHERE sl_name = 'sl7'; UPDATE shoelace_data SET sl_avail = 6 WHERE sl_name = 'sl7';
SELECT * FROM shoelace_log; SELECT * FROM shoelace_log;
sl_name | sl_avail | log_who | log_when sl_name | sl_avail | log_who | log_when
------------+----------+----------+---------- ------------+----------+----------+--------------------------
sl7 | 6 | Al Bundy | epoch sl7 | 6 | Al Bundy | Thu Jan 01 00:00:00 1970
(1 row) (1 row)
CREATE RULE shoelace_ins AS ON INSERT TO shoelace CREATE RULE shoelace_ins AS ON INSERT TO shoelace
...@@ -1099,11 +1099,11 @@ SELECT * FROM shoelace ORDER BY sl_name; ...@@ -1099,11 +1099,11 @@ SELECT * FROM shoelace ORDER BY sl_name;
SELECT * FROM shoelace_log ORDER BY sl_name; SELECT * FROM shoelace_log ORDER BY sl_name;
sl_name | sl_avail | log_who | log_when sl_name | sl_avail | log_who | log_when
------------+----------+----------+---------- ------------+----------+----------+--------------------------
sl3 | 10 | Al Bundy | epoch sl3 | 10 | Al Bundy | Thu Jan 01 00:00:00 1970
sl6 | 20 | Al Bundy | epoch sl6 | 20 | Al Bundy | Thu Jan 01 00:00:00 1970
sl7 | 6 | Al Bundy | epoch sl7 | 6 | Al Bundy | Thu Jan 01 00:00:00 1970
sl8 | 21 | Al Bundy | epoch sl8 | 21 | Al Bundy | Thu Jan 01 00:00:00 1970
(4 rows) (4 rows)
CREATE VIEW shoelace_obsolete AS CREATE VIEW shoelace_obsolete AS
...@@ -1309,7 +1309,7 @@ SELECT viewname, definition FROM pg_views ORDER BY viewname; ...@@ -1309,7 +1309,7 @@ SELECT viewname, definition FROM pg_views ORDER BY viewname;
SELECT tablename, rulename, definition FROM pg_rules SELECT tablename, rulename, definition FROM pg_rules
ORDER BY tablename, rulename; ORDER BY tablename, rulename;
tablename | rulename | definition tablename | rulename | definition
---------------+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---------------+-----------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
rtest_emp | rtest_emp_del | CREATE RULE rtest_emp_del AS ON DELETE TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (old.ename, "current_user"(), 'fired '::bpchar, '$0.00'::money, old.salary); rtest_emp | rtest_emp_del | CREATE RULE rtest_emp_del AS ON DELETE TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (old.ename, "current_user"(), 'fired '::bpchar, '$0.00'::money, old.salary);
rtest_emp | rtest_emp_ins | CREATE RULE rtest_emp_ins AS ON INSERT TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'hired '::bpchar, new.salary, '$0.00'::money); rtest_emp | rtest_emp_ins | CREATE RULE rtest_emp_ins AS ON INSERT TO rtest_emp DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'hired '::bpchar, new.salary, '$0.00'::money);
rtest_emp | rtest_emp_upd | CREATE RULE rtest_emp_upd AS ON UPDATE TO rtest_emp WHERE (new.salary <> old.salary) DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'honored '::bpchar, new.salary, old.salary); rtest_emp | rtest_emp_upd | CREATE RULE rtest_emp_upd AS ON UPDATE TO rtest_emp WHERE (new.salary <> old.salary) DO INSERT INTO rtest_emplog (ename, who, "action", newsal, oldsal) VALUES (new.ename, "current_user"(), 'honored '::bpchar, new.salary, old.salary);
...@@ -1335,7 +1335,7 @@ SELECT tablename, rulename, definition FROM pg_rules ...@@ -1335,7 +1335,7 @@ SELECT tablename, rulename, definition FROM pg_rules
shoelace | shoelace_del | CREATE RULE shoelace_del AS ON DELETE TO shoelace DO INSTEAD DELETE FROM shoelace_data WHERE (shoelace_data.sl_name = old.sl_name); shoelace | shoelace_del | CREATE RULE shoelace_del AS ON DELETE TO shoelace DO INSTEAD DELETE FROM shoelace_data WHERE (shoelace_data.sl_name = old.sl_name);
shoelace | shoelace_ins | CREATE RULE shoelace_ins AS ON INSERT TO shoelace DO INSTEAD INSERT INTO shoelace_data (sl_name, sl_avail, sl_color, sl_len, sl_unit) VALUES (new.sl_name, new.sl_avail, new.sl_color, new.sl_len, new.sl_unit); shoelace | shoelace_ins | CREATE RULE shoelace_ins AS ON INSERT TO shoelace DO INSTEAD INSERT INTO shoelace_data (sl_name, sl_avail, sl_color, sl_len, sl_unit) VALUES (new.sl_name, new.sl_avail, new.sl_color, new.sl_len, new.sl_unit);
shoelace | shoelace_upd | CREATE RULE shoelace_upd AS ON UPDATE TO shoelace DO INSTEAD UPDATE shoelace_data SET sl_name = new.sl_name, sl_avail = new.sl_avail, sl_color = new.sl_color, sl_len = new.sl_len, sl_unit = new.sl_unit WHERE (shoelace_data.sl_name = old.sl_name); shoelace | shoelace_upd | CREATE RULE shoelace_upd AS ON UPDATE TO shoelace DO INSTEAD UPDATE shoelace_data SET sl_name = new.sl_name, sl_avail = new.sl_avail, sl_color = new.sl_color, sl_len = new.sl_len, sl_unit = new.sl_unit WHERE (shoelace_data.sl_name = old.sl_name);
shoelace_data | log_shoelace | CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data WHERE (new.sl_avail <> old.sl_avail) DO INSERT INTO shoelace_log (sl_name, sl_avail, log_who, log_when) VALUES (new.sl_name, new.sl_avail, 'Al Bundy'::name, "timestamp"('epoch'::text)); shoelace_data | log_shoelace | CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data WHERE (new.sl_avail <> old.sl_avail) DO INSERT INTO shoelace_log (sl_name, sl_avail, log_who, log_when) VALUES (new.sl_name, new.sl_avail, 'Al Bundy'::name, 'Thu Jan 01 00:00:00 1970'::"timestamp");
shoelace_ok | shoelace_ok_ins | CREATE RULE shoelace_ok_ins AS ON INSERT TO shoelace_ok DO INSTEAD UPDATE shoelace SET sl_avail = (shoelace.sl_avail + new.ok_quant) WHERE (shoelace.sl_name = new.ok_name); shoelace_ok | shoelace_ok_ins | CREATE RULE shoelace_ok_ins AS ON INSERT TO shoelace_ok DO INSTEAD UPDATE shoelace SET sl_avail = (shoelace.sl_avail + new.ok_quant) WHERE (shoelace.sl_name = new.ok_name);
(27 rows) (27 rows)
-- --
-- TIME -- TIME
-- --
CREATE TABLE TIME_TBL (f1 time, f2 time with time zone); CREATE TABLE TIME_TBL (f1 time);
INSERT INTO TIME_TBL VALUES ('00:00', '00:00 PDT'); INSERT INTO TIME_TBL VALUES ('00:00');
INSERT INTO TIME_TBL VALUES ('01:00', '01:00 PDT'); INSERT INTO TIME_TBL VALUES ('01:00');
INSERT INTO TIME_TBL VALUES ('02:03', '02:03 PDT'); INSERT INTO TIME_TBL VALUES ('02:03');
INSERT INTO TIME_TBL VALUES ('11:59', '11:59 PDT'); INSERT INTO TIME_TBL VALUES ('07:07 PST');
INSERT INTO TIME_TBL VALUES ('12:00', '12:00 PDT'); ERROR: Bad time external representation '07:07 PST'
INSERT INTO TIME_TBL VALUES ('12:01', '12:01 PDT'); INSERT INTO TIME_TBL VALUES ('08:08 EDT');
INSERT INTO TIME_TBL VALUES ('23:59', '23:59 PDT'); ERROR: Bad time external representation '08:08 EDT'
INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM', '11:59:59.99 PM PDT'); INSERT INTO TIME_TBL VALUES ('11:59');
SELECT f1 AS "Time", f2 AS "Time TZ" FROM TIME_TBL; INSERT INTO TIME_TBL VALUES ('12:00');
Time | Time TZ INSERT INTO TIME_TBL VALUES ('12:01');
----------+------------- INSERT INTO TIME_TBL VALUES ('23:59');
00:00:00 | 00:00:00-07 INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
01:00:00 | 01:00:00-07 SELECT f1 AS "Time" FROM TIME_TBL;
02:03:00 | 02:03:00-07 Time
11:59:00 | 11:59:00-07 ----------
12:00:00 | 12:00:00-07 00:00:00
12:01:00 | 12:01:00-07 01:00:00
23:59:00 | 23:59:00-07 02:03:00
23:59:59 | 23:59:59-07 11:59:00
12:00:00
12:01:00
23:59:00
23:59:59
(8 rows) (8 rows)
SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07'; SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
...@@ -70,6 +74,3 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00'; ...@@ -70,6 +74,3 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL; SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
ERROR: Unable to identify an operator '+' for types 'time' and 'time' ERROR: Unable to identify an operator '+' for types 'time' and 'time'
You will have to retype this query using an explicit cast You will have to retype this query using an explicit cast
SELECT f2 + time with time zone '00:01' AS "Illegal" FROM TIME_TBL;
ERROR: Unable to identify an operator '+' for types 'time with time zone' and 'time with time zone'
You will have to retype this query using an explicit cast
This diff is collapsed.
This diff is collapsed.
--
-- TIMETZ
--
CREATE TABLE TIMETZ_TBL (f1 time with time zone);
INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT');
INSERT INTO TIMETZ_TBL VALUES ('02:03 PDT');
INSERT INTO TIMETZ_TBL VALUES ('07:07 PST');
INSERT INTO TIMETZ_TBL VALUES ('08:08 EDT');
INSERT INTO TIMETZ_TBL VALUES ('11:59 PDT');
INSERT INTO TIMETZ_TBL VALUES ('12:00 PDT');
INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT');
INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT');
SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
Time TZ
-------------
00:01:00-07
01:00:00-07
02:03:00-07
07:07:00-08
08:08:00-04
11:59:00-07
12:00:00-07
12:01:00-07
23:59:00-07
23:59:59-07
(10 rows)
SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07';
Three
-------------
00:01:00-07
01:00:00-07
02:03:00-07
(3 rows)
SELECT f1 AS "Seven" FROM TIMETZ_TBL WHERE f1 > '05:06:07';
Seven
-------------
07:07:00-08
08:08:00-04
11:59:00-07
12:00:00-07
12:01:00-07
23:59:00-07
23:59:59-07
(7 rows)
SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00';
None
------
(0 rows)
SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00';
Ten
-------------
00:01:00-07
01:00:00-07
02:03:00-07
07:07:00-08
08:08:00-04
11:59:00-07
12:00:00-07
12:01:00-07
23:59:00-07
23:59:59-07
(10 rows)
--
-- TIME simple math
--
-- We now make a distinction between time and intervals,
-- and adding two times together makes no sense at all.
-- Leave in one query to show that it is rejected,
-- and do the rest of the testing in horology.sql
-- where we do mixed-type arithmetic. - thomas 2000-12-02
SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL;
ERROR: Unable to identify an operator '+' for types 'time with time zone' and 'time with time zone'
You will have to retype this query using an explicit cast
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
-- TINTERVAL -- TINTERVAL
-- --
CREATE TABLE TINTERVAL_TBL (f1 tinterval); CREATE TABLE TINTERVAL_TBL (f1 tinterval);
-- Should accept any abstime,
-- so do not bother with extensive testing of values
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["-infinity" "infinity"]'); VALUES ('["-infinity" "infinity"]');
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
...@@ -11,7 +13,7 @@ INSERT INTO TINTERVAL_TBL (f1) ...@@ -11,7 +13,7 @@ INSERT INTO TINTERVAL_TBL (f1)
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["epoch" "Mon May 1 00:30:30 1995"]'); VALUES ('["epoch" "Mon May 1 00:30:30 1995"]');
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["Feb 15 1990 12:15:03" "current"]'); VALUES ('["Feb 15 1990 12:15:03" "2001-09-23 11:12:13"]');
-- badly formatted tintervals -- badly formatted tintervals
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["bad time specifications" ""]'); VALUES ('["bad time specifications" ""]');
...@@ -26,8 +28,8 @@ SELECT '' AS five, TINTERVAL_TBL.*; ...@@ -26,8 +28,8 @@ SELECT '' AS five, TINTERVAL_TBL.*;
| ["-infinity" "infinity"] | ["-infinity" "infinity"]
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
(5 rows) (5 rows)
-- length == -- length ==
...@@ -46,8 +48,8 @@ SELECT '' AS three, t.* ...@@ -46,8 +48,8 @@ SELECT '' AS three, t.*
three | f1 three | f1
-------+----------------------------------------------------------------- -------+-----------------------------------------------------------------
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
(3 rows) (3 rows)
-- length < -- length <
...@@ -74,8 +76,8 @@ SELECT '' AS three, t.* ...@@ -74,8 +76,8 @@ SELECT '' AS three, t.*
three | f1 three | f1
-------+----------------------------------------------------------------- -------+-----------------------------------------------------------------
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
(3 rows) (3 rows)
-- length >= -- length >=
...@@ -85,8 +87,8 @@ SELECT '' AS three, t.* ...@@ -85,8 +87,8 @@ SELECT '' AS three, t.*
three | f1 three | f1
-------+----------------------------------------------------------------- -------+-----------------------------------------------------------------
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
(3 rows) (3 rows)
-- overlaps -- overlaps
...@@ -98,7 +100,7 @@ SELECT '' AS three, t1.* ...@@ -98,7 +100,7 @@ SELECT '' AS three, t1.*
-------+----------------------------------------------------------------- -------+-----------------------------------------------------------------
| ["-infinity" "infinity"] | ["-infinity" "infinity"]
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
(3 rows) (3 rows)
SET geqo TO 'off'; SET geqo TO 'off';
...@@ -111,8 +113,8 @@ SELECT '' AS five, t1.f1, t2.f1 ...@@ -111,8 +113,8 @@ SELECT '' AS five, t1.f1, t2.f1
------+-----------------------------------------------------------------+----------------------------------------------------------------- ------+-----------------------------------------------------------------+-----------------------------------------------------------------
| ["-infinity" "infinity"] | ["-infinity" "infinity"] | ["-infinity" "infinity"] | ["-infinity" "infinity"]
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
(5 rows) (5 rows)
...@@ -123,19 +125,19 @@ SELECT '' AS fourteen, t1.f1 AS interval1, t2.f1 AS interval2 ...@@ -123,19 +125,19 @@ SELECT '' AS fourteen, t1.f1 AS interval1, t2.f1 AS interval2
fourteen | interval1 | interval2 fourteen | interval1 | interval2
----------+-----------------------------------------------------------------+----------------------------------------------------------------- ----------+-----------------------------------------------------------------+-----------------------------------------------------------------
| ["-infinity" "infinity"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["-infinity" "infinity"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["-infinity" "infinity"] | ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["-infinity" "infinity"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
| ["-infinity" "infinity"] | ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["-infinity" "infinity"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["-infinity" "infinity"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["-infinity" "infinity"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["-infinity" "infinity"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["-infinity" "infinity"]
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["-infinity" "infinity"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"] | ["-infinity" "infinity"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["-infinity" "infinity"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["-infinity" "infinity"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["-infinity" "infinity"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["-infinity" "infinity"]
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
(14 rows) (14 rows)
-- contains -- contains
...@@ -147,7 +149,7 @@ SELECT '' AS five, t1.f1 ...@@ -147,7 +149,7 @@ SELECT '' AS five, t1.f1
five | f1 five | f1
------+----------------------------------------------------------------- ------+-----------------------------------------------------------------
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["Thu Feb 15 12:15:03 1990 PST" "current"] | ["Thu Feb 15 12:15:03 1990 PST" "Sun Sep 23 11:12:13 2001 PDT"]
| ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"] | ["Sat May 10 23:59:12 1947 PST" "Sun Jan 14 03:14:21 1973 PST"]
(3 rows) (3 rows)
...@@ -162,7 +164,7 @@ SELECT '' AS three, t1.f1 ...@@ -162,7 +164,7 @@ SELECT '' AS three, t1.f1
-------+----------------------------------------------------------------- -------+-----------------------------------------------------------------
| ["-infinity" "infinity"] | ["-infinity" "infinity"]
| ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"] | ["Sun Sep 04 23:59:12 1983 PDT" "Tue Oct 04 23:59:12 1983 PDT"]
| ["epoch" "Mon May 01 00:30:30 1995 PDT"] | ["Wed Dec 31 16:00:00 1969 PST" "Mon May 01 00:30:30 1995 PDT"]
(3 rows) (3 rows)
RESET geqo; RESET geqo;
...@@ -650,11 +650,13 @@ SELECT user_relns() AS user_relns ...@@ -650,11 +650,13 @@ SELECT user_relns() AS user_relns
text_tbl text_tbl
time_tbl time_tbl
timestamp_tbl timestamp_tbl
timestamptz_tbl
timetz_tbl
tinterval_tbl tinterval_tbl
toyemp toyemp
varchar_tbl varchar_tbl
xacttest xacttest
(91 rows) (93 rows)
--SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) AS equip_name; --SELECT name(equipment(hobby_construct(text 'skywalking', text 'mer'))) AS equip_name;
SELECT hobbies_by_name('basketball'); SELECT hobbies_by_name('basketball');
......
...@@ -11,11 +11,11 @@ test: numerology ...@@ -11,11 +11,11 @@ test: numerology
# ---------- # ----------
# The second group of parallel test # The second group of parallel test
# ---------- # ----------
test: point lseg box path polygon circle date time timestamp interval abstime reltime tinterval inet comments oidjoins type_sanity opr_sanity test: point lseg box path polygon circle date time timestamp timestamptz interval abstime reltime tinterval inet comments oidjoins type_sanity opr_sanity
# Depends on point, lseg, box, path, polygon and circle # Depends on point, lseg, box, path, polygon and circle
test: geometry test: geometry
# Depends on interval, timestamp, reltime and abstime # Depends on interval, timestamp, timestamptz, reltime and abstime
test: horology test: horology
# ---------- # ----------
......
# $Header: /cvsroot/pgsql/src/test/regress/serial_schedule,v 1.6 2001/06/12 16:34:27 momjian Exp $ # $Header: /cvsroot/pgsql/src/test/regress/serial_schedule,v 1.7 2001/09/28 07:59:38 thomas Exp $
# This should probably be in an order similar to parallel_schedule. # This should probably be in an order similar to parallel_schedule.
test: boolean test: boolean
test: char test: char
...@@ -23,7 +23,9 @@ test: polygon ...@@ -23,7 +23,9 @@ test: polygon
test: circle test: circle
test: date test: date
test: time test: time
test: timetz
test: timestamp test: timestamp
test: timestamptz
test: interval test: interval
test: abstime test: abstime
test: reltime test: reltime
......
...@@ -12,31 +12,27 @@ ...@@ -12,31 +12,27 @@
CREATE TABLE ABSTIME_TBL (f1 abstime); CREATE TABLE ABSTIME_TBL (f1 abstime);
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21'); BEGIN;
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'current');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
END;
-- was INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now'): DELETE FROM ABSTIME_TBL;
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May 1 00:30:30 1995');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'current');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12'); INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
-- what happens if we specify slightly misformatted abstime? -- what happens if we specify slightly misformatted abstime?
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00'); INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10'); INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
-- badly formatted abstimes: these should result in invalid abstimes -- badly formatted abstimes: these should result in invalid abstimes
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format'); INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843'); INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
-- test abstime operators -- test abstime operators
...@@ -52,9 +48,6 @@ SELECT '' AS six, ABSTIME_TBL.* ...@@ -52,9 +48,6 @@ SELECT '' AS six, ABSTIME_TBL.*
SELECT '' AS six, ABSTIME_TBL.* SELECT '' AS six, ABSTIME_TBL.*
WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1; WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
SELECT '' AS one, ABSTIME_TBL.*
WHERE abstime 'current' = ABSTIME_TBL.f1;
SELECT '' AS three, ABSTIME_TBL.* SELECT '' AS three, ABSTIME_TBL.*
WHERE abstime 'epoch' >= ABSTIME_TBL.f1; WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
...@@ -70,5 +63,5 @@ SELECT '' AS four, f1 AS abstime, ...@@ -70,5 +63,5 @@ SELECT '' AS four, f1 AS abstime,
date_part('day',f1) AS day, date_part('hour', f1) AS hour, date_part('day',f1) AS day, date_part('hour', f1) AS hour,
date_part('minute', f1) AS minute, date_part('second', f1) AS second date_part('minute', f1) AS minute, date_part('second', f1) AS second
FROM ABSTIME_TBL FROM ABSTIME_TBL
WHERE isfinite(f1) and f1 <> abstime 'current' WHERE isfinite(f1)
ORDER BY abstime; ORDER BY abstime;
This diff is collapsed.
...@@ -394,7 +394,6 @@ WHERE p1.aggfinalfn = 0 AND p1.aggfinaltype != p1.aggtranstype; ...@@ -394,7 +394,6 @@ WHERE p1.aggfinalfn = 0 AND p1.aggfinaltype != p1.aggtranstype;
-- implemented using int4larger/int4smaller. Until we have -- implemented using int4larger/int4smaller. Until we have
-- some cleaner way of dealing with binary-equivalent types, just leave -- some cleaner way of dealing with binary-equivalent types, just leave
-- those two tuples in the expected output. -- those two tuples in the expected output.
SELECT p1.oid, p1.aggname, p2.oid, p2.proname SELECT p1.oid, p1.aggname, p2.oid, p2.proname
FROM pg_aggregate AS p1, pg_proc AS p2 FROM pg_aggregate AS p1, pg_proc AS p2
WHERE p1.aggtransfn = p2.oid AND WHERE p1.aggtransfn = p2.oid AND
......
...@@ -2,18 +2,20 @@ ...@@ -2,18 +2,20 @@
-- TIME -- TIME
-- --
CREATE TABLE TIME_TBL (f1 time, f2 time with time zone); CREATE TABLE TIME_TBL (f1 time);
INSERT INTO TIME_TBL VALUES ('00:00', '00:00 PDT'); INSERT INTO TIME_TBL VALUES ('00:00');
INSERT INTO TIME_TBL VALUES ('01:00', '01:00 PDT'); INSERT INTO TIME_TBL VALUES ('01:00');
INSERT INTO TIME_TBL VALUES ('02:03', '02:03 PDT'); INSERT INTO TIME_TBL VALUES ('02:03');
INSERT INTO TIME_TBL VALUES ('11:59', '11:59 PDT'); INSERT INTO TIME_TBL VALUES ('07:07 PST');
INSERT INTO TIME_TBL VALUES ('12:00', '12:00 PDT'); INSERT INTO TIME_TBL VALUES ('08:08 EDT');
INSERT INTO TIME_TBL VALUES ('12:01', '12:01 PDT'); INSERT INTO TIME_TBL VALUES ('11:59');
INSERT INTO TIME_TBL VALUES ('23:59', '23:59 PDT'); INSERT INTO TIME_TBL VALUES ('12:00');
INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM', '11:59:59.99 PM PDT'); INSERT INTO TIME_TBL VALUES ('12:01');
INSERT INTO TIME_TBL VALUES ('23:59');
INSERT INTO TIME_TBL VALUES ('11:59:59.99 PM');
SELECT f1 AS "Time", f2 AS "Time TZ" FROM TIME_TBL; SELECT f1 AS "Time" FROM TIME_TBL;
SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07'; SELECT f1 AS "Three" FROM TIME_TBL WHERE f1 < '05:06:07';
...@@ -33,5 +35,3 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00'; ...@@ -33,5 +35,3 @@ SELECT f1 AS "Eight" FROM TIME_TBL WHERE f1 >= '00:00';
-- where we do mixed-type arithmetic. - thomas 2000-12-02 -- where we do mixed-type arithmetic. - thomas 2000-12-02
SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL; SELECT f1 + time '00:01' AS "Illegal" FROM TIME_TBL;
SELECT f2 + time with time zone '00:01' AS "Illegal" FROM TIME_TBL;
-- --
-- DATETIME -- TIMESTAMP
-- --
-- Shorthand values -- needed so tests pass even in Australia
-- Not directly usable for regression testing since these are not constants.
-- So, just try to test parser and hope for the best - thomas 97/04/26
-- needed so tests pass
SET australian_timezones = 'off'; SET australian_timezones = 'off';
SELECT (timestamp 'today' = (timestamp 'yesterday' + interval '1 day')) as "True"; CREATE TABLE TIMESTAMP_TBL ( d1 timestamp without time zone);
SELECT (timestamp 'today' = (timestamp 'tomorrow' - interval '1 day')) as "True";
SELECT (timestamp 'tomorrow' = (timestamp 'yesterday' + interval '2 days')) as "True";
SELECT (timestamp 'current' = 'now') as "True";
SELECT (timestamp 'now' - 'current') AS "ZeroSecs";
SET DateStyle = 'Postgres,NonEuropean'; -- Shorthand values
SELECT timestamp(date '1994-01-01', time '11:00') AS "Jan_01_1994_11am"; -- Not directly usable for regression testing since these are not constants.
SELECT timestamp(date '1994-01-01', time '10:00') AS "Jan_01_1994_10am"; -- So, just try to test parser and hope for the best - thomas 97/04/26
SELECT timestamp(date '1994-01-01', time with time zone '11:00-5') AS "Jan_01_1994_8am";
CREATE TABLE TIMESTAMP_TBL ( d1 timestamp);
INSERT INTO TIMESTAMP_TBL VALUES ('now');
INSERT INTO TIMESTAMP_TBL VALUES ('current'); INSERT INTO TIMESTAMP_TBL VALUES ('current');
INSERT INTO TIMESTAMP_TBL VALUES ('today'); INSERT INTO TIMESTAMP_TBL VALUES ('today');
INSERT INTO TIMESTAMP_TBL VALUES ('yesterday'); INSERT INTO TIMESTAMP_TBL VALUES ('yesterday');
...@@ -27,29 +18,27 @@ INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow'); ...@@ -27,29 +18,27 @@ INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow');
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST'); INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow EST');
INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu'); INSERT INTO TIMESTAMP_TBL VALUES ('tomorrow zulu');
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'today'; SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'today';
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'tomorrow'; SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'tomorrow';
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'yesterday'; SELECT count(*) AS One FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'yesterday';
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'today' + interval '1 day'; SELECT count(*) AS None FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'now';
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'today' - interval '1 day';
SELECT count(*) AS one FROM TIMESTAMP_TBL WHERE d1 = timestamp 'now';
DELETE FROM TIMESTAMP_TBL; DELETE FROM TIMESTAMP_TBL;
-- verify uniform transaction time within transaction block -- verify uniform transaction time within transaction block
INSERT INTO TIMESTAMP_TBL VALUES ('current');
BEGIN; BEGIN;
INSERT INTO TIMESTAMP_TBL VALUES ('now'); INSERT INTO TIMESTAMP_TBL VALUES ('now');
SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 = timestamp 'now'; INSERT INTO TIMESTAMP_TBL VALUES ('now');
SELECT count(*) AS two FROM TIMESTAMP_TBL WHERE d1 = timestamp without time zone 'now';
END; END;
DELETE FROM TIMESTAMP_TBL; DELETE FROM TIMESTAMP_TBL;
-- Special values -- Special values
INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
INSERT INTO TIMESTAMP_TBL VALUES ('-infinity'); INSERT INTO TIMESTAMP_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('infinity'); INSERT INTO TIMESTAMP_TBL VALUES ('infinity');
INSERT INTO TIMESTAMP_TBL VALUES ('epoch'); INSERT INTO TIMESTAMP_TBL VALUES ('epoch');
-- Obsolete special values
INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
-- Postgres v6.0 standard output format -- Postgres v6.0 standard output format
INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST'); INSERT INTO TIMESTAMP_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
...@@ -71,6 +60,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-0800'); ...@@ -71,6 +60,7 @@ INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01-0800');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 -08:00'); INSERT INTO TIMESTAMP_TBL VALUES ('1997-02-10 17:32:01 -08:00');
INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 -0800'); INSERT INTO TIMESTAMP_TBL VALUES ('19970210 173201 -0800');
INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 17:32:01 -07:00'); INSERT INTO TIMESTAMP_TBL VALUES ('1997-06-10 17:32:01 -07:00');
INSERT INTO TIMESTAMP_TBL VALUES ('2001-09-22T18:19:20');
-- POSIX format -- POSIX format
INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 08:14:01 GMT+8'); INSERT INTO TIMESTAMP_TBL VALUES ('2000-03-15 08:14:01 GMT+8');
...@@ -133,50 +123,46 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001'); ...@@ -133,50 +123,46 @@ INSERT INTO TIMESTAMP_TBL VALUES ('Jan 01 17:32:01 2001');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097'); INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 -0097');
INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC'); INSERT INTO TIMESTAMP_TBL VALUES ('Feb 16 17:32:01 5097 BC');
SELECT '' AS "66", d1 FROM TIMESTAMP_TBL; SELECT '' AS "64", d1 FROM TIMESTAMP_TBL;
-- Demonstrate functions and operators -- Demonstrate functions and operators
SELECT '' AS "47", d1 FROM TIMESTAMP_TBL SELECT '' AS "48", d1 FROM TIMESTAMP_TBL
WHERE d1 > timestamp '1997-01-02' and d1 != timestamp 'current'; WHERE d1 > timestamp without time zone '1997-01-02';
SELECT '' AS "15", d1 FROM TIMESTAMP_TBL SELECT '' AS "15", d1 FROM TIMESTAMP_TBL
WHERE d1 < timestamp '1997-01-02' and d1 != timestamp 'current'; WHERE d1 < timestamp without time zone '1997-01-02';
SELECT '' AS one, d1 FROM TIMESTAMP_TBL SELECT '' AS one, d1 FROM TIMESTAMP_TBL
WHERE d1 = timestamp '1997-01-02' and d1 != timestamp 'current'; WHERE d1 = timestamp without time zone '1997-01-02';
SELECT '' AS "62", d1 FROM TIMESTAMP_TBL SELECT '' AS "63", d1 FROM TIMESTAMP_TBL
WHERE d1 != timestamp '1997-01-02' and d1 != timestamp 'current'; WHERE d1 != timestamp without time zone '1997-01-02';
SELECT '' AS "16", d1 FROM TIMESTAMP_TBL SELECT '' AS "16", d1 FROM TIMESTAMP_TBL
WHERE d1 <= timestamp '1997-01-02' and d1 != timestamp 'current'; WHERE d1 <= timestamp without time zone '1997-01-02';
SELECT '' AS "48", d1 FROM TIMESTAMP_TBL SELECT '' AS "49", d1 FROM TIMESTAMP_TBL
WHERE d1 >= timestamp '1997-01-02' and d1 != timestamp 'current'; WHERE d1 >= timestamp without time zone '1997-01-02';
SELECT '' AS "66", d1 + interval '1 year' AS one_year FROM TIMESTAMP_TBL; SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
SELECT '' AS "66", d1 - interval '1 year' AS one_year FROM TIMESTAMP_TBL;
SELECT '' AS "53", d1 - timestamp '1997-01-02' AS diff
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'; FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
-- Test casting within a BETWEEN qualifier -- Test casting within a BETWEEN qualifier
SELECT '' AS "53", d1 - timestamp '1997-01-02' AS diff SELECT '' AS "54", d1 - timestamp without time zone '1997-01-02' AS diff
FROM TIMESTAMP_TBL FROM TIMESTAMP_TBL
WHERE d1 BETWEEN timestamp '1902-01-01' AND timestamp '2038-01-01'; WHERE d1 BETWEEN timestamp without time zone '1902-01-01'
AND timestamp without time zone '2038-01-01';
SELECT '' AS "53", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month, SELECT '' AS "54", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour, date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'; FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
SELECT '' AS "53", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec, SELECT '' AS "54", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec date_part( 'usec', d1) AS usec
FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01'; FROM TIMESTAMP_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
-- TO_CHAR() -- TO_CHAR()
--
SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon') SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
FROM TIMESTAMP_TBL; FROM TIMESTAMP_TBL;
...@@ -192,7 +178,7 @@ SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM ...@@ -192,7 +178,7 @@ SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM
SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS') SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
FROM TIMESTAMP_TBL; FROM TIMESTAMP_TBL;
SELECT '' AS to_char_6, to_char(d1, '"HH:MI:SS is" HH:MI:SS "\\"text bettween quote marks\\""') SELECT '' AS to_char_6, to_char(d1, '"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""')
FROM TIMESTAMP_TBL; FROM TIMESTAMP_TBL;
SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS') SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
...@@ -205,7 +191,6 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H ...@@ -205,7 +191,6 @@ SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. H
FROM TIMESTAMP_TBL; FROM TIMESTAMP_TBL;
-- TO_TIMESTAMP() -- TO_TIMESTAMP()
--
SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS'); SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
SELECT '' AS to_timestamp_2, to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS'); SELECT '' AS to_timestamp_2, to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS');
...@@ -217,8 +202,8 @@ SELECT '' AS to_timestamp_4, to_timestamp('My birthday-> Year: 1976, Month: May, ...@@ -217,8 +202,8 @@ SELECT '' AS to_timestamp_4, to_timestamp('My birthday-> Year: 1976, Month: May,
SELECT '' AS to_timestamp_5, to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD'); SELECT '' AS to_timestamp_5, to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD');
SELECT '' AS to_timestamp_6, to_timestamp('15 "text bettween quote marks" 98 54 45', SELECT '' AS to_timestamp_6, to_timestamp('15 "text between quote marks" 98 54 45',
'HH "\\text bettween quote marks\\"" YY MI SS'); 'HH "\\text between quote marks\\"" YY MI SS');
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHHMISSYYYY'); SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHHMISSYYYY');
......
--
-- TIMESTAMPTZ
--
-- needed so tests pass even in Australia
SET australian_timezones = 'off';
CREATE TABLE TIMESTAMPTZ_TBL ( d1 timestamp with time zone);
INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('current');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('today');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('yesterday');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow EST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('tomorrow zulu');
SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'today';
SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'tomorrow';
SELECT count(*) AS One FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'yesterday';
SELECT count(*) AS None FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'now';
DELETE FROM TIMESTAMPTZ_TBL;
-- verify uniform transaction time within transaction block
BEGIN;
INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('now');
SELECT count(*) AS two FROM TIMESTAMPTZ_TBL WHERE d1 = timestamp with time zone 'now';
END;
DELETE FROM TIMESTAMPTZ_TBL;
-- Special values
INSERT INTO TIMESTAMPTZ_TBL VALUES ('-infinity');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('infinity');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('epoch');
-- Obsolete special values
INSERT INTO TIMESTAMPTZ_TBL VALUES ('invalid');
-- Postgres v6.0 standard output format
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01 1997 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Invalid Abstime');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Undefined Abstime');
-- Variations on Postgres v6.1 standard output format
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.000001 1997 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.999999 1997 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.4 1997 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.5 1997 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mon Feb 10 17:32:01.6 1997 PST');
-- ISO 8601 format
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-01-02 03:04:05');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-08');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-0800');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 -08:00');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 -0800');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 17:32:01 -07:00');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('2001-09-22T18:19:20');
-- POSIX format
INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 08:14:01 GMT+8');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 13:14:02 GMT-1');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 12:14:03 GMT -2');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 03:14:04 EST+3');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('2000-03-15 02:14:05 EST +2:00');
-- Variations for acceptable input formats
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997 -0800');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 5:32PM 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997/02/10 17:32:01-0800');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('02-10-1997 17:32:01 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('19970210 173201 PST');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97FEB10 5:32:01PM UTC');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97/02/10 17:32:01 UTC');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('97.041 17:32:01 UTC');
-- Check date conversion and date arithmetic
INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-06-10 18:32:01 PDT');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 10 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 11 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 12 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 13 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 14 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 15 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097 BC');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0097');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 0597');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1097');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1697');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1797');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1897');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 2097');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1996');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1996');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1996');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1996');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1996');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 28 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 29 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Mar 01 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 30 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1997');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 1999');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2000');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Dec 31 17:32:01 2000');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Jan 01 17:32:01 2001');
-- Currently unsupported syntax and ranges
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 -0097');
INSERT INTO TIMESTAMPTZ_TBL VALUES ('Feb 16 17:32:01 5097 BC');
SELECT '' AS "64", d1 FROM TIMESTAMPTZ_TBL;
-- Demonstrate functions and operators
SELECT '' AS "48", d1 FROM TIMESTAMPTZ_TBL
WHERE d1 > timestamp with time zone '1997-01-02';
SELECT '' AS "15", d1 FROM TIMESTAMPTZ_TBL
WHERE d1 < timestamp with time zone '1997-01-02';
SELECT '' AS one, d1 FROM TIMESTAMPTZ_TBL
WHERE d1 = timestamp with time zone '1997-01-02';
SELECT '' AS "63", d1 FROM TIMESTAMPTZ_TBL
WHERE d1 != timestamp with time zone '1997-01-02';
SELECT '' AS "16", d1 FROM TIMESTAMPTZ_TBL
WHERE d1 <= timestamp with time zone '1997-01-02';
SELECT '' AS "49", d1 FROM TIMESTAMPTZ_TBL
WHERE d1 >= timestamp with time zone '1997-01-02';
SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
-- Test casting within a BETWEEN qualifier
SELECT '' AS "54", d1 - timestamp with time zone '1997-01-02' AS diff
FROM TIMESTAMPTZ_TBL
WHERE d1 BETWEEN timestamp with time zone '1902-01-01' AND timestamp with time zone '2038-01-01';
SELECT '' AS "54", date_part( 'year', d1) AS year, date_part( 'month', d1) AS month,
date_part( 'day', d1) AS day, date_part( 'hour', d1) AS hour,
date_part( 'minute', d1) AS minute, date_part( 'second', d1) AS second
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
SELECT '' AS "54", date_part( 'quarter', d1) AS quarter, date_part( 'msec', d1) AS msec,
date_part( 'usec', d1) AS usec
FROM TIMESTAMPTZ_TBL WHERE d1 BETWEEN '1902-01-01' AND '2038-01-01';
-- TO_CHAR()
SELECT '' AS to_char_1, to_char(d1, 'DAY Day day DY Dy dy MONTH Month month RM MON Mon mon')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_2, to_char(d1, 'FMDAY FMDay FMday FMMONTH FMMonth FMmonth FMRM')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_3, to_char(d1, 'Y,YYY YYYY YYY YY Y CC Q MM WW DDD DD D J')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_4, to_char(d1, 'FMY,YYY FMYYYY FMYYY FMYY FMY FMCC FMQ FMMM FMWW FMDDD FMDD FMD FMJ')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_5, to_char(d1, 'HH HH12 HH24 MI SS SSSS')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_6, to_char(d1, '"HH:MI:SS is" HH:MI:SS "\\"text between quote marks\\""')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_7, to_char(d1, 'HH24--text--MI--text--SS')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_8, to_char(d1, 'YYYYTH YYYYth Jth')
FROM TIMESTAMPTZ_TBL;
SELECT '' AS to_char_9, to_char(d1, 'YYYY A.D. YYYY a.d. YYYY bc HH:MI:SS P.M. HH:MI:SS p.m. HH:MI:SS pm')
FROM TIMESTAMPTZ_TBL;
-- TO_TIMESTAMP()
SELECT '' AS to_timestamp_1, to_timestamp('0097/Feb/16 --> 08:14:30', 'YYYY/Mon/DD --> HH:MI:SS');
SELECT '' AS to_timestamp_2, to_timestamp('97/2/16 8:14:30', 'FMYYYY/FMMM/FMDD FMHH:FMMI:FMSS');
SELECT '' AS to_timestamp_3, to_timestamp('1985 January 12', 'YYYY FMMonth DD');
SELECT '' AS to_timestamp_4, to_timestamp('My birthday-> Year: 1976, Month: May, Day: 16',
'"My birthday-> Year" YYYY, "Month:" FMMonth, "Day:" DD');
SELECT '' AS to_timestamp_5, to_timestamp('1,582nd VIII 21', 'Y,YYYth FMRM DD');
SELECT '' AS to_timestamp_6, to_timestamp('15 "text between quote marks" 98 54 45',
'HH "\\text between quote marks\\"" YY MI SS');
SELECT '' AS to_timestamp_7, to_timestamp('05121445482000', 'MMDDHHMISSYYYY');
SELECT '' AS to_timestamp_8, to_timestamp('2000January09Sunday', 'YYYYFMMonthDDFMDay');
SELECT '' AS to_timestamp_9, to_timestamp('97/Feb/16', 'YYMonDD');
SELECT '' AS to_timestamp_10, to_timestamp('19971116', 'YYYYMMDD');
SELECT '' AS to_timestamp_11, to_timestamp('20000-1116', 'YYYY-MMDD');
SELECT '' AS to_timestamp_12, to_timestamp('9-1116', 'Y-MMDD');
SELECT '' AS to_timestamp_13, to_timestamp('95-1116', 'YY-MMDD');
SELECT '' AS to_timestamp_14, to_timestamp('995-1116', 'YYY-MMDD');
SET DateStyle TO DEFAULT;
--
-- TIMETZ
--
CREATE TABLE TIMETZ_TBL (f1 time with time zone);
INSERT INTO TIMETZ_TBL VALUES ('00:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('01:00 PDT');
INSERT INTO TIMETZ_TBL VALUES ('02:03 PDT');
INSERT INTO TIMETZ_TBL VALUES ('07:07 PST');
INSERT INTO TIMETZ_TBL VALUES ('08:08 EDT');
INSERT INTO TIMETZ_TBL VALUES ('11:59 PDT');
INSERT INTO TIMETZ_TBL VALUES ('12:00 PDT');
INSERT INTO TIMETZ_TBL VALUES ('12:01 PDT');
INSERT INTO TIMETZ_TBL VALUES ('23:59 PDT');
INSERT INTO TIMETZ_TBL VALUES ('11:59:59.99 PM PDT');
SELECT f1 AS "Time TZ" FROM TIMETZ_TBL;
SELECT f1 AS "Three" FROM TIMETZ_TBL WHERE f1 < '05:06:07';
SELECT f1 AS "Seven" FROM TIMETZ_TBL WHERE f1 > '05:06:07';
SELECT f1 AS "None" FROM TIMETZ_TBL WHERE f1 < '00:00';
SELECT f1 AS "Ten" FROM TIMETZ_TBL WHERE f1 >= '00:00';
--
-- TIME simple math
--
-- We now make a distinction between time and intervals,
-- and adding two times together makes no sense at all.
-- Leave in one query to show that it is rejected,
-- and do the rest of the testing in horology.sql
-- where we do mixed-type arithmetic. - thomas 2000-12-02
SELECT f1 + time with time zone '00:01' AS "Illegal" FROM TIMETZ_TBL;
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
CREATE TABLE TINTERVAL_TBL (f1 tinterval); CREATE TABLE TINTERVAL_TBL (f1 tinterval);
-- Should accept any abstime,
-- so do not bother with extensive testing of values
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["-infinity" "infinity"]'); VALUES ('["-infinity" "infinity"]');
...@@ -17,7 +20,7 @@ INSERT INTO TINTERVAL_TBL (f1) ...@@ -17,7 +20,7 @@ INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["epoch" "Mon May 1 00:30:30 1995"]'); VALUES ('["epoch" "Mon May 1 00:30:30 1995"]');
INSERT INTO TINTERVAL_TBL (f1) INSERT INTO TINTERVAL_TBL (f1)
VALUES ('["Feb 15 1990 12:15:03" "current"]'); VALUES ('["Feb 15 1990 12:15:03" "2001-09-23 11:12:13"]');
-- badly formatted tintervals -- badly formatted tintervals
...@@ -96,4 +99,3 @@ SELECT '' AS three, t1.f1 ...@@ -96,4 +99,3 @@ SELECT '' AS three, t1.f1
ORDER BY t1.f1; ORDER BY t1.f1;
RESET geqo; RESET geqo;
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