~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#
# Test of date format functions
#

--disable_warnings
drop table if exists t1;
--enable_warnings

#
# The following tests will work only when we at some point will enable
# dynamic changing of formats
#

# SET date_format='%d.%m.%Y';
# select CAST('01.01.2001' as DATE) as a;
# SET datetime_format='%d.%m.%Y %H.%i.%s';
# select CAST('01.01.2001 05.12.06' as DATETIME) as a;
# SET time_format='%H.%i.%s';
# select CAST('05.12.06' as TIME) as a;
# 
# SET datetime_format='%d.%m.%Y %h:%i:%s %p';
# select CAST('01.01.2001 05:12:06AM' as DATETIME) as a;
# select CAST('01.01.2001 05:12:06 PM' as DATETIME) as a;
# 
# SET time_format='%h:%i:%s %p';
# select CAST('05:12:06 AM' as TIME) as a;
# select CAST('05:12:06.1234PM' as TIME) as a;
# 
# SET time_format='%h.%i.%s %p';
# SET date_format='%d.%m.%y';
# SET datetime_format='%d.%m.%y %h.%i.%s %p';
# select CAST('12-12-06' as DATE) as a;
# 
# select adddate('01.01.97 11.59.59.000001 PM', 10);
# select datediff('31.12.97 11.59:59.000001 PM','01.01.98');
# select weekofyear('31.11.97 11:59:59.000001 PM');
# select makedate(1997,1);
# select addtime('31.12.97 11.59.59.999999 PM', '1 1.1.1.000002');
# select maketime(23,11,12);
# select timediff('01.01.97 11:59:59.000001 PM','31.12.95 11:59:59.000002 PM');
# 
# SET time_format='%i:%s:%H';
# select cast(str_to_date('15-01-2001 12:59:59', '%d-%m-%Y %H:%i:%S') as TIME);

explain extended select makedate(1997,1), microsecond("1997-12-31 23:59:59.000001");

#
# Test of date_format()
#

create table t1 (d date);
insert into t1 values ('2004-07-14'),('2005-07-14');
select date_format(d,"%d") from t1 order by 1;
drop table t1;

#
# Bug #14016 
#
create table t1 (f1 datetime);
insert into t1 (f1) values ("2005-01-01");
insert into t1 (f1) values ("2005-02-01");
select date_format(f1, "%m") as d1, date_format(f1, "%M") as d2 from t1 order by date_format(f1, "%M");
drop table t1;

#
# Bug#11326
# TIME_FORMAT using "%r" returns wrong hour using 24:00:00 in TIME column
#
# This tests that 24:00:00 does not return PM, when it should be AM.
# Some other values are being tested same time.
#

SELECT TIME_FORMAT("24:00:00", '%r');
SELECT TIME_FORMAT("00:00:00", '%r');
SELECT TIME_FORMAT("12:00:00", '%r');
SELECT TIME_FORMAT("15:00:00", '%r');
SELECT TIME_FORMAT("01:00:00", '%r');
SELECT TIME_FORMAT("25:00:00", '%r');

#
# Bug#11324
# TIME_FORMAT using "%l:%i" returns 36:00 with 24:00:00 in TIME column
#
# This tests that 24:00:00 does not change to "36:00 AM". Testing
# some other values same time.
#

SELECT TIME_FORMAT("00:00:00", '%l %p');
SELECT TIME_FORMAT("01:00:00", '%l %p');
SELECT TIME_FORMAT("12:00:00", '%l %p');
SELECT TIME_FORMAT("23:00:00", '%l %p');
SELECT TIME_FORMAT("24:00:00", '%l %p');
SELECT TIME_FORMAT("25:00:00", '%l %p');

#
# Bug#20729:  Bad date_format() call makes mysql server crash
#
SELECT DATE_FORMAT('%Y-%m-%d %H:%i:%s', 1151414896);

--echo "End of 4.1 tests"