~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/r/pbxt/func_str.result

Remove dead memset call.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
drop table if exists t1,t2;
 
2
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
 
3
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
select 'hello' 'monty';
 
6
hello
 
7
hellomonty
 
8
select length('\n\t\r\b\0\_\%\\');
 
9
length('\n\t\r\b\0\_\%\\')
 
10
10
 
11
select char_length('\n\t\r\b\0\_\%\\');
 
12
char_length('\n\t\r\b\0\_\%\\')
 
13
10
 
14
select character_length('\n\t\r\b\0\_\%\\');
 
15
character_length('\n\t\r\b\0\_\%\\')
 
16
10
 
17
select length('\n\t\n\b\0\\_\\%\\');
 
18
length('\n\t\n\b\0\\_\\%\\')
 
19
10
 
20
select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
 
21
concat('monty',' was here ','again')    length('hello') char(ascii('h'))        ord('h')
 
22
monty was here again    5       h       104
 
23
select hex(char(256));
 
24
hex(char(256))
 
25
0100
 
26
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
 
27
locate('he','hello')    locate('he','hello',2)  locate('lo','hello',2)
 
28
1       0       4
 
29
select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE');
 
30
instr('hello','HE')     instr('hello',binary 'HE')      instr(binary 'hello','HE')
 
31
1       0       0
 
32
select position(binary 'll' in 'hello'),position('a' in binary 'hello');
 
33
position(binary 'll' in 'hello')        position('a' in binary 'hello')
 
34
3       0
 
35
select left('hello',null), right('hello',null);
 
36
left('hello',null)      right('hello',null)
 
37
NULL    NULL
 
38
select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ;
 
39
left('hello',2) right('hello',2)        substring('hello',2,2)  mid('hello',1,5)
 
40
he      lo      el      hello
 
41
select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ;
 
42
concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1))
 
43
happy
 
44
select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1);
 
45
substring_index('www.tcx.se','.',-2)    substring_index('www.tcx.se','.',1)
 
46
tcx.se  www
 
47
select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1);
 
48
substring_index('www.tcx.se','tcx',1)   substring_index('www.tcx.se','tcx',-1)
 
49
www.    .se
 
50
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
 
51
substring_index('.tcx.se','.',-2)       substring_index('.tcx.se','.tcx',-1)
 
52
tcx.se  .se
 
53
select substring_index('aaaaaaaaa1','a',1);
 
54
substring_index('aaaaaaaaa1','a',1)
 
55
 
 
56
select substring_index('aaaaaaaaa1','aa',1);
 
57
substring_index('aaaaaaaaa1','aa',1)
 
58
 
 
59
select substring_index('aaaaaaaaa1','aa',2);
 
60
substring_index('aaaaaaaaa1','aa',2)
 
61
aa
 
62
select substring_index('aaaaaaaaa1','aa',3);
 
63
substring_index('aaaaaaaaa1','aa',3)
 
64
aaaa
 
65
select substring_index('aaaaaaaaa1','aa',4);
 
66
substring_index('aaaaaaaaa1','aa',4)
 
67
aaaaaa
 
68
select substring_index('aaaaaaaaa1','aa',5);
 
69
substring_index('aaaaaaaaa1','aa',5)
 
70
aaaaaaaaa1
 
71
select substring_index('aaaaaaaaa1','aaa',1);
 
72
substring_index('aaaaaaaaa1','aaa',1)
 
73
 
 
74
select substring_index('aaaaaaaaa1','aaa',2);
 
75
substring_index('aaaaaaaaa1','aaa',2)
 
76
aaa
 
77
select substring_index('aaaaaaaaa1','aaa',3);
 
78
substring_index('aaaaaaaaa1','aaa',3)
 
79
aaaaaa
 
80
select substring_index('aaaaaaaaa1','aaa',4);
 
81
substring_index('aaaaaaaaa1','aaa',4)
 
82
aaaaaaaaa1
 
83
select substring_index('aaaaaaaaa1','aaaa',1);
 
84
substring_index('aaaaaaaaa1','aaaa',1)
 
85
 
 
86
select substring_index('aaaaaaaaa1','aaaa',2);
 
87
substring_index('aaaaaaaaa1','aaaa',2)
 
88
aaaa
 
89
select substring_index('aaaaaaaaa1','1',1);
 
90
substring_index('aaaaaaaaa1','1',1)
 
91
aaaaaaaaa
 
92
select substring_index('aaaaaaaaa1','a',-1);
 
93
substring_index('aaaaaaaaa1','a',-1)
 
94
1
 
95
select substring_index('aaaaaaaaa1','aa',-1);
 
96
substring_index('aaaaaaaaa1','aa',-1)
 
97
a1
 
98
select substring_index('aaaaaaaaa1','aa',-2);
 
99
substring_index('aaaaaaaaa1','aa',-2)
 
100
aaa1
 
101
select substring_index('aaaaaaaaa1','aa',-3);
 
102
substring_index('aaaaaaaaa1','aa',-3)
 
103
aaaaa1
 
104
select substring_index('aaaaaaaaa1','aa',-4);
 
105
substring_index('aaaaaaaaa1','aa',-4)
 
106
aaaaaaa1
 
107
select substring_index('aaaaaaaaa1','aa',-5);
 
108
substring_index('aaaaaaaaa1','aa',-5)
 
109
aaaaaaaaa1
 
110
select substring_index('aaaaaaaaa1','aaa',-1);
 
111
substring_index('aaaaaaaaa1','aaa',-1)
 
112
1
 
113
select substring_index('aaaaaaaaa1','aaa',-2);
 
114
substring_index('aaaaaaaaa1','aaa',-2)
 
115
aaa1
 
116
select substring_index('aaaaaaaaa1','aaa',-3);
 
117
substring_index('aaaaaaaaa1','aaa',-3)
 
118
aaaaaa1
 
119
select substring_index('aaaaaaaaa1','aaa',-4);
 
120
substring_index('aaaaaaaaa1','aaa',-4)
 
121
aaaaaaaaa1
 
122
select substring_index('the king of thethe hill','the',-2);
 
123
substring_index('the king of thethe hill','the',-2)
 
124
the hill
 
125
select substring_index('the king of the the hill','the',-2);
 
126
substring_index('the king of the the hill','the',-2)
 
127
 the hill
 
128
select substring_index('the king of the  the hill','the',-2);
 
129
substring_index('the king of the  the hill','the',-2)
 
130
  the hill
 
131
select substring_index('the king of the  the hill',' the ',-1);
 
132
substring_index('the king of the  the hill',' the ',-1)
 
133
hill
 
134
select substring_index('the king of the  the hill',' the ',-2);
 
135
substring_index('the king of the  the hill',' the ',-2)
 
136
 the hill
 
137
select substring_index('the king of the  the hill',' ',-1);
 
138
substring_index('the king of the  the hill',' ',-1)
 
139
hill
 
140
select substring_index('the king of the  the hill',' ',-2);
 
141
substring_index('the king of the  the hill',' ',-2)
 
142
the hill
 
143
select substring_index('the king of the  the hill',' ',-3);
 
144
substring_index('the king of the  the hill',' ',-3)
 
145
 the hill
 
146
select substring_index('the king of the  the hill',' ',-4);
 
147
substring_index('the king of the  the hill',' ',-4)
 
148
the  the hill
 
149
select substring_index('the king of the  the hill',' ',-5);
 
150
substring_index('the king of the  the hill',' ',-5)
 
151
of the  the hill
 
152
select substring_index('the king of the.the hill','the',-2);
 
153
substring_index('the king of the.the hill','the',-2)
 
154
.the hill
 
155
select substring_index('the king of thethethe.the hill','the',-3);
 
156
substring_index('the king of thethethe.the hill','the',-3)
 
157
the.the hill
 
158
select substring_index('the king of thethethe.the hill','the',-1);
 
159
substring_index('the king of thethethe.the hill','the',-1)
 
160
 hill
 
161
select substring_index('the king of the the hill','the',1);
 
162
substring_index('the king of the the hill','the',1)
 
163
 
 
164
select substring_index('the king of the the hill','the',2);
 
165
substring_index('the king of the the hill','the',2)
 
166
the king of 
 
167
select substring_index('the king of the the hill','the',3);
 
168
substring_index('the king of the the hill','the',3)
 
169
the king of the 
 
170
select concat(':',ltrim('  left  '),':',rtrim('  right  '),':');
 
171
concat(':',ltrim('  left  '),':',rtrim('  right  '),':')
 
172
:left  :  right:
 
173
select concat(':',trim(leading from '  left  '),':',trim(trailing from '  right  '),':');
 
174
concat(':',trim(leading from '  left  '),':',trim(trailing from '  right  '),':')
 
175
:left  :  right:
 
176
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
 
177
concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':')
 
178
:left: right:
 
179
select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':');
 
180
concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':')
 
181
:m:y:s:
 
182
select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':');
 
183
concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':')
 
184
:my:sql:
 
185
select concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':');
 
186
concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':')
 
187
:my:sql:
 
188
select TRIM("foo" FROM "foo"), TRIM("foo" FROM "foook"), TRIM("foo" FROM "okfoo");
 
189
TRIM("foo" FROM "foo")  TRIM("foo" FROM "foook")        TRIM("foo" FROM "okfoo")
 
190
        ok      ok
 
191
select concat_ws(', ','monty','was here','again');
 
192
concat_ws(', ','monty','was here','again')
 
193
monty, was here, again
 
194
select concat_ws(NULL,'a'),concat_ws(',',NULL,'');
 
195
concat_ws(NULL,'a')     concat_ws(',',NULL,'')
 
196
NULL    
 
197
select concat_ws(',','',NULL,'a');
 
198
concat_ws(',','',NULL,'a')
 
199
,a
 
200
SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"');
 
201
CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"')
 
202
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
 
203
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
 
204
insert('txs',2,1,'hi')  insert('is ',4,0,'a')   insert('txxxxt',2,4,'es')
 
205
this    is a    test
 
206
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
 
207
replace('aaaa','a','b') replace('aaaa','aa','b')        replace('aaaa','a','bb')        replace('aaaa','','b')  replace('bbbb','a','c')
 
208
bbbb    bb      bbbbbbbb        aaaa    bbbb
 
209
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
 
210
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
 
211
this is a REAL test
 
212
select crc32("123");
 
213
crc32("123")
 
214
2286445522
 
215
select repeat('monty',5),concat('*',space(5),'*');
 
