~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
select cast("A" as binary) = "a", cast(BINARY "a" as CHAR) = "A";
2
cast("A" as binary) = "a"	cast(BINARY "a" as CHAR) = "A"
1217 by Brian Aker
Removed bits of charset support from the parser.
3
0	0
1 by brian
clean slate
4
select cast("2001-1-1" as DATE), cast("2001-1-1" as DATETIME);
5
cast("2001-1-1" as DATE)	cast("2001-1-1" as DATETIME)
6
2001-01-01	2001-01-01 00:00:00
7
select CONVERT("2004-01-22 21:45:33",DATE);
8
CONVERT("2004-01-22 21:45:33",DATE)
9
2004-01-22
10
select 10+'10';
11
10+'10'
12
20
13
select 10.0+'10';
14
10.0+'10'
15
20
16
select 10E+0+'10';
17
10E+0+'10'
18
20
19
select CONVERT(DATE "2004-01-22 21:45:33",CHAR);
20
CONVERT(DATE "2004-01-22 21:45:33",CHAR)
21
2004-01-22 21:45:33
22
select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4));
23
CONVERT(DATE "2004-01-22 21:45:33",CHAR(4))
24
2004
25
Warnings:
26
Warning	1292	Truncated incorrect CHAR(4) value: '2004-01-22 21:45:33'
27
select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4));
28
CONVERT(DATE "2004-01-22 21:45:33",BINARY(4))
29
2004
30
Warnings:
31
Warning	1292	Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
32
select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4));
33
CAST(DATE "2004-01-22 21:45:33" AS BINARY(4))
34
2004
35
Warnings:
36
Warning	1292	Truncated incorrect BINARY(4) value: '2004-01-22 21:45:33'
37
select 10+'a';
38
10+'a'
39
10
40
Warnings:
41
Warning	1292	Truncated incorrect DOUBLE value: 'a'
42
select 10.0+cast('a' as decimal);
43
10.0+cast('a' as decimal)
44
10.0
45
Warnings:
46
Warning	1292	Truncated incorrect DECIMAL value: 'a'
47
select 10E+0+'a';
48
10E+0+'a'
49
10
50
Warnings:
51
Warning	1292	Truncated incorrect DOUBLE value: 'a'
52
select
685.2.5 by Monty Taylor
Fixed up the cast test.
53
cast('ab'  AS char)    as c1,
54
cast('a '  AS char)    as c2,
55
cast('abc' AS char(2)) as c3,
56
cast('a  ' AS char(2)) as c4,
57
hex(cast('a'   AS char(2))) as c5;
1 by brian
clean slate
58
c1	c2	c3	c4	c5
685.2.5 by Monty Taylor
Fixed up the cast test.
59
ab	a 	ab	a 	61
1 by brian
clean slate
60
Warnings:
685.2.5 by Monty Taylor
Fixed up the cast test.
61
Warning	1292	Truncated incorrect CHAR(2) value: 'abc'
62
Warning	1292	Truncated incorrect CHAR(2) value: 'a  '
1 by brian
clean slate
63
select cast(1000 as CHAR(3));
64
cast(1000 as CHAR(3))
65
100
66
Warnings:
685.2.5 by Monty Taylor
Fixed up the cast test.
67
Warning	1292	Truncated incorrect CHAR(3) value: '1000'
1 by brian
clean slate
68
create table t1 select
685.2.5 by Monty Taylor
Fixed up the cast test.
69
cast('ab'  AS char)    as c1,
70
cast('a '  AS char)    as c2,
71
cast('abc' AS char(2)) as c3,
72
cast('a  ' AS char(2)) as c4,
73
cast('a'   AS char(2)) as c5;
74
ERROR 22007: Truncated incorrect CHAR(2) value: 'abc'
1 by brian
clean slate
75
select cast("2001-1-1" as date) = "2001-01-01";
76
cast("2001-1-1" as date) = "2001-01-01"
77
1
78
select cast("2001-1-1" as datetime) = "2001-01-01 00:00:00";
79
cast("2001-1-1" as datetime) = "2001-01-01 00:00:00"
80
1
81
select cast(NULL as DATE);
82
cast(NULL as DATE)
83
NULL
84
select cast(NULL as BINARY);
85
cast(NULL as BINARY)
86
NULL
87
CREATE TABLE t1 (a enum ('aac','aab','aaa') not null);
88
INSERT INTO t1 VALUES ('aaa'),('aab'),('aac');
89
SELECT a, CAST(a AS CHAR(3)) FROM t1 ORDER BY CAST(a AS CHAR(2)), a;
90
a	CAST(a AS CHAR(3))
91
aac	aac
92
aab	aab
93
aaa	aaa
94
Warnings:
685.2.5 by Monty Taylor
Fixed up the cast test.
95
Warning	1292	Truncated incorrect CHAR(2) value: 'aaa'
96
Warning	1292	Truncated incorrect CHAR(2) value: 'aab'
97
Warning	1292	Truncated incorrect CHAR(2) value: 'aac'
1 by brian
clean slate
98
SELECT a, CAST(a AS CHAR(2)) FROM t1 ORDER BY CAST(a AS CHAR(3)), a;
99
a	CAST(a AS CHAR(2))
100
aaa	aa
101
aab	aa
102
aac	aa
103
Warnings:
685.2.5 by Monty Taylor
Fixed up the cast test.
104
Warning	1292	Truncated incorrect CHAR(2) value: 'aaa'
105
Warning	1292	Truncated incorrect CHAR(2) value: 'aab'
106
Warning	1292	Truncated incorrect CHAR(2) value: 'aac'
1 by brian
clean slate
107
DROP TABLE t1;
108
select date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour);
109
date_add(cast('2004-12-30 12:00:00' as date), interval 0 hour)
110
2004-12-30 00:00:00
111
select isnull(date(NULL)), isnull(cast(NULL as DATE));
112
isnull(date(NULL))	isnull(cast(NULL as DATE))
113
1	1
114
select cast('1.2' as decimal(3,2));
115
cast('1.2' as decimal(3,2))
116
1.20
117
select 1e18 * cast('1.2' as decimal(3,2));
118
1e18 * cast('1.2' as decimal(3,2))
119
1.2e18
120
set @v1=1e18;
121
select cast(@v1 as decimal(22, 2));
122
cast(@v1 as decimal(22, 2))
123
1000000000000000000.00
124
select cast(-1e18 as decimal(22,2));
125
cast(-1e18 as decimal(22,2))
126
-1000000000000000000.00
127
CREATE TABLE t1 (v varchar(10), tt tinytext, t text,
128
mt mediumtext, lt longtext);
129
INSERT INTO t1 VALUES ('1.01', '2.02', '3.03', '4.04', '5.05');
130
SELECT CAST(v AS DECIMAL), CAST(tt AS DECIMAL), CAST(t AS DECIMAL),
131
CAST(mt AS DECIMAL), CAST(lt AS DECIMAL) from t1;
132
CAST(v AS DECIMAL)	CAST(tt AS DECIMAL)	CAST(t AS DECIMAL)	CAST(mt AS DECIMAL)	CAST(lt AS DECIMAL)
133
1	2	3	4	5
134
DROP TABLE t1;
135
select cast(NULL as decimal(6)) as t1;
136
t1
137
NULL
138
select hex(cast('a' as binary(2)));
139
hex(cast('a' as binary(2)))
140
6100
141
CREATE TABLE t1 (f1 DATE);
142
INSERT INTO t1 VALUES ('2007-07-19'), (NULL);
143
SELECT HOUR(f1),
144
MINUTE(f1),
145
SECOND(f1) FROM t1;
146
HOUR(f1)	MINUTE(f1)	SECOND(f1)
147
0	0	0
148
NULL	NULL	NULL
149
SELECT HOUR(CAST('2007-07-19' AS DATE)),
150
MINUTE(CAST('2007-07-19' AS DATE)),
151
SECOND(CAST('2007-07-19' AS DATE));
152
HOUR(CAST('2007-07-19' AS DATE))	MINUTE(CAST('2007-07-19' AS DATE))	SECOND(CAST('2007-07-19' AS DATE))
153
0	0	0
154
SELECT HOUR(CAST(NULL AS DATE)),
155
MINUTE(CAST(NULL AS DATE)),
156
SECOND(CAST(NULL AS DATE));
157
HOUR(CAST(NULL AS DATE))	MINUTE(CAST(NULL AS DATE))	SECOND(CAST(NULL AS DATE))
158
NULL	NULL	NULL
159
SELECT HOUR(NULL),
160
MINUTE(NULL),
161
SECOND(NULL);
162
HOUR(NULL)	MINUTE(NULL)	SECOND(NULL)
163
NULL	NULL	NULL
164
DROP TABLE t1;
165
End of 5.0 tests