~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/func_str.test

  • Committer: Monty Taylor
  • Date: 2008-07-05 22:08:52 UTC
  • mto: This revision was merged to the branch mainline in revision 77.
  • Revision ID: monty@inaugust.com-20080705220852-cqd9t6tfkhvlcf73
Removed HAVE_LONG_LONG, as this is now assumed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
drop table if exists t1,t2;
7
7
--enable_warnings
8
8
 
 
9
set names latin1;
 
10
 
9
11
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
10
12
select 'hello' 'monty';
11
13
select length('\n\t\r\b\0\_\%\\');
12
14
select bit_length('\n\t\r\b\0\_\%\\');
13
15
select char_length('\n\t\r\b\0\_\%\\');
14
 
select length('\n\t\n\b\0\\_\\%\\');
 
16
select length(_latin1'\n\t\n\b\0\\_\\%\\');
15
17
select concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h');
16
18
select hex(char(256));
17
19
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
83
85
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
84
86
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
85
87
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
 
88
select md5('hello');
86
89
select crc32("123");
 
90
select aes_decrypt(aes_encrypt('abc','1'),'1');
 
91
select aes_decrypt(aes_encrypt('abc','1'),1);
 
92
select aes_encrypt(NULL,"a");
 
93
select aes_encrypt("a",NULL);
 
94
select aes_decrypt(NULL,"a");
 
95
select aes_decrypt("a",NULL);
 
96
select aes_decrypt("a","a");
 
97
select aes_decrypt(aes_encrypt("","a"),"a");
87
98
select repeat('monty',5),concat('*',space(5),'*');
88
99
select reverse('abc'),reverse('abcd');
89
100
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
95
106
select lpad('STRING', 20, CONCAT('p','a','d') );
96
107
 
97
108
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
 
109
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");
 
110
 
 
111
select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
 
112
select decode(encode("abcdef","monty"),"monty")="abcdef";
98
113
 
99
114
select quote('\'\"\\test');
100
115
select quote(concat('abc\'', '\\cba'));
103
118
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
104
119
select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), unhex(NULL);
105
120
select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456"));
 
121
select length(unhex(md5("abrakadabra")));
106
122
 
107
123
#
108
124
# Bug #6564: QUOTE(NULL
119
135
select elt(2,1),field(NULL,"a","b","c"),reverse("");
120
136
select locate("a","b",2),locate("","a",1);
121
137
select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
 
138
select concat("1","2")|0,concat("1",".5")+0.0;
122
139
select substring_index("www.tcx.se","",3);
123
140
select length(repeat("a",100000000)),length(repeat("a",1000*64));
124
141
select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
141
158
#
142
159
 
143
160
CREATE TABLE t1 (
144
 
  id int NOT NULL,
 
161
  id int(10) unsigned NOT NULL,
145
162
  title varchar(255) default NULL,
146
 
  prio int default NULL,
147
 
  category int default NULL,
148
 
  program int default NULL,
 
163
  prio int(10) unsigned default NULL,
 
164
  category int(10) unsigned default NULL,
 
165
  program int(10) unsigned default NULL,
149
166
  bugdesc text,
150
167
  created datetime default NULL,
151
168
  modified timestamp NOT NULL,
152
 
  bugstatus int default NULL,
153
 
  submitter int default NULL
 
169
  bugstatus int(10) unsigned default NULL,
 
170
  submitter int(10) unsigned default NULL
154
171
) ENGINE=MyISAM;
155
172
 
156
173
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
164
181
# Test bug in AES_DECRYPT() when called with wrong argument
165
182
#
166
183
 
167
 
CREATE TABLE t1 (id int NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) ENGINE=MyISAM;
 
184
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) ENGINE=MyISAM;
168
185
INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
 
186
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
169
187
DROP TABLE t1;
170
188
 