216
repeat('monty',5)       concat('*',space(5),'*')
 
217
montymontymontymontymonty       *     *
 
218
select reverse('abc'),reverse('abcd');
 
219
reverse('abc')  reverse('abcd')
 
220
cba     dcba
 
221
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
 
222
rpad('a',4,'1') rpad('a',4,'12')        rpad('abcd',3,'12')     rpad(11, 10 , 22)       rpad("ab", 10, 22)
 
223
a111    a121    abc     1122222222      ab22222222
 
224
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22);
 
225
lpad('a',4,'1') lpad('a',4,'12')        lpad('abcd',3,'12')     lpad(11, 10 , 22)
 
226
111a    121a    abc     2222222211
 
227
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
 
228
rpad(741653838,17,'0')  lpad(741653838,17,'0')
 
229
74165383800000000       00000000741653838
 
230
select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
 
231
rpad('abcd',7,'ab')     lpad('abcd',7,'ab')
 
232
abcdaba abaabcd
 
233
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
 
234
rpad('abcd',1,'ab')     lpad('abcd',1,'ab')
 
235
a       a
 
236
select rpad('STRING', 20, CONCAT('p','a','d') );
 
237
rpad('STRING', 20, CONCAT('p','a','d') )
 
238
STRINGpadpadpadpadpa
 
239
select lpad('STRING', 20, CONCAT('p','a','d') );
 
240
lpad('STRING', 20, CONCAT('p','a','d') )
 
241
padpadpadpadpaSTRING
 
242
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
 
243
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')     GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
 
244
NULL    NULL
 
245
select quote('\'\"\\test');
 
246
quote('\'\"\\test')
 
247
'\'"\\test'
 
248
select quote(concat('abc\'', '\\cba'));
 
249
quote(concat('abc\'', '\\cba'))
 
250
'abc\'\\cba'
 
251
select quote(1/0), quote('\0\Z');
 
252
quote(1/0)      quote('\0\Z')
 
253
NULL    '\0\Z'
 
254
Warnings:
 
255
Error   1365    Division by 0
 
256
select length(quote(concat(char(0),"test")));
 
257
length(quote(concat(char(0),"test")))
 
258
8
 
259
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
 
260
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
 
261
27E0E3E6E7E8EAEB27
 
262
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL);
 
263
unhex(hex("foobar"))    hex(unhex("1234567890ABCDEF"))  unhex("345678") unhex(NULL)
 
264
foobar  1234567890ABCDEF        4Vx     NULL
 
265
select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456"));
 
266
hex(unhex("1")) hex(unhex("12"))        hex(unhex("123"))       hex(unhex("1234"))      hex(unhex("12345"))     hex(unhex("123456"))
 
267
01      12      0123    1234    012345  123456
 
268
select concat('a', quote(NULL));
 
269
concat('a', quote(NULL))
 
270
aNULL
 
271
select reverse("");
 
272
reverse("")
 
273
 
 
274
select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
 
275
insert("aa",100,1,"b")  insert("aa",1,3,"b")    left("aa",-1)   substring("a",1,2)
 
276
aa      b               a
 
277
select elt(2,1),field(NULL,"a","b","c"),reverse("");
 
278
elt(2,1)        field(NULL,"a","b","c") reverse("")
 
279
NULL    0       
 
280
select locate("a","b",2),locate("","a",1);
 
281
locate("a","b",2)       locate("","a",1)
 
282
0       1
 
283
select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
 
284
ltrim("a")      rtrim("a")      trim(BOTH "" from "a")  trim(BOTH " " from "a")
 
285
a       a       a       a
 
286
select substring_index("www.tcx.se","",3);
 
287
substring_index("www.tcx.se","",3)
 
288
 
 
289
select length(repeat("a",100000000)),length(repeat("a",1000*64));
 
290
length(repeat("a",100000000))   length(repeat("a",1000*64))
 
291
NULL    64000
 
292
Warnings:
 
293
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
294
select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
 
295
position("0" in "baaa" in (1))  position("0" in "1" in (1,2,3)) position("sql" in ("mysql"))
 
296
1       0       3
 
297
Warnings:
 
298
Warning 1292    Truncated incorrect DOUBLE value: 'baaa'
 
299
select position(("1" in (1,2,3)) in "01");
 
300
position(("1" in (1,2,3)) in "01")
 
301
2
 
302
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)));
 
303
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)))
 
304
65500   64000   50000   60000
 
305
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)));
 
306
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)))
 
307
1000000 96000   160000  95000
 
308
create table t1 ( domain char(50) );
 
309
insert into t1 VALUES ("hello.de" ), ("test.de" );
 
310
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de';
 
311
domain
 
312
hello.de
 
313
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
 
314
domain
 
315
test.de
 
316
drop table t1;
 
317
CREATE TEMPORARY TABLE t1 (
 
318
id int NOT NULL,
 
319
title varchar(255) default NULL,
 
320
prio int default NULL,
 
321
category int default NULL,
 
322
program int default NULL,
 
323
bugdesc text,
 
324
created datetime default NULL,
 
325
modified timestamp NOT NULL,
 
326
bugstatus int default NULL,
 
327
submitter int default NULL
 
328
) ENGINE=MyISAM;
 
329
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
 
330
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"') FROM t1;
 
331
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter), '"')
 
332
"Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4"
 
333
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
 
334
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"')
 
335
"Link";"1";"1";"1";"0";"4"
 
336
SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter) FROM t1;
 
337
CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified+0,bugstatus,submitter)
 
338
Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4
 
339
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
 
340
bugdesc REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb')
 
341
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa      aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
342
drop table t1;
 
343
CREATE TEMPORARY TABLE t1 (id int NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) ENGINE=MyISAM;
 
344
INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
 
345
DROP TABLE t1;
 
346
CREATE TABLE t1 (
 
347
wid int NOT NULL auto_increment,
 
348
data_podp date default NULL,
 
349
status_wnio enum('nowy','podp','real','arch') NOT NULL default 'nowy',
 
350
PRIMARY KEY(wid)
 
351
);
 
352
INSERT INTO t1 VALUES (8,NULL,'real');
 
353
INSERT INTO t1 VALUES (9,NULL,'nowy');
 
354
SELECT elt(status_wnio,data_podp) FROM t1 GROUP BY wid;
 
355
elt(status_wnio,data_podp)
 
356
NULL
 
357
NULL
 
358
DROP TABLE t1;
 
359
CREATE TEMPORARY TABLE t1 (title text) ENGINE=MyISAM;
 
360
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
 
361
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
 
362
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
 
363
CONCAT("</a>",RPAD("",(55 - LENGTH(title)),"."))
 
364
NULL
 
365
</a>..........................
 
366
DROP TABLE t1;
 
367
CREATE TABLE t1 (i int, j int);
 
368
INSERT INTO t1 VALUES (1,1),(2,2);
 
369
SELECT DISTINCT i, ELT(j, '345', '34') FROM t1;
 
370
i       ELT(j, '345', '34')
 
371
1       345
 
372
2       34
 
373
DROP TABLE t1;
 
374
create table t1(a char(4));
 
375
insert into t1 values ('one'),(NULL),('two'),('four');
 
376
select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1;
 
377
a       quote(a)        isnull(quote(a))        quote(a) is null        ifnull(quote(a), 'n')
 
378
one     'one'   0       0       'one'
 
379
NULL    NULL    0       0       NULL
 
380
two     'two'   0       0       'two'
 
381
four    'four'  0       0       'four'
 
382
drop table t1;
 
383
select trim(trailing 'foo' from 'foo');
 
384
trim(trailing 'foo' from 'foo')
 
385
 
 
386
select trim(leading 'foo' from 'foo');
 
387
trim(leading 'foo' from 'foo')
 
388
 
 
389
select quote(ltrim(concat('    ', 'a')));
 
390
quote(ltrim(concat('    ', 'a')))
 
391
'a'
 
392
select quote(trim(concat('    ', 'a')));
 
393
quote(trim(concat('    ', 'a')))
 
394
'a'
 
395
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
 
396
SELECT QUOTE('A') FROM t1;
 
397
QUOTE('A')
 
398
'A'
 
399
'A'
 
400
'A'
 
401
DROP TABLE t1;
 
402
select SUBSTR('abcdefg',3,2);
 
403
SUBSTR('abcdefg',3,2)
 
404
cd
 
405
select SUBSTRING('abcdefg',3,2);
 
406
SUBSTRING('abcdefg',3,2)
 
407
cd
 
408
select SUBSTR('abcdefg',-3,2);
 
409
SUBSTR('abcdefg',-3,2)
 
410
ef
 
411
select SUBSTR('abcdefg',-1,5);
 
412
SUBSTR('abcdefg',-1,5)
 
413
g
 
414
select SUBSTR('abcdefg',0,0);
 
415
SUBSTR('abcdefg',0,0)
 
416
 
 
417
select SUBSTR('abcdefg',-1,-1);
 
418
SUBSTR('abcdefg',-1,-1)
 
419
 
 
420
select SUBSTR('abcdefg',1,-1);
 
421
SUBSTR('abcdefg',1,-1)
 
422
 
 
423
select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
 
424
substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)      substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2)
 
425
1abcd;2abcd     3abcd;4abcd
 
426
explain extended select concat('*',space(5),'*');
 
427
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
428
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
429
Warnings:
 
430
Note    1003    select concat('*',repeat(' ',5),'*') AS `concat('*',space(5),'*')`
 
431
explain extended select reverse('abc');
 
432
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
433
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
434
Warnings:
 
435
Note    1003    select reverse('abc') AS `reverse('abc')`
 
436
explain extended select rpad('a',4,'1');
 
437
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
438
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
439
Warnings:
 
440
Note    1003    select rpad('a',4,'1') AS `rpad('a',4,'1')`
 
441
explain extended select lpad('a',4,'1');
 
442
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
443
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
444
Warnings:
 
445
Note    1003    select lpad('a',4,'1') AS `lpad('a',4,'1')`
 
446
explain extended select concat_ws(',','',NULL,'a');
 
447
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
448
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
449
Warnings:
 
450
Note    1003    select concat_ws(',','',NULL,'a') AS `concat_ws(',','',NULL,'a')`
 
451
explain extended select elt(2,1);
 
452
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
453
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
454
Warnings:
 
455
Note    1003    select elt(2,1) AS `elt(2,1)`
 
