~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
DROP TABLE IF EXISTS t1, t2;
2
select format(1.5555,0),format(123.5555,1),format(1234.5555,2),format(12345.55555,3),format(123456.5555,4),format(1234567.5555,5),format("12345.2399",2);
3
format(1.5555,0)	format(123.5555,1)	format(1234.5555,2)	format(12345.55555,3)	format(123456.5555,4)	format(1234567.5555,5)	format("12345.2399",2)
4
2	123.6	1,234.56	12,345.556	123,456.5555	1,234,567.55550	12,345.24
5
select inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"));
6
inet_ntoa(inet_aton("255.255.255.255.255.255.255.255"))
7
NULL
8
select inet_aton("255.255.255.255.255"),inet_aton("255.255.1.255"),inet_aton("0.1.255");
9
inet_aton("255.255.255.255.255")	inet_aton("255.255.1.255")	inet_aton("0.1.255")
10
1099511627775	4294902271	65791
11
select inet_ntoa(1099511627775),inet_ntoa(4294902271),inet_ntoa(511);
12
inet_ntoa(1099511627775)	inet_ntoa(4294902271)	inet_ntoa(511)
13
NULL	255.255.1.255	0.0.1.255
14
select hex(inet_aton('127'));
15
hex(inet_aton('127'))
16
7F
17
select hex(inet_aton('127.1'));
18
hex(inet_aton('127.1'))
19
7F000001
20
select hex(inet_aton('127.1.1'));
21
hex(inet_aton('127.1.1'))
22
7F010001
23
select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8'')));
24
length(uuid())	charset(uuid())	length(unhex(replace(uuid(),_utf8'-',_utf8'')))
25
36	utf8	16
26
select length(format('nan', 2)) > 0;
27
length(format('nan', 2)) > 0
28
1
29
Warnings:
30
Warning	1292	Truncated incorrect DOUBLE value: 'nan'
31
select concat("$",format(2500,2));
32
concat("$",format(2500,2))
33
$2,500.00
34
create table t1 ( a timestamp );
35
insert into t1 values ( '2004-01-06 12:34' );
36
select a from t1 where left(a+0,6) in ( left(20040106,6) );
37
a
38
2004-01-06 12:34:00
39
select a from t1 where left(a+0,6) = ( left(20040106,6) );
40
a
41
2004-01-06 12:34:00
42
select a from t1 where right(a+0,6) in ( right(20040106123400,6) );
43
a
44
2004-01-06 12:34:00
45
select a from t1 where right(a+0,6) = ( right(20040106123400,6) );
46
a
47
2004-01-06 12:34:00
48
select a from t1 where mid(a+0,6,3) in ( mid(20040106123400,6,3) );
49
a
50
2004-01-06 12:34:00
51
select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) );
52
a
53
2004-01-06 12:34:00
54
drop table t1;
55
CREATE TABLE t1 (conn CHAR(7), connection_id INT);
56
INSERT INTO t1 VALUES ('default', CONNECTION_ID());
57
SELECT GET_LOCK('bug16501',600);
58
GET_LOCK('bug16501',600)
59
1
60
INSERT INTO t1 VALUES ('con1', CONNECTION_ID());
61
SELECT IS_USED_LOCK('bug16501') = connection_id
62
FROM t1
63
WHERE conn = 'default';
64
IS_USED_LOCK('bug16501') = connection_id
65
1
66
SELECT GET_LOCK('bug16501',600);
67
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
68
IS_USED_LOCK('bug16501') = CONNECTION_ID()
69
1
70
SELECT RELEASE_LOCK('bug16501');
71
RELEASE_LOCK('bug16501')
72
1
73
GET_LOCK('bug16501',600)
74
1
75
SELECT IS_USED_LOCK('bug16501') = connection_id
76
FROM t1
77
WHERE conn = 'con1';
78
IS_USED_LOCK('bug16501') = connection_id
79
1
80
SELECT IS_USED_LOCK('bug16501') = CONNECTION_ID();
81
IS_USED_LOCK('bug16501') = CONNECTION_ID()
82
1
83
SELECT RELEASE_LOCK('bug16501');
84
RELEASE_LOCK('bug16501')
85
1
86
SELECT IS_USED_LOCK('bug16501');
87
IS_USED_LOCK('bug16501')
88
NULL
89
DROP TABLE t1;
90
select export_set(3, _latin1'foo', _utf8'bar', ',', 4);
91
export_set(3, _latin1'foo', _utf8'bar', ',', 4)
92
foo,foo,bar,bar
93
End of 4.1 tests
94
create table t1 as select uuid(), length(uuid());
95
show create table t1;
96
Table	Create Table
97
t1	CREATE TABLE `t1` (
98
  `uuid()` varchar(36) CHARACTER SET utf8 NOT NULL DEFAULT '',
99
  `length(uuid())` int(10) NOT NULL DEFAULT '0'
100
) ENGINE=MyISAM DEFAULT CHARSET=latin1
101
drop table t1;
102
create table t1 (a timestamp default '2005-05-05 01:01:01',
103
b timestamp default '2005-05-05 01:01:01');
104
insert into t1 set a = now();
105
select sleep(3);
106
sleep(3)
107
0
108
update t1 set b = now();
109
select timediff(b, a) >= '00:00:03' from t1;
110
timediff(b, a) >= '00:00:03'
111
1
112
drop table t1;
113
set global query_cache_size=1355776;
114
create table t1 (a int);
115
insert into t1 values (1),(1),(1);
116
create table t2 (a datetime default null, b datetime default null);
117
insert into t2 set a = now();
118
select a from t1 where sleep(1);
119
a
120
update t2 set b = now() where b is null;
121
insert into t2 set a = now();
122
select a from t1 where sleep(a);
123
a
124
update t2 set b = now() where b is null;
125
insert into t2 set a = now();
126
select a from t1 where sleep(1);
127
a
128
update t2 set b = now() where b is null;
129
select timediff(b, a) >= '00:00:03' from t2;
130
timediff(b, a) >= '00:00:03'
131
1
132
1
133
1
134
drop table t2;
135
drop table t1;
136
set global query_cache_size=default;
137
create table t1 select INET_ATON('255.255.0.1') as `a`;
138
show create table t1;
139
Table	Create Table
140
t1	CREATE TABLE `t1` (
141
  `a` bigint(21) unsigned DEFAULT NULL
142
) ENGINE=MyISAM DEFAULT CHARSET=latin1
143
drop table t1;
144
drop table if exists table_26093;
145
drop function if exists func_26093_a;
146
drop function if exists func_26093_b;
147
create table table_26093(a int);
148
insert into table_26093 values
149
(1), (2), (3), (4), (5),
150
(6), (7), (8), (9), (10);
151
create function func_26093_a(x int) returns int
152
begin
153
set @invoked := @invoked + 1;
154
return x;
155
end//
156
create function func_26093_b(x int, y int) returns int
157
begin
158
set @invoked := @invoked + 1;
159
return x;
160
end//
161
select avg(a) from table_26093;
162
avg(a)
163
5.5000
164
select benchmark(100, (select avg(a) from table_26093));
165
benchmark(100, (select avg(a) from table_26093))
166
0
167
set @invoked := 0;
168
select benchmark(100, (select avg(func_26093_a(a)) from table_26093));
169
benchmark(100, (select avg(func_26093_a(a)) from table_26093))
170
0
171
select @invoked;
172
@invoked
173
10
174
set @invoked := 0;
175
select benchmark(100, (select avg(func_26093_b(a, rand())) from table_26093));
176
benchmark(100, (select avg(func_26093_b(a, rand())) from table_26093))
177
0
178
select @invoked;
179
@invoked
180
1000
181
select benchmark(100, (select (a) from table_26093));
182
ERROR 21000: Subquery returns more than 1 row
183
select benchmark(100, (select 1, 1));
184
ERROR 21000: Operand should contain 1 column(s)
185
drop table table_26093;
186
drop function func_26093_a;
187
drop function func_26093_b;
188
SELECT NAME_CONST('test', NOW());
189
ERROR HY000: Incorrect arguments to NAME_CONST
190
SELECT NAME_CONST('test', UPPER('test'));
191
ERROR HY000: Incorrect arguments to NAME_CONST
192
SELECT NAME_CONST('test', NULL);
193
test
194
NULL
195
SELECT NAME_CONST('test', 1);
196
test
197
1
198
SELECT NAME_CONST('test', -1);
199
test
200
-1
201
SELECT NAME_CONST('test', 1.0);
202
test
203
1.0
204
SELECT NAME_CONST('test', -1.0);
205
test
206
-1.0
207
SELECT NAME_CONST('test', 'test');
208
test
209
test
210
CREATE TABLE t1 (a INT);
211
INSERT INTO t1 VALUES (1),(2),(3);
212
SELECT NAME_CONST('flag',1)    * MAX(a) FROM t1;
213
NAME_CONST('flag',1)    * MAX(a)
214
3
215
SELECT NAME_CONST('flag',1.5)  * MAX(a) FROM t1;
216
NAME_CONST('flag',1.5)  * MAX(a)
217
4.5
218
SELECT NAME_CONST('flag',-1)   * MAX(a) FROM t1;
219
NAME_CONST('flag',-1)   * MAX(a)
220
-3
221
SELECT NAME_CONST('flag',-1.5) * MAX(a) FROM t1;
222
NAME_CONST('flag',-1.5) * MAX(a)
223
-4.5
224
SELECT NAME_CONST('flag', SQRT(4)) * MAX(a) FROM t1;
225
ERROR HY000: Incorrect arguments to NAME_CONST
226
SELECT NAME_CONST('flag',-SQRT(4)) * MAX(a) FROM t1;
227
ERROR HY000: Incorrect arguments to NAME_CONST
228
DROP TABLE t1;
229
CREATE TABLE t1 (a int);
230
INSERT INTO t1 VALUES (5), (2);
231
SELECT NAME_CONST(x,2) FROM (SELECT a x FROM t1) t;
232
ERROR HY000: Incorrect arguments to NAME_CONST
233
DROP TABLE t1;
234
CREATE TABLE t1(a INT);
235
INSERT INTO t1 VALUES (), (), ();
236
SELECT NAME_CONST(a, '1') FROM t1;
237
ERROR HY000: Incorrect arguments to NAME_CONST
238
SET INSERT_ID= NAME_CONST(a, a);
239
ERROR HY000: Incorrect arguments to NAME_CONST
240
DROP TABLE t1;
241
create table t1 (a int not null);
242
insert into t1 values (-1), (-2);
243
select min(a) from t1 group by inet_ntoa(a);
244
min(a)
245
-2
246
drop table t1;
247
SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs;
248
NAME_CONST('var', 'value') COLLATE latin1_general_cs
249
value
250
End of 5.0 tests
251
select connection_id() > 0;
252
connection_id() > 0
253
1
254
End of tests