~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1;
1063.9.3 by Brian Aker
Partial fix for tests for tmp
2
CREATE TEMPORARY TABLE t1 (
512 by Brian Aker
Adding back more test cases.
3
visitor_id int DEFAULT '0' NOT NULL,
4
group_id int DEFAULT '0' NOT NULL,
5
hits int DEFAULT '0' NOT NULL,
6
sessions int DEFAULT '0' NOT NULL,
1 by brian
clean slate
7
ts timestamp,
8
PRIMARY KEY (visitor_id,group_id)
9
)/*! engine=MyISAM */;
10
INSERT INTO t1 VALUES (465931136,7,2,2,20000318160952);
11
INSERT INTO t1 VALUES (173865424,2,2,2,20000318233615);
12
INSERT INTO t1 VALUES (173865424,8,2,2,20000318233615);
13
INSERT INTO t1 VALUES (173865424,39,2,2,20000318233615);
14
INSERT INTO t1 VALUES (173865424,7,2,2,20000318233615);
15
INSERT INTO t1 VALUES (173865424,3,2,2,20000318233615);
16
INSERT INTO t1 VALUES (173865424,6,2,2,20000318233615);
17
INSERT INTO t1 VALUES (173865424,60,2,2,20000318233615);
18
INSERT INTO t1 VALUES (173865424,1502,2,2,20000318233615);
19
INSERT INTO t1 VALUES (48985536,2,2,2,20000319013932);
20
INSERT INTO t1 VALUES (48985536,8,2,2,20000319013932);
21
INSERT INTO t1 VALUES (48985536,39,2,2,20000319013932);
22
INSERT INTO t1 VALUES (48985536,7,2,2,20000319013932);
23
INSERT INTO t1 VALUES (465931136,3,2,2,20000318160951);
24
INSERT INTO t1 VALUES (465931136,119,1,1,20000318160953);
25
INSERT INTO t1 VALUES (465931136,2,1,1,20000318160950);
26
INSERT INTO t1 VALUES (465931136,8,1,1,20000318160950);
27
INSERT INTO t1 VALUES (465931136,39,1,1,20000318160950);
28
INSERT INTO t1 VALUES (1092858576,14,1,1,20000319013445);
29
INSERT INTO t1 VALUES (357917728,3,2,2,20000319145026);
30
INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
31
select visitor_id,max(ts) as mts from t1 group by visitor_id
32
having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
33
visitor_id	mts
34
48985536	2000-03-19 01:39:32
35
173865424	2000-03-18 23:36:15
36
357917728	2000-03-19 14:50:27
37
465931136	2000-03-18 16:09:53
38
1092858576	2000-03-19 01:34:45
39
select visitor_id,max(ts) as mts from t1 group by visitor_id
40
having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
41
visitor_id	mts
42
48985536	2000-03-19 01:39:32
43
173865424	2000-03-18 23:36:15
44
357917728	2000-03-19 14:50:27
45
465931136	2000-03-18 16:09:53
46
1092858576	2000-03-19 01:34:45
47
drop table t1;
48
create table t1 (d date);
49
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
50
ERROR 22008: Datetime function: datetime field overflow
51
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
52
ERROR 22008: Datetime function: datetime field overflow
53
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
54
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
55
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
512 by Brian Aker
Adding back more test cases.
56
ERROR 22008: Datetime function: datetime field overflow
1 by brian
clean slate
57
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
512 by Brian Aker
Adding back more test cases.
58
ERROR 22008: Datetime function: datetime field overflow
1 by brian
clean slate
59
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
60
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
61
select * from t1;
62
d
63
NULL
64
NULL
65
NULL
66
NULL
67
drop table t1;
68
End of 4.1 tests
69
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY;
70
CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY
71
2006-09-27
72
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH;
73
CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH
74
2006-10-26
75
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR;
76
CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR
77
2007-09-26
78
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK;
79
CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK
80
2006-10-03
81
create table t1 (a int, b varchar(10));
82
insert into t1 values (1, '2001-01-01'),(2, '2002-02-02');
83
select '2007-01-01' + interval a day from t1;
512 by Brian Aker
Adding back more test cases.
84
'2007-01-01' + interval a day 
1 by brian
clean slate
85
2007-01-02
86
2007-01-03
87
select b + interval a day from t1;
512 by Brian Aker
Adding back more test cases.
88
b + interval a day 
1 by brian
clean slate
89
2001-01-02
90
2002-02-04
91
drop table t1;
92
End of 5.0 tests