456
explain extended select locate("a","b",2);
 
457
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
458
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
459
Warnings:
 
460
Note    1003    select locate('a','b',2) AS `locate("a","b",2)`
 
461
explain extended select char(0);
 
462
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
463
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
464
Warnings:
 
465
Note    1003    select char(0) AS `char(0)`
 
466
explain extended select conv(130,16,10);
 
467
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
468
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
469
Warnings:
 
470
Note    1003    select conv(130,16,10) AS `conv(130,16,10)`
 
471
explain extended select hex(130);
 
472
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
473
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
474
Warnings:
 
475
Note    1003    select hex(130) AS `hex(130)`
 
476
explain extended select binary 'HE';
 
477
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
478
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
479
Warnings:
 
480
Note    1003    select cast('HE' as char charset binary) AS `binary 'HE'`
 
481
explain extended select collation(conv(130,16,10));
 
482
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
483
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
484
Warnings:
 
485
Note    1003    select collation(conv(130,16,10)) AS `collation(conv(130,16,10))`
 
486
explain extended select coercibility(conv(130,16,10));
 
487
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
488
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
489
Warnings:
 
490
Note    1003    select coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`
 
491
explain extended select length('\n\t\r\b\0\_\%\\');
 
492
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
493
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
494
Warnings:
 
495
Note    1003    select length('\n       \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`
 
496
explain extended select concat('monty',' was here ','again');
 
497
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
498
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
499
Warnings:
 
500
Note    1003    select concat('monty',' was here ','again') AS `concat('monty',' was here ','again')`
 
501
explain extended select length('hello');
 
502
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
503
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
504
Warnings:
 
505
Note    1003    select length('hello') AS `length('hello')`
 
506
explain extended select char(ascii('h'));
 
507
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
508
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
509
Warnings:
 
510
Note    1003    select char(ascii('h')) AS `char(ascii('h'))`
 
511
explain extended select ord('h');
 
512
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
513
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
514
Warnings:
 
515
Note    1003    select ord('h') AS `ord('h')`
 
516
explain extended select quote(1/0);
 
517
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
518
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
519
Warnings:
 
520
Note    1003    select quote((1 / 0)) AS `quote(1/0)`
 
521
explain extended select crc32("123");
 
522
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
523
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
524
Warnings:
 
525
Note    1003    select crc32('123') AS `crc32("123")`
 
526
explain extended select replace('aaaa','a','b');
 
527
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
528
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
529
Warnings:
 
530
Note    1003    select replace('aaaa','a','b') AS `replace('aaaa','a','b')`
 
531
explain extended select insert('txs',2,1,'hi');
 
532
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
533
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
534
Warnings:
 
535
Note    1003    select insert('txs',2,1,'hi') AS `insert('txs',2,1,'hi')`
 
536
explain extended select SUBSTR('abcdefg',3,2);
 
537
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
538
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
539
Warnings:
 
540
Note    1003    select substr('abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`
 
541
explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2);
 
542
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
543
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    NULL    No tables used
 
544
Warnings:
 
545
Note    1003    select substring_index('1abcd;2abcd;3abcd;4abcd',';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`
 
546
SELECT lpad(12345, 5, "#");
 
547
lpad(12345, 5, "#")
 
548
12345
 
549
SELECT conv(71, 10, 36), conv('1Z', 36, 10);
 
550
conv(71, 10, 36)        conv('1Z', 36, 10)
 
551
1Z      71
 
552
SELECT conv(71, 10, 37), conv('1Z', 37, 10), conv(0,1,10),conv(0,0,10), conv(0,-1,10);
 
553
conv(71, 10, 37)        conv('1Z', 37, 10)      conv(0,1,10)    conv(0,0,10)    conv(0,-1,10)
 
554
NULL    NULL    NULL    NULL    NULL
 
555
create table t1 (id int, str varchar(10));
 
556
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
 
557
create table t2 (id int, str varchar(10));
 
558
insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
 
559
select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2 
 
560
where t2.id=t1.id order by name;
 
561
name
 
562
aaaaaaaaaaccccc
 
563
bbbbbbbbbbddddd
 
564
drop table t1, t2;
 
565
create table t1 (c1 INT, c2 INT);
 
566
insert into t1 values ('21474836461','21474836461');
 
567
ERROR 22003: Out of range value for column 'c1' at row 1
 
568
insert into t1 values ('-21474836461','-21474836461');
 
569
ERROR 22003: Out of range value for column 'c1' at row 1
 
570
select * from t1;
 
571
c1      c2
 
572
drop table t1;
 
573
select left(1234, 3) + 0;
 
574
left(1234, 3) + 0
 
575
123
 
576
create table t1 (a int not null primary key, b varchar(40), c datetime);
 
577
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');
 
578
select count(*) as total, left(c,10) as reg from t1 group by reg order by reg desc limit 0,12;
 
579
total   reg
 
580
10      2004-12-10
 
581
drop table t1;
 
582
select trim(null from 'kate') as "must_be_null";
 
583
must_be_null
 
584
NULL
 
585
select trim('xyz' from null) as "must_be_null";
 
586
must_be_null
 
587
NULL
 
588
select trim(leading NULL from 'kate') as "must_be_null";
 
589
must_be_null
 
590
NULL
 
591
select trim(trailing NULL from 'xyz') as "must_be_null";
 
592
must_be_null
 
593
NULL
 
594
CREATE TEMPORARY TABLE t1 (
 
595
id int NOT NULL auto_increment,
 
596
a bigint default NULL,
 
597
PRIMARY KEY  (id)
 
598
) ENGINE=MyISAM;
 
599
INSERT INTO t1 VALUES ('0','16307858876001849059');
 
600
ERROR 22003: Out of range value for column 'a' at row 1
 
601
SELECT CONV('e251273eb74a8ee3', 16, 10);
 
602
CONV('e251273eb74a8ee3', 16, 10)
 
603
16307858876001849059
 
604
EXPLAIN 
 
605
SELECT id
 
606
FROM t1
 
607
WHERE a = 16307858876001849059;
 
608
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
609
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
 
610
EXPLAIN 
 
611
SELECT id
 
612
FROM t1
 
613
WHERE a = CONV('e251273eb74a8ee3', 16, 10);
 
614
id      select_type     table   type    possible_keys   key     key_len ref     rows    Extra
 
615
1       SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
 
616
DROP TABLE t1;
 
617
SELECT CHAR(NULL,121,83,81,'76') as my_column;
 
618
my_column
 
619
ySQL
 
620
SELECT CHAR_LENGTH(CHAR(NULL,121,83,81,'76')) as my_column;
 
621
my_column
 
622
4
 
623
CREATE TABLE t1 (id int PRIMARY KEY, str char(255) NOT NULL);
 
624
CREATE TABLE t2 (id int NOT NULL UNIQUE);
 
625
INSERT INTO t2 VALUES (1),(2);
 
626
INSERT INTO t1 VALUES (2, 'not valid');
 
627
DROP TABLE t1, t2;
 
628
select field(0,NULL,1,0), field("",NULL,"bar",""), field(0.0,NULL,1.0,0.0);
 
629
field(0,NULL,1,0)       field("",NULL,"bar","") field(0.0,NULL,1.0,0.0)
 
630
3       3       3
 
631
select field(NULL,1,2,NULL), field(NULL,1,2,0);
 
632
field(NULL,1,2,NULL)    field(NULL,1,2,0)
 
633
0       0
 
634
CREATE TABLE t1 (str varchar(20) PRIMARY KEY);
 
635
CREATE TABLE t2 (num int primary key);
 
636
INSERT INTO t1 VALUES ('notnumber');
 
637
INSERT INTO t2 VALUES (0), (1);
 
638
SELECT * FROM t1, t2 WHERE num=str;
 
639
str     num
 
640
notnumber       0
 
641
SELECT * FROM t1, t2 WHERE num=substring(str from 1 for 6);
 
642
str     num
 
643
notnumber       0
 
644
DROP TABLE t1,t2;
 
645
CREATE TABLE t1(
 
646
id int NOT NULL auto_increment,
 
647
pc int NOT NULL default '0',
 
648
title varchar(20) default NULL,
 
649
PRIMARY KEY (id)
 
650
);
 
651
INSERT INTO t1 VALUES
 
652
(1, 0, 'Main'),
 
653
(2, 1, 'Toys'),
 
654
(3, 1, 'Games');
 
655
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
 
656
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
 
657
LEFT JOIN t1 AS t3 ON t2.pc=t3.id;
 
658
id      col1
 
659
1       Main
 
660
2       Main->Toys
 
661
3       Main->Games
 
662
SELECT t1.id, CONCAT_WS('->', t3.title, t2.title, t1.title) as col1
 
663
FROM t1 LEFT JOIN t1 AS t2 ON t1.pc=t2.id
 
664
LEFT JOIN t1 AS t3 ON t2.pc=t3.id
 
665
WHERE CONCAT_WS('->', t3.title, t2.title, t1.title) LIKE '%Toys%';
 
666
id      col1
 
667
2       Main->Toys
 
668
DROP TABLE t1;
 
669
CREATE TABLE t1(
 
670
trackid     int NOT NULL auto_increment,
 
671
trackname   varchar(100) NOT NULL default '',
 
672
PRIMARY KEY (trackid)
 
673
);
 
674
CREATE TABLE t2(
 
675
artistid    int NOT NULL auto_increment,
 
676
artistname  varchar(100) NOT NULL default '',
 
677
PRIMARY KEY (artistid)
 
678
);
 
679
CREATE TABLE t3(
 
680
trackid     int NOT NULL,
 
681
artistid    int NOT NULL,
 
682
PRIMARY KEY (trackid,artistid)
 
683
);
 
684
INSERT INTO t1 VALUES (1, 'April In Paris'), (2, 'Autumn In New York');
 
685
INSERT INTO t2 VALUES (1, 'Vernon Duke');
 
686
INSERT INTO t3 VALUES (1,1);
 
687
SELECT CONCAT_WS(' ', trackname, artistname) trackname, artistname
 
688
FROM t1 LEFT JOIN t3 ON t1.trackid=t3.trackid
 
689
LEFT JOIN t2 ON t2.artistid=t3.artistid
 
690
WHERE CONCAT_WS(' ', trackname, artistname) LIKE '%In%';
 
691
trackname       artistname
 
692
April In Paris Vernon Duke      Vernon Duke
 
693
Autumn In New York      NULL
 
694
DROP TABLE t1,t2,t3;
 
695
create table t1 (b varchar(5));
 
696
insert t1 values ('ab'), ('abc'), ('abcd'), ('abcde');
 
697
select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1;
 
698
b       substring(b,1)  substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5)
 