171
189
CREATE TABLE t1 (
172
 
  wid int NOT NULL auto_increment,
 
190
  wid int(10) unsigned NOT NULL auto_increment,
173
191
  data_podp date default NULL,
174
192
  status_wnio enum('nowy','podp','real','arch') NOT NULL default 'nowy',
175
193
  PRIMARY KEY(wid)
227
245
SELECT QUOTE('A') FROM t1;
228
246
DROP TABLE t1;
229
247
 
 
248
# Test collation and coercibility
 
249
#
 
250
 
 
251
select 1=_latin1'1';
 
252
select _latin1'1'=1;
 
253
select _latin2'1'=1;
 
254
select 1=_latin2'1';
 
255
--error 1267
 
256
select _latin1'1'=_latin2'1';
 
257
select row('a','b','c') = row('a','b','c');
 
258
select row('A','b','c') = row('a','b','c');
 
259
select row('A' COLLATE latin1_bin,'b','c') = row('a','b','c');
 
260
select row('A','b','c') = row('a' COLLATE latin1_bin,'b','c');
 
261
--error 1267
 
262
select row('A' COLLATE latin1_general_ci,'b','c') = row('a' COLLATE latin1_bin,'b','c');
 
263
 
 
264
--error 1267
 
265
select concat(_latin1'a',_latin2'a');
 
266
--error 1270
 
267
select concat(_latin1'a',_latin2'a',_latin5'a');
 
268
--error 1271
 
269
select concat(_latin1'a',_latin2'a',_latin5'a',_latin7'a');
 
270
--error 1267
 
271
select concat_ws(_latin1'a',_latin2'a');
 
272
 
 
273
#
 
274
# Test FIELD() and collations
 
275
#
 
276
select FIELD('b','A','B');
 
277
select FIELD('B','A','B');
 
278
select FIELD('b' COLLATE latin1_bin,'A','B');
 
279
select FIELD('b','A' COLLATE latin1_bin,'B');
 
280
--error 1270
 
281
select FIELD(_latin2'b','A','B');
 
282
--error 1270
 
283
select FIELD('b',_latin2'A','B');
 
284
select FIELD('1',_latin2'3','2',1);
 
285
 
 
286
select POSITION(_latin1'B' IN _latin1'abcd');
 
287
select POSITION(_latin1'B' IN _latin1'abcd' COLLATE latin1_bin);
 
288
select POSITION(_latin1'B' COLLATE latin1_bin IN _latin1'abcd');
 
289
--error 1267
 
290
select POSITION(_latin1'B' COLLATE latin1_general_ci IN _latin1'abcd' COLLATE latin1_bin);
 
291
--error 1267
 
292
select POSITION(_latin1'B' IN _latin2'abcd');
 
293
 
 
294
select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d');
 
295
 
 
296
# fix this:
 
297
--disable_parsing
 
298
select FIND_IN_SET(_latin1'B',_latin1'a,b,c,d' COLLATE latin1_bin);
 
299
select FIND_IN_SET(_latin1'B' COLLATE latin1_bin,_latin1'a,b,c,d');
 
300
--enable_parsing
 
301
 
 
302
--error 1267
 
303
select FIND_IN_SET(_latin1'B' COLLATE latin1_general_ci,_latin1'a,b,c,d' COLLATE latin1_bin);
 
304
--error 1267
 
305
select FIND_IN_SET(_latin1'B',_latin2'a,b,c,d');
 
306
 
 
307
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd',2);
 
308
 
 
309
# fix this:
 
310
--disable_parsing
 
311
select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_bin,_latin1'd',2);
 
312
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin1'd' COLLATE latin1_bin,2);
 
313
--enable_parsing
 
314
 
 
315
--error 1267
 
316
select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2);
 
317
--error 1267
 
318
select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2);
 
319
 
 
320
select _latin1'B' between _latin1'a' and _latin1'c';
 
321
select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c';
 
322
select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c';
 
323
select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin;
 
324
--error 1270
 
325
select _latin2'B' between _latin1'a' and _latin1'b';
 
326
--error 1270
 
327
select _latin1'B' between _latin2'a' and _latin1'b';
 
328
--error 1270
 
329
select _latin1'B' between _latin1'a' and _latin2'b';
 
330
--error 1270
 
