~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
--disable_warnings
2
drop table if exists t1, test;
3
--enable_warnings
4
5
6
#
7
# time functions
8
#
9
select extract(DAY_MICROSECOND FROM "1999-01-02 10:11:12.000123");
10
select extract(HOUR_MICROSECOND FROM "1999-01-02 10:11:12.000123");
11
select extract(MINUTE_MICROSECOND FROM "1999-01-02 10:11:12.000123");
12
select extract(SECOND_MICROSECOND FROM "1999-01-02 10:11:12.000123");
13
select extract(MICROSECOND FROM "1999-01-02 10:11:12.000123");
14
select date_format("1997-12-31 23:59:59.000002", "%f");
15
16
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000 99:99:99.999999" DAY_MICROSECOND);
17
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99:99.999999" HOUR_MICROSECOND);
18
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000:99.999999" MINUTE_MICROSECOND);
19
select date_add("1997-12-31 23:59:59.000002",INTERVAL "10000.999999" SECOND_MICROSECOND);
20
select date_add("1997-12-31 23:59:59.000002",INTERVAL "999999" MICROSECOND);
21
22
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1 1:1:1.000002" DAY_MICROSECOND);
23
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1:1.000002" HOUR_MICROSECOND);
24
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1:1.000002" MINUTE_MICROSECOND);
25
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "1.000002" SECOND_MICROSECOND);
26
select date_sub("1998-01-01 00:00:00.000001",INTERVAL "000002" MICROSECOND);
27
28
#Date functions
29
select adddate("1997-12-31 23:59:59.000001", 10);
30
select subdate("1997-12-31 23:59:59.000001", 10);
31
32
select datediff("1997-12-31 23:59:59.000001","1997-12-30");
33
select datediff("1997-11-30 23:59:59.000001","1997-12-31");
34
873.1.9 by Jay Pipes
This patch fixes the following functions to properly error out
35
# This will give an error
1731.3.1 by Lee Bieber
change tests to use enum values instead of error numbers
36
--error ER_INVALID_DATETIME_VALUE # Bad datetime
1 by brian
clean slate
37
select datediff("1997-11-31 23:59:59.000001","1997-12-31");
38
select datediff("1997-11-30 23:59:59.000001",null);
39
40
select makedate(03,1);
41
select makedate('0003',1);
42
select makedate(1997,1);
43
select makedate(1997,0);
44
select makedate(9999,365);
45
select makedate(9999,366);
46
select makedate(100,1);
47
48
# Extraction functions
49
50
# PS doesn't support fractional seconds
51
--disable_ps_protocol
52
select timestamp("2001-12-01 01:01:01.000100");
53
select timestamp("2001-12-01");
54
select day("1997-12-31 23:59:59.000001");
55
select date("1997-12-31 23:59:59.000001");
56
select date("1997-13-31 23:59:59.000001");
57
select microsecond("1997-12-31 23:59:59.000001");
58
--enable_ps_protocol
59
60
create table t1 
61
select makedate(1997,1) as f1,
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
62
   date("1997-12-31 23:59:59.000001") as f8;
1 by brian
clean slate
63
describe t1;
64
# PS doesn't support fractional seconds
65
--disable_ps_protocol
66
select * from t1;
67
--enable_ps_protocol
68
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
69
create table test(t1 datetime, t4 datetime);
1 by brian
clean slate
70
insert into test values 
896.5.1 by Jay Pipes
Removes the TIME column type and related time functions.
71
('2001-01-01 01:01:01', '2001-02-01 01:01:01'),
72
('2001-01-01 01:01:01', "1997-12-31 23:59:59.000001"),
73
('1997-12-31 23:59:59.000001', '2001-01-01 01:01:01'),
74
('2001-01-01 01:01:01', null),
75
('2001-01-01 01:01:01', '2001-01-01 01:01:01'),
76
('2001-01-01 01:01:01', null),
77
(null, null),
78
('2001-01-01 01:01:01', '2001-01-01 01:01:01');
1 by brian
clean slate
79
80
drop table t1, test;
81
82
select microsecond("1997-12-31 23:59:59.01") as a;
83
select microsecond(19971231235959.01) as a;
84
select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a;
85
# PS doesn't support fractional seconds
86
87
# End of 4.1 tests