699
ab      ab      b       ab                      
 
700
abc     abc     c       bc      abc             
 
701
abcd    abcd    d       cd      bcd     abcd    
 
702
abcde   abcde   e       de      cde     bcde    abcde
 
703
select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t;
 
704
b       substring(b,1)  substring(b,-1) substring(b,-2) substring(b,-3) substring(b,-4) substring(b,-5)
 
705
ab      ab      b       ab                      
 
706
abc     abc     c       bc      abc             
 
707
abcd    abcd    d       cd      bcd     abcd    
 
708
abcde   abcde   e       de      cde     bcde    abcde
 
709
drop table t1;
 
710
select hex(29223372036854775809), hex(-29223372036854775809);
 
711
hex(29223372036854775809)       hex(-29223372036854775809)
 
712
FFFFFFFFFFFFFFFF        FFFFFFFFFFFFFFFF
 
713
create table t1 (i int);
 
714
insert into t1 values (1000000000),(1);
 
715
select lpad(i, 7, ' ') as t from t1;
 
716
Catalog Database        Table   Table_alias     Column  Column_alias    Type    Length  Max length      Is_null Flags   Decimals        Charsetnr
 
717
def                                     t       8       7       7       Y       128     31      63
 
718
t
 
719
1000000
 
720
      1
 
721
select rpad(i, 7, ' ') as t from t1;
 
722
Catalog Database        Table   Table_alias     Column  Column_alias    Type    Length  Max length      Is_null Flags   Decimals        Charsetnr
 
723
def                                     t       8       7       7       Y       128     31      63
 
724
t
 
725
1000000
 
726
1      
 
727
drop table t1;
 
728
select load_file("lkjlkj");
 
729
load_file("lkjlkj")
 
730
NULL
 
731
select ifnull(load_file("lkjlkj"),"it's null");
 
732
ifnull(load_file("lkjlkj"),"it's null")
 
733
it's null
 
734
CREATE TABLE t1 (a varchar(10));
 
735
INSERT INTO t1 VALUES ('abc'), ('xyz');
 
736
SELECT a, CONCAT(a,' ',a) AS c FROM t1
 
737
HAVING LEFT(c,LENGTH(c)-INSTR(REVERSE(c)," ")) = a;
 
738
a       c
 
739
abc     abc abc
 
740
xyz     xyz xyz
 
741
SELECT a, CONCAT(a,' ',a) AS c FROM t1
 
742
HAVING LEFT(CONCAT(a,' ',a),
 
743
LENGTH(CONCAT(a,' ',a))-
 
744
INSTR(REVERSE(CONCAT(a,' ',a))," ")) = a;
 
745
a       c
 
746
abc     abc abc
 
747
xyz     xyz xyz
 
748
DROP TABLE t1;
 
749
CREATE TABLE t1 (s varchar(10));
 
750
INSERT INTO t1 VALUES ('yadda'), ('yaddy');
 
751
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(s) > 'ab';
 
752
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
753
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
 
754
Warnings:
 
755
Note    1003    select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(`test`.`t1`.`s`) > 'ab')
 
756
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM('y' FROM s) > 'ab';
 
757
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
758
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
 
759
Warnings:
 
760
Note    1003    select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
 
761
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(LEADING 'y' FROM s) > 'ab';
 
762
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
763
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
 
764
Warnings:
 
765
Note    1003    select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(leading 'y' from `test`.`t1`.`s`) > 'ab')
 
766
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(TRAILING 'y' FROM s) > 'ab';
 
767
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
768
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
 
769
Warnings:
 
770
Note    1003    select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(trailing 'y' from `test`.`t1`.`s`) > 'ab')
 
771
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
 
772
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
773
1       SIMPLE  t1      ALL     NULL    NULL    NULL    NULL    2       100.00  Using where
 
774
Warnings:
 
775
Note    1003    select `test`.`t1`.`s` AS `s` from `test`.`t1` where (trim(both 'y' from `test`.`t1`.`s`) > 'ab')
 
776
DROP TABLE t1;
 
777
create TEMPORARY table t1 (a bigint not null)engine=myisam;
 
778
insert into t1 set a = 1024*1024*1024*4;
 
779
drop table t1;
 
780
create TEMPORARY table t1 (a char(36) not null)engine=myisam;
 
781
insert ignore into t1 set a = ' ';
 
782
insert ignore into t1 set a = ' ';
 
783
select * from t1 order by (oct(a));
 
784
a
 
785
 
 
786
 
 
787
drop table t1;
 
788
End of 4.1 tests
 
789
create table t1 (d decimal default null);
 
790
insert into t1 values (null);
 
791
select format(d, 2) from t1;
 
792
format(d, 2)
 
793
NULL
 
794
drop table t1;
 
795
create table t1 (c varchar(40));
 
796
insert into t1 values ('y,abc'),('y,abc');
 
797
select c, substring_index(lcase(c), @q:=',', -1) as res from t1;
 
798
c       res
 
799
y,abc   abc
 
800
y,abc   abc
 
801
drop table t1;
 
802
select cast(rtrim('  20.06 ') as decimal(19,2));
 
803
cast(rtrim('  20.06 ') as decimal(19,2))
 
804
20.06
 
805
select cast(ltrim('  20.06 ') as decimal(19,2));
 
806
cast(ltrim('  20.06 ') as decimal(19,2))
 
807
20.06
 
808
select cast(rtrim(ltrim('  20.06 ')) as decimal(19,2));
 
809
cast(rtrim(ltrim('  20.06 ')) as decimal(19,2))
 
810
20.06
 
811
select conv("18383815659218730760",10,10) + 0;
 
812
conv("18383815659218730760",10,10) + 0
 
813
1.83838156592187e19
 
814
select "18383815659218730760" + 0;
 
815
"18383815659218730760" + 0
 
816
1.83838156592187e19
 
817
CREATE TABLE t1 (code varchar(10));
 
818
INSERT INTO t1 VALUES ('a12'), ('A12'), ('a13');
 
819
SELECT ASCII(code), code FROM t1 WHERE code='A12';
 
820
ASCII(code)     code
 
821
97      a12
 
822
65      A12
 
823
SELECT ASCII(code), code FROM t1 WHERE code='A12' AND ASCII(code)=65;
 
824
ASCII(code)     code
 
825
65      A12
 
826
INSERT INTO t1 VALUES ('a12 '), ('A12  ');
 
827
SELECT LENGTH(code), code FROM t1 WHERE code='A12';
 
828
LENGTH(code)    code
 
829
3       a12
 
830
3       A12
 
831
4       a12 
 
832
5       A12  
 
833
SELECT LENGTH(code), code FROM t1 WHERE code='A12' AND LENGTH(code)=5;
 
834
LENGTH(code)    code
 
835
5       A12  
 
836
ALTER TABLE t1 ADD INDEX (code);
 
837
CREATE TABLE t2 (id varchar(10) PRIMARY KEY);
 
838
INSERT INTO t2 VALUES ('a11'), ('a12'), ('a13'), ('a14');
 
839
SELECT * FROM t1 INNER JOIN t2 ON t1.code=t2.id 
 
840
WHERE t2.id='a12' AND (LENGTH(code)=5 OR code < 'a00');
 
841
code    id
 
842
A12     a12
 
843
EXPLAIN EXTENDED 
 
844
SELECT * FROM t1 INNER JOIN t2 ON code=id 
 
845
WHERE id='a12' AND (LENGTH(code)=5 OR code < 'a00');
 
846
id      select_type     table   type    possible_keys   key     key_len ref     rows    filtered        Extra
 
847
1       SIMPLE  t2      const   PRIMARY PRIMARY 42      const   1       100.00  
 
848
1       SIMPLE  t1      ref     code    code    43      const   3       100.00  Using where
 
849
Warnings:
 
850
Note    1003    select `test`.`t1`.`code` AS `code`,'a12' AS `id` from `test`.`t1` join `test`.`t2` where ((`test`.`t1`.`code` = 'a12') and <cache>(('a12' = 'a12')) and ((length(`test`.`t1`.`code`) = 5) or <cache>(('a12' < 'a00'))))
 
851
DROP TABLE t1,t2;
 
852
select benchmark(-1, 1);
 
853
benchmark(-1, 1)
 
854
NULL
 
855
Warnings:
 
856
Error   1411    Incorrect count value: '-1' for function benchmark
 
857
set @dec=5;
 
858
select format(pi(), (1+1));
 
859
format(pi(), (1+1))
 
860
3.14
 
861
select format(pi(), (select 3));
 
862
format(pi(), (select 3))
 
863
3.142
 
864
select format(pi(), @dec);
 
865
format(pi(), @dec)
 
866
3.14159
 
867
set @bench_count=10;
 
868
select benchmark(10, pi());
 
869
benchmark(10, pi())
 
870
0
 
871
select benchmark(5+5, pi());
 
872
benchmark(5+5, pi())
 
873
0
 
874
select benchmark((select 10), pi());
 
875
benchmark((select 10), pi())
 
876
0
 
877
select benchmark(@bench_count, pi());
 
878
benchmark(@bench_count, pi())
 
879
0
 
880
select locate('he','hello',-2);
 
881
locate('he','hello',-2)
 
882
0
 
883
select locate('lo','hello',-4294967295);
 
884
locate('lo','hello',-4294967295)
 
885
0
 
886
select locate('lo','hello',4294967295);
 
887
locate('lo','hello',4294967295)
 
888
0
 
889
select locate('lo','hello',-4294967296);
 
890
locate('lo','hello',-4294967296)
 
891
0
 
892
select locate('lo','hello',4294967296);
 
893
locate('lo','hello',4294967296)
 
894
0
 
895
select locate('lo','hello',-4294967297);
 
896
locate('lo','hello',-4294967297)
 
897
0
 
898
select locate('lo','hello',4294967297);
 
899
locate('lo','hello',4294967297)
 
900
0
 
901
select locate('lo','hello',-18446744073709551615);
 
902
locate('lo','hello',-18446744073709551615)
 
903
0
 
904
Warnings:
 
905
Error   1292    Truncated incorrect DECIMAL value: ''
 
906
select locate('lo','hello',18446744073709551615);
 