331
select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b';
 
332
 
 
333
select _latin1'B' in (_latin1'a',_latin1'b');
 
334
select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b');
 
335
select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b');
 
336
select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin);
 
337
--error 1270
 
338
select _latin2'B' in (_latin1'a',_latin1'b');
 
339
--error 1270
 
340
select _latin1'B' in (_latin2'a',_latin1'b');
 
341
--error 1270
 
342
select _latin1'B' in (_latin1'a',_latin2'b');
 
343
--error 1270
 
344
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b');
 
345
--error 1270
 
346
select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin);
 
347
 
 
348
select collation(bin(130)), coercibility(bin(130));
 
349
select collation(oct(130)), coercibility(oct(130));
 
350
select collation(conv(130,16,10)), coercibility(conv(130,16,10));
 
351
select collation(hex(130)), coercibility(hex(130));
 
352
select collation(char(130)), coercibility(hex(130));
 
353
select collation(format(130,10)), coercibility(format(130,10));
 
354
select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a'));
 
355
select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a'));
 
356
select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1));
 
357
select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1));
 
358
select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1));
 
359
select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b'));
 
360
select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b'));
 
361
select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b'));
 
362
select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b'));
 
363
select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c'));
 
364
select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' '));
 
365
select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a '));
 
366
select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a '));
 
367
select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a '));
 
368
select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a'));
 
369
select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a'));
 
370
select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a'));
 
371
select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10));
 
372
select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab'));
 
373
select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab'));
 
374
select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1));
 
375
select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef'));
 
376
select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B'));
 
377
select collation(encode('abcd','ab')), coercibility(encode('abcd','ab'));
 
378
 
 
379
create table t1 
 
380
select
 
381
  bin(130),
 
382
  oct(130),
 
383
  conv(130,16,10),
 
384
  hex(130),
 
385
  char(130),
 
386
  left(_latin2'a',1),
 
387
  right(_latin2'a',1), 
 
388
  lcase(_latin2'a'), 
 
389
  ucase(_latin2'a'),
 
390
  substring(_latin2'a',1,1),
 
391
  concat(_latin2'a',_latin2'b'),
 
392
  lpad(_latin2'a',4,_latin2'b'),
 
393
  rpad(_latin2'a',4,_latin2'b'),
 
394
  concat_ws(_latin2'a',_latin2'b'),
 
395
  make_set(255,_latin2'a',_latin2'b',_latin2'c'),
 
396
  export_set(255,_latin2'y',_latin2'n',_latin2' '),
 
397
  trim(_latin2' a '),
 
398
  ltrim(_latin2' a '),
 
399
  rtrim(_latin2' a '),
 
400
  trim(LEADING _latin2' ' FROM _latin2' a '),
 
401
  trim(TRAILING _latin2' ' FROM _latin2' a '),
 
402
  trim(BOTH _latin2' ' FROM _latin2' a '),
 
403
  repeat(_latin2'a',10),
 
404
  reverse(_latin2'ab'),
 
405
  quote(_latin2'ab'),
 
406
  substring(_latin2'ab',1),
 
407
  insert(_latin2'abcd',2,3,_latin2'ef'),
 
408
  replace(_latin2'abcd',_latin2'b',_latin2'B'),
 
409
  encode('abcd','ab')
 
410
;
 
411
show create table t1;
 
412
drop table t1;
 
413
 
 
414
#
 
415
# Bug#9129
 
416
#
 
417
create table t1 (a char character set latin2);
 
418
insert into t1 values (null);
 
419
select charset(a), collation(a), coercibility(a) from t1;
 
420
drop table t1;
 
421
select charset(null), collation(null), coercibility(null);
 
422
#
 
423
# Make sure OUTER JOIN is not replaced with a regular joun
 
424
#
 
425
CREATE TABLE t1 (a int, b int);
 
426
CREATE TABLE t2 (a int, b int);
 
427
INSERT INTO t1 VALUES (1,1),(2,2);
 
428
INSERT INTO t2 VALUES (2,2),(3,3);
 
