~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/t/func_date_add.test

  • Committer: Mark Atwood
  • Date: 2008-10-03 01:39:40 UTC
  • mto: This revision was merged to the branch mainline in revision 437.
  • Revision ID: mark@fallenpegasus.com-20081003013940-mvefjo725dltz41h
rename logging_noop to logging_query

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# Test of DATE_ADD
3
 
#
4
 
 
5
 
--disable_warnings
6
 
drop table if exists t1;
7
 
--enable_warnings
8
 
 
9
 
CREATE TEMPORARY TABLE t1 (
10
 
  visitor_id int DEFAULT '0' NOT NULL,
11
 
  group_id int DEFAULT '0' NOT NULL,
12
 
  hits int DEFAULT '0' NOT NULL,
13
 
  sessions int DEFAULT '0' NOT NULL,
14
 
  ts timestamp,
15
 
  PRIMARY KEY (visitor_id,group_id)
16
 
)/*! engine=MyISAM */;
17
 
INSERT INTO t1 VALUES (465931136,7,2,2,20000318160952);
18
 
INSERT INTO t1 VALUES (173865424,2,2,2,20000318233615);
19
 
INSERT INTO t1 VALUES (173865424,8,2,2,20000318233615);
20
 
INSERT INTO t1 VALUES (173865424,39,2,2,20000318233615);
21
 
INSERT INTO t1 VALUES (173865424,7,2,2,20000318233615);
22
 
INSERT INTO t1 VALUES (173865424,3,2,2,20000318233615);
23
 
INSERT INTO t1 VALUES (173865424,6,2,2,20000318233615);
24
 
INSERT INTO t1 VALUES (173865424,60,2,2,20000318233615);
25
 
INSERT INTO t1 VALUES (173865424,1502,2,2,20000318233615);
26
 
INSERT INTO t1 VALUES (48985536,2,2,2,20000319013932);
27
 
INSERT INTO t1 VALUES (48985536,8,2,2,20000319013932);
28
 
INSERT INTO t1 VALUES (48985536,39,2,2,20000319013932);
29
 
INSERT INTO t1 VALUES (48985536,7,2,2,20000319013932);
30
 
INSERT INTO t1 VALUES (465931136,3,2,2,20000318160951);
31
 
INSERT INTO t1 VALUES (465931136,119,1,1,20000318160953);
32
 
INSERT INTO t1 VALUES (465931136,2,1,1,20000318160950);
33
 
INSERT INTO t1 VALUES (465931136,8,1,1,20000318160950);
34
 
INSERT INTO t1 VALUES (465931136,39,1,1,20000318160950);
35
 
INSERT INTO t1 VALUES (1092858576,14,1,1,20000319013445);
36
 
INSERT INTO t1 VALUES (357917728,3,2,2,20000319145026);
37
 
INSERT INTO t1 VALUES (357917728,7,2,2,20000319145027);
38
 
select visitor_id,max(ts) as mts from t1 group by visitor_id
39
 
having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH);
40
 
select visitor_id,max(ts) as mts from t1 group by visitor_id
41
 
having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW();
42
 
drop table t1;
43
 
 
44
 
#
45
 
# Bug #10627: Invalid date turned to NULL from date_sub/date_add in
46
 
# traditional mode
47
 
#
48
 
create table t1 (d date);
49
 
--error S22008
50
 
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
51
 
--error S22008
52
 
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
53
 
# No warnings/errors from the next two
54
 
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
55
 
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
56
 
# These will all work now, and we'll end up with some NULL entries in the
57
 
# table and some warnings.
58
 
--error ER_DATETIME_FUNCTION_OVERFLOW
59
 
insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR);
60
 
--error ER_DATETIME_FUNCTION_OVERFLOW
61
 
insert into t1 (d) select date_add('2000-01-01',interval 8000 year);
62
 
insert into t1 values (date_add(NULL, INTERVAL 1 DAY));
63
 
insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY));
64
 
select * from t1;
65
 
drop table t1;
66
 
 
67
 
--echo End of 4.1 tests
68
 
 
69
 
#
70
 
# Bug#21811
71
 
#
72
 
# Make sure we end up with an appropriate
73
 
# date format (DATE) after addition operation
74
 
#
75
 
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 DAY;
76
 
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH;
77
 
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR;
78
 
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK;
79
 
 
80
 
#
81
 
# Bug#28450: The Item_date_add_interval in select list may fail the field 
82
 
#            type assertion.
83
 
#
84
 
create table t1 (a int, b varchar(10));
85
 
insert into t1 values (1, '2001-01-01'),(2, '2002-02-02'); 
86
 
select '2007-01-01' + interval a day from t1;
87
 
select b + interval a day from t1;
88
 
drop table t1;
89
 
 
90
 
--echo End of 5.0 tests