907
locate('lo','hello',18446744073709551615)
 
908
0
 
909
select locate('lo','hello',-18446744073709551616);
 
910
locate('lo','hello',-18446744073709551616)
 
911
0
 
912
Warnings:
 
913
Error   1292    Truncated incorrect DECIMAL value: ''
 
914
select locate('lo','hello',18446744073709551616);
 
915
locate('lo','hello',18446744073709551616)
 
916
0
 
917
Warnings:
 
918
Error   1292    Truncated incorrect DECIMAL value: ''
 
919
select locate('lo','hello',-18446744073709551617);
 
920
locate('lo','hello',-18446744073709551617)
 
921
0
 
922
Warnings:
 
923
Error   1292    Truncated incorrect DECIMAL value: ''
 
924
select locate('lo','hello',18446744073709551617);
 
925
locate('lo','hello',18446744073709551617)
 
926
0
 
927
Warnings:
 
928
Error   1292    Truncated incorrect DECIMAL value: ''
 
929
select left('hello', 10);
 
930
left('hello', 10)
 
931
hello
 
932
select left('hello', 0);
 
933
left('hello', 0)
 
934
 
 
935
select left('hello', -1);
 
936
left('hello', -1)
 
937
 
 
938
select left('hello', -4294967295);
 
939
left('hello', -4294967295)
 
940
 
 
941
select left('hello', 4294967295);
 
942
left('hello', 4294967295)
 
943
hello
 
944
select left('hello', -4294967296);
 
945
left('hello', -4294967296)
 
946
 
 
947
select left('hello', 4294967296);
 
948
left('hello', 4294967296)
 
949
hello
 
950
select left('hello', -4294967297);
 
951
left('hello', -4294967297)
 
952
 
 
953
select left('hello', 4294967297);
 
954
left('hello', 4294967297)
 
955
hello
 
956
select left('hello', -18446744073709551615);
 
957
left('hello', -18446744073709551615)
 
958
 
 
959
Warnings:
 
960
Error   1292    Truncated incorrect DECIMAL value: ''
 
961
Error   1292    Truncated incorrect DECIMAL value: ''
 
962
select left('hello', 18446744073709551615);
 
963
left('hello', 18446744073709551615)
 
964
hello
 
965
select left('hello', -18446744073709551616);
 
966
left('hello', -18446744073709551616)
 
967
 
 
968
Warnings:
 
969
Error   1292    Truncated incorrect DECIMAL value: ''
 
970
Error   1292    Truncated incorrect DECIMAL value: ''
 
971
select left('hello', 18446744073709551616);
 
972
left('hello', 18446744073709551616)
 
973
hello
 
974
Warnings:
 
975
Error   1292    Truncated incorrect DECIMAL value: ''
 
976
Error   1292    Truncated incorrect DECIMAL value: ''
 
977
select left('hello', -18446744073709551617);
 
978
left('hello', -18446744073709551617)
 
979
 
 
980
Warnings:
 
981
Error   1292    Truncated incorrect DECIMAL value: ''
 
982
Error   1292    Truncated incorrect DECIMAL value: ''
 
983
select left('hello', 18446744073709551617);
 
984
left('hello', 18446744073709551617)
 
985
hello
 
986
Warnings:
 
987
Error   1292    Truncated incorrect DECIMAL value: ''
 
988
Error   1292    Truncated incorrect DECIMAL value: ''
 
989
select right('hello', 10);
 
990
right('hello', 10)
 
991
hello
 
992
select right('hello', 0);
 
993
right('hello', 0)
 
994
 
 
995
select right('hello', -1);
 
996
right('hello', -1)
 
997
 
 
998
select right('hello', -4294967295);
 
999
right('hello', -4294967295)
 
1000
 
 
1001
select right('hello', 4294967295);
 
1002
right('hello', 4294967295)
 
1003
hello
 
1004
select right('hello', -4294967296);
 
1005
right('hello', -4294967296)
 
1006
 
 
1007
select right('hello', 4294967296);
 
1008
right('hello', 4294967296)
 
1009
hello
 
1010
select right('hello', -4294967297);
 
1011
right('hello', -4294967297)
 
1012
 
 
1013
select right('hello', 4294967297);
 
1014
right('hello', 4294967297)
 
1015
hello
 
1016
select right('hello', -18446744073709551615);
 
1017
right('hello', -18446744073709551615)
 
1018
 
 
1019
Warnings:
 
1020
Error   1292    Truncated incorrect DECIMAL value: ''
 
1021
Error   1292    Truncated incorrect DECIMAL value: ''
 
1022
select right('hello', 18446744073709551615);
 
1023
right('hello', 18446744073709551615)
 
1024
hello
 
1025
select right('hello', -18446744073709551616);
 
1026
right('hello', -18446744073709551616)
 
1027
 
 
1028
Warnings:
 
1029
Error   1292    Truncated incorrect DECIMAL value: ''
 
1030
Error   1292    Truncated incorrect DECIMAL value: ''
 
1031
select right('hello', 18446744073709551616);
 
1032
right('hello', 18446744073709551616)
 
1033
hello
 
1034
Warnings:
 
1035
Error   1292    Truncated incorrect DECIMAL value: ''
 
1036
Error   1292    Truncated incorrect DECIMAL value: ''
 
1037
select right('hello', -18446744073709551617);
 
1038
right('hello', -18446744073709551617)
 
1039
 
 
1040
Warnings:
 
1041
Error   1292    Truncated incorrect DECIMAL value: ''
 
1042
Error   1292    Truncated incorrect DECIMAL value: ''
 
1043
select right('hello', 18446744073709551617);
 
1044
right('hello', 18446744073709551617)
 
1045
hello
 
1046
Warnings:
 
1047
Error   1292    Truncated incorrect DECIMAL value: ''
 
1048
Error   1292    Truncated incorrect DECIMAL value: ''
 
1049
select substring('hello', 2, -1);
 
1050
substring('hello', 2, -1)
 
1051
 
 
1052
select substring('hello', -1, 1);
 
1053
substring('hello', -1, 1)
 
1054
o
 
1055
select substring('hello', -2, 1);
 
1056
substring('hello', -2, 1)
 
1057
l
 
1058
select substring('hello', -4294967295, 1);
 
1059
substring('hello', -4294967295, 1)
 
1060
 
 
1061
select substring('hello', 4294967295, 1);
 
1062
substring('hello', 4294967295, 1)
 
1063
 
 
1064
select substring('hello', -4294967296, 1);
 
1065
substring('hello', -4294967296, 1)
 
1066
 
 
1067
select substring('hello', 4294967296, 1);
 
1068
substring('hello', 4294967296, 1)
 
1069
 
 
1070
select substring('hello', -4294967297, 1);
 
1071
substring('hello', -4294967297, 1)
 
1072
 
 
1073
select substring('hello', 4294967297, 1);
 
1074
substring('hello', 4294967297, 1)
 
1075
 
 
1076
select substring('hello', -18446744073709551615, 1);
 
1077
substring('hello', -18446744073709551615, 1)
 
1078
 
 
1079
Warnings:
 
1080
Error   1292    Truncated incorrect DECIMAL value: ''
 
1081
Error   1292    Truncated incorrect DECIMAL value: ''
 
1082
select substring('hello', 18446744073709551615, 1);
 
1083
substring('hello', 18446744073709551615, 1)
 
1084
 
 
1085
select substring('hello', -18446744073709551616, 1);
 
1086
substring('hello', -18446744073709551616, 1)
 
1087
 
 
1088
Warnings:
 
1089
Error   1292    Truncated incorrect DECIMAL value: ''
 
1090
Error   1292    Truncated incorrect DECIMAL value: ''
 
1091
select substring('hello', 18446744073709551616, 1);
 
1092
substring('hello', 18446744073709551616, 1)
 
1093
 
 
1094
Warnings:
 
1095
Error   1292    Truncated incorrect DECIMAL value: ''
 
1096
Error   1292    Truncated incorrect DECIMAL value: ''
 
1097
select substring('hello', -18446744073709551617, 1);
 
1098
substring('hello', -18446744073709551617, 1)
 
1099
 
 
1100
Warnings:
 
1101
Error   1292    Truncated incorrect DECIMAL value: ''
 
1102
Error   1292    Truncated incorrect DECIMAL value: ''
 
1103
select substring('hello', 18446744073709551617, 1);
 
1104
substring('hello', 18446744073709551617, 1)
 
1105
 
 
1106
Warnings:
 
1107
Error   1292    Truncated incorrect DECIMAL value: ''
 
1108
Error   1292    Truncated incorrect DECIMAL value: ''
 
1109
select substring('hello', 1, -1);
 
1110
substring('hello', 1, -1)
 
1111
 
 
1112
select substring('hello', 1, -4294967295);
 
1113
substring('hello', 1, -4294967295)
 
1114
 
 
1115
select substring('hello', 1, 4294967295);
 
1116
substring('hello', 1, 4294967295)
 
1117
hello
 
1118
select substring('hello', 1, -4294967296);
 
1119
substring('hello', 1, -4294967296)
 
1120
 
 
1121
select substring('hello', 1, 4294967296);
 
1122
substring('hello', 1, 4294967296)
 
1123
hello
 
1124
select substring('hello', 1, -4294967297);
 
1125
substring('hello', 1, -4294967297)
 
1126
 
 
1127
select substring('hello', 1, 4294967297);
 
1128
substring('hello', 1, 4294967297)
 
1129
hello
 
1130
select substring('hello', 1, -18446744073709551615);
 
1131
substring('hello', 1, -18446744073709551615)
 
1132
 
 
1133
Warnings:
 
1134
Error   1292    Truncated incorrect DECIMAL value: ''
 
1135
Error   1292    Truncated incorrect DECIMAL value: ''
 
1136
select substring('hello', 1, 18446744073709551615);
 
1137
substring('hello', 1, 18446744073709551615)
 
1138
hello
 
1139
select substring('hello', 1, -18446744073709551616);
 
1140
substring('hello', 1, -18446744073709551616)
 
1141
 
 
1142
Warnings:
 
1143
Error   1292    Truncated incorrect DECIMAL value: ''
 
1144
Error   1292    Truncated incorrect DECIMAL value: ''
 
1145
select substring('hello', 1, 18446744073709551616);
 
1146
substring('hello', 1, 18446744073709551616)
 
1147
hello
 
1148
Warnings:
 
1149
Error   1292    Truncated incorrect DECIMAL value: ''
 