429
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
 
430
where collation(t2.a) = _utf8'binary' order by t1.a,t2.a;
 
431
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
 
432
where charset(t2.a) = _utf8'binary' order by t1.a,t2.a;
 
433
select t1.*,t2.* from t1 left join t2 on (t1.b=t2.b)
 
434
where coercibility(t2.a) = 2 order by t1.a,t2.a;
 
435
DROP TABLE t1, t2;
 
436
 
230
437
#
231
438
# test for SUBSTR
232
439
#
238
445
select SUBSTR('abcdefg',-1,-1);
239
446
select SUBSTR('abcdefg',1,-1);
240
447
 
 
448
#
 
449
# Test that fix_fields doesn't follow to upper level (to comparison)
 
450
# when an error on a lower level (in concat) has accured:
 
451
#
 
452
create table t7 (s1 char);
 
453
--error 1267
 
454
select * from t7
 
455
where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA';
 
456
drop table t7;
 
457
 
241
458
select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2);
242
459
 
 
460
explain extended select md5('hello');
 
461
explain extended select aes_decrypt(aes_encrypt('abc','1'),'1');
243
462
explain extended select concat('*',space(5),'*');
244
463
explain extended select reverse('abc');
245
464
explain extended select rpad('a',4,'1');
246
465
explain extended select lpad('a',4,'1');
247
466
explain extended select concat_ws(',','',NULL,'a');
 
467
explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c');
248
468
explain extended select elt(2,1);
249
469
explain extended select locate("a","b",2);
250
470
explain extended select char(0);
251
471
explain extended select conv(130,16,10);
252
472
explain extended select hex(130);
253
473
explain extended select binary 'HE';
 
474
explain extended select export_set(255,_latin2'y', _latin2'n', _latin2' ');
 
475
explain extended select FIELD('b' COLLATE latin1_bin,'A','B');
 
476
explain extended select FIND_IN_SET(_latin1'B', _latin1'a,b,c,d');
254
477
explain extended select collation(conv(130,16,10));
255
478
explain extended select coercibility(conv(130,16,10));
256
479
explain extended select length('\n\t\r\b\0\_\%\\');
 
480
explain extended select bit_length('\n\t\r\b\0\_\%\\');
 
481
explain extended select bit_length('\n\t\r\b\0\_\%\\');
257
482
explain extended select concat('monty',' was here ','again');
258
483
explain extended select length('hello');
259
484
explain extended select char(ascii('h'));
262
487
explain extended select crc32("123");
263
488
explain extended select replace('aaaa','a','b');
264
489
explain extended select insert('txs',2,1,'hi');
 
490
explain extended select left(_latin2'a',1);
 
491
explain extended select right(_latin2'a',1);
 
492
explain extended select lcase(_latin2'a');
 
493
explain extended select ucase(_latin2'a');
265
494
explain extended select SUBSTR('abcdefg',3,2);
266
495
explain extended select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2);
 
496
explain extended select trim(_latin2' a ');
 
497
explain extended select ltrim(_latin2' a ');
 
498
explain extended select rtrim(_latin2' a ');
 
499
explain extended select decode(encode(repeat("a",100000),"monty"),"monty");
267
500
 
268
501
#
269
502
# lpad returns incorrect result (Bug #2182)
282
515
# Bug in SUBSTRING when mixed with CONCAT and ORDER BY (Bug #3089)
283
516
#
284
517
 
285
 
create table t1 (id int, str varchar(10));
 
518
create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
286
519
insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb');
287
 
create table t2 (id int, str varchar(10));
 
520
create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8;
288
521
insert into t2 values (1,'cccccccccc'), (2,'dddddddddd');
289
522
select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2 
290
523
where t2.id=t1.id order by name;
294
527
# Test case for conversion of long string value to integer (Bug #3472)
295
528
#
296
529
 
297
 
create table t1 (c1 INT, c2 INT);
298
 
--error 1264
 
530
create table t1 (c1 INT, c2 INT UNSIGNED);
299
531
insert into t1 values ('21474836461','21474836461');
300
 
