~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/expected/abstime.out

  • Committer: alvherre
  • Date: 2005-12-16 21:24:52 UTC
  • Revision ID: svn-v4:db760fc0-0f08-0410-9d63-cc6633f64896:trunk:1
Initial import of the REL8_0_3 sources from the Pgsql CVS repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--
 
2
-- ABSTIME
 
3
-- testing built-in time type abstime
 
4
-- uses reltime and tinterval
 
5
--
 
6
--
 
7
-- timezones may vary based not only on location but the operating
 
8
-- system.  the main correctness issue is that the OS may not get 
 
9
-- daylight savings time right for times prior to Unix epoch (jan 1 1970).
 
10
--
 
11
CREATE TABLE ABSTIME_TBL (f1 abstime);
 
12
BEGIN;
 
13
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
 
14
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
 
15
SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
 
16
 two 
 
17
-----
 
18
   2
 
19
(1 row)
 
20
 
 
21
END;
 
22
DELETE FROM ABSTIME_TBL;
 
23
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jan 14, 1973 03:14:21');
 
24
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'Mon May  1 00:30:30 1995');
 
25
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'epoch');
 
26
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'infinity');
 
27
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime '-infinity');
 
28
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'May 10, 1947 23:59:12');
 
29
-- what happens if we specify slightly misformatted abstime? 
 
30
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
 
31
ERROR:  date/time field value out of range: "Feb 35, 1946 10:00:00"
 
32
HINT:  Perhaps you need a different "datestyle" setting.
 
33
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
 
34
ERROR:  date/time field value out of range: "Feb 28, 1984 25:08:10"
 
35
-- badly formatted abstimes:  these should result in invalid abstimes 
 
36
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
 
37
ERROR:  invalid input syntax for type abstime: "bad date format"
 
38
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
 
39
-- test abstime operators
 
40
SELECT '' AS eight, ABSTIME_TBL.*;
 
41
 eight |              f1              
 
42
-------+------------------------------
 
43
       | Sun Jan 14 03:14:21 1973 PST
 
44
       | Mon May 01 00:30:30 1995 PDT
 
45
       | Wed Dec 31 16:00:00 1969 PST
 
46
       | infinity
 
47
       | -infinity
 
48
       | Sat May 10 23:59:12 1947 PST
 
49
       | invalid
 
50
(7 rows)
 
51
 
 
52
SELECT '' AS six, ABSTIME_TBL.*
 
53
   WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
 
54
 six |              f1              
 
55
-----+------------------------------
 
56
     | Sun Jan 14 03:14:21 1973 PST
 
57
     | Mon May 01 00:30:30 1995 PDT
 
58
     | Wed Dec 31 16:00:00 1969 PST
 
59
     | -infinity
 
60
     | Sat May 10 23:59:12 1947 PST
 
61
(5 rows)
 
62
 
 
63
SELECT '' AS six, ABSTIME_TBL.*
 
64
   WHERE ABSTIME_TBL.f1 > abstime '-infinity';
 
65
 six |              f1              
 
66
-----+------------------------------
 
67
     | Sun Jan 14 03:14:21 1973 PST
 
68
     | Mon May 01 00:30:30 1995 PDT
 
69
     | Wed Dec 31 16:00:00 1969 PST
 
70
     | infinity
 
71
     | Sat May 10 23:59:12 1947 PST
 
72
     | invalid
 
73
(6 rows)
 
74
 
 
75
SELECT '' AS six, ABSTIME_TBL.*
 
76
   WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
 
77
 six |              f1              
 
78
-----+------------------------------
 
79
     | Sun Jan 14 03:14:21 1973 PST
 
80
     | Mon May 01 00:30:30 1995 PDT
 
81
     | Wed Dec 31 16:00:00 1969 PST
 
82
     | infinity
 
83
     | -infinity
 
84
     | invalid
 
85
(6 rows)
 
86
 
 
87
SELECT '' AS three, ABSTIME_TBL.*
 
88
   WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
 
89
 three |              f1              
 
90
-------+------------------------------
 
91
       | Wed Dec 31 16:00:00 1969 PST
 
92
       | -infinity
 
93
       | Sat May 10 23:59:12 1947 PST
 
94
(3 rows)
 
95
 
 
96
SELECT '' AS four, ABSTIME_TBL.*
 
97
   WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
 
98
 four |              f1              
 
99
------+------------------------------
 
100
      | Sun Jan 14 03:14:21 1973 PST
 
101
      | Wed Dec 31 16:00:00 1969 PST
 
102
      | -infinity
 
103
      | Sat May 10 23:59:12 1947 PST
 
104
(4 rows)
 
105
 
 
106
SELECT '' AS four, ABSTIME_TBL.*
 
107
  WHERE ABSTIME_TBL.f1 <?>
 
108
        tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
 
109
 four |              f1              
 
110
------+------------------------------
 
111
      | Sun Jan 14 03:14:21 1973 PST
 
112
      | Mon May 01 00:30:30 1995 PDT
 
113
      | Wed Dec 31 16:00:00 1969 PST
 
114
(3 rows)
 
115
 
 
116
SELECT '' AS four, f1 AS abstime,
 
117
  date_part('year', f1) AS year, date_part('month', f1) AS month,
 
118
  date_part('day',f1) AS day, date_part('hour', f1) AS hour,
 
119
  date_part('minute', f1) AS minute, date_part('second', f1) AS second
 
120
  FROM ABSTIME_TBL
 
121
  WHERE isfinite(f1)
 
122
  ORDER BY abstime;
 
123
 four |           abstime            | year | month | day | hour | minute | second 
 
124
------+------------------------------+------+-------+-----+------+--------+--------
 
125
      | Sat May 10 23:59:12 1947 PST | 1947 |     5 |  10 |   23 |     59 |     12
 
126
      | Wed Dec 31 16:00:00 1969 PST | 1969 |    12 |  31 |   16 |      0 |      0
 
127
      | Sun Jan 14 03:14:21 1973 PST | 1973 |     1 |  14 |    3 |     14 |     21
 
128
      | Mon May 01 00:30:30 1995 PDT | 1995 |     5 |   1 |    0 |     30 |     30
 
129
(4 rows)
 
130