~vcs-imports/mammoth-replicator/trunk

« back to all changes in this revision

Viewing changes to src/test/regress/sql/abstime.sql

  • 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
--
 
8
-- timezones may vary based not only on location but the operating
 
9
-- system.  the main correctness issue is that the OS may not get 
 
10
-- daylight savings time right for times prior to Unix epoch (jan 1 1970).
 
11
--
 
12
 
 
13
CREATE TABLE ABSTIME_TBL (f1 abstime);
 
14
 
 
15
BEGIN;
 
16
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
 
17
INSERT INTO ABSTIME_TBL (f1) VALUES (abstime 'now');
 
18
SELECT count(*) AS two FROM ABSTIME_TBL WHERE f1 = 'now' ;
 
19
END;
 
20
 
 
21
DELETE FROM ABSTIME_TBL;
 
22
 
 
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
 
 
30
-- what happens if we specify slightly misformatted abstime? 
 
31
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 35, 1946 10:00:00');
 
32
INSERT INTO ABSTIME_TBL (f1) VALUES ('Feb 28, 1984 25:08:10');
 
33
 
 
34
-- badly formatted abstimes:  these should result in invalid abstimes 
 
35
INSERT INTO ABSTIME_TBL (f1) VALUES ('bad date format');
 
36
INSERT INTO ABSTIME_TBL (f1) VALUES ('Jun 10, 1843');
 
37
 
 
38
-- test abstime operators
 
39
 
 
40
SELECT '' AS eight, ABSTIME_TBL.*;
 
41
 
 
42
SELECT '' AS six, ABSTIME_TBL.*
 
43
   WHERE ABSTIME_TBL.f1 < abstime 'Jun 30, 2001';
 
44
 
 
45
SELECT '' AS six, ABSTIME_TBL.*
 
46
   WHERE ABSTIME_TBL.f1 > abstime '-infinity';
 
47
 
 
48
SELECT '' AS six, ABSTIME_TBL.*
 
49
   WHERE abstime 'May 10, 1947 23:59:12' <> ABSTIME_TBL.f1;
 
50
 
 
51
SELECT '' AS three, ABSTIME_TBL.*
 
52
   WHERE abstime 'epoch' >= ABSTIME_TBL.f1;
 
53
 
 
54
SELECT '' AS four, ABSTIME_TBL.*
 
55
   WHERE ABSTIME_TBL.f1 <= abstime 'Jan 14, 1973 03:14:21';
 
56
 
 
57
SELECT '' AS four, ABSTIME_TBL.*
 
58
  WHERE ABSTIME_TBL.f1 <?>
 
59
        tinterval '["Apr 1 1950 00:00:00" "Dec 30 1999 23:00:00"]';
 
60
 
 
61
SELECT '' AS four, f1 AS abstime,
 
62
  date_part('year', f1) AS year, date_part('month', f1) AS month,
 
63
  date_part('day',f1) AS day, date_part('hour', f1) AS hour,
 
64
  date_part('minute', f1) AS minute, date_part('second', f1) AS second
 
65
  FROM ABSTIME_TBL
 
66
  WHERE isfinite(f1)
 
67
  ORDER BY abstime;