--error 1264
301
532
insert into t1 values ('-21474836461','-21474836461');
 
533
show warnings;
302
534
select * from t1;
303
535
drop table t1;
304
536
 
327
559
select trim(trailing NULL from 'xyz') as "must_be_null";
328
560
 
329
561
#
330
 
# Bug #7751 - conversion for a bigint constant 
 
562
# Bug #7751 - conversion for a bigint unsigned constant 
331
563
#
332
564
 
333
565
CREATE TABLE t1 (
334
 
  id int NOT NULL auto_increment,
335
 
  a bigint default NULL,
 
566
  id int(11) NOT NULL auto_increment,
 
567
  a bigint(20) unsigned default NULL,
336
568
  PRIMARY KEY  (id)
337
569
) ENGINE=MyISAM;
338
570
 
339
 
--error 1264
340
 
INSERT INTO t1 VALUES ('0','16307858876001849059');
 
571
INSERT INTO t1 VALUES
 
572
('0','16307858876001849059');
341
573
 
342
574
SELECT CONV('e251273eb74a8ee3', 16, 10);
343
575
 
365
597
CREATE TABLE t1 (id int PRIMARY KEY, str char(255) NOT NULL);
366
598
CREATE TABLE t2 (id int NOT NULL UNIQUE);
367
599
INSERT INTO t2 VALUES (1),(2);
 
600
INSERT INTO t1 VALUES (1, aes_encrypt('foo', 'bar'));
368
601
INSERT INTO t1 VALUES (2, 'not valid');
369
602
 
 
603
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id;
 
604
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
 
605
 ORDER BY t1.id;
 
606
 
370
607
DROP TABLE t1, t2;
371
608
 
372
609
#
394
631
#
395
632
 
396
633
CREATE TABLE t1(
397
 
  id int NOT NULL auto_increment,
398
 
  pc int NOT NULL default '0',
 
634
  id int(11) NOT NULL auto_increment,
 
635
  pc int(11) NOT NULL default '0',
399
636
  title varchar(20) default NULL,
400
637
  PRIMARY KEY (id)
401
638
);
417
654
 
418
655
 
419
656
CREATE TABLE t1(
420
 
  trackid     int NOT NULL auto_increment,
 
657
  trackid     int(10) unsigned NOT NULL auto_increment,
421
658
  trackname   varchar(100) NOT NULL default '',
422
659
  PRIMARY KEY (trackid)
423
660
);
424
661
 
425
662
CREATE TABLE t2(
426
 
  artistid    int NOT NULL auto_increment,
 
663
  artistid    int(10) unsigned NOT NULL auto_increment,
427
664
  artistname  varchar(100) NOT NULL default '',
428
665
  PRIMARY KEY (artistid)
429
666
);
430
667
 
431
668
CREATE TABLE t3(
432
 
  trackid     int NOT NULL,
433
 
  artistid    int NOT NULL,
 
669
  trackid     int(10) unsigned NOT NULL,
 
670
  artistid    int(10) unsigned NOT NULL,
434
671
  PRIMARY KEY (trackid,artistid)
435
672
);
436
673
 
478
715
select ifnull(load_file("lkjlkj"),"it's null");
479
716
 
480
717
#
 
718
# Bug#15351: Wrong collation used for comparison of md5() and sha()
 
719
# parameter can lead to a wrong result.
 
720
#
 
721
create table t1 (f1 varchar(4), f2 varchar(64), unique key k1 (f1,f2));
 
722
insert into t1 values ( 'test',md5('test')), ('test', sha('test'));
 
723
select * from t1 where f1='test' and (f2= md5("test") or f2= md5("TEST"));
 
724
select * from t1 where f1='test' and (f2= md5("TEST") or f2= md5("test"));
 
725
select * from t1 where f1='test' and (f2= sha("test") or f2= sha("TEST"));
 
726
select * from t1 where f1='test' and (f2= sha("TEST") or f2= sha("test"));
 
727
drop table t1;
 
728
 
 
729
#
481
730
# Bug#18243: REVERSE changes its argument
482
731
#
483
732
 