1150
Error   1292    Truncated incorrect DECIMAL value: ''
 
1151
select substring('hello', 1, -18446744073709551617);
 
1152
substring('hello', 1, -18446744073709551617)
 
1153
 
 
1154
Warnings:
 
1155
Error   1292    Truncated incorrect DECIMAL value: ''
 
1156
Error   1292    Truncated incorrect DECIMAL value: ''
 
1157
select substring('hello', 1, 18446744073709551617);
 
1158
substring('hello', 1, 18446744073709551617)
 
1159
hello
 
1160
Warnings:
 
1161
Error   1292    Truncated incorrect DECIMAL value: ''
 
1162
Error   1292    Truncated incorrect DECIMAL value: ''
 
1163
select substring('hello', -1, -1);
 
1164
substring('hello', -1, -1)
 
1165
 
 
1166
select substring('hello', -4294967295, -4294967295);
 
1167
substring('hello', -4294967295, -4294967295)
 
1168
 
 
1169
select substring('hello', 4294967295, 4294967295);
 
1170
substring('hello', 4294967295, 4294967295)
 
1171
 
 
1172
select substring('hello', -4294967296, -4294967296);
 
1173
substring('hello', -4294967296, -4294967296)
 
1174
 
 
1175
select substring('hello', 4294967296, 4294967296);
 
1176
substring('hello', 4294967296, 4294967296)
 
1177
 
 
1178
select substring('hello', -4294967297, -4294967297);
 
1179
substring('hello', -4294967297, -4294967297)
 
1180
 
 
1181
select substring('hello', 4294967297, 4294967297);
 
1182
substring('hello', 4294967297, 4294967297)
 
1183
 
 
1184
select substring('hello', -18446744073709551615, -18446744073709551615);
 
1185
substring('hello', -18446744073709551615, -18446744073709551615)
 
1186
 
 
1187
Warnings:
 
1188
Error   1292    Truncated incorrect DECIMAL value: ''
 
1189
Error   1292    Truncated incorrect DECIMAL value: ''
 
1190
Error   1292    Truncated incorrect DECIMAL value: ''
 
1191
Error   1292    Truncated incorrect DECIMAL value: ''
 
1192
select substring('hello', 18446744073709551615, 18446744073709551615);
 
1193
substring('hello', 18446744073709551615, 18446744073709551615)
 
1194
 
 
1195
select substring('hello', -18446744073709551616, -18446744073709551616);
 
1196
substring('hello', -18446744073709551616, -18446744073709551616)
 
1197
 
 
1198
Warnings:
 
1199
Error   1292    Truncated incorrect DECIMAL value: ''
 
1200
Error   1292    Truncated incorrect DECIMAL value: ''
 
1201
Error   1292    Truncated incorrect DECIMAL value: ''
 
1202
Error   1292    Truncated incorrect DECIMAL value: ''
 
1203
select substring('hello', 18446744073709551616, 18446744073709551616);
 
1204
substring('hello', 18446744073709551616, 18446744073709551616)
 
1205
 
 
1206
Warnings:
 
1207
Error   1292    Truncated incorrect DECIMAL value: ''
 
1208
Error   1292    Truncated incorrect DECIMAL value: ''
 
1209
Error   1292    Truncated incorrect DECIMAL value: ''
 
1210
Error   1292    Truncated incorrect DECIMAL value: ''
 
1211
select substring('hello', -18446744073709551617, -18446744073709551617);
 
1212
substring('hello', -18446744073709551617, -18446744073709551617)
 
1213
 
 
1214
Warnings:
 
1215
Error   1292    Truncated incorrect DECIMAL value: ''
 
1216
Error   1292    Truncated incorrect DECIMAL value: ''
 
1217
Error   1292    Truncated incorrect DECIMAL value: ''
 
1218
Error   1292    Truncated incorrect DECIMAL value: ''
 
1219
select substring('hello', 18446744073709551617, 18446744073709551617);
 
1220
substring('hello', 18446744073709551617, 18446744073709551617)
 
1221
 
 
1222
Warnings:
 
1223
Error   1292    Truncated incorrect DECIMAL value: ''
 
1224
Error   1292    Truncated incorrect DECIMAL value: ''
 
1225
Error   1292    Truncated incorrect DECIMAL value: ''
 
1226
Error   1292    Truncated incorrect DECIMAL value: ''
 
1227
select insert('hello', -1, 1, 'hi');
 
1228
insert('hello', -1, 1, 'hi')
 
1229
hello
 
1230
select insert('hello', -4294967295, 1, 'hi');
 
1231
insert('hello', -4294967295, 1, 'hi')
 
1232
hello
 
1233
select insert('hello', 4294967295, 1, 'hi');
 
1234
insert('hello', 4294967295, 1, 'hi')
 
1235
hello
 
1236
select insert('hello', -4294967296, 1, 'hi');
 
1237
insert('hello', -4294967296, 1, 'hi')
 
1238
hello
 
1239
select insert('hello', 4294967296, 1, 'hi');
 
1240
insert('hello', 4294967296, 1, 'hi')
 
1241
hello
 
1242
select insert('hello', -4294967297, 1, 'hi');
 
1243
insert('hello', -4294967297, 1, 'hi')
 
1244
hello
 
1245
select insert('hello', 4294967297, 1, 'hi');
 
1246
insert('hello', 4294967297, 1, 'hi')
 
1247
hello
 
1248
select insert('hello', -18446744073709551615, 1, 'hi');
 
1249
insert('hello', -18446744073709551615, 1, 'hi')
 
1250
hello
 
1251
Warnings:
 
1252
Error   1292    Truncated incorrect DECIMAL value: ''
 
1253
select insert('hello', 18446744073709551615, 1, 'hi');
 
1254
insert('hello', 18446744073709551615, 1, 'hi')
 
1255
hello
 
1256
select insert('hello', -18446744073709551616, 1, 'hi');
 
1257
insert('hello', -18446744073709551616, 1, 'hi')
 
1258
hello
 
1259
Warnings:
 
1260
Error   1292    Truncated incorrect DECIMAL value: ''
 
1261
select insert('hello', 18446744073709551616, 1, 'hi');
 
1262
insert('hello', 18446744073709551616, 1, 'hi')
 
1263
hello
 
1264
Warnings:
 
1265
Error   1292    Truncated incorrect DECIMAL value: ''
 
1266
select insert('hello', -18446744073709551617, 1, 'hi');
 
1267
insert('hello', -18446744073709551617, 1, 'hi')
 
1268
hello
 
1269
Warnings:
 
1270
Error   1292    Truncated incorrect DECIMAL value: ''
 
1271
select insert('hello', 18446744073709551617, 1, 'hi');
 
1272
insert('hello', 18446744073709551617, 1, 'hi')
 
1273
hello
 
1274
Warnings:
 
1275
Error   1292    Truncated incorrect DECIMAL value: ''
 
1276
select insert('hello', 1, -1, 'hi');
 
1277
insert('hello', 1, -1, 'hi')
 
1278
hi
 
1279
select insert('hello', 1, -4294967295, 'hi');
 
1280
insert('hello', 1, -4294967295, 'hi')
 
1281
hi
 
1282
select insert('hello', 1, 4294967295, 'hi');
 
1283
insert('hello', 1, 4294967295, 'hi')
 
1284
hi
 
1285
select insert('hello', 1, -4294967296, 'hi');
 
1286
insert('hello', 1, -4294967296, 'hi')
 
1287
hi
 
1288
select insert('hello', 1, 4294967296, 'hi');
 
1289
insert('hello', 1, 4294967296, 'hi')
 
1290
hi
 
1291
select insert('hello', 1, -4294967297, 'hi');
 
1292
insert('hello', 1, -4294967297, 'hi')
 
1293
hi
 
1294
select insert('hello', 1, 4294967297, 'hi');
 
1295
insert('hello', 1, 4294967297, 'hi')
 
1296
hi
 
1297
select insert('hello', 1, -18446744073709551615, 'hi');
 
1298
insert('hello', 1, -18446744073709551615, 'hi')
 
1299
hi
 
1300
Warnings:
 
1301
Error   1292    Truncated incorrect DECIMAL value: ''
 
1302
select insert('hello', 1, 18446744073709551615, 'hi');
 
1303
insert('hello', 1, 18446744073709551615, 'hi')
 
1304
hi
 
1305
select insert('hello', 1, -18446744073709551616, 'hi');
 
1306
insert('hello', 1, -18446744073709551616, 'hi')
 
1307
hi
 
1308
Warnings:
 
1309
Error   1292    Truncated incorrect DECIMAL value: ''
 
1310
select insert('hello', 1, 18446744073709551616, 'hi');
 
1311
insert('hello', 1, 18446744073709551616, 'hi')
 
1312
hi
 
1313
Warnings:
 
1314
Error   1292    Truncated incorrect DECIMAL value: ''
 
1315
select insert('hello', 1, -18446744073709551617, 'hi');
 
1316
insert('hello', 1, -18446744073709551617, 'hi')
 
1317
hi
 
1318
Warnings:
 
1319
Error   1292    Truncated incorrect DECIMAL value: ''
 
1320
select insert('hello', 1, 18446744073709551617, 'hi');
 
1321
insert('hello', 1, 18446744073709551617, 'hi')
 
1322
hi
 
1323
Warnings:
 
1324
Error   1292    Truncated incorrect DECIMAL value: ''
 
1325
select insert('hello', -1, -1, 'hi');
 
1326
insert('hello', -1, -1, 'hi')
 
1327
hello
 
1328
select insert('hello', -4294967295, -4294967295, 'hi');
 
1329
insert('hello', -4294967295, -4294967295, 'hi')
 
1330
hello
 
1331
select insert('hello', 4294967295, 4294967295, 'hi');
 
1332
insert('hello', 4294967295, 4294967295, 'hi')
 
1333
hello
 
1334
select insert('hello', -4294967296, -4294967296, 'hi');
 
1335
insert('hello', -4294967296, -4294967296, 'hi')
 
1336
hello
 
1337
select insert('hello', 4294967296, 4294967296, 'hi');
 
1338
insert('hello', 4294967296, 4294967296, 'hi')
 
1339
hello
 
1340
select insert('hello', -4294967297, -4294967297, 'hi');
 
1341
insert('hello', -4294967297, -4294967297, 'hi')
 
1342
hello
 
1343
select insert('hello', 4294967297, 4294967297, 'hi');
 
