~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
drop table if exists t1,t2;
2
set names latin1;
3
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
4
hello	'hello'	""hello""	'h'e'l'l'o'	hel"lo	hel'lo
5
hello	'hello'	""hello""	'h'e'l'l'o'	hel"lo	hel'lo
6
select 'hello' 'monty';
7
hello
8
hellomonty
9
select length('\n\t\r\b\0\_\%\\');
10
length('\n\t\r\b\0\_\%\\')
11
10
12
select bit_length('\n\t\r\b\0\_\%\\');
13
bit_length('\n\t\r\b\0\_\%\\')
14
80
15
select char_length('\n\t\r\b\0\_\%\\');
16
char_length('\n\t\r\b\0\_\%\\')
17
10
18
select length(_latin1'\n\t\n\b\0\\_\\%\\');
19
length(_latin1'\n\t\n\b\0\\_\\%\\')
20
10
21
select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
22
concat('monty',' was here ','again')	length('hello')	char(ascii('h'))	ord('h')
23
monty was here again	5	h	104
24
select hex(char(256));
25
hex(char(256))
26
0100
27
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
28
locate('he','hello')	locate('he','hello',2)	locate('lo','hello',2)
29
1	0	4
30
select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE');
31
instr('hello','HE')	instr('hello',binary 'HE')	instr(binary 'hello','HE')
32
1	0	0
33
select position(binary 'll' in 'hello'),position('a' in binary 'hello');
34
position(binary 'll' in 'hello')	position('a' in binary 'hello')
35
3	0
36
select left('hello',null), right('hello',null);
37
left('hello',null)	right('hello',null)
38
NULL	NULL
39
select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ;
40
left('hello',2)	right('hello',2)	substring('hello',2,2)	mid('hello',1,5)
41
he	lo	el	hello
42
select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ;
43
concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1))
44
happy
45
select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1);
46
substring_index('www.tcx.se','.',-2)	substring_index('www.tcx.se','.',1)
47
tcx.se	www
48
select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1);
49
substring_index('www.tcx.se','tcx',1)	substring_index('www.tcx.se','tcx',-1)
50
www.	.se
51
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
52
substring_index('.tcx.se','.',-2)	substring_index('.tcx.se','.tcx',-1)
53
tcx.se	.se
54
select substring_index('aaaaaaaaa1','a',1);
55
substring_index('aaaaaaaaa1','a',1)
56
57
select substring_index('aaaaaaaaa1','aa',1);
58
substring_index('aaaaaaaaa1','aa',1)
59
60
select substring_index('aaaaaaaaa1','aa',2);
61
substring_index('aaaaaaaaa1','aa',2)
62
aa
63
select substring_index('aaaaaaaaa1','aa',3);
64
substring_index('aaaaaaaaa1','aa',3)
65
aaaa
66
select substring_index('aaaaaaaaa1','aa',4);
67
substring_index('aaaaaaaaa1','aa',4)
68
aaaaaa
69
select substring_index('aaaaaaaaa1','aa',5);
70
substring_index('aaaaaaaaa1','aa',5)
71
aaaaaaaaa1
72
select substring_index('aaaaaaaaa1','aaa',1);
73
substring_index('aaaaaaaaa1','aaa',1)
74
75
select substring_index('aaaaaaaaa1','aaa',2);
76
substring_index('aaaaaaaaa1','aaa',2)
77
aaa
78
select substring_index('aaaaaaaaa1','aaa',3);
79
substring_index('aaaaaaaaa1','aaa',3)
80
aaaaaa
81
select substring_index('aaaaaaaaa1','aaa',4);
82
substring_index('aaaaaaaaa1','aaa',4)
83
aaaaaaaaa1
84
select substring_index('aaaaaaaaa1','aaaa',1);
85
substring_index('aaaaaaaaa1','aaaa',1)
86
87
select substring_index('aaaaaaaaa1','aaaa',2);
88
substring_index('aaaaaaaaa1','aaaa',2)
89
aaaa
90
select substring_index('aaaaaaaaa1','1',1);
91
substring_index('aaaaaaaaa1','1',1)
92
aaaaaaaaa
93
select substring_index('aaaaaaaaa1','a',-1);
94
substring_index('aaaaaaaaa1','a',-1)
95
1
96
select substring_index('aaaaaaaaa1','aa',-1);
97
substring_index('aaaaaaaaa1','aa',-1)
98
1
99
select substring_index('aaaaaaaaa1','aa',-2);
100
substring_index('aaaaaaaaa1','aa',-2)
101
aa1
102
select substring_index('aaaaaaaaa1','aa',-3);
103
substring_index('aaaaaaaaa1','aa',-3)
104
aaaa1
105
select substring_index('aaaaaaaaa1','aa',-4);
106
substring_index('aaaaaaaaa1','aa',-4)
107
aaaaaa1
108
select substring_index('aaaaaaaaa1','aa',-5);
109
substring_index('aaaaaaaaa1','aa',-5)
110
aaaaaaaaa1
111
select substring_index('aaaaaaaaa1','aaa',-1);
112
substring_index('aaaaaaaaa1','aaa',-1)
113
1
114
select substring_index('aaaaaaaaa1','aaa',-2);
115
substring_index('aaaaaaaaa1','aaa',-2)
116
aaa1
117
select substring_index('aaaaaaaaa1','aaa',-3);
118
substring_index('aaaaaaaaa1','aaa',-3)
119
aaaaaa1
120
select substring_index('aaaaaaaaa1','aaa',-4);
121
substring_index('aaaaaaaaa1','aaa',-4)
122
123
select substring_index('the king of thethe hill','the',-2);
124
substring_index('the king of thethe hill','the',-2)
125
the hill
126
select substring_index('the king of the the hill','the',-2);
127
substring_index('the king of the the hill','the',-2)
128
 the hill
129
select substring_index('the king of the  the hill','the',-2);
130
substring_index('the king of the  the hill','the',-2)
131
  the hill
132
select substring_index('the king of the  the hill',' the ',-1);
133
substring_index('the king of the  the hill',' the ',-1)
134
hill
135
select substring_index('the king of the  the hill',' the ',-2);
136
substring_index('the king of the  the hill',' the ',-2)
137
 the hill
138
select substring_index('the king of the  the hill',' ',-1);
139
substring_index('the king of the  the hill',' ',-1)
140
hill
141
select substring_index('the king of the  the hill',' ',-2);
142
substring_index('the king of the  the hill',' ',-2)
143
the hill
144
select substring_index('the king of the  the hill',' ',-3);
145
substring_index('the king of the  the hill',' ',-3)
146
 the hill
147
select substring_index('the king of the  the hill',' ',-4);
148
substring_index('the king of the  the hill',' ',-4)
149
the  the hill
150
select substring_index('the king of the  the hill',' ',-5);
151
substring_index('the king of the  the hill',' ',-5)
152
of the  the hill
153
select substring_index('the king of the.the hill','the',-2);
154
substring_index('the king of the.the hill','the',-2)
155
.the hill
156
select substring_index('the king of thethethe.the hill','the',-3);
157
substring_index('the king of thethethe.the hill','the',-3)
158
the.the hill
159
select substring_index('the king of thethethe.the hill','the',-1);
160
substring_index('the king of thethethe.the hill','the',-1)
161
 hill
162
select substring_index('the king of the the hill','the',1);
163
substring_index('the king of the the hill','the',1)
164
165
select substring_index('the king of the the hill','the',2);
166
substring_index('the king of the the hill','the',2)
167
the king of 
168
select substring_index('the king of the the hill','the',3);
169
substring_index('the king of the the hill','the',3)
170
the king of the 
171
select concat(':',ltrim('  left  '),':',rtrim('  right  '),':');
172
concat(':',ltrim('  left  '),':',rtrim('  right  '),':')
173
:left  :  right:
174
select concat(':',trim(leading from '  left  '),':',trim(trailing from '  right  '),':');
175
concat(':',trim(leading from '  left  '),':',trim(trailing from '  right  '),':')
176
:left  :  right:
177
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
178
concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':')
179
:left: right:
180
select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':');
181
concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':')
182
:m:y:s:
183
select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':');
184
concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':')
185
:my:sql:
186
select concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':');
187
concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':')
188
:my:sql:
189
select TRIM("foo" FROM "foo"), TRIM("foo" FROM "foook"), TRIM("foo" FROM "okfoo");
190
TRIM("foo" FROM "foo")	TRIM("foo" FROM "foook")	TRIM("foo" FROM "okfoo")
191
	ok	ok
192
select concat_ws(', ','monty','was here','again');
193
concat_ws(', ','monty','was here','again')
194
monty, was here, again
195
select concat_ws(NULL,'a'),concat_ws(',',NULL,'');
196
concat_ws(NULL,'a')	concat_ws(',',NULL,'')
197
NULL	
198
select concat_ws(',','',NULL,'a');
199
concat_ws(',','',NULL,'a')
200
,a
201
SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"');
202
CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"')
203
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
204
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
205
insert('txs',2,1,'hi')	insert('is ',4,0,'a')	insert('txxxxt',2,4,'es')
206
this	is a	test
207
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
208
replace('aaaa','a','b')	replace('aaaa','aa','b')	replace('aaaa','a','bb')	replace('aaaa','','b')	replace('bbbb','a','c')
209
bbbb	bb	bbbbbbbb	aaaa	bbbb
210
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
211
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
212
this is a REAL test
213
select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
214
soundex('')	soundex('he')	soundex('hello all folks')	soundex('#3556 in bugdb')
215
	H000	H4142	I51231