508
757
EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab';
509
758
 
510
759
DROP TABLE t1;
 
760
 
 
761
#
 
762
# Bug#23409: ENCODE() and DECODE() functions aren't printed correctly
 
763
#
 
764
create table t1(f1 varchar(4));
 
765
explain extended select encode(f1,'zxcv') as 'enc' from t1;
 
766
explain extended select decode(f1,'zxcv') as 'enc' from t1;
 
767
drop table t1;
511
768
 
512
769
#
513
770
# Bug #31758 inet_ntoa, oct, crashes server with null + filesort 
514
771
#
515
772
create table t1 (a bigint not null)engine=myisam;
516
773
insert into t1 set a = 1024*1024*1024*4;
 
774
delete from t1 order by (inet_ntoa(a)) desc limit 10;
517
775
drop table t1;
518
776
create table t1 (a char(36) not null)engine=myisam;
519
777
insert ignore into t1 set a = ' ';
580
838
DROP TABLE t1,t2;
581
839
 
582
840
#
 
841
# Bug#22684: The Functions ENCODE, DECODE and FORMAT are not real functions
 
842
#
 
843
 
 
844
select encode(NULL, NULL);
 
845
select encode("data", NULL);
 
846
select encode(NULL, "password");
 
847
 
 
848
select decode(NULL, NULL);
 
849
select decode("data", NULL);
 
850
select decode(NULL, "password");
 
851
 
 
852
select format(NULL, NULL);
 
853
select format(pi(), NULL);
 
854
select format(NULL, 2);
 
855
 
 
856
select benchmark(NULL, NULL);
 
857
select benchmark(0, NULL);
 
858
select benchmark(100, NULL);
 
859
select benchmark(NULL, 1+1);
 
860
 
 
861
#
583
862
# Bug #20752: BENCHMARK with many iterations returns too quickly
584
863
#
585
864
 
596
875
# 3) Each md5() result must be identical.
597
876
# 4) The md5() result must never change, and must be stable across releases.
598
877
#
 
878
set @password="password";
 
879
set @my_data="clear text to encode";
 
880
select md5(encode(@my_data, "password"));
 
881
select md5(encode(@my_data, _utf8 "password"));
 
882
select md5(encode(@my_data, binary "password"));
 
883
select md5(encode(@my_data, _latin1 "password"));
 
884
select md5(encode(@my_data, _koi8r "password"));
 
885
select md5(encode(@my_data, (select "password" from dual)));
 
886
select md5(encode(@my_data, concat("pass", "word")));
 
887
select md5(encode(@my_data, @password));
 
888
 
 
889
set @my_data="binary encoded data";
 
890
select md5(decode(@my_data, "password"));
 
891
select md5(decode(@my_data, _utf8 "password"));
 
892
select md5(decode(@my_data, binary "password"));
 
893
select md5(decode(@my_data, _latin1 "password"));
 
894
select md5(decode(@my_data, _koi8r "password"));
 
895
select md5(decode(@my_data, (select "password" from dual)));
 
896
select md5(decode(@my_data, concat("pass", "word")));
 
897
select md5(decode(@my_data, @password));
599
898
 
600
899
set @dec=5;
601
900
select format(pi(), (1+1));
602
 
select format(pi(), (select 3));
 
901
select format(pi(), (select 3 from dual));
603
902
select format(pi(), @dec);
604
903
 
605
904
set @bench_count=10;
606
905
select benchmark(10, pi());
607
906
select benchmark(5+5, pi());
608
 
select benchmark((select 10), pi());
 
907
select benchmark((select 10 from dual), pi());
609
908
select benchmark(@bench_count, pi());
610
909
 
611
910
 
803
1102
# BUG#17047: CHAR() and IN() can return NULL without signaling NULL
804
1103
# result
805
1104
#
806
 
SELECT CHAR(0xff,0x8f);
807
 
SELECT CHAR(0xff,0x8f) IS NULL;
808
 
 
809
 
#
810
 