1344
insert('hello', 4294967297, 4294967297, 'hi')
 
1345
hello
 
1346
select insert('hello', -18446744073709551615, -18446744073709551615, 'hi');
 
1347
insert('hello', -18446744073709551615, -18446744073709551615, 'hi')
 
1348
hello
 
1349
Warnings:
 
1350
Error   1292    Truncated incorrect DECIMAL value: ''
 
1351
Error   1292    Truncated incorrect DECIMAL value: ''
 
1352
select insert('hello', 18446744073709551615, 18446744073709551615, 'hi');
 
1353
insert('hello', 18446744073709551615, 18446744073709551615, 'hi')
 
1354
hello
 
1355
select insert('hello', -18446744073709551616, -18446744073709551616, 'hi');
 
1356
insert('hello', -18446744073709551616, -18446744073709551616, 'hi')
 
1357
hello
 
1358
Warnings:
 
1359
Error   1292    Truncated incorrect DECIMAL value: ''
 
1360
Error   1292    Truncated incorrect DECIMAL value: ''
 
1361
select insert('hello', 18446744073709551616, 18446744073709551616, 'hi');
 
1362
insert('hello', 18446744073709551616, 18446744073709551616, 'hi')
 
1363
hello
 
1364
Warnings:
 
1365
Error   1292    Truncated incorrect DECIMAL value: ''
 
1366
Error   1292    Truncated incorrect DECIMAL value: ''
 
1367
select insert('hello', -18446744073709551617, -18446744073709551617, 'hi');
 
1368
insert('hello', -18446744073709551617, -18446744073709551617, 'hi')
 
1369
hello
 
1370
Warnings:
 
1371
Error   1292    Truncated incorrect DECIMAL value: ''
 
1372
Error   1292    Truncated incorrect DECIMAL value: ''
 
1373
select insert('hello', 18446744073709551617, 18446744073709551617, 'hi');
 
1374
insert('hello', 18446744073709551617, 18446744073709551617, 'hi')
 
1375
hello
 
1376
Warnings:
 
1377
Error   1292    Truncated incorrect DECIMAL value: ''
 
1378
Error   1292    Truncated incorrect DECIMAL value: ''
 
1379
select repeat('hello', -1);
 
1380
repeat('hello', -1)
 
1381
 
 
1382
select repeat('hello', -4294967295);
 
1383
repeat('hello', -4294967295)
 
1384
 
 
1385
select repeat('hello', 4294967295);
 
1386
repeat('hello', 4294967295)
 
1387
NULL
 
1388
Warnings:
 
1389
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1390
select repeat('hello', -4294967296);
 
1391
repeat('hello', -4294967296)
 
1392
 
 
1393
select repeat('hello', 4294967296);
 
1394
repeat('hello', 4294967296)
 
1395
NULL
 
1396
Warnings:
 
1397
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1398
select repeat('hello', -4294967297);
 
1399
repeat('hello', -4294967297)
 
1400
 
 
1401
select repeat('hello', 4294967297);
 
1402
repeat('hello', 4294967297)
 
1403
NULL
 
1404
Warnings:
 
1405
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1406
select repeat('hello', -18446744073709551615);
 
1407
repeat('hello', -18446744073709551615)
 
1408
 
 
1409
Warnings:
 
1410
Error   1292    Truncated incorrect DECIMAL value: ''
 
1411
Error   1292    Truncated incorrect DECIMAL value: ''
 
1412
select repeat('hello', 18446744073709551615);
 
1413
repeat('hello', 18446744073709551615)
 
1414
NULL
 
1415
Warnings:
 
1416
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1417
select repeat('hello', -18446744073709551616);
 
1418
repeat('hello', -18446744073709551616)
 
1419
 
 
1420
Warnings:
 
1421
Error   1292    Truncated incorrect DECIMAL value: ''
 
1422
Error   1292    Truncated incorrect DECIMAL value: ''
 
1423
select repeat('hello', 18446744073709551616);
 
1424
repeat('hello', 18446744073709551616)
 
1425
NULL
 
1426
Warnings:
 
1427
Error   1292    Truncated incorrect DECIMAL value: ''
 
1428
Error   1292    Truncated incorrect DECIMAL value: ''
 
1429
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1430
select repeat('hello', -18446744073709551617);
 
1431
repeat('hello', -18446744073709551617)
 
1432
 
 
1433
Warnings:
 
1434
Error   1292    Truncated incorrect DECIMAL value: ''
 
1435
Error   1292    Truncated incorrect DECIMAL value: ''
 
1436
select repeat('hello', 18446744073709551617);
 
1437
repeat('hello', 18446744073709551617)
 
1438
NULL
 
1439
Warnings:
 
1440
Error   1292    Truncated incorrect DECIMAL value: ''
 
1441
Error   1292    Truncated incorrect DECIMAL value: ''
 
1442
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1443
select space(-1);
 
1444
space(-1)
 
1445
 
 
1446
select space(-4294967295);
 
1447
space(-4294967295)
 
1448
 
 
1449
select space(4294967295);
 
1450
space(4294967295)
 
1451
NULL
 
1452
Warnings:
 
1453
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1454
select space(-4294967296);
 
1455
space(-4294967296)
 
1456
 
 
1457
select space(4294967296);
 
1458
space(4294967296)
 
1459
NULL
 
1460
Warnings:
 
1461
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1462
select space(-4294967297);
 
1463
space(-4294967297)
 
1464
 
 
1465
select space(4294967297);
 
1466
space(4294967297)
 
1467
NULL
 
1468
Warnings:
 
1469
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1470
select space(-18446744073709551615);
 
1471
space(-18446744073709551615)
 
1472
 
 
1473
Warnings:
 
1474
Error   1292    Truncated incorrect DECIMAL value: ''
 
1475
Error   1292    Truncated incorrect DECIMAL value: ''
 
1476
select space(18446744073709551615);
 
1477
space(18446744073709551615)
 
1478
NULL
 
1479
Warnings:
 
1480
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1481
select space(-18446744073709551616);
 
1482
space(-18446744073709551616)
 
1483
 
 
1484
Warnings:
 
1485
Error   1292    Truncated incorrect DECIMAL value: ''
 
1486
Error   1292    Truncated incorrect DECIMAL value: ''
 
1487
select space(18446744073709551616);
 
1488
space(18446744073709551616)
 
1489
NULL
 
1490
Warnings:
 
1491
Error   1292    Truncated incorrect DECIMAL value: ''
 
1492
Error   1292    Truncated incorrect DECIMAL value: ''
 
1493
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1494
select space(-18446744073709551617);
 
1495
space(-18446744073709551617)
 
1496
 
 
1497
Warnings:
 
1498
Error   1292    Truncated incorrect DECIMAL value: ''
 
1499
Error   1292    Truncated incorrect DECIMAL value: ''
 
1500
select space(18446744073709551617);
 
1501
space(18446744073709551617)
 
1502
NULL
 
1503
Warnings:
 
1504
Error   1292    Truncated incorrect DECIMAL value: ''
 
1505
Error   1292    Truncated incorrect DECIMAL value: ''
 
1506
Warning 1301    Result of repeat() was larger than max_allowed_packet (1048576) - truncated
 
1507
select rpad('hello', -1, '1');
 
1508
rpad('hello', -1, '1')
 
1509
NULL
 
1510
select rpad('hello', -4294967295, '1');
 
1511
rpad('hello', -4294967295, '1')
 
1512
NULL
 
1513
select rpad('hello', 4294967295, '1');
 
1514
rpad('hello', 4294967295, '1')
 
1515
NULL
 
1516
Warnings:
 
1517
Warning 1301    Result of rpad() was larger than max_allowed_packet (1048576) - truncated
 
1518
select rpad('hello', -4294967296, '1');
 
1519
rpad('hello', -4294967296, '1')
 
1520
NULL
 
1521
select rpad('hello', 4294967296, '1');
 
1522
rpad('hello', 4294967296, '1')
 
1523
NULL
 
1524
Warnings:
 
1525
Warning 1301    Result of rpad() was larger than max_allowed_packet (1048576) - truncated
 
1526
select rpad('hello', -4294967297, '1');
 
1527
rpad('hello', -4294967297, '1')
 
1528
NULL
 
1529
select rpad('hello', 4294967297, '1');
 
1530
rpad('hello', 4294967297, '1')
 
1531
NULL
 
1532
Warnings:
 
1533
Warning 1301    Result of rpad() was larger than max_allowed_packet (1048576) - truncated
 
1534
select rpad('hello', -18446744073709551615, '1');
 
1535
rpad('hello', -18446744073709551615, '1')
 
1536
NULL
 
1537
Warnings:
 
1538
Error   1292    Truncated incorrect DECIMAL value: ''
 
1539
Error   1292    Truncated incorrect DECIMAL value: ''
 
1540
select rpad('hello', 18446744073709551615, '1');
 
1541
rpad('hello', 18446744073709551615, '1')
 
1542
NULL
 
1543
Warnings:
 
1544
Warning 1301    Result of rpad() was larger than max_allowed_packet (1048576) - truncated
 
1545
select rpad('hello', -18446744073709551616, '1');
 
1546
rpad('hello', -18446744073709551616, '1')
 
1547
NULL
 
1548
Warnings:
 
1549
Error   1292    Truncated incorrect DECIMAL value: ''
 
1550
Error   1292    Truncated incorrect DECIMAL value: ''
 
1551
select rpad('hello', 18446744073709551616, '1');
 
1552
rpad('hello', 18446744073709551616, '1')
 
1553
NULL
 
1554
Warnings:
 
1555
Error   1292    Truncated incorrect DECIMAL value: ''
 
1556
Error   1292    Truncated incorrect DECIMAL value: ''
 
1557
Warning 1301    Result of rpad() was larger than max_allowed_packet (1048576) - truncated
 
1558
select rpad('hello', -18446744073709551617, '1');
 
1559
rpad('hello', -18446744073709551617, '1')
 
1560
NULL
 
1561
Warnings:
 
1562
Error   1292    Truncated incorrect DECIMAL value: ''
 
1563
Error   1292    Truncated incorrect DECIMAL value: ''
 
1564
select rpad('hello', 18446744073709551617, '1');
 
1565
rpad('hello', 18446744073709551617, '1')
 
1566
NULL
 
1567
Warnings:
 
1568
Error   1292    Truncated incorrect DECIMAL value: ''
 
