2000-12-15 09:58:17 +01:00
|
|
|
# Version: 3.23.29
|
|
|
|
#
|
|
|
|
# Description
|
|
|
|
# -----------
|
|
|
|
# Testing string functions
|
|
|
|
|
2001-03-23 19:38:42 +01:00
|
|
|
drop table if exists t1;
|
|
|
|
|
2000-12-15 09:58:17 +01:00
|
|
|
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
|
|
|
|
select 'hello' 'monty';
|
|
|
|
select length('\n\t\r\b\0\_\%\\');
|
2002-01-03 20:47:14 +01:00
|
|
|
select bit_length('\n\t\r\b\0\_\%\\');
|
2000-12-15 09:58:17 +01:00
|
|
|
select concat('monty',' was here ','again'),length('hello'),char(ascii('h'));
|
|
|
|
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
|
2001-11-22 12:50:50 +01:00
|
|
|
select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE');
|
|
|
|
select position(binary 'll' in 'hello'),position('a' in binary 'hello');
|
2000-12-15 09:58:17 +01:00
|
|
|
select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ;
|
|
|
|
select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ;
|
|
|
|
select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1);
|
|
|
|
select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1);
|
|
|
|
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
|
|
|
|
|
|
|
|
select concat(':',ltrim(' left '),':',rtrim(' right '),':');
|
|
|
|
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
|
|
|
|
select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':');
|
|
|
|
select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':');
|
|
|
|
select concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':');
|
2001-01-19 03:57:29 +01:00
|
|
|
select TRIM("foo" FROM "foo"), TRIM("foo" FROM "foook"), TRIM("foo" FROM "okfoo");
|
2000-12-15 09:58:17 +01:00
|
|
|
|
2001-03-23 19:38:42 +01:00
|
|
|
select concat_ws(', ','monty','was here','again');
|
|
|
|
select concat_ws(NULL,'a'),concat_ws(',',NULL,'');
|
|
|
|
select concat_ws(',','',NULL,'a');
|
|
|
|
SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"');
|
|
|
|
|
2000-12-15 09:58:17 +01:00
|
|
|
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
|
|
|
|
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
|
|
|
|
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
|
|
|
|
select soundex(''),soundex('he'),soundex('hello all folks');
|
|
|
|
select md5('hello');
|
2002-06-11 11:37:48 +02:00
|
|
|
select sha('abc');
|
|
|
|
select sha1('abc');
|
|
|
|
select aes_decrypt(aes_encrypt('abc','1'),'1');
|
|
|
|
select aes_decrypt(aes_encrypt('abc','1'),1);
|
|
|
|
select aes_encrypt(NULL,"a");
|
|
|
|
select aes_encrypt("a",NULL);
|
|
|
|
select aes_decrypt(NULL,"a");
|
|
|
|
select aes_decrypt("a",NULL);
|
|
|
|
select aes_decrypt("a","a");
|
|
|
|
select aes_decrypt(aes_encrypt("","a"),"a");
|
2000-12-15 09:58:17 +01:00
|
|
|
select repeat('monty',5),concat('*',space(5),'*');
|
|
|
|
select reverse('abc'),reverse('abcd');
|
|
|
|
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12');
|
|
|
|
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12');
|
|
|
|
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
|
|
|
|
select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
|
|
|
|
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
|
|
|
|
|
|
|
|
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
|
2000-12-28 02:56:38 +01:00
|
|
|
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");
|
|
|
|
|
|
|
|
select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
|
|
|
|
select decode(encode("abcdef","monty"),"monty")="abcdef";
|
|
|
|
|
2002-08-09 14:58:30 +02:00
|
|
|
select quote('\'\"\\test');
|
|
|
|
select quote(concat('abc\'', '\\cba'));
|
2002-08-12 02:33:46 +02:00
|
|
|
select quote(1/0), quote('\0\Z');
|
2003-01-03 16:46:15 +01:00
|
|
|
select length(quote(concat(char(0),"test")));
|
2002-08-09 14:58:30 +02:00
|
|
|
|
2000-12-28 02:56:38 +01:00
|
|
|
#
|
|
|
|
# Wrong usage of functions
|
|
|
|
#
|
|
|
|
|
|
|
|
select reverse("");
|
|
|
|
select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
|
|
|
|
select elt(2,1),field(NULL,"a","b","c"),reverse("");
|
|
|
|
select locate("a","b",2),locate("","a",1);
|
|
|
|
select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
|
|
|
|
select concat("1","2")|0,concat("1",".5")+0.0;
|
|
|
|
select substring_index("www.tcx.se","",3);
|
|
|
|
select length(repeat("a",100000000)),length(repeat("a",1000*64));
|
|
|
|
select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
|
|
|
|
select position(("1" in (1,2,3)) in "01");
|
|
|
|
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)));
|
|
|
|
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)));
|
|
|
|
|
|
|
|
#
|
|
|
|
# Problem med concat
|
|
|
|
#
|
|
|
|
|
|
|
|
create table t1 ( domain char(50) );
|
|
|
|
insert into t1 VALUES ("hello.de" ), ("test.de" );
|
|
|
|
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@hello.de';
|
|
|
|
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
|
|
|
|
drop table t1;
|
2001-03-23 19:38:42 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test bug in concat_ws
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (
|
|
|
|
id int(10) unsigned NOT NULL,
|
|
|
|
title varchar(255) default NULL,
|
|
|
|
prio int(10) unsigned default NULL,
|
|
|
|
category int(10) unsigned default NULL,
|
|
|
|
program int(10) unsigned default NULL,
|
|
|
|
bugdesc text,
|
|
|
|
created datetime default NULL,
|
|
|
|
modified timestamp(14) NOT NULL,
|
|
|
|
bugstatus int(10) unsigned default NULL,
|
|
|
|
submitter int(10) unsigned default NULL
|
|
|
|
) TYPE=MyISAM;
|
|
|
|
|
|
|
|
INSERT INTO t1 VALUES (1,'Link',1,1,1,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa','2001-02-28 08:40:16',20010228084016,0,4);
|
|
|
|
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"') FROM t1;
|
|
|
|
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
|
|
|
|
SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1;
|
|
|
|
drop table t1;
|
2002-09-17 22:46:53 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test bug in AES_DECRYPT() when called with wrong argument
|
|
|
|
#
|
|
|
|
|
|
|
|
CREATE TABLE t1 (id int(11) NOT NULL auto_increment, tmp text NOT NULL, KEY id (id)) TYPE=MyISAM;
|
|
|
|
INSERT INTO t1 VALUES (1, 'a545f661efdd1fb66fdee3aab79945bf');
|
|
|
|
SELECT 1 FROM t1 WHERE tmp=AES_DECRYPT(tmp,"password");
|
|
|
|
DROP TABLE t1;
|