# Bug #24947: problem with some string function with int parameters
811
 
#
812
 
#
813
 
#select substring('abc', cast(2 as int));
814
 
#select repeat('a', cast(2 as int));
815
 
#select rpad('abc', cast(5 as integer), 'x');
816
 
#select lpad('abc', cast(5 as integer), 'x');
 
1105
SET @orig_sql_mode = @@SQL_MODE;
 
1106
SET SQL_MODE=traditional;
 
1107
 
 
1108
SELECT CHAR(0xff,0x8f USING utf8);
 
1109
SELECT CHAR(0xff,0x8f USING utf8) IS NULL;
 
1110
 
 
1111
SET SQL_MODE=@orig_sql_mode;
 
1112
 
 
1113
#
 
1114
# Bug #24947: problem with some string function with unsigned int parameters
 
1115
#
 
1116
 
 
1117
select substring('abc', cast(2 as unsigned int));
 
1118
select repeat('a', cast(2 as unsigned int));
 
1119
select rpad('abc', cast(5 as unsigned integer), 'x');
 
1120
select lpad('abc', cast(5 as unsigned integer), 'x');
817
1121
 
818
1122
#
819
1123
# Bug#15757: Wrong SUBSTRING() result when a tmp table was employed.
836
1140
 
837
1141
CREATE TABLE `t1` (
838
1142
  `id` varchar(20) NOT NULL,
839
 
  `tire` int NOT NULL,
 
1143
  `tire` tinyint(3) unsigned NOT NULL,
840
1144
  PRIMARY KEY (`id`)
841
1145
);
842
1146
 
845
1149
SELECT REPEAT( '#', tire ) AS A,
846
1150
       REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`;
847
1151
 
848
 
SELECT REPEAT('0', 0);
 
1152
SELECT REPEAT('0', CAST(0 AS UNSIGNED));
849
1153
SELECT REPEAT('0', -2);
850
1154
SELECT REPEAT('0', 2);
851
1155
 
866
1170
SELECT INSERT('abc', 6, 3, '1234');
867
1171
 
868
1172
#
 
1173
# Bug #27530: Grouping on crc32, or create table select crc32
 
1174
#
 
1175
CREATE TABLE t1 (a INT);
 
1176
CREATE VIEW v1 AS SELECT CRC32(a) AS C FROM t1;
 
1177
 
 
1178
INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10);
 
1179
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1;
 
1180
SELECT CRC32(a), COUNT(*) FROM t1 GROUP BY 1 ORDER BY 1;
 
1181
SELECT * FROM (SELECT CRC32(a) FROM t1) t2;
 
1182
CREATE TABLE t2 SELECT CRC32(a) FROM t1;
 
1183
desc t2;
 
1184
SELECT * FROM v1;
 
1185
SELECT * FROM (SELECT * FROM v1) x;
 
1186
 
 
1187
DROP TABLE t1, t2;
 
1188
DROP VIEW v1;
 
1189
 
 
1190
#
869
1191
# Bug #27932: LOCATE with argument evaluated to NULL
870
1192
#
871
1193
 
899
1221
DROP TABLE t1;
900
1222
 
901
1223
#
902
 
# Bug #27130: SUBSTR with 0 as the last argument
 
1224
# Bug #27130: SUBSTR with UNSIGNED 0 as the last argument
903
1225
#
904
1226
 
905
1227
SELECT SUBSTR('foo',1,0);
906
 
SELECT SUBSTR('foo',1,0);
907
 
SELECT SUBSTR('foo',1,0);
 
1228
SELECT SUBSTR('foo',1,CAST(0 AS SIGNED));
 
1229
SELECT SUBSTR('foo',1,CAST(0 AS UNSIGNED));
908
1230
 
909
 
CREATE TABLE t1 (a varchar(10), len int);
 
1231
CREATE TABLE t1 (a varchar(10), len int unsigned);
910
1232
INSERT INTO t1 VALUES ('bar', 2), ('foo', 0);
911
1233
 
912
1234
SELECT SUBSTR(a,1,len) FROM t1;