1569
Error   1292    Truncated incorrect DECIMAL value: ''
 
1570
Warning 1301    Result of rpad() was larger than max_allowed_packet (1048576) - truncated
 
1571
select lpad('hello', -1, '1');
 
1572
lpad('hello', -1, '1')
 
1573
NULL
 
1574
select lpad('hello', -4294967295, '1');
 
1575
lpad('hello', -4294967295, '1')
 
1576
NULL
 
1577
select lpad('hello', 4294967295, '1');
 
1578
lpad('hello', 4294967295, '1')
 
1579
NULL
 
1580
Warnings:
 
1581
Warning 1301    Result of lpad() was larger than max_allowed_packet (1048576) - truncated
 
1582
select lpad('hello', -4294967296, '1');
 
1583
lpad('hello', -4294967296, '1')
 
1584
NULL
 
1585
select lpad('hello', 4294967296, '1');
 
1586
lpad('hello', 4294967296, '1')
 
1587
NULL
 
1588
Warnings:
 
1589
Warning 1301    Result of lpad() was larger than max_allowed_packet (1048576) - truncated
 
1590
select lpad('hello', -4294967297, '1');
 
1591
lpad('hello', -4294967297, '1')
 
1592
NULL
 
1593
select lpad('hello', 4294967297, '1');
 
1594
lpad('hello', 4294967297, '1')
 
1595
NULL
 
1596
Warnings:
 
1597
Warning 1301    Result of lpad() was larger than max_allowed_packet (1048576) - truncated
 
1598
select lpad('hello', -18446744073709551615, '1');
 
1599
lpad('hello', -18446744073709551615, '1')
 
1600
NULL
 
1601
Warnings:
 
1602
Error   1292    Truncated incorrect DECIMAL value: ''
 
1603
Error   1292    Truncated incorrect DECIMAL value: ''
 
1604
select lpad('hello', 18446744073709551615, '1');
 
1605
lpad('hello', 18446744073709551615, '1')
 
1606
NULL
 
1607
Warnings:
 
1608
Warning 1301    Result of lpad() was larger than max_allowed_packet (1048576) - truncated
 
1609
select lpad('hello', -18446744073709551616, '1');
 
1610
lpad('hello', -18446744073709551616, '1')
 
1611
NULL
 
1612
Warnings:
 
1613
Error   1292    Truncated incorrect DECIMAL value: ''
 
1614
Error   1292    Truncated incorrect DECIMAL value: ''
 
1615
select lpad('hello', 18446744073709551616, '1');
 
1616
lpad('hello', 18446744073709551616, '1')
 
1617
NULL
 
1618
Warnings:
 
1619
Error   1292    Truncated incorrect DECIMAL value: ''
 
1620
Error   1292    Truncated incorrect DECIMAL value: ''
 
1621
Warning 1301    Result of lpad() was larger than max_allowed_packet (1048576) - truncated
 
1622
select lpad('hello', -18446744073709551617, '1');
 
1623
lpad('hello', -18446744073709551617, '1')
 
1624
NULL
 
1625
Warnings:
 
1626
Error   1292    Truncated incorrect DECIMAL value: ''
 
1627
Error   1292    Truncated incorrect DECIMAL value: ''
 
1628
select lpad('hello', 18446744073709551617, '1');
 
1629
lpad('hello', 18446744073709551617, '1')
 
1630
NULL
 
1631
Warnings:
 
1632
Error   1292    Truncated incorrect DECIMAL value: ''
 
1633
Error   1292    Truncated incorrect DECIMAL value: ''
 
1634
Warning 1301    Result of lpad() was larger than max_allowed_packet (1048576) - truncated
 
1635
SELECT CHAR(0xff,0x8f);
 
1636
CHAR(0xff,0x8f)
 
1637
��
 
1638
SELECT CHAR(0xff,0x8f) IS NULL;
 
1639
CHAR(0xff,0x8f) IS NULL
 
1640
0
 
1641
create table t1(f1 longtext);
 
1642
insert into t1 values ("123"),("456");
 
1643
select substring(f1,1,1) from t1 group by 1;
 
1644
substring(f1,1,1)
 
1645
1
 
1646
4
 
1647
create table t2(f1 varchar(3));
 
1648
insert into t1 values ("123"),("456");
 
1649
select substring(f1,4,1), substring(f1,-4,1) from t2;
 
1650
substring(f1,4,1)       substring(f1,-4,1)
 
1651
drop table t1,t2;
 
1652
DROP TABLE IF EXISTS t1;
 
1653
CREATE TABLE `t1` (
 
1654
`id` varchar(20) NOT NULL,
 
1655
`tire` int NOT NULL,
 
1656
PRIMARY KEY (`id`)
 
1657
);
 
1658
INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2);
 
1659
SELECT REPEAT( '#', tire ) AS A,
 
1660
REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`;
 
1661
A       B       tire
 
1662
                0
 
1663
#       #       1
 
1664
##      ##      2
 
1665
SELECT REPEAT('0', 0);
 
1666
REPEAT('0', 0)
 
1667
 
 
1668
SELECT REPEAT('0', -2);
 
1669
REPEAT('0', -2)
 
1670
 
 
1671
SELECT REPEAT('0', 2);
 
1672
REPEAT('0', 2)
 
1673
00
 
1674
DROP TABLE t1;
 
1675
SELECT UNHEX('G');
 
1676
UNHEX('G')
 
1677
NULL
 
1678
SELECT UNHEX('G') IS NULL;
 
1679
UNHEX('G') IS NULL
 
1680
1
 
1681
SELECT INSERT('abc', 3, 3, '1234');
 
1682
INSERT('abc', 3, 3, '1234')
 
1683
ab1234
 
1684
SELECT INSERT('abc', 4, 3, '1234');
 
1685
INSERT('abc', 4, 3, '1234')
 
1686
abc1234
 
1687
SELECT INSERT('abc', 5, 3, '1234');
 
1688
INSERT('abc', 5, 3, '1234')
 
1689
abc
 
1690
SELECT INSERT('abc', 6, 3, '1234');
 
1691
INSERT('abc', 6, 3, '1234')
 
1692
abc
 
1693
SELECT LOCATE('foo', NULL);
 
1694
LOCATE('foo', NULL)
 
1695
NULL
 
1696
SELECT LOCATE(NULL, 'o');
 
1697
LOCATE(NULL, 'o')
 
1698
NULL
 
1699
SELECT LOCATE(NULL, NULL);
 
1700
LOCATE(NULL, NULL)
 
1701
NULL
 
1702
SELECT LOCATE('foo', NULL) IS NULL;
 
1703
LOCATE('foo', NULL) IS NULL
 
1704
1
 
1705
SELECT LOCATE(NULL, 'o') IS NULL;
 
1706
LOCATE(NULL, 'o') IS NULL
 
1707
1
 
1708
SELECT LOCATE(NULL, NULL) IS NULL;
 
1709
LOCATE(NULL, NULL) IS NULL
 
1710
1
 
1711
SELECT ISNULL(LOCATE('foo', NULL));
 
1712
ISNULL(LOCATE('foo', NULL))
 
1713
1
 
1714
SELECT ISNULL(LOCATE(NULL, 'o'));
 
1715
ISNULL(LOCATE(NULL, 'o'))
 
1716
1
 
1717
SELECT ISNULL(LOCATE(NULL, NULL));
 
1718
ISNULL(LOCATE(NULL, NULL))
 
1719
1
 
1720
SELECT LOCATE('foo', NULL) <=> NULL;
 
1721
LOCATE('foo', NULL) <=> NULL
 
1722
1
 
1723
SELECT LOCATE(NULL, 'o') <=> NULL;
 
1724
LOCATE(NULL, 'o') <=> NULL
 
1725
1
 
1726
SELECT LOCATE(NULL, NULL) <=> NULL;
 
1727
LOCATE(NULL, NULL) <=> NULL
 
1728
1
 
1729
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a varchar(10), p varchar(10));
 
1730
INSERT INTO t1 VALUES (1, 'foo', 'o');
 
1731
INSERT INTO t1 VALUES (2, 'foo', NULL);
 
1732
INSERT INTO t1 VALUES (3, NULL, 'o');
 
1733
INSERT INTO t1 VALUES (4, NULL, NULL);
 
1734
SELECT id, LOCATE(a,p) FROM t1;
 
1735
id      LOCATE(a,p)
 
1736
1       0
 
1737
2       NULL
 
1738
3       NULL
 
1739
4       NULL
 
1740
SELECT id, LOCATE(a,p) IS NULL FROM t1;
 
1741
id      LOCATE(a,p) IS NULL 
 
1742
1       0
 
1743
2       1
 
1744
3       1
 
1745
4       1
 
1746
SELECT id, ISNULL(LOCATE(a,p)) FROM t1;
 
1747
id      ISNULL(LOCATE(a,p))
 
1748
1       0
 
1749
2       1
 
1750
3       1
 
1751
4       1
 
1752
SELECT id, LOCATE(a,p) <=> NULL FROM t1;
 
1753
id      LOCATE(a,p) <=> NULL 
 
1754
1       0
 
1755
2       1
 
1756
3       1
 
1757
4       1
 
1758
SELECT id FROM t1 WHERE LOCATE(a,p) IS NULL;
 
1759
id
 
1760
2
 
1761
3
 
1762
4
 
1763
SELECT id FROM t1 WHERE LOCATE(a,p) <=> NULL;
 
1764
id
 
1765
2
 
1766
3
 
1767
4
 
1768
DROP TABLE t1;
 
1769
SELECT SUBSTR('foo',1,0);
 
1770
SUBSTR('foo',1,0)
 
1771
 
 
1772
SELECT SUBSTR('foo',1,0);
 
1773
SUBSTR('foo',1,0)
 
1774
 
 
1775
SELECT SUBSTR('foo',1,0);
 
1776
SUBSTR('foo',1,0)
 
1777
 
 
1778
CREATE TABLE t1 (a varchar(10), len int);
 
1779
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
 
1780
SELECT SUBSTR(a,1,len) FROM t1;
 
1781
SUBSTR(a,1,len)
 
1782
ba
 
1783
 
 
1784
DROP TABLE t1;
 
1785
CREATE TABLE t1 AS SELECT CHAR(0x414243) as c1;
 
1786
SELECT HEX(c1) from t1;
 
1787
HEX(c1)
 
1788
414243
 
1789
DROP TABLE t1;
 
1790
End of 5.0 tests