216
select 'mood' sounds like 'mud';
217
'mood' sounds like 'mud'
218
1
219
select 'Glazgo' sounds like 'Liverpool';
220
'Glazgo' sounds like 'Liverpool'
221
0
222
select null sounds like 'null';
223
null sounds like 'null'
224
NULL
225
select 'null' sounds like null;
226
'null' sounds like null
227
NULL
228
select null sounds like null;
229
null sounds like null
230
NULL
231
select md5('hello');
232
md5('hello')
233
5d41402abc4b2a76b9719d911017c592
234
select crc32("123");
235
crc32("123")
236
2286445522
237
select sha('abc');
238
sha('abc')
239
a9993e364706816aba3e25717850c26c9cd0d89d
240
select sha1('abc');
241
sha1('abc')
242
a9993e364706816aba3e25717850c26c9cd0d89d
243
select aes_decrypt(aes_encrypt('abc','1'),'1');
244
aes_decrypt(aes_encrypt('abc','1'),'1')
245
abc
246
select aes_decrypt(aes_encrypt('abc','1'),1);
247
aes_decrypt(aes_encrypt('abc','1'),1)
248
abc
249
select aes_encrypt(NULL,"a");
250
aes_encrypt(NULL,"a")
251
NULL
252
select aes_encrypt("a",NULL);
253
aes_encrypt("a",NULL)
254
NULL
255
select aes_decrypt(NULL,"a");
256
aes_decrypt(NULL,"a")
257
NULL
258
select aes_decrypt("a",NULL);
259
aes_decrypt("a",NULL)
260
NULL
261
select aes_decrypt("a","a");
262
aes_decrypt("a","a")
263
NULL
264
select aes_decrypt(aes_encrypt("","a"),"a");
265
aes_decrypt(aes_encrypt("","a"),"a")
266
267
select repeat('monty',5),concat('*',space(5),'*');
268
repeat('monty',5)	concat('*',space(5),'*')
269
montymontymontymontymonty	*     *
270
select reverse('abc'),reverse('abcd');
271
reverse('abc')	reverse('abcd')
272
cba	dcba
273
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
274
rpad('a',4,'1')	rpad('a',4,'12')	rpad('abcd',3,'12')	rpad(11, 10 , 22)	rpad("ab", 10, 22)
275
a111	a121	abc	1122222222	ab22222222
276
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22);
277
lpad('a',4,'1')	lpad('a',4,'12')	lpad('abcd',3,'12')	lpad(11, 10 , 22)
278
111a	121a	abc	2222222211
279
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
280
rpad(741653838,17,'0')	lpad(741653838,17,'0')
281
74165383800000000	00000000741653838
282
select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
283
rpad('abcd',7,'ab')	lpad('abcd',7,'ab')
284
abcdaba	abaabcd
285
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
286
rpad('abcd',1,'ab')	lpad('abcd',1,'ab')
287
a	a
288
select rpad('STRING', 20, CONCAT('p','a','d') );
289
rpad('STRING', 20, CONCAT('p','a','d') )
290
STRINGpadpadpadpadpa
291
select lpad('STRING', 20, CONCAT('p','a','d') );
292
lpad('STRING', 20, CONCAT('p','a','d') )
293
padpadpadpadpaSTRING
294
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
295
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')	GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
296
NULL	NULL
297
select least(1,2,3) | greatest(16,32,8), least(5,4)*1,greatest(-1.0,1.0)*1,least(3,2,1)*1.0,greatest(1,1.1,1.0),least("10",9),greatest("A","B","0");
298
least(1,2,3) | greatest(16,32,8)	least(5,4)*1	greatest(-1.0,1.0)*1	least(3,2,1)*1.0	greatest(1,1.1,1.0)	least("10",9)	greatest("A","B","0")
299
33	4	1.0	1.0	1.1	9	B
300
select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
301
decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000)
302
1
303
select decode(encode("abcdef","monty"),"monty")="abcdef";
304
decode(encode("abcdef","monty"),"monty")="abcdef"
305
1
306
select quote('\'\"\\test');
307
quote('\'\"\\test')
308
'\'"\\test'
309
select quote(concat('abc\'', '\\cba'));
310
quote(concat('abc\'', '\\cba'))
311
'abc\'\\cba'
312
select quote(1/0), quote('\0\Z');
313
quote(1/0)	quote('\0\Z')
314
NULL	'\0\Z'
315
select length(quote(concat(char(0),"test")));
316
length(quote(concat(char(0),"test")))
317
8
318
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
319
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
320
27E0E3E6E7E8EAEB27
321
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL);
322
unhex(hex("foobar"))	hex(unhex("1234567890ABCDEF"))	unhex("345678")	unhex(NULL)
323
foobar	1234567890ABCDEF	4Vx	NULL
324
select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456"));
325
hex(unhex("1"))	hex(unhex("12"))	hex(unhex("123"))	hex(unhex("1234"))	hex(unhex("12345"))	hex(unhex("123456"))
326
01	12	0123	1234	012345	123456
327
select length(unhex(md5("abrakadabra")));
328
length(unhex(md5("abrakadabra")))
329
16
330
select concat('a', quote(NULL));
331
concat('a', quote(NULL))
332
aNULL
333
select reverse("");
334
reverse("")
335
336
select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
337
insert("aa",100,1,"b")	insert("aa",1,3,"b")	left("aa",-1)	substring("a",1,2)
338
aa	b		a
339
select elt(2,1),field(NULL,"a","b","c"),reverse("");
340
elt(2,1)	field(NULL,"a","b","c")	reverse("")
341
NULL	0	
342
select locate("a","b",2),locate("","a",1);
343
locate("a","b",2)	locate("","a",1)
344
0	1
345
select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
346
ltrim("a")	rtrim("a")	trim(BOTH "" from "a")	trim(BOTH " " from "a")
347
a	a	a	a
348
select concat("1","2")|0,concat("1",".5")+0.0;
349
concat("1","2")|0	concat("1",".5")+0.0
350
12	1.5
351
select substring_index("www.tcx.se","",3);
352
substring_index("www.tcx.se","",3)
353
354
select length(repeat("a",100000000)),length(repeat("a",1000*64));
355
length(repeat("a",100000000))	length(repeat("a",1000*64))
356
NULL	64000
357
Warnings:
358
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
359
select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
360
position("0" in "baaa" in (1))	position("0" in "1" in (1,2,3))	position("sql" in ("mysql"))
361
1	0	3
362
Warnings:
363
Warning	1292	Truncated incorrect DOUBLE value: 'baaa'
364
select position(("1" in (1,2,3)) in "01");
365
position(("1" in (1,2,3)) in "01")
366
2
367
select length(repeat("a",65500)),length(concat(repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",10000)))),length(insert(repeat("a",40000),1,30000,repeat("b",50000)));
368
length(repeat("a",65500))	length(concat(repeat("a",32000),repeat("a",32000)))	length(replace("aaaaa","a",concat(repeat("a",10000))))	length(insert(repeat("a",40000),1,30000,repeat("b",50000)))
369
65500	64000	50000	60000
370
select length(repeat("a",1000000)),length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000))),length(replace("aaaaa","a",concat(repeat("a",32000)))),length(insert(repeat("a",48000),1,1000,repeat("a",48000)));
371
length(repeat("a",1000000))	length(concat(repeat("a",32000),repeat("a",32000),repeat("a",32000)))	length(replace("aaaaa","a",concat(repeat("a",32000))))	length(insert(repeat("a",48000),1,1000,repeat("a",48000)))
372
1000000	96000	160000	95000
373
create table t1 ( domain char(50) );
374
insert into t1 VALUES ("hello.de" ), ("test.de" );
375
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de';
376
domain
377
hello.de
378
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
379
domain
380
test.de
381
drop table t1;
382
CREATE TABLE t1 (
383
id int(10) unsigned NOT NULL,
384
title varchar(255) default NULL,
385
prio int(10) unsigned default NULL,
386
category int(10) unsigned default NULL,
387
program int(10) unsigned default NULL,
388
bugdesc text,
389
created datetime default NULL,
390
modified timestamp NOT NULL,
391
bugstatus int(10) unsigned default NULL,
392
submitter int(10) unsigned default NULL
393
) ENGINE=MyISAM;
394
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
395
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1;
396
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"')
397
"Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4"
398
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
399
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"')
400
"Link";"1";"1";"1";"0";"4"
401
SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1;
402
CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter)
403
Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4
404
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
405
bugdesc	REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb')
406
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa	aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
407
drop table t1;
408
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) ENGINE=MyISAM;
409
INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
410
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
411
1
412
DROP TABLE t1;
413
CREATE TABLE t1 (
414
wid int(10) unsigned NOT NULL auto_increment,
415
data_podp date default NULL,
416
status_wnio enum('nowy','podp','real','arch') NOT NULL default 'nowy',
417
PRIMARY KEY(wid)
418
);
419
INSERT INTO t1 VALUES (8,NULL,'real');
420
INSERT INTO t1 VALUES (9,NULL,'nowy');
421
SELECT elt(status_wnio,data_podp) FROM t1 GROUP BY wid;
422
elt(status_wnio,data_podp)
423
NULL
424
NULL
425
DROP TABLE t1;
426
CREATE TABLE t1 (title text) ENGINE=MyISAM;
427
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
428
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
429
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
430
CONCAT("</a>",RPAD("",(55 - LENGTH(title)),"."))
431
NULL
432
</a>..........................
433
DROP TABLE t1;
434
CREATE TABLE t1 (i int, j int);
435
INSERT INTO t1 VALUES (1,1),(2,2);
436
SELECT DISTINCT i, ELT(j, '345', '34') FROM t1;
437
i	ELT(j, '345', '34')
438
1	345
439
2	34
440
DROP TABLE t1;
441
create table t1(a char(4));
442
insert into t1 values ('one'),(NULL),('two'),('four');
443
select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1;
444
a	quote(a)	isnull(quote(a))	quote(a) is null	ifnull(quote(a), 'n')
445
one	'one'	0	0	'one'
446
NULL	NULL	0	0	NULL
447
two	'two'	0	0	'two'
448
four	'four'	0	0	'four'
449
drop table t1;
450
select trim(trailing 'foo' from 'foo');
451
trim(trailing 'foo' from 'foo')
452
453
select trim(leading 'foo' from 'foo');
454
trim(leading 'foo' from 'foo')
455
456
select quote(ltrim(concat('    ', 'a')));
457
quote(ltrim(concat('    ', 'a')))
458
'a'
459
select quote(trim(concat('    ', 'a')));
460
quote(trim(concat('    ', 'a')))
461
'a'
462
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
463
SELECT QUOTE('A') FROM t1;
464
QUOTE('A')
465
'A'
466
'A'
467
'A'
468
DROP TABLE t1;
469
select 1=_latin1'1';
470
1=_latin1'1'
471
1
472
select _latin1'1'=1;
473
_latin1'1'=1
474
1
475
select _latin2'1'=1;
476
_latin2'1'=1
477
1
478
select 1=_latin2'1';
479
1=_latin2'1'
480
1
481
select _latin1'1'=_latin2'1';
482
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation '='
483
select row('a','b','c') = row('a','b','c');
484
row('a','b','c') = row('a','b','c')
485
1
486
select row('A','b','c') = row('a','b','c');
487
row('A','b','c') = row('a','b','c')
488
1
489
select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c');
490
row('A' COLLATE latin1_bin,'b','c') = row('a','b','c')
491
0
492
select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
493
row('A','b','c') = row('a' COLLATE latin1_bin,'b','c')
494
0
495
select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
496
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation '='
497
select concat(_latin1'a',_latin2'a');
498
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
499
select concat(_latin1'a',_latin2'a',_latin5'a');
500
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin5_turkish_ci,COERCIBLE) for operation 'concat'
501
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
502
ERROR HY000: Illegal mix of collations for operation 'concat'
503
select concat_ws(_latin1'a',_latin2'a');
504
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat_ws'
505
select FIELD('b','A','B');
506
FIELD('b','A','B')
507
2
508
select FIELD('B','A','B');
509
FIELD('B','A','B')
510
2
511
select FIELD('b' COLLATE latin1_bin,'A','B');
512
FIELD('b' COLLATE latin1_bin,'A','B')
513
0
514
select FIELD('b','A' COLLATE latin1_bin,'B');
515
FIELD('b','A' COLLATE latin1_bin,'B')
516
0
517
select FIELD(_latin2'b','A','B');
518
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
519
select FIELD('b',_latin2'A','B');
520
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'field'
521
select FIELD('1',_latin2'3','2',1);
522
FIELD('1',_latin2'3','2',1)
523
3
524
select POSITION(_latin1'B' IN _latin1'abcd');
525
POSITION(_latin1'B' IN _latin1'abcd')
526
2
527
select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
528
POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin)
529
0
530
select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd');
531
POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd')
532
0
533
select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin);
534
ERROR HY000: Illegal mix of collations (latin1_bin,EXPLICIT) and (latin1_general_ci,EXPLICIT) for operation 'locate'
535
select POSITION(_latin1'B' IN _latin2'abcd');
536
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE) and (latin1_swedish_ci,COERCIBLE) for operation 'locate'
537
select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d');
538
FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')
539
2
540
select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin);
541
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'find_in_set'
542
select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d');
543
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'find_in_set'
544
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2);
545
SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2)
546
abcdabc
547
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2);
548
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'substring_index'
549
select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2);
550
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'substring_index'
551
select _latin1'B' between _latin1'a' and _latin1'c';
552
_latin1'B' between _latin1'a' and _latin1'c'
553
1
554
select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c';
555
_latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'
556
0
557
select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c';
558
_latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'
559
0
560
select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin;
561
_latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin
562
0
563
select _latin2'B' between _latin1'a' and _latin1'b';
564
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between'
565
select _latin1'B' between _latin2'a' and _latin1'b';
566
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between'
567
select _latin1'B' between _latin1'a' and _latin2'b';
568
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation 'between'
569
select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b';
570
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'between'
571
select _latin1'B' in (_latin1'a',_latin1'b');
572
_latin1'B' in (_latin1'a',_latin1'b')
573
1
574
select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
575
_latin1'B' collate latin1_bin in (_latin1'a',_latin1'b')
576
0
577
select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
578
_latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b')
579
0
580
select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
581
_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin)
582
0
583
select _latin2'B' in (_latin1'a',_latin1'b');
584
ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
585
select _latin1'B' in (_latin2'a',_latin1'b');
586
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
587
select _latin1'B' in (_latin1'a',_latin2'b');
588
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN '
589
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
590
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN '
591
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
592
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN '
593
select collation(bin(130)), coercibility(bin(130));
594
collation(bin(130))	coercibility(bin(130))
595
latin1_swedish_ci	4
596
select collation(oct(130)), coercibility(oct(130));
597
collation(oct(130))	coercibility(oct(130))
598
latin1_swedish_ci	4
599
select collation(conv(130,16,10)), coercibility(conv(130,16,10));
600
collation(conv(130,16,10))	coercibility(conv(130,16,10))
601
latin1_swedish_ci	4
602
select collation(hex(130)), coercibility(hex(130));
603
collation(hex(130))	coercibility(hex(130))
604
latin1_swedish_ci	4
605
select collation(char(130)), coercibility(hex(130));
606
collation(char(130))	coercibility(hex(130))
607
binary	4
608
select collation(format(130,10)), coercibility(format(130,10));
609
collation(format(130,10))	coercibility(format(130,10))
610
latin1_swedish_ci	4
611
select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
612
collation(lcase(_latin2'a'))	coercibility(lcase(_latin2'a'))
613
latin2_general_ci	4
614
select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a'));
615
collation(ucase(_latin2'a'))	coercibility(ucase(_latin2'a'))
616
latin2_general_ci	4
617
select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
618
collation(left(_latin2'a',1))	coercibility(left(_latin2'a',1))
619
latin2_general_ci	4
620
select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
621
collation(right(_latin2'a',1))	coercibility(right(_latin2'a',1))
622
latin2_general_ci	4
623
select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
624
collation(substring(_latin2'a',1,1))	coercibility(substring(_latin2'a',1,1))
625
latin2_general_ci	4
626
select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
627
collation(concat(_latin2'a',_latin2'b'))	coercibility(concat(_latin2'a',_latin2'b'))
628
latin2_general_ci	4
629
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
630
collation(lpad(_latin2'a',4,_latin2'b'))	coercibility(lpad(_latin2'a',4,_latin2'b'))
631
latin2_general_ci	4
632
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
633
collation(rpad(_latin2'a',4,_latin2'b'))	coercibility(rpad(_latin2'a',4,_latin2'b'))
634
latin2_general_ci	4
635
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
636
collation(concat_ws(_latin2'a',_latin2'b'))	coercibility(concat_ws(_latin2'a',_latin2'b'))
637
latin2_general_ci	4
638
select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
639
collation(make_set(255,_latin2'a',_latin2'b',_latin2'c'))	coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'))
640
latin2_general_ci	4
641
select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
642
collation(export_set(255,_latin2'y',_latin2'n',_latin2' '))	coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '))
643
latin2_general_ci	4
644
select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
645
collation(trim(_latin2' a '))	coercibility(trim(_latin2' a '))
646
latin2_general_ci	4
647
select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
648
collation(ltrim(_latin2' a '))	coercibility(ltrim(_latin2' a '))
649
latin2_general_ci	4
650
select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
651
collation(rtrim(_latin2' a '))	coercibility(rtrim(_latin2' a '))
652
latin2_general_ci	4
653
select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
654
collation(trim(LEADING _latin2' ' FROM _latin2'a'))	coercibility(trim(LEADING _latin2'a' FROM _latin2'a'))
655
latin2_general_ci	4
656
select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
657
collation(trim(TRAILING _latin2' ' FROM _latin2'a'))	coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'))
658
latin2_general_ci	4
659
select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
660
collation(trim(BOTH _latin2' ' FROM _latin2'a'))	coercibility(trim(BOTH _latin2'a' FROM _latin2'a'))
661
latin2_general_ci	4
662
select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
663
collation(repeat(_latin2'a',10))	coercibility(repeat(_latin2'a',10))
664
latin2_general_ci	4
665
select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
666
collation(reverse(_latin2'ab'))	coercibility(reverse(_latin2'ab'))
667
latin2_general_ci	4
668
select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
669
collation(quote(_latin2'ab'))	coercibility(quote(_latin2'ab'))
670
latin2_general_ci	4
671
select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab'));
672
collation(soundex(_latin2'ab'))	coercibility(soundex(_latin2'ab'))
673
latin2_general_ci	4
674
select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
675
collation(substring(_latin2'ab',1))	coercibility(substring(_latin2'ab',1))
676
latin2_general_ci	4
677
select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
678
collation(insert(_latin2'abcd',2,3,_latin2'ef'))	coercibility(insert(_latin2'abcd',2,3,_latin2'ef'))
679
latin2_general_ci	4
680
select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
681
collation(replace(_latin2'abcd',_latin2'b',_latin2'B'))	coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'))
682
latin2_general_ci	4
683
select collation(encode('abcd','ab')), coercibility(encode('abcd','ab'));
684
collation(encode('abcd','ab'))	coercibility(encode('abcd','ab'))
685
binary	4
686
create table t1 
687
select
688
bin(130),
689
oct(130),
690
conv(130,16,10),
691
hex(130),
692
char(130),
693
format(130,10),
694
left(_latin2'a',1),
695
right(_latin2'a',1), 
696
lcase(_latin2'a'), 
697
ucase(_latin2'a'),
698
substring(_latin2'a',1,1),
699
concat(_latin2'a',_latin2'b'),
700
lpad(_latin2'a',4,_latin2'b'),
701
rpad(_latin2'a',4,_latin2'b'),
702
concat_ws(_latin2'a',_latin2'b'),
703
make_set(255,_latin2'a',_latin2'b',_latin2'c'),
704
export_set(255,_latin2'y',_latin2'n',_latin2' '),
705
trim(_latin2' a '),
706
ltrim(_latin2' a '),
707
rtrim(_latin2' a '),
708
trim(LEADING _latin2' ' FROM _latin2' a '),
709
trim(TRAILING _latin2' ' FROM _latin2' a '),
710
trim(BOTH _latin2' ' FROM _latin2' a '),
711
repeat(_latin2'a',10),
712
reverse(_latin2'ab'),
713
quote(_latin2'ab'),
714
soundex(_latin2'ab'),
715
substring(_latin2'ab',1),
716
insert(_latin2'abcd',2,3,_latin2'ef'),
717
replace(_latin2'abcd',_latin2'b',_latin2'B'),
718
encode('abcd','ab')
719
;
720
Warnings:
721
Warning	1265	Data truncated for column 'format(130,10)' at row 1
722
show create table t1;
723
Table	Create Table
724
t1	CREATE TABLE `t1` (
725
  `bin(130)` varchar(64) DEFAULT NULL,
726
  `oct(130)` varchar(64) DEFAULT NULL,
727
  `conv(130,16,10)` varchar(64) DEFAULT NULL,
728
  `hex(130)` varchar(6) NOT NULL DEFAULT '',
729
  `char(130)` varbinary(4) NOT NULL DEFAULT '',
730
  `format(130,10)` varchar(4) NOT NULL DEFAULT '',
731
  `left(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
732
  `right(_latin2'a',1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
733
  `lcase(_latin2'a')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
734
  `ucase(_latin2'a')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
735
  `substring(_latin2'a',1,1)` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
736
  `concat(_latin2'a',_latin2'b')` varchar(2) CHARACTER SET latin2 NOT NULL DEFAULT '',
737
  `lpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
738
  `rpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
739
  `concat_ws(_latin2'a',_latin2'b')` varchar(1) CHARACTER SET latin2 NOT NULL DEFAULT '',
740
  `make_set(255,_latin2'a',_latin2'b',_latin2'c')` varchar(5) CHARACTER SET latin2 NOT NULL DEFAULT '',
741
  `export_set(255,_latin2'y',_latin2'n',_latin2' ')` varchar(127) CHARACTER SET latin2 NOT NULL DEFAULT '',
742
  `trim(_latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
743
  `ltrim(_latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
744
  `rtrim(_latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
745
  `trim(LEADING _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
746
  `trim(TRAILING _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
747
  `trim(BOTH _latin2' ' FROM _latin2' a ')` varchar(3) CHARACTER SET latin2 NOT NULL DEFAULT '',
748
  `repeat(_latin2'a',10)` varchar(10) CHARACTER SET latin2 NOT NULL DEFAULT '',
749
  `reverse(_latin2'ab')` varchar(2) CHARACTER SET latin2 NOT NULL DEFAULT '',
750
  `quote(_latin2'ab')` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '',
751
  `soundex(_latin2'ab')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
752
  `substring(_latin2'ab',1)` varchar(2) CHARACTER SET latin2 NOT NULL DEFAULT '',
753
  `insert(_latin2'abcd',2,3,_latin2'ef')` varchar(6) CHARACTER SET latin2 NOT NULL DEFAULT '',
754
  `replace(_latin2'abcd',_latin2'b',_latin2'B')` varchar(4) CHARACTER SET latin2 NOT NULL DEFAULT '',
755
  `encode('abcd','ab')` varbinary(4) NOT NULL DEFAULT ''
756
) ENGINE=MyISAM DEFAULT CHARSET=latin1
757
drop table t1;
758
create table t1 (a char character set latin2);
759
insert into t1 values (null);
760
select charset(a), collation(a), coercibility(a) from t1;
761
charset(a)	collation(a)	coercibility(a)
762
latin2	latin2_general_ci	2
763
drop table t1;
764
select charset(null), collation(null), coercibility(null);
765
charset(null)	collation(null)	coercibility(null)
766
binary	binary	5
767
CREATE TABLE t1 (a int, b int);
768
CREATE TABLE t2 (a int, b int);
769
INSERT INTO t1 VALUES (1,1),(2,2);
770
INSERT INTO t2 VALUES (2,2),(3,3);
771
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
772
where collation(t2.a) = _utf8'binary' order by t1.a,t2.a;
773
a	b	a	b
774
1	1	NULL	NULL
775
2	2	2	2
776
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
777
where charset(t2.a) = _utf8'binary' order by t1.a,t2.a;
778
a	b	a	b
779
1	1	NULL	NULL
780
2	2	2	2
781
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
782
where coercibility(t2.a) = 2 order by t1.a,t2.a;
783
a	b	a	b
784
1	1	NULL	NULL
785
2	2	2	2
786
DROP TABLE t1, t2;
787
select SUBSTR('abcdefg',3,2);
788
SUBSTR('abcdefg',3,2)
789
cd
790
select SUBSTRING('abcdefg',3,2);
791
SUBSTRING('abcdefg',3,2)
792
cd
793
select SUBSTR('abcdefg',-3,2) FROM DUAL;
794
SUBSTR('abcdefg',-3,2)
795
ef
796
select SUBSTR('abcdefg',-1,5) FROM DUAL;
797
SUBSTR('abcdefg',-1,5)
798
g
799
select SUBSTR('abcdefg',0,0) FROM DUAL;
800
SUBSTR('abcdefg',0,0)
801
802
select SUBSTR('abcdefg',-1,-1) FROM DUAL;
803
SUBSTR('abcdefg',-1,-1)
804
805
select SUBSTR('abcdefg',1,-1) FROM DUAL;
806
SUBSTR('abcdefg',1,-1)
807
808
create table t7 (s1 char);
809
select * from t7
810
where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA';
811
ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat'
812
drop table t7;
813
select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
814
substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)	substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2)
815
1abcd;2abcd	3abcd;4abcd
816
explain extended select md5('hello');
817
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
818
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
819
Warnings:
820
Note	1003	select md5('hello') AS `md5('hello')`
821
explain extended select sha('abc');
822
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
823
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
824
Warnings:
825
Note	1003	select sha('abc') AS `sha('abc')`
826
explain extended select sha1('abc');
827
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
828
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
829
Warnings:
830
Note	1003	select sha('abc') AS `sha1('abc')`
831
explain extended select soundex('');
832
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
833
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
834
Warnings:
835
Note	1003	select soundex('') AS `soundex('')`
836
explain extended select 'mood' sounds like 'mud';
837
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
838
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
839
Warnings:
840
Note	1003	select (soundex('mood') = soundex('mud')) AS `'mood' sounds like 'mud'`
841
explain extended select aes_decrypt(aes_encrypt('abc','1'),'1');
842
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
843
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
844
Warnings:
845
Note	1003	select aes_decrypt(aes_encrypt('abc','1'),'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`
846
explain extended select concat('*',space(5),'*');
847
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
848
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
849
Warnings:
850
Note	1003	select concat('*',repeat(' ',5),'*') AS `concat('*',space(5),'*')`
851
explain extended select reverse('abc');
852
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
853
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
854
Warnings:
855
Note	1003	select reverse('abc') AS `reverse('abc')`
856
explain extended select rpad('a',4,'1');
857
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
858
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
859
Warnings:
860
Note	1003	select rpad('a',4,'1') AS `rpad('a',4,'1')`
861
explain extended select lpad('a',4,'1');
862
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
863
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
864
Warnings:
865
Note	1003	select lpad('a',4,'1') AS `lpad('a',4,'1')`
866
explain extended select concat_ws(',','',NULL,'a');
867
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
868
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
869
Warnings:
870
Note	1003	select concat_ws(',','',NULL,'a') AS `concat_ws(',','',NULL,'a')`
871
explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c');
872
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
873
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
874
Warnings:
875
Note	1003	select make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a', _latin2'b', _latin2'c')`
876
explain extended select elt(2,1);
877
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
878
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
879
Warnings:
880
Note	1003	select elt(2,1) AS `elt(2,1)`
881
explain extended select locate("a","b",2);
882
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
883
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
884
Warnings:
885
Note	1003	select locate('a','b',2) AS `locate("a","b",2)`
886
explain extended select format(130,10);
887
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
888
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
889
Warnings:
890
Note	1003	select format(130,10) AS `format(130,10)`
891
explain extended select char(0);
892
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
893
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
894
Warnings:
895
Note	1003	select char(0) AS `char(0)`
896
explain extended select conv(130,16,10);
897
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
898
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
899
Warnings:
900
Note	1003	select conv(130,16,10) AS `conv(130,16,10)`
901
explain extended select hex(130);
902
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
903
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
904
Warnings:
905
Note	1003	select hex(130) AS `hex(130)`
906
explain extended select binary 'HE';
907
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
908
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
909
Warnings:
910
Note	1003	select cast('HE' as char charset binary) AS `binary 'HE'`
911
explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' ');
912
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
913
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
914
Warnings:
915
Note	1003	select export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y', _latin2'n', _latin2' ')`
916
explain extended select FIELD('b' COLLATE latin1_bin,'A','B');
917
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
918
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
919
Warnings:
920
Note	1003	select field(('b' collate latin1_bin),'A','B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`
921
explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d');
922
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
923
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
924
Warnings:
925
Note	1003	select find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B', _latin1'a,b,c,d')`
926
explain extended select collation(conv(130,16,10));
927
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
928
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
929
Warnings:
930
Note	1003	select collation(conv(130,16,10)) AS `collation(conv(130,16,10))`
931
explain extended select coercibility(conv(130,16,10));
932
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
933
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
934
Warnings:
935
Note	1003	select coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`
936
explain extended select length('\n\t\r\b\0\_\%\\');
937
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
938
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
939
Warnings:
940
Note	1003	select length('\n	\r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`
941
explain extended select bit_length('\n\t\r\b\0\_\%\\');
942
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
943
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
944
Warnings:
945
Note	1003	select bit_length('\n	\r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
946
explain extended select bit_length('\n\t\r\b\0\_\%\\');
947
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
948
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
949
Warnings:
950
Note	1003	select bit_length('\n	\r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`
951
explain extended select concat('monty',' was here ','again');
952
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
953
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
954
Warnings:
955
Note	1003	select concat('monty',' was here ','again') AS `concat('monty',' was here ','again')`
956
explain extended select length('hello');
957
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
958
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
959
Warnings:
960
Note	1003	select length('hello') AS `length('hello')`
961
explain extended select char(ascii('h'));
962
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
963
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
964
Warnings:
965
Note	1003	select char(ascii('h')) AS `char(ascii('h'))`
966
explain extended select ord('h');
967
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
968
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
969
Warnings:
970
Note	1003	select ord('h') AS `ord('h')`
971
explain extended select quote(1/0);
972
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
973
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
974
Warnings:
975
Note	1003	select quote((1 / 0)) AS `quote(1/0)`
976
explain extended select crc32("123");
977
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
978
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
979
Warnings:
980
Note	1003	select crc32('123') AS `crc32("123")`
981
explain extended select replace('aaaa','a','b');
982
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
983
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
984
Warnings:
985
Note	1003	select replace('aaaa','a','b') AS `replace('aaaa','a','b')`
986
explain extended select insert('txs',2,1,'hi');
987
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
988
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
989
Warnings:
990
Note	1003	select insert('txs',2,1,'hi') AS `insert('txs',2,1,'hi')`
991
explain extended select left(_latin2'a',1);
992
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
993
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
994
Warnings:
995
Note	1003	select left(_latin2'a',1) AS `left(_latin2'a',1)`
996
explain extended select right(_latin2'a',1);
997
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
998
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
999
Warnings:
1000
Note	1003	select right(_latin2'a',1) AS `right(_latin2'a',1)`
1001
explain extended select lcase(_latin2'a');
1002
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1003
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1004
Warnings:
1005
Note	1003	select lcase(_latin2'a') AS `lcase(_latin2'a')`
1006
explain extended select ucase(_latin2'a');
1007
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1008
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1009
Warnings:
1010
Note	1003	select ucase(_latin2'a') AS `ucase(_latin2'a')`
1011
explain extended select SUBSTR('abcdefg',3,2);
1012
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1013
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1014
Warnings:
1015
Note	1003	select substr('abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`
1016
explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2);
1017
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1018
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1019
Warnings:
1020
Note	1003	select substring_index('1abcd;2abcd;3abcd;4abcd',';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`
1021
explain extended select trim(_latin2' a ');
1022
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1023
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1024
Warnings:
1025
Note	1003	select trim(_latin2' a ') AS `trim(_latin2' a ')`
1026
explain extended select ltrim(_latin2' a ');
1027
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1028
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1029
Warnings:
1030
Note	1003	select ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`
1031
explain extended select rtrim(_latin2' a ');
1032
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1033
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1034
Warnings:
1035
Note	1003	select rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`
1036
explain extended select decode(encode(repeat("a",100000),"monty"),"monty");
1037
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1038
1	SIMPLE	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	No tables used
1039
Warnings:
1040
Note	1003	select decode(encode(repeat('a',100000),'monty'),'monty') AS `decode(encode(repeat("a",100000),"monty"),"monty")`
1041
SELECT lpad(12345, 5, "#");
1042
lpad(12345, 5, "#")
1043
12345
1044
SELECT conv(71, 10, 36), conv('1Z', 36, 10);
1045
conv(71, 10, 36)	conv('1Z', 36, 10)
1046
1Z	71
1047
SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
1048
conv(71, 10, 37)	conv('1Z', 37, 10)	conv(0,1,10)	conv(0,0,10)	conv(0,-1,10)
1049
NULL	NULL	NULL	NULL	NULL
1050
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
1051
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
1052
create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
1053
insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
1054
select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2 
1055
where t2.id=t1.id order by name;
1056
name
1057
aaaaaaaaaaccccc
1058
bbbbbbbbbbddddd
1059
drop table t1, t2;
1060
create table t1 (c1 INT, c2 INT UNSIGNED);
1061
insert into t1 values ('21474836461','21474836461');
1062
Warnings:
1063
Warning	1264	Out of range value for column 'c1' at row 1
1064
Warning	1264	Out of range value for column 'c2' at row 1
1065
insert into t1 values ('-21474836461','-21474836461');
1066
Warnings:
1067
Warning	1264	Out of range value for column 'c1' at row 1
1068
Warning	1264	Out of range value for column 'c2' at row 1
1069
show warnings;
1070
Level	Code	Message
1071
Warning	1264	Out of range value for column 'c1' at row 1
1072
Warning	1264	Out of range value for column 'c2' at row 1
1073
select * from t1;
1074
c1	c2
1075
2147483647	4294967295
1076
-2147483648	0
1077
drop table t1;
1078
select left(1234, 3) + 0;
1079
left(1234, 3) + 0
1080
123
1081
create table t1 (a int not null primary key, b varchar(40), c datetime);
1082
insert into t1 (a,b,c) values (1,'Tom','2004-12-10 12:13:14'),(2,'ball games','2004-12-10 12:13:14'), (3,'Basil','2004-12-10 12:13:14'), (4,'Dean','2004-12-10 12:13:14'),(5,'Ellis','2004-12-10 12:13:14'), (6,'Serg','2004-12-10 12:13:14'), (7,'Sergei','2004-12-10 12:13:14'),(8,'Georg','2004-12-10 12:13:14'),(9,'Salle','2004-12-10 12:13:14'),(10,'Sinisa','2004-12-10 12:13:14');
1083
select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12;
1084
total	reg
1085
10	2004-12-10
1086
drop table t1;
1087
select trim(null from 'kate') as "must_be_null";
1088
must_be_null
1089
NULL
1090
select trim('xyz' from null) as "must_be_null";
1091
must_be_null
1092
NULL
1093
select trim(leading NULL from 'kate') as "must_be_null";
1094
must_be_null
1095
NULL
1096
select trim(trailing NULL from 'xyz') as "must_be_null";
1097
must_be_null
1098
NULL
1099
CREATE TABLE t1 (
1100
id int(11) NOT NULL auto_increment,
1101
a bigint(20) unsigned default NULL,
1102
PRIMARY KEY  (id)
1103
) ENGINE=MyISAM;
1104
INSERT INTO t1 VALUES
1105
('0','16307858876001849059');
1106
SELECT CONV('e251273eb74a8ee3', 16, 10);
1107
CONV('e251273eb74a8ee3', 16, 10)
1108
16307858876001849059
1109
EXPLAIN 
1110
SELECT id
1111
FROM t1
1112
WHERE a = 16307858876001849059;
1113
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1114
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
1115
EXPLAIN 
1116
SELECT id
1117
FROM t1
1118
WHERE a = CONV('e251273eb74a8ee3', 16, 10);
1119
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1120
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	1	
1121
DROP TABLE t1;
1122
SELECT CHAR(NULL,121,83,81,'76') as my_column;
1123
my_column
1124
ySQL
1125
SELECT CHAR_LENGTH(CHAR(NULL,121,83,81,'76')) as my_column;
1126
my_column
1127
4
1128
CREATE TABLE t1 (id int PRIMARY KEY, str char(255) NOT NULL);
1129
CREATE TABLE t2 (id int NOT NULL UNIQUE);
1130
INSERT INTO t2 VALUES (1),(2);
1131
INSERT INTO t1 VALUES (1, aes_encrypt('foo', 'bar'));
1132
INSERT INTO t1 VALUES (2, 'not valid');
1133
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id;
1134
id	aes_decrypt(str, 'bar')
1135
1	foo
1136
2	NULL
1137
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
1138
ORDER BY t1.id;
1139
id	aes_decrypt(str, 'bar')
1140
1	foo
1141
2	NULL
1142
DROP TABLE t1, t2;
1143
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
1144
field(0,NULL,1,0)	field("",NULL,"bar","")	field(0.0,NULL,1.0,0.0)
1145
3	3	3
1146
select field(NULL,1,2,NULL), field(NULL,1,2,0);
1147
field(NULL,1,2,NULL)	field(NULL,1,2,0)
1148
0	0
1149
CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
1150
CREATE TABLE t2 (num int primary key);
1151
INSERT INTO t1 VALUES ('notnumber');
1152
INSERT INTO t2 VALUES (0), (1);
1153
SELECT * FROM t1, t2 WHERE num=str;
1154
str	num
1155
notnumber	0
1156
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
1157
str	num
1158
notnumber	0
1159
DROP TABLE t1,t2;
1160
CREATE TABLE t1(
1161
id int(11) NOT NULL auto_increment,
1162
pc int(11) NOT NULL default '0',
1163
title varchar(20) default NULL,
1164
PRIMARY KEY (id)
1165
);
1166
INSERT INTO t1 VALUES
1167
(1, 0, 'Main'),
1168
(2, 1, 'Toys'),
1169
(3, 1, 'Games');
1170
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
1171
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
1172
LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
1173
id	col1
1174
1	Main
1175
2	Main->Toys
1176
3	Main->Games
1177
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
1178
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
1179
LEFT JOIN t1 AS t3 ON t2.pc=t3.id
1180
WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
1181
id	col1
1182
2	Main->Toys
1183
DROP TABLE t1;
1184
CREATE TABLE t1(
1185
trackid     int(10) unsigned NOT NULL auto_increment,
1186
trackname   varchar(100) NOT NULL default '',
1187
PRIMARY KEY (trackid)
1188
);
1189
CREATE TABLE t2(
1190
artistid    int(10) unsigned NOT NULL auto_increment,
1191
artistname  varchar(100) NOT NULL default '',
1192
PRIMARY KEY (artistid)
1193
);
1194
CREATE TABLE t3(
1195
trackid     int(10) unsigned NOT NULL,
1196
artistid    int(10) unsigned NOT NULL,
1197
PRIMARY KEY (trackid,artistid)
1198
);
1199
INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
1200
INSERT INTO t2 VALUES (1, 'Vernon Duke');
1201
INSERT INTO t3 VALUES (1,1);
1202
SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
1203
FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
1204
LEFT JOIN t2 ON t2.artistid=t3.artistid
1205
WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
1206
trackname	artistname
1207
April In Paris Vernon Duke	Vernon Duke
1208
Autumn In New York	NULL
1209
DROP TABLE t1,t2,t3;
1210
create table t1 (b varchar(5));
1211
insert t1 values ('ab'), ('abc'), ('abcd'), ('abcde');
1212
select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1;
1213
b	substring(b,1)	substring(b,-1)	substring(b,-2)	substring(b,-3)	substring(b,-4)	substring(b,-5)
1214
ab	ab	b	ab			
1215
abc	abc	c	bc	abc		
1216
abcd	abcd	d	cd	bcd	abcd	
1217
abcde	abcde	e	de	cde	bcde	abcde
1218
select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t;
1219
b	substring(b,1)	substring(b,-1)	substring(b,-2)	substring(b,-3)	substring(b,-4)	substring(b,-5)
1220
ab	ab	b	ab			
1221
abc	abc	c	bc	abc		
1222
abcd	abcd	d	cd	bcd	abcd	
1223
abcde	abcde	e	de	cde	bcde	abcde
1224
drop table t1;
1225
select hex(29223372036854775809), hex(-29223372036854775809);
1226
hex(29223372036854775809)	hex(-29223372036854775809)
1227
FFFFFFFFFFFFFFFF	FFFFFFFFFFFFFFFF
1228
create table t1 (i int);
1229
insert into t1 values (1000000000),(1);
1230
select lpad(i, 7, ' ') as t from t1;
1231
Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
1232
def					t	253	7	7	Y	128	31	63
1233
t
1234
1000000
1235
      1
1236
select rpad(i, 7, ' ') as t from t1;
1237
Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
1238
def					t	253	7	7	Y	128	31	63
1239
t
1240
1000000
1241
1      
1242
drop table t1;
1243
select load_file("lkjlkj");
1244
load_file("lkjlkj")
1245
NULL
1246
select ifnull(load_file("lkjlkj"),"it's null");
1247
ifnull(load_file("lkjlkj"),"it's null")
1248
it's null
1249
create table t1 (f1 varchar(4), f2 varchar(64), unique key k1 (f1,f2));
1250
insert into t1 values ( 'test',md5('test')), ('test', sha('test'));
1251
select * from t1 where f1='test' and (f2= md5("test") or f2= md5("TEST"));
1252
f1	f2
1253
test	098f6bcd4621d373cade4e832627b4f6
1254
select * from t1 where f1='test' and (f2= md5("TEST") or f2= md5("test"));
1255
f1	f2
1256
test	098f6bcd4621d373cade4e832627b4f6
1257
select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
1258
f1	f2
1259
test	a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
1260
select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
1261
f1	f2
1262
test	a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
1263
drop table t1;
1264
CREATE TABLE t1 (a varchar(10));
1265
INSERT INTO t1 VALUES ('abc'), ('xyz');
1266
SELECT a, CONCAT(a,' ',a) AS c FROM t1
1267
HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a;
1268
a	c
1269
abc	abc abc
1270
xyz	xyz xyz
1271
SELECT a, CONCAT(a,' ',a) AS c FROM t1
1272
HAVING LEFT(CONCAT(a,' ',a),
1273
LENGTH(CONCAT(a,' ',a))-
1274
INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
1275
a	c
1276
abc	abc abc
1277
xyz	xyz xyz
1278
DROP TABLE t1;
1279
CREATE TABLE t1 (s varchar(10));
1280
INSERT INTO t1 VALUES ('yadda'), ('yaddy');
1281
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
1282
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1283
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1284
Warnings:
1285
Note	1003	select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > 'ab')
1286
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
1287
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1288
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1289
Warnings:
1290
Note	1003	select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
1291
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
1292
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1293
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1294
Warnings:
1295
Note	1003	select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading 'y' from `test`.`t1`.`s`) > 'ab')
1296
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
1297
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1298
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1299
Warnings:
1300
Note	1003	select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing 'y' from `test`.`t1`.`s`) > 'ab')
1301
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
1302
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1303
1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	2	100.00	Using where
1304
Warnings:
1305
Note	1003	select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
1306
DROP TABLE t1;
1307
create table t1(f1 varchar(4));
1308
explain extended select encode(f1,'zxcv') as 'enc' from t1;
1309
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1310
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	0	0.00	const row not found
1311
Warnings:
1312
Note	1003	select encode('','zxcv') AS `enc` from `test`.`t1`
1313
explain extended select decode(f1,'zxcv') as 'enc' from t1;
1314
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1315
1	SIMPLE	t1	system	NULL	NULL	NULL	NULL	0	0.00	const row not found
1316
Warnings:
1317
Note	1003	select decode('','zxcv') AS `enc` from `test`.`t1`
1318
drop table t1;
1319
create table t1 (a bigint not null)engine=myisam;
1320
insert into t1 set a = 1024*1024*1024*4;
1321
delete from t1 order by (inet_ntoa(a)) desc limit 10;
1322
drop table t1;
1323
create table t1 (a char(36) not null)engine=myisam;
1324
insert ignore into t1 set a = ' ';
1325
insert ignore into t1 set a = ' ';
1326
select * from t1 order by (oct(a));
1327
a
1328
1329
1330
drop table t1;
1331
End of 4.1 tests
1332
create table t1 (d decimal default null);
1333
insert into t1 values (null);
1334
select format(d, 2) from t1;
1335
format(d, 2)
1336
NULL
1337
drop table t1;
1338
create table t1 (c varchar(40));
1339
insert into t1 values ('y,abc'),('y,abc');
1340
select c, substring_index(lcase(c), @q:=',', -1) as res from t1;
1341
c	res
1342
y,abc	abc
1343
y,abc	abc
1344
drop table t1;
1345
select cast(rtrim('  20.06 ') as decimal(19,2));
1346
cast(rtrim('  20.06 ') as decimal(19,2))
1347
20.06
1348
select cast(ltrim('  20.06 ') as decimal(19,2));
1349
cast(ltrim('  20.06 ') as decimal(19,2))
1350
20.06
1351
select cast(rtrim(ltrim('  20.06 ')) as decimal(19,2));
1352
cast(rtrim(ltrim('  20.06 ')) as decimal(19,2))
1353
20.06
1354
select conv("18383815659218730760",10,10) + 0;
1355
conv("18383815659218730760",10,10) + 0
1356
1.838381565921873e19
1357
select "18383815659218730760" + 0;
1358
"18383815659218730760" + 0
1359
1.838381565921873e19
1360
CREATE TABLE t1 (code varchar(10));
1361
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
1362
SELECT ASCII(code), code FROM t1 WHERE code='A12';
1363
ASCII(code)	code
1364
97	a12
1365
65	A12
1366
SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65;
1367
ASCII(code)	code
1368
65	A12
1369
INSERT INTO t1 VALUES ('a12 '), ('A12  ');
1370
SELECT LENGTH(code), code FROM t1 WHERE code='A12';
1371
LENGTH(code)	code
1372
3	a12
1373
3	A12
1374
4	a12 
1375
5	A12  
1376
SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5;
1377
LENGTH(code)	code
1378
5	A12  
1379
ALTER TABLE t1 ADD INDEX (code);
1380
CREATE TABLE t2 (id varchar(10) PRIMARY KEY);
1381
INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14');
1382
SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id 
1383
WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00');
1384
code	id
1385
A12  	a12
1386
EXPLAIN EXTENDED 
1387
SELECT * FROM t1 INNER JOIN t2 ON code=id 
1388
WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
1389
id	select_type	table	type	possible_keys	key	key_len	ref	rows	filtered	Extra
1390
1	SIMPLE	t2	const	PRIMARY	PRIMARY	12	const	1	100.00	Using index
1391
1	SIMPLE	t1	ref	code	code	13	const	3	100.00	Using where; Using index
1392
Warnings:
1393
Note	1003	select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and (length(`test`.`t1`.`code`) = 5))
1394
DROP TABLE t1,t2;
1395
select encode(NULL, NULL);
1396
encode(NULL, NULL)
1397
NULL
1398
select encode("data", NULL);
1399
encode("data", NULL)
1400
NULL
1401
select encode(NULL, "password");
1402
encode(NULL, "password")
1403
NULL
1404
select decode(NULL, NULL);
1405
decode(NULL, NULL)
1406
NULL
1407
select decode("data", NULL);
1408
decode("data", NULL)
1409
NULL
1410
select decode(NULL, "password");
1411
decode(NULL, "password")
1412
NULL
1413
select format(NULL, NULL);
1414
format(NULL, NULL)
1415
NULL
1416
select format(pi(), NULL);
1417
format(pi(), NULL)
1418
NULL
1419
select format(NULL, 2);
1420
format(NULL, 2)
1421
NULL
1422
select benchmark(NULL, NULL);
1423
benchmark(NULL, NULL)
1424
NULL
1425
select benchmark(0, NULL);
1426
benchmark(0, NULL)
1427
0
1428
select benchmark(100, NULL);
1429
benchmark(100, NULL)
1430
0
1431
select benchmark(NULL, 1+1);
1432
benchmark(NULL, 1+1)
1433
NULL
1434
select benchmark(-1, 1);
1435
benchmark(-1, 1)
1436
NULL
1437
Warnings:
1438
Error	1411	Incorrect count value: '-1' for function benchmark
1439
set @password="password";
1440
set @my_data="clear text to encode";
1441
select md5(encode(@my_data, "password"));
1442
md5(encode(@my_data, "password"))
1443
44320fd2b4a0ec92faa2da2122def917
1444
select md5(encode(@my_data, _utf8 "password"));
1445
md5(encode(@my_data, _utf8 "password"))
1446
44320fd2b4a0ec92faa2da2122def917
1447
select md5(encode(@my_data, binary "password"));
1448
md5(encode(@my_data, binary "password"))
1449
44320fd2b4a0ec92faa2da2122def917
1450
select md5(encode(@my_data, _latin1 "password"));
1451
md5(encode(@my_data, _latin1 "password"))
1452
44320fd2b4a0ec92faa2da2122def917
1453
select md5(encode(@my_data, _koi8r "password"));
1454
md5(encode(@my_data, _koi8r "password"))
1455
44320fd2b4a0ec92faa2da2122def917
1456
select md5(encode(@my_data, (select "password" from dual)));
1457
md5(encode(@my_data, (select "password" from dual)))
1458
44320fd2b4a0ec92faa2da2122def917
1459
select md5(encode(@my_data, concat("pass", "word")));
1460
md5(encode(@my_data, concat("pass", "word")))
1461
44320fd2b4a0ec92faa2da2122def917
1462
select md5(encode(@my_data, @password));
1463
md5(encode(@my_data, @password))
1464
44320fd2b4a0ec92faa2da2122def917
1465
set @my_data="binary encoded data";
1466
select md5(decode(@my_data, "password"));
1467
md5(decode(@my_data, "password"))
1468
5bea8c394368dbc03b76684483b7756b
1469
select md5(decode(@my_data, _utf8 "password"));
1470
md5(decode(@my_data, _utf8 "password"))
1471
5bea8c394368dbc03b76684483b7756b
1472
select md5(decode(@my_data, binary "password"));
1473
md5(decode(@my_data, binary "password"))
1474
5bea8c394368dbc03b76684483b7756b
1475
select md5(decode(@my_data, _latin1 "password"));
1476
md5(decode(@my_data, _latin1 "password"))
1477
5bea8c394368dbc03b76684483b7756b
1478
select md5(decode(@my_data, _koi8r "password"));
1479
md5(decode(@my_data, _koi8r "password"))
1480
5bea8c394368dbc03b76684483b7756b
1481
select md5(decode(@my_data, (select "password" from dual)));
1482
md5(decode(@my_data, (select "password" from dual)))
1483
5bea8c394368dbc03b76684483b7756b
1484
select md5(decode(@my_data, concat("pass", "word")));
1485
md5(decode(@my_data, concat("pass", "word")))
1486
5bea8c394368dbc03b76684483b7756b
1487
select md5(decode(@my_data, @password));
1488
md5(decode(@my_data, @password))
1489
5bea8c394368dbc03b76684483b7756b
1490
set @dec=5;
1491
select format(pi(), (1+1));
1492
format(pi(), (1+1))
1493
3.14
1494
select format(pi(), (select 3 from dual));
1495
format(pi(), (select 3 from dual))
1496
3.142
1497
select format(pi(), @dec);
1498
format(pi(), @dec)
1499
3.14159
1500
set @bench_count=10;
1501
select benchmark(10, pi());
1502
benchmark(10, pi())
1503
0
1504
select benchmark(5+5, pi());
1505
benchmark(5+5, pi())
1506
0
1507
select benchmark((select 10 from dual), pi());
1508
benchmark((select 10 from dual), pi())
1509
0
1510
select benchmark(@bench_count, pi());
1511
benchmark(@bench_count, pi())
1512
0
1513
select locate('he','hello',-2);
1514
locate('he','hello',-2)
1515
0
1516
select locate('lo','hello',-4294967295);
1517
locate('lo','hello',-4294967295)
1518
0
1519
select locate('lo','hello',4294967295);
1520
locate('lo','hello',4294967295)
1521
0
1522
select locate('lo','hello',-4294967296);
1523
locate('lo','hello',-4294967296)
1524
0
1525
select locate('lo','hello',4294967296);
1526
locate('lo','hello',4294967296)
1527
0
1528
select locate('lo','hello',-4294967297);
1529
locate('lo','hello',-4294967297)
1530
0
1531
select locate('lo','hello',4294967297);
1532
locate('lo','hello',4294967297)
1533
0
1534
select locate('lo','hello',-18446744073709551615);
1535
locate('lo','hello',-18446744073709551615)
1536
0
1537
Warnings:
1538
Error	1292	Truncated incorrect DECIMAL value: ''
1539
select locate('lo','hello',18446744073709551615);
1540
locate('lo','hello',18446744073709551615)
1541
0
1542
select locate('lo','hello',-18446744073709551616);
1543
locate('lo','hello',-18446744073709551616)
1544
0
1545
Warnings:
1546
Error	1292	Truncated incorrect DECIMAL value: ''
1547
select locate('lo','hello',18446744073709551616);
1548
locate('lo','hello',18446744073709551616)
1549
0
1550
Warnings:
1551
Error	1292	Truncated incorrect DECIMAL value: ''
1552
select locate('lo','hello',-18446744073709551617);
1553
locate('lo','hello',-18446744073709551617)
1554
0
1555
Warnings:
1556
Error	1292	Truncated incorrect DECIMAL value: ''
1557
select locate('lo','hello',18446744073709551617);
1558
locate('lo','hello',18446744073709551617)
1559
0
1560
Warnings:
1561
Error	1292	Truncated incorrect DECIMAL value: ''
1562
select left('hello', 10);
1563
left('hello', 10)
1564
hello
1565
select left('hello', 0);
1566
left('hello', 0)
1567
1568
select left('hello', -1);
1569
left('hello', -1)
1570
1571
select left('hello', -4294967295);
1572
left('hello', -4294967295)
1573
1574
select left('hello', 4294967295);
1575
left('hello', 4294967295)
1576
hello
1577
select left('hello', -4294967296);
1578
left('hello', -4294967296)
1579
1580
select left('hello', 4294967296);
1581
left('hello', 4294967296)
1582
hello
1583
select left('hello', -4294967297);
1584
left('hello', -4294967297)
1585
1586
select left('hello', 4294967297);
1587
left('hello', 4294967297)
1588
hello
1589
select left('hello', -18446744073709551615);
1590
left('hello', -18446744073709551615)
1591
1592
Warnings:
1593
Error	1292	Truncated incorrect DECIMAL value: ''
1594
Error	1292	Truncated incorrect DECIMAL value: ''
1595
select left('hello', 18446744073709551615);
1596
left('hello', 18446744073709551615)
1597
hello
1598
select left('hello', -18446744073709551616);
1599
left('hello', -18446744073709551616)
1600
1601
Warnings:
1602
Error	1292	Truncated incorrect DECIMAL value: ''
1603
Error	1292	Truncated incorrect DECIMAL value: ''
1604
select left('hello', 18446744073709551616);
1605
left('hello', 18446744073709551616)
1606
hello
1607
Warnings:
1608
Error	1292	Truncated incorrect DECIMAL value: ''
1609
Error	1292	Truncated incorrect DECIMAL value: ''
1610
select left('hello', -18446744073709551617);
1611
left('hello', -18446744073709551617)
1612
1613
Warnings:
1614
Error	1292	Truncated incorrect DECIMAL value: ''
1615
Error	1292	Truncated incorrect DECIMAL value: ''
1616
select left('hello', 18446744073709551617);
1617
left('hello', 18446744073709551617)
1618
hello
1619
Warnings:
1620
Error	1292	Truncated incorrect DECIMAL value: ''
1621
Error	1292	Truncated incorrect DECIMAL value: ''
1622
select right('hello', 10);
1623
right('hello', 10)
1624
hello
1625
select right('hello', 0);
1626
right('hello', 0)
1627
1628
select right('hello', -1);
1629
right('hello', -1)
1630
1631
select right('hello', -4294967295);
1632
right('hello', -4294967295)
1633
1634
select right('hello', 4294967295);
1635
right('hello', 4294967295)
1636
hello
1637
select right('hello', -4294967296);
1638
right('hello', -4294967296)
1639
1640
select right('hello', 4294967296);
1641
right('hello', 4294967296)
1642
hello
1643
select right('hello', -4294967297);
1644
right('hello', -4294967297)
1645
1646
select right('hello', 4294967297);
1647
right('hello', 4294967297)
1648
hello
1649
select right('hello', -18446744073709551615);
1650
right('hello', -18446744073709551615)
1651
1652
Warnings:
1653
Error	1292	Truncated incorrect DECIMAL value: ''
1654
Error	1292	Truncated incorrect DECIMAL value: ''
1655
select right('hello', 18446744073709551615);
1656
right('hello', 18446744073709551615)
1657
hello
1658
select right('hello', -18446744073709551616);
1659
right('hello', -18446744073709551616)
1660
1661
Warnings:
1662
Error	1292	Truncated incorrect DECIMAL value: ''
1663
Error	1292	Truncated incorrect DECIMAL value: ''
1664
select right('hello', 18446744073709551616);
1665
right('hello', 18446744073709551616)
1666
hello
1667
Warnings:
1668
Error	1292	Truncated incorrect DECIMAL value: ''
1669
Error	1292	Truncated incorrect DECIMAL value: ''
1670
select right('hello', -18446744073709551617);
1671
right('hello', -18446744073709551617)
1672
1673
Warnings:
1674
Error	1292	Truncated incorrect DECIMAL value: ''
1675
Error	1292	Truncated incorrect DECIMAL value: ''
1676
select right('hello', 18446744073709551617);
1677
right('hello', 18446744073709551617)
1678
hello
1679
Warnings:
1680
Error	1292	Truncated incorrect DECIMAL value: ''
1681
Error	1292	Truncated incorrect DECIMAL value: ''
1682
select substring('hello', 2, -1);
1683
substring('hello', 2, -1)
1684
1685
select substring('hello', -1, 1);
1686
substring('hello', -1, 1)
1687
o
1688
select substring('hello', -2, 1);
1689
substring('hello', -2, 1)
1690
l
1691
select substring('hello', -4294967295, 1);
1692
substring('hello', -4294967295, 1)
1693
1694
select substring('hello', 4294967295, 1);
1695
substring('hello', 4294967295, 1)
1696
1697
select substring('hello', -4294967296, 1);
1698
substring('hello', -4294967296, 1)
1699
1700
select substring('hello', 4294967296, 1);
1701
substring('hello', 4294967296, 1)
1702
1703
select substring('hello', -4294967297, 1);
1704
substring('hello', -4294967297, 1)
1705
1706
select substring('hello', 4294967297, 1);
1707
substring('hello', 4294967297, 1)
1708
1709
select substring('hello', -18446744073709551615, 1);
1710
substring('hello', -18446744073709551615, 1)
1711
1712
Warnings:
1713
Error	1292	Truncated incorrect DECIMAL value: ''
1714
Error	1292	Truncated incorrect DECIMAL value: ''
1715
select substring('hello', 18446744073709551615, 1);
1716
substring('hello', 18446744073709551615, 1)
1717
1718
select substring('hello', -18446744073709551616, 1);
1719
substring('hello', -18446744073709551616, 1)
1720
1721
Warnings:
1722
Error	1292	Truncated incorrect DECIMAL value: ''
1723
Error	1292	Truncated incorrect DECIMAL value: ''
1724
select substring('hello', 18446744073709551616, 1);
1725
substring('hello', 18446744073709551616, 1)
1726
1727
Warnings:
1728
Error	1292	Truncated incorrect DECIMAL value: ''
1729
Error	1292	Truncated incorrect DECIMAL value: ''
1730
select substring('hello', -18446744073709551617, 1);
1731
substring('hello', -18446744073709551617, 1)
1732
1733
Warnings:
1734
Error	1292	Truncated incorrect DECIMAL value: ''
1735
Error	1292	Truncated incorrect DECIMAL value: ''
1736
select substring('hello', 18446744073709551617, 1);
1737
substring('hello', 18446744073709551617, 1)
1738
1739
Warnings:
1740
Error	1292	Truncated incorrect DECIMAL value: ''
1741
Error	1292	Truncated incorrect DECIMAL value: ''
1742
select substring('hello', 1, -1);
1743
substring('hello', 1, -1)
1744
1745
select substring('hello', 1, -4294967295);
1746
substring('hello', 1, -4294967295)
1747
1748
select substring('hello', 1, 4294967295);
1749
substring('hello', 1, 4294967295)
1750
hello
1751
select substring('hello', 1, -4294967296);
1752
substring('hello', 1, -4294967296)
1753
1754
select substring('hello', 1, 4294967296);
1755
substring('hello', 1, 4294967296)
1756
hello
1757
select substring('hello', 1, -4294967297);
1758
substring('hello', 1, -4294967297)
1759
1760
select substring('hello', 1, 4294967297);
1761
substring('hello', 1, 4294967297)
1762
hello
1763
select substring('hello', 1, -18446744073709551615);
1764
substring('hello', 1, -18446744073709551615)
1765
1766
Warnings:
1767
Error	1292	Truncated incorrect DECIMAL value: ''
1768
Error	1292	Truncated incorrect DECIMAL value: ''
1769
select substring('hello', 1, 18446744073709551615);
1770
substring('hello', 1, 18446744073709551615)
1771
hello
1772
select substring('hello', 1, -18446744073709551616);
1773
substring('hello', 1, -18446744073709551616)
1774
1775
Warnings:
1776
Error	1292	Truncated incorrect DECIMAL value: ''
1777
Error	1292	Truncated incorrect DECIMAL value: ''
1778
select substring('hello', 1, 18446744073709551616);
1779
substring('hello', 1, 18446744073709551616)
1780
hello
1781
Warnings:
1782
Error	1292	Truncated incorrect DECIMAL value: ''
1783
Error	1292	Truncated incorrect DECIMAL value: ''
1784
select substring('hello', 1, -18446744073709551617);
1785
substring('hello', 1, -18446744073709551617)
1786
1787
Warnings:
1788
Error	1292	Truncated incorrect DECIMAL value: ''
1789
Error	1292	Truncated incorrect DECIMAL value: ''
1790
select substring('hello', 1, 18446744073709551617);
1791
substring('hello', 1, 18446744073709551617)
1792
hello
1793
Warnings:
1794
Error	1292	Truncated incorrect DECIMAL value: ''
1795
Error	1292	Truncated incorrect DECIMAL value: ''
1796
select substring('hello', -1, -1);
1797
substring('hello', -1, -1)
1798
1799
select substring('hello', -4294967295, -4294967295);
1800
substring('hello', -4294967295, -4294967295)
1801
1802
select substring('hello', 4294967295, 4294967295);
1803
substring('hello', 4294967295, 4294967295)
1804
1805
select substring('hello', -4294967296, -4294967296);
1806
substring('hello', -4294967296, -4294967296)
1807
1808
select substring('hello', 4294967296, 4294967296);
1809
substring('hello', 4294967296, 4294967296)
1810
1811
select substring('hello', -4294967297, -4294967297);
1812
substring('hello', -4294967297, -4294967297)
1813
1814
select substring('hello', 4294967297, 4294967297);
1815
substring('hello', 4294967297, 4294967297)
1816
1817
select substring('hello', -18446744073709551615, -18446744073709551615);
1818
substring('hello', -18446744073709551615, -18446744073709551615)
1819
1820
Warnings:
1821
Error	1292	Truncated incorrect DECIMAL value: ''
1822
Error	1292	Truncated incorrect DECIMAL value: ''
1823
Error	1292	Truncated incorrect DECIMAL value: ''
1824
Error	1292	Truncated incorrect DECIMAL value: ''
1825
select substring('hello', 18446744073709551615, 18446744073709551615);
1826
substring('hello', 18446744073709551615, 18446744073709551615)
1827
1828
select substring('hello', -18446744073709551616, -18446744073709551616);
1829
substring('hello', -18446744073709551616, -18446744073709551616)
1830
1831
Warnings:
1832
Error	1292	Truncated incorrect DECIMAL value: ''
1833
Error	1292	Truncated incorrect DECIMAL value: ''
1834
Error	1292	Truncated incorrect DECIMAL value: ''
1835
Error	1292	Truncated incorrect DECIMAL value: ''
1836
select substring('hello', 18446744073709551616, 18446744073709551616);
1837
substring('hello', 18446744073709551616, 18446744073709551616)
1838
1839
Warnings:
1840
Error	1292	Truncated incorrect DECIMAL value: ''
1841
Error	1292	Truncated incorrect DECIMAL value: ''
1842
Error	1292	Truncated incorrect DECIMAL value: ''
1843
Error	1292	Truncated incorrect DECIMAL value: ''
1844
select substring('hello', -18446744073709551617, -18446744073709551617);
1845
substring('hello', -18446744073709551617, -18446744073709551617)
1846
1847
Warnings:
1848
Error	1292	Truncated incorrect DECIMAL value: ''
1849
Error	1292	Truncated incorrect DECIMAL value: ''
1850
Error	1292	Truncated incorrect DECIMAL value: ''
1851
Error	1292	Truncated incorrect DECIMAL value: ''
1852
select substring('hello', 18446744073709551617, 18446744073709551617);
1853
substring('hello', 18446744073709551617, 18446744073709551617)
1854
1855
Warnings:
1856
Error	1292	Truncated incorrect DECIMAL value: ''
1857
Error	1292	Truncated incorrect DECIMAL value: ''
1858
Error	1292	Truncated incorrect DECIMAL value: ''
1859
Error	1292	Truncated incorrect DECIMAL value: ''
1860
select insert('hello', -1, 1, 'hi');
1861
insert('hello', -1, 1, 'hi')
1862
hello
1863
select insert('hello', -4294967295, 1, 'hi');
1864
insert('hello', -4294967295, 1, 'hi')
1865
hello
1866
select insert('hello', 4294967295, 1, 'hi');
1867
insert('hello', 4294967295, 1, 'hi')
1868
hello
1869
select insert('hello', -4294967296, 1, 'hi');
1870
insert('hello', -4294967296, 1, 'hi')
1871
hello
1872
select insert('hello', 4294967296, 1, 'hi');
1873
insert('hello', 4294967296, 1, 'hi')
1874
hello
1875
select insert('hello', -4294967297, 1, 'hi');
1876
insert('hello', -4294967297, 1, 'hi')
1877
hello
1878
select insert('hello', 4294967297, 1, 'hi');
1879
insert('hello', 4294967297, 1, 'hi')
1880
hello
1881
select insert('hello', -18446744073709551615, 1, 'hi');
1882
insert('hello', -18446744073709551615, 1, 'hi')
1883
hello
1884
Warnings:
1885
Error	1292	Truncated incorrect DECIMAL value: ''
1886
select insert('hello', 18446744073709551615, 1, 'hi');
1887
insert('hello', 18446744073709551615, 1, 'hi')
1888
hello
1889
select insert('hello', -18446744073709551616, 1, 'hi');
1890
insert('hello', -18446744073709551616, 1, 'hi')
1891
hello
1892
Warnings:
1893
Error	1292	Truncated incorrect DECIMAL value: ''
1894
select insert('hello', 18446744073709551616, 1, 'hi');
1895
insert('hello', 18446744073709551616, 1, 'hi')
1896
hello
1897
Warnings:
1898
Error	1292	Truncated incorrect DECIMAL value: ''
1899
select insert('hello', -18446744073709551617, 1, 'hi');
1900
insert('hello', -18446744073709551617, 1, 'hi')
1901
hello
1902
Warnings:
1903
Error	1292	Truncated incorrect DECIMAL value: ''
1904
select insert('hello', 18446744073709551617, 1, 'hi');
1905
insert('hello', 18446744073709551617, 1, 'hi')
1906
hello
1907
Warnings:
1908
Error	1292	Truncated incorrect DECIMAL value: ''
1909
select insert('hello', 1, -1, 'hi');
1910
insert('hello', 1, -1, 'hi')
1911
hi
1912
select insert('hello', 1, -4294967295, 'hi');
1913
insert('hello', 1, -4294967295, 'hi')
1914
hi
1915
select insert('hello', 1, 4294967295, 'hi');
1916
insert('hello', 1, 4294967295, 'hi')
1917
hi
1918
select insert('hello', 1, -4294967296, 'hi');
1919
insert('hello', 1, -4294967296, 'hi')
1920
hi
1921
select insert('hello', 1, 4294967296, 'hi');
1922
insert('hello', 1, 4294967296, 'hi')
1923
hi
1924
select insert('hello', 1, -4294967297, 'hi');
1925
insert('hello', 1, -4294967297, 'hi')
1926
hi
1927
select insert('hello', 1, 4294967297, 'hi');
1928
insert('hello', 1, 4294967297, 'hi')
1929
hi
1930
select insert('hello', 1, -18446744073709551615, 'hi');
1931
insert('hello', 1, -18446744073709551615, 'hi')
1932
hi
1933
Warnings:
1934
Error	1292	Truncated incorrect DECIMAL value: ''
1935
select insert('hello', 1, 18446744073709551615, 'hi');
1936
insert('hello', 1, 18446744073709551615, 'hi')
1937
hi
1938
select insert('hello', 1, -18446744073709551616, 'hi');
1939
insert('hello', 1, -18446744073709551616, 'hi')
1940
hi
1941
Warnings:
1942
Error	1292	Truncated incorrect DECIMAL value: ''
1943
select insert('hello', 1, 18446744073709551616, 'hi');
1944
insert('hello', 1, 18446744073709551616, 'hi')
1945
hi
1946
Warnings:
1947
Error	1292	Truncated incorrect DECIMAL value: ''
1948
select insert('hello', 1, -18446744073709551617, 'hi');
1949
insert('hello', 1, -18446744073709551617, 'hi')
1950
hi
1951
Warnings:
1952
Error	1292	Truncated incorrect DECIMAL value: ''
1953
select insert('hello', 1, 18446744073709551617, 'hi');
1954
insert('hello', 1, 18446744073709551617, 'hi')
1955
hi
1956
Warnings:
1957
Error	1292	Truncated incorrect DECIMAL value: ''
1958
select insert('hello', -1, -1, 'hi');
1959
insert('hello', -1, -1, 'hi')
1960
hello
1961
select insert('hello', -4294967295, -4294967295, 'hi');
1962
insert('hello', -4294967295, -4294967295, 'hi')
1963
hello
1964
select insert('hello', 4294967295, 4294967295, 'hi');
1965
insert('hello', 4294967295, 4294967295, 'hi')
1966
hello
1967
select insert('hello', -4294967296, -4294967296, 'hi');
1968
insert('hello', -4294967296, -4294967296, 'hi')
1969
hello
1970
select insert('hello', 4294967296, 4294967296, 'hi');
1971
insert('hello', 4294967296, 4294967296, 'hi')
1972
hello
1973
select insert('hello', -4294967297, -4294967297, 'hi');
1974
insert('hello', -4294967297, -4294967297, 'hi')
1975
hello
1976
select insert('hello', 4294967297, 4294967297, 'hi');
1977
insert('hello', 4294967297, 4294967297, 'hi')
1978
hello
1979
select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
1980
insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
1981
hello
1982
Warnings:
1983
Error	1292	Truncated incorrect DECIMAL value: ''
1984
Error	1292	Truncated incorrect DECIMAL value: ''
1985
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
1986
insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
1987
hello
1988
select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
1989
insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
1990
hello
1991
Warnings:
1992
Error	1292	Truncated incorrect DECIMAL value: ''
1993
Error	1292	Truncated incorrect DECIMAL value: ''
1994
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
1995
insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
1996
hello
1997
Warnings:
1998
Error	1292	Truncated incorrect DECIMAL value: ''
1999
Error	1292	Truncated incorrect DECIMAL value: ''
2000
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
2001
insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
2002
hello
2003
Warnings:
2004
Error	1292	Truncated incorrect DECIMAL value: ''
2005
Error	1292	Truncated incorrect DECIMAL value: ''
2006
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
2007
insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
2008
hello
2009
Warnings:
2010
Error	1292	Truncated incorrect DECIMAL value: ''
2011
Error	1292	Truncated incorrect DECIMAL value: ''
2012
select repeat('hello', -1);
2013
repeat('hello', -1)
2014
2015
select repeat('hello', -4294967295);
2016
repeat('hello', -4294967295)
2017
2018
select repeat('hello', 4294967295);
2019
repeat('hello', 4294967295)
2020
NULL
2021
Warnings:
2022
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2023
select repeat('hello', -4294967296);
2024
repeat('hello', -4294967296)
2025
2026
select repeat('hello', 4294967296);
2027
repeat('hello', 4294967296)
2028
NULL
2029
Warnings:
2030
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2031
select repeat('hello', -4294967297);
2032
repeat('hello', -4294967297)
2033
2034
select repeat('hello', 4294967297);
2035
repeat('hello', 4294967297)
2036
NULL
2037
Warnings:
2038
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2039
select repeat('hello', -18446744073709551615);
2040
repeat('hello', -18446744073709551615)
2041
2042
Warnings:
2043
Error	1292	Truncated incorrect DECIMAL value: ''
2044
Error	1292	Truncated incorrect DECIMAL value: ''
2045
select repeat('hello', 18446744073709551615);
2046
repeat('hello', 18446744073709551615)
2047
NULL
2048
Warnings:
2049
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2050
select repeat('hello', -18446744073709551616);
2051
repeat('hello', -18446744073709551616)
2052
2053
Warnings:
2054
Error	1292	Truncated incorrect DECIMAL value: ''
2055
Error	1292	Truncated incorrect DECIMAL value: ''
2056
select repeat('hello', 18446744073709551616);
2057
repeat('hello', 18446744073709551616)
2058
NULL
2059
Warnings:
2060
Error	1292	Truncated incorrect DECIMAL value: ''
2061
Error	1292	Truncated incorrect DECIMAL value: ''
2062
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2063
select repeat('hello', -18446744073709551617);
2064
repeat('hello', -18446744073709551617)
2065
2066
Warnings:
2067
Error	1292	Truncated incorrect DECIMAL value: ''
2068
Error	1292	Truncated incorrect DECIMAL value: ''
2069
select repeat('hello', 18446744073709551617);
2070
repeat('hello', 18446744073709551617)
2071
NULL
2072
Warnings:
2073
Error	1292	Truncated incorrect DECIMAL value: ''
2074
Error	1292	Truncated incorrect DECIMAL value: ''
2075
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2076
select space(-1);
2077
space(-1)
2078
2079
select space(-4294967295);
2080
space(-4294967295)
2081
2082
select space(4294967295);
2083
space(4294967295)
2084
NULL
2085
Warnings:
2086
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2087
select space(-4294967296);
2088
space(-4294967296)
2089
2090
select space(4294967296);
2091
space(4294967296)
2092
NULL
2093
Warnings:
2094
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2095
select space(-4294967297);
2096
space(-4294967297)
2097
2098
select space(4294967297);
2099
space(4294967297)
2100
NULL
2101
Warnings:
2102
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2103
select space(-18446744073709551615);
2104
space(-18446744073709551615)
2105
2106
Warnings:
2107
Error	1292	Truncated incorrect DECIMAL value: ''
2108
Error	1292	Truncated incorrect DECIMAL value: ''
2109
select space(18446744073709551615);
2110
space(18446744073709551615)
2111
NULL
2112
Warnings:
2113
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2114
select space(-18446744073709551616);
2115
space(-18446744073709551616)
2116
2117
Warnings:
2118
Error	1292	Truncated incorrect DECIMAL value: ''
2119
Error	1292	Truncated incorrect DECIMAL value: ''
2120
select space(18446744073709551616);
2121
space(18446744073709551616)
2122
NULL
2123
Warnings:
2124
Error	1292	Truncated incorrect DECIMAL value: ''
2125
Error	1292	Truncated incorrect DECIMAL value: ''
2126
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2127
select space(-18446744073709551617);
2128
space(-18446744073709551617)
2129
2130
Warnings:
2131
Error	1292	Truncated incorrect DECIMAL value: ''
2132
Error	1292	Truncated incorrect DECIMAL value: ''
2133
select space(18446744073709551617);
2134
space(18446744073709551617)
2135
NULL
2136
Warnings:
2137
Error	1292	Truncated incorrect DECIMAL value: ''
2138
Error	1292	Truncated incorrect DECIMAL value: ''
2139
Warning	1301	Result of repeat() was larger than max_allowed_packet (1048576) - truncated
2140
select rpad('hello', -1, '1');
2141
rpad('hello', -1, '1')
2142
NULL
2143
select rpad('hello', -4294967295, '1');
2144
rpad('hello', -4294967295, '1')
2145
NULL
2146
select rpad('hello', 4294967295, '1');
2147
rpad('hello', 4294967295, '1')
2148
NULL
2149
Warnings:
2150
Warning	1301	Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2151
select rpad('hello', -4294967296, '1');
2152
rpad('hello', -4294967296, '1')
2153
NULL
2154
select rpad('hello', 4294967296, '1');
2155
rpad('hello', 4294967296, '1')
2156
NULL
2157
Warnings:
2158
Warning	1301	Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2159
select rpad('hello', -4294967297, '1');
2160
rpad('hello', -4294967297, '1')
2161
NULL
2162
select rpad('hello', 4294967297, '1');
2163
rpad('hello', 4294967297, '1')
2164
NULL
2165
Warnings:
2166
Warning	1301	Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2167
select rpad('hello', -18446744073709551615, '1');
2168
rpad('hello', -18446744073709551615, '1')
2169
NULL
2170
Warnings:
2171
Error	1292	Truncated incorrect DECIMAL value: ''
2172
Error	1292	Truncated incorrect DECIMAL value: ''
2173
select rpad('hello', 18446744073709551615, '1');
2174
rpad('hello', 18446744073709551615, '1')
2175
NULL
2176
Warnings:
2177
Warning	1301	Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2178
select rpad('hello', -18446744073709551616, '1');
2179
rpad('hello', -18446744073709551616, '1')
2180
NULL
2181
Warnings:
2182
Error	1292	Truncated incorrect DECIMAL value: ''
2183
Error	1292	Truncated incorrect DECIMAL value: ''
2184
select rpad('hello', 18446744073709551616, '1');
2185
rpad('hello', 18446744073709551616, '1')
2186
NULL
2187
Warnings:
2188
Error	1292	Truncated incorrect DECIMAL value: ''
2189
Error	1292	Truncated incorrect DECIMAL value: ''
2190
Warning	1301	Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2191
select rpad('hello', -18446744073709551617, '1');
2192
rpad('hello', -18446744073709551617, '1')
2193
NULL
2194
Warnings:
2195
Error	1292	Truncated incorrect DECIMAL value: ''
2196
Error	1292	Truncated incorrect DECIMAL value: ''
2197
select rpad('hello', 18446744073709551617, '1');
2198
rpad('hello', 18446744073709551617, '1')
2199
NULL
2200
Warnings:
2201
Error	1292	Truncated incorrect DECIMAL value: ''
2202
Error	1292	Truncated incorrect DECIMAL value: ''
2203
Warning	1301	Result of rpad() was larger than max_allowed_packet (1048576) - truncated
2204
select lpad('hello', -1, '1');
2205
lpad('hello', -1, '1')
2206
NULL
2207
select lpad('hello', -4294967295, '1');
2208
lpad('hello', -4294967295, '1')
2209
NULL
2210
select lpad('hello', 4294967295, '1');
2211
lpad('hello', 4294967295, '1')
2212
NULL
2213
Warnings:
2214
Warning	1301	Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2215
select lpad('hello', -4294967296, '1');
2216
lpad('hello', -4294967296, '1')
2217
NULL
2218
select lpad('hello', 4294967296, '1');
2219
lpad('hello', 4294967296, '1')
2220
NULL
2221
Warnings:
2222
Warning	1301	Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2223
select lpad('hello', -4294967297, '1');
2224
lpad('hello', -4294967297, '1')
2225
NULL
2226
select lpad('hello', 4294967297, '1');
2227
lpad('hello', 4294967297, '1')
2228
NULL
2229
Warnings:
2230
Warning	1301	Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2231
select lpad('hello', -18446744073709551615, '1');
2232
lpad('hello', -18446744073709551615, '1')
2233
NULL
2234
Warnings:
2235
Error	1292	Truncated incorrect DECIMAL value: ''
2236
Error	1292	Truncated incorrect DECIMAL value: ''
2237
select lpad('hello', 18446744073709551615, '1');
2238
lpad('hello', 18446744073709551615, '1')
2239
NULL
2240
Warnings:
2241
Warning	1301	Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2242
select lpad('hello', -18446744073709551616, '1');
2243
lpad('hello', -18446744073709551616, '1')
2244
NULL
2245
Warnings:
2246
Error	1292	Truncated incorrect DECIMAL value: ''
2247
Error	1292	Truncated incorrect DECIMAL value: ''
2248
select lpad('hello', 18446744073709551616, '1');
2249
lpad('hello', 18446744073709551616, '1')
2250
NULL
2251
Warnings:
2252
Error	1292	Truncated incorrect DECIMAL value: ''
2253
Error	1292	Truncated incorrect DECIMAL value: ''
2254
Warning	1301	Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2255
select lpad('hello', -18446744073709551617, '1');
2256
lpad('hello', -18446744073709551617, '1')
2257
NULL
2258
Warnings:
2259
Error	1292	Truncated incorrect DECIMAL value: ''
2260
Error	1292	Truncated incorrect DECIMAL value: ''
2261
select lpad('hello', 18446744073709551617, '1');
2262
lpad('hello', 18446744073709551617, '1')
2263
NULL
2264
Warnings:
2265
Error	1292	Truncated incorrect DECIMAL value: ''
2266
Error	1292	Truncated incorrect DECIMAL value: ''
2267
Warning	1301	Result of lpad() was larger than max_allowed_packet (1048576) - truncated
2268
SET @orig_sql_mode = @@SQL_MODE;
2269
SET SQL_MODE=traditional;
2270
SELECT CHAR(0xff,0x8f USING utf8);
2271
CHAR(0xff,0x8f USING utf8)
2272
NULL
2273
Warnings:
2274
Error	1300	Invalid utf8 character string: 'FF8F'
2275
SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
2276
CHAR(0xff,0x8f USING utf8) IS NULL
2277
1
2278
Warnings:
2279
Error	1300	Invalid utf8 character string: 'FF8F'
2280
SET SQL_MODE=@orig_sql_mode;
2281
select substring('abc', cast(2 as unsigned int));
2282
substring('abc', cast(2 as unsigned int))
2283
bc
2284
select repeat('a', cast(2 as unsigned int));
2285
repeat('a', cast(2 as unsigned int))
2286
aa
2287
select rpad('abc', cast(5 as unsigned integer), 'x');
2288
rpad('abc', cast(5 as unsigned integer), 'x')
2289
abcxx
2290
select lpad('abc', cast(5 as unsigned integer), 'x');
2291
lpad('abc', cast(5 as unsigned integer), 'x')
2292
xxabc
2293
create table t1(f1 longtext);
2294
insert into t1 values ("123"),("456");
2295
select substring(f1,1,1) from t1 group by 1;
2296
substring(f1,1,1)
2297
1
2298
4
2299
create table t2(f1 varchar(3));
2300
insert into t1 values ("123"),("456");
2301
select substring(f1,4,1), substring(f1,-4,1) from t2;
2302
substring(f1,4,1)	substring(f1,-4,1)
2303
drop table t1,t2;
2304
DROP TABLE IF EXISTS t1;
2305
CREATE TABLE `t1` (
2306
`id` varchar(20) NOT NULL,
2307
`tire` tinyint(3) unsigned NOT NULL,
2308
PRIMARY KEY (`id`)
2309
);
2310
INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2);
2311
SELECT REPEAT( '#', tire ) AS A,
2312
REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`;
2313
A	B	tire
2314
		0
2315
#	#	1
2316
##	##	2
2317
SELECT REPEAT('0', CAST(0 AS UNSIGNED));
2318
REPEAT('0', CAST(0 AS UNSIGNED))
2319
2320
SELECT REPEAT('0', -2);
2321
REPEAT('0', -2)
2322
2323
SELECT REPEAT('0', 2);
2324
REPEAT('0', 2)
2325
00
2326
DROP TABLE t1;
2327
SELECT UNHEX('G');
2328
UNHEX('G')
2329
NULL
2330
SELECT UNHEX('G') IS NULL;
2331
UNHEX('G') IS NULL
2332
1
2333
SELECT INSERT('abc', 3, 3, '1234');
2334
INSERT('abc', 3, 3, '1234')
2335
ab1234
2336
SELECT INSERT('abc', 4, 3, '1234');
2337
INSERT('abc', 4, 3, '1234')
2338
abc1234
2339
SELECT INSERT('abc', 5, 3, '1234');
2340
INSERT('abc', 5, 3, '1234')
2341
abc
2342
SELECT INSERT('abc', 6, 3, '1234');
2343
INSERT('abc', 6, 3, '1234')
2344
abc
2345
CREATE TABLE t1 (a INT);
2346
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
2347
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
2348
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
2349
CRC32(a)	COUNT(*)
2350
450215437	1
2351
498629140	1
2352
1790921346	1
2353
1842515611	1
2354
2212294583	1
2355
2226203566	1
2356
2366072709	1
2357
2707236321	1
2358
4088798008	1
2359
4194326291	1
2360
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
2361
CRC32(a)	COUNT(*)
2362
450215437	1
2363
498629140	1
2364
1790921346	1
2365
1842515611	1
2366
2212294583	1
2367
2226203566	1
2368
2366072709	1
2369
2707236321	1
2370
4088798008	1
2371
4194326291	1
2372
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
2373
CRC32(a)
2374
2212294583
2375
450215437
2376
1842515611
2377
4088798008
2378
2226203566
2379
498629140
2380
1790921346
2381
4194326291
2382
2366072709
2383
2707236321
2384
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
2385
desc t2;
2386
Field	Type	Null	Key	Default	Extra
2387
CRC32(a)	int(10) unsigned	YES		NULL	
2388
SELECT * FROM v1;
2389
C
2390
2212294583
2391
450215437
2392
1842515611
2393
4088798008
2394
2226203566
2395
498629140
2396
1790921346
2397
4194326291
2398
2366072709
2399
2707236321
2400
SELECT * FROM (SELECT * FROM v1) x;
2401
C
2402
2212294583
2403
450215437
2404
1842515611
2405
4088798008
2406
2226203566
2407
498629140
2408
1790921346
2409
4194326291
2410
2366072709
2411
2707236321
2412
DROP TABLE t1, t2;
2413
DROP VIEW v1;
2414
SELECT LOCATE('foo', NULL) FROM DUAL;
2415
LOCATE('foo', NULL)
2416
NULL
2417
SELECT LOCATE(NULL, 'o') FROM DUAL;
2418
LOCATE(NULL, 'o')
2419
NULL
2420
SELECT LOCATE(NULL, NULL) FROM DUAL;
2421
LOCATE(NULL, NULL)
2422
NULL
2423
SELECT LOCATE('foo', NULL) IS NULL FROM DUAL;
2424
LOCATE('foo', NULL) IS NULL
2425
1
2426
SELECT LOCATE(NULL, 'o') IS NULL FROM DUAL;
2427
LOCATE(NULL, 'o') IS NULL
2428
1
2429
SELECT LOCATE(NULL, NULL) IS NULL FROM DUAL;
2430
LOCATE(NULL, NULL) IS NULL
2431
1
2432
SELECT ISNULL(LOCATE('foo', NULL)) FROM DUAL;
2433
ISNULL(LOCATE('foo', NULL))
2434
1
2435
SELECT ISNULL(LOCATE(NULL, 'o')) FROM DUAL;
2436
ISNULL(LOCATE(NULL, 'o'))
2437
1
2438
SELECT ISNULL(LOCATE(NULL, NULL)) FROM DUAL;
2439
ISNULL(LOCATE(NULL, NULL))
2440
1
2441
SELECT LOCATE('foo', NULL) <=> NULL FROM DUAL;
2442
LOCATE('foo', NULL) <=> NULL
2443
1
2444
SELECT LOCATE(NULL, 'o') <=> NULL FROM DUAL;
2445
LOCATE(NULL, 'o') <=> NULL
2446
1
2447
SELECT LOCATE(NULL, NULL) <=> NULL FROM DUAL;
2448
LOCATE(NULL, NULL) <=> NULL
2449
1
2450
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a varchar(10), p varchar(10));
2451
INSERT INTO t1 VALUES (1, 'foo', 'o');
2452
INSERT INTO t1 VALUES (2, 'foo', NULL);
2453
INSERT INTO t1 VALUES (3, NULL, 'o');
2454
INSERT INTO t1 VALUES (4, NULL, NULL);
2455
SELECT id, LOCATE(a,p) FROM t1;
2456
id	LOCATE(a,p)
2457
1	0
2458
2	NULL
2459
3	NULL
2460
4	NULL
2461
SELECT id, LOCATE(a,p) IS NULL FROM t1;
2462
id	LOCATE(a,p) IS NULL
2463
1	0
2464
2	1
2465
3	1
2466
4	1
2467
SELECT id, ISNULL(LOCATE(a,p)) FROM t1;
2468
id	ISNULL(LOCATE(a,p))
2469
1	0
2470
2	1
2471
3	1
2472
4	1
2473
SELECT id, LOCATE(a,p) <=> NULL FROM t1;
2474
id	LOCATE(a,p) <=> NULL
2475
1	0
2476
2	1
2477
3	1
2478
4	1
2479
SELECT id FROM t1 WHERE LOCATE(a,p) IS NULL;
2480
id
2481
2
2482
3
2483
4
2484
SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
2485
id
2486
2
2487
3
2488
4
2489
DROP TABLE t1;
2490
SELECT SUBSTR('foo',1,0) FROM DUAL;
2491
SUBSTR('foo',1,0)
2492
2493
SELECT SUBSTR('foo',1,CAST(0 AS SIGNED)) FROM DUAL;
2494
SUBSTR('foo',1,CAST(0 AS SIGNED))
2495
2496
SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED)) FROM DUAL;
2497
SUBSTR('foo',1,CAST(0 AS UNSIGNED))
2498
2499
CREATE TABLE t1 (a varchar(10), len int unsigned);
2500
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
2501
SELECT SUBSTR(a,1,len) FROM t1;
2502
SUBSTR(a,1,len)
2503
ba
2504
2505
DROP TABLE t1;
2506
CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1;
2507
SELECT HEX(c1) from t1;
2508
HEX(c1)
2509
414243
2510
DROP TABLE t1;
2511
CREATE VIEW v1 AS SELECT CHAR(0x414243) as c1;
2512
SELECT HEX(c1) from v1;
2513
HEX(c1)
2514
414243
2515
DROP VIEW v1;
2516
End of 5.0 tests