mirror of
https://github.com/MariaDB/server.git
synced 2025-11-16 20:23:18 +03:00
needed to be fixed in earlier versions)
Fixed the iteration of how substrings are handled with negative indexes in
SUBSTRING_INDEX
mysql-test/r/func_str.result:
New results for the fix to substring_index
mysql-test/t/func_str.test:
Added tests for fix to substring_index, various lenth search patterns. Also included
are the queuries the user who reported the bug listed in the bug report
sql/item_strfunc.cc:
Fix to BUG 11104
Took out the offset-=delimiter_length-1 out of the for loop. It was causing
basically this:
select substring_index('the king of the the hill', 'the', -2) to not work.
The first iteration, offset would be initialised to 24, then strstr would
point at 'the king of the the* hill' ('*'means right before the
character following), returning a offset of 16. The for loop would then
decrement offset by two (3 - 1), to 14, now pointing at
"the king of th*e the hill", _skipping_ past the 'e' in the second to last
'the', and therefore strstr would never have a chance of matching the
second to last 'the', then moving on to the 'the' at the begginning of the
string!
In a nutshell, offset was being decremented by too great a value, preventing
the second to last 'the' from being ever found, hence the result of
'king of the the hill' from the query that is reported in the bug report
439 lines
18 KiB
Plaintext
439 lines
18 KiB
Plaintext
drop table if exists t1;
|
|
select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
|
|
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
|
|
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
|
|
select 'hello' 'monty';
|
|
hello
|
|
hellomonty
|
|
select length('\n\t\r\b\0\_\%\\');
|
|
length('\n\t\r\b\0\_\%\\')
|
|
10
|
|
select bit_length('\n\t\r\b\0\_\%\\');
|
|
bit_length('\n\t\r\b\0\_\%\\')
|
|
80
|
|
select concat('monty',' was here ','again'),length('hello'),char(ascii('h'));
|
|
concat('monty',' was here ','again') length('hello') char(ascii('h'))
|
|
monty was here again 5 h
|
|
select locate('he','hello'),locate('he','hello',2),locate('lo','hello',2) ;
|
|
locate('he','hello') locate('he','hello',2) locate('lo','hello',2)
|
|
1 0 4
|
|
select instr('hello','HE'), instr('hello',binary 'HE'), instr(binary 'hello','HE');
|
|
instr('hello','HE') instr('hello',binary 'HE') instr(binary 'hello','HE')
|
|
1 0 0
|
|
select position(binary 'll' in 'hello'),position('a' in binary 'hello');
|
|
position(binary 'll' in 'hello') position('a' in binary 'hello')
|
|
3 0
|
|
select left('hello',2),right('hello',2),substring('hello',2,2),mid('hello',1,5) ;
|
|
left('hello',2) right('hello',2) substring('hello',2,2) mid('hello',1,5)
|
|
he lo el hello
|
|
select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1)) ;
|
|
concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',substring('monty',5,1))
|
|
happy
|
|
select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1);
|
|
substring_index('www.tcx.se','.',-2) substring_index('www.tcx.se','.',1)
|
|
tcx.se www
|
|
select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1);
|
|
substring_index('www.tcx.se','tcx',1) substring_index('www.tcx.se','tcx',-1)
|
|
www. .se
|
|
select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1);
|
|
substring_index('.tcx.se','.',-2) substring_index('.tcx.se','.tcx',-1)
|
|
tcx.se .se
|
|
select substring_index('aaaaaaaaa1','a',1);
|
|
substring_index('aaaaaaaaa1','a',1)
|
|
|
|
select substring_index('aaaaaaaaa1','aa',1);
|
|
substring_index('aaaaaaaaa1','aa',1)
|
|
|
|
select substring_index('aaaaaaaaa1','aa',2);
|
|
substring_index('aaaaaaaaa1','aa',2)
|
|
aa
|
|
select substring_index('aaaaaaaaa1','aa',3);
|
|
substring_index('aaaaaaaaa1','aa',3)
|
|
aaaa
|
|
select substring_index('aaaaaaaaa1','aa',4);
|
|
substring_index('aaaaaaaaa1','aa',4)
|
|
aaaaaa
|
|
select substring_index('aaaaaaaaa1','aa',5);
|
|
substring_index('aaaaaaaaa1','aa',5)
|
|
aaaaaaaaa1
|
|
select substring_index('aaaaaaaaa1','aaa',1);
|
|
substring_index('aaaaaaaaa1','aaa',1)
|
|
|
|
select substring_index('aaaaaaaaa1','aaa',2);
|
|
substring_index('aaaaaaaaa1','aaa',2)
|
|
aaa
|
|
select substring_index('aaaaaaaaa1','aaa',3);
|
|
substring_index('aaaaaaaaa1','aaa',3)
|
|
aaaaaa
|
|
select substring_index('aaaaaaaaa1','aaa',4);
|
|
substring_index('aaaaaaaaa1','aaa',4)
|
|
aaaaaaaaa1
|
|
select substring_index('aaaaaaaaa1','aaaa',1);
|
|
substring_index('aaaaaaaaa1','aaaa',1)
|
|
|
|
select substring_index('aaaaaaaaa1','aaaa',2);
|
|
substring_index('aaaaaaaaa1','aaaa',2)
|
|
aaaa
|
|
select substring_index('aaaaaaaaa1','1',1);
|
|
substring_index('aaaaaaaaa1','1',1)
|
|
aaaaaaaaa
|
|
select substring_index('aaaaaaaaa1','a',-1);
|
|
substring_index('aaaaaaaaa1','a',-1)
|
|
1
|
|
select substring_index('aaaaaaaaa1','aa',-1);
|
|
substring_index('aaaaaaaaa1','aa',-1)
|
|
1
|
|
select substring_index('aaaaaaaaa1','aa',-2);
|
|
substring_index('aaaaaaaaa1','aa',-2)
|
|
aa1
|
|
select substring_index('aaaaaaaaa1','aa',-3);
|
|
substring_index('aaaaaaaaa1','aa',-3)
|
|
aaaa1
|
|
select substring_index('aaaaaaaaa1','aa',-4);
|
|
substring_index('aaaaaaaaa1','aa',-4)
|
|
aaaaaa1
|
|
select substring_index('aaaaaaaaa1','aa',-5);
|
|
substring_index('aaaaaaaaa1','aa',-5)
|
|
aaaaaaaaa1
|
|
select substring_index('aaaaaaaaa1','aaa',-1);
|
|
substring_index('aaaaaaaaa1','aaa',-1)
|
|
1
|
|
select substring_index('aaaaaaaaa1','aaa',-2);
|
|
substring_index('aaaaaaaaa1','aaa',-2)
|
|
aaa1
|
|
select substring_index('aaaaaaaaa1','aaa',-3);
|
|
substring_index('aaaaaaaaa1','aaa',-3)
|
|
aaaaaa1
|
|
select substring_index('aaaaaaaaa1','aaa',-4);
|
|
substring_index('aaaaaaaaa1','aaa',-4)
|
|
|
|
select substring_index('the king of thethe hill','the',-2);
|
|
substring_index('the king of thethe hill','the',-2)
|
|
the hill
|
|
select substring_index('the king of the the hill','the',-2);
|
|
substring_index('the king of the the hill','the',-2)
|
|
the hill
|
|
select substring_index('the king of the the hill','the',-2);
|
|
substring_index('the king of the the hill','the',-2)
|
|
the hill
|
|
select substring_index('the king of the the hill',' the ',-1);
|
|
substring_index('the king of the the hill',' the ',-1)
|
|
hill
|
|
select substring_index('the king of the the hill',' the ',-2);
|
|
substring_index('the king of the the hill',' the ',-2)
|
|
the hill
|
|
select substring_index('the king of the the hill',' ',-1);
|
|
substring_index('the king of the the hill',' ',-1)
|
|
hill
|
|
select substring_index('the king of the the hill',' ',-2);
|
|
substring_index('the king of the the hill',' ',-2)
|
|
the hill
|
|
select substring_index('the king of the the hill',' ',-3);
|
|
substring_index('the king of the the hill',' ',-3)
|
|
the hill
|
|
select substring_index('the king of the the hill',' ',-4);
|
|
substring_index('the king of the the hill',' ',-4)
|
|
the the hill
|
|
select substring_index('the king of the the hill',' ',-5);
|
|
substring_index('the king of the the hill',' ',-5)
|
|
of the the hill
|
|
select substring_index('the king of the.the hill','the',-2);
|
|
substring_index('the king of the.the hill','the',-2)
|
|
.the hill
|
|
select substring_index('the king of thethethe.the hill','the',-3);
|
|
substring_index('the king of thethethe.the hill','the',-3)
|
|
the.the hill
|
|
select substring_index('the king of thethethe.the hill','the',-1);
|
|
substring_index('the king of thethethe.the hill','the',-1)
|
|
hill
|
|
select substring_index('the king of the the hill','the',1);
|
|
substring_index('the king of the the hill','the',1)
|
|
|
|
select substring_index('the king of the the hill','the',2);
|
|
substring_index('the king of the the hill','the',2)
|
|
the king of
|
|
select substring_index('the king of the the hill','the',3);
|
|
substring_index('the king of the the hill','the',3)
|
|
the king of the
|
|
select concat(':',ltrim(' left '),':',rtrim(' right '),':');
|
|
concat(':',ltrim(' left '),':',rtrim(' right '),':')
|
|
:left : right:
|
|
select concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':');
|
|
concat(':',trim(LEADING FROM ' left'),':',trim(TRAILING FROM ' right '),':')
|
|
:left: right:
|
|
select concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':');
|
|
concat(':',trim(' m '),':',trim(BOTH FROM ' y '),':',trim('*' FROM '*s*'),':')
|
|
:m:y:s:
|
|
select concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':');
|
|
concat(':',trim(BOTH 'ab' FROM 'ababmyabab'),':',trim(BOTH '*' FROM '***sql'),':')
|
|
:my:sql:
|
|
select concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':');
|
|
concat(':',trim(LEADING '.*' FROM '.*my'),':',trim(TRAILING '.*' FROM 'sql.*.*'),':')
|
|
:my:sql:
|
|
select TRIM("foo" FROM "foo"), TRIM("foo" FROM "foook"), TRIM("foo" FROM "okfoo");
|
|
TRIM("foo" FROM "foo") TRIM("foo" FROM "foook") TRIM("foo" FROM "okfoo")
|
|
ok ok
|
|
select concat_ws(', ','monty','was here','again');
|
|
concat_ws(', ','monty','was here','again')
|
|
monty, was here, again
|
|
select concat_ws(NULL,'a'),concat_ws(',',NULL,'');
|
|
concat_ws(NULL,'a') concat_ws(',',NULL,'')
|
|
NULL
|
|
select concat_ws(',','',NULL,'a');
|
|
concat_ws(',','',NULL,'a')
|
|
,a
|
|
SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"');
|
|
CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),repeat('d',100)), '"')
|
|
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb";"cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc";"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
|
|
select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es');
|
|
insert('txs',2,1,'hi') insert('is ',4,0,'a') insert('txxxxt',2,4,'es')
|
|
this is a test
|
|
select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c');
|
|
replace('aaaa','a','b') replace('aaaa','aa','b') replace('aaaa','a','bb') replace('aaaa','','b') replace('bbbb','a','c')
|
|
bbbb bb bbbbbbbb aaaa bbbb
|
|
select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') ;
|
|
replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL')
|
|
this is a REAL test
|
|
select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb');
|
|
soundex('') soundex('he') soundex('hello all folks') soundex('#3556 in bugdb')
|
|
H000 H4142 I51231
|
|
select md5('hello');
|
|
md5('hello')
|
|
5d41402abc4b2a76b9719d911017c592
|
|
select sha('abc');
|
|
sha('abc')
|
|
a9993e364706816aba3e25717850c26c9cd0d89d
|
|
select sha1('abc');
|
|
sha1('abc')
|
|
a9993e364706816aba3e25717850c26c9cd0d89d
|
|
select aes_decrypt(aes_encrypt('abc','1'),'1');
|
|
aes_decrypt(aes_encrypt('abc','1'),'1')
|
|
abc
|
|
select aes_decrypt(aes_encrypt('abc','1'),1);
|
|
aes_decrypt(aes_encrypt('abc','1'),1)
|
|
abc
|
|
select aes_encrypt(NULL,"a");
|
|
aes_encrypt(NULL,"a")
|
|
NULL
|
|
select aes_encrypt("a",NULL);
|
|
aes_encrypt("a",NULL)
|
|
NULL
|
|
select aes_decrypt(NULL,"a");
|
|
aes_decrypt(NULL,"a")
|
|
NULL
|
|
select aes_decrypt("a",NULL);
|
|
aes_decrypt("a",NULL)
|
|
NULL
|
|
select aes_decrypt("a","a");
|
|
aes_decrypt("a","a")
|
|
NULL
|
|
select aes_decrypt(aes_encrypt("","a"),"a");
|
|
aes_decrypt(aes_encrypt("","a"),"a")
|
|
|
|
select repeat('monty',5),concat('*',space(5),'*');
|
|
repeat('monty',5) concat('*',space(5),'*')
|
|
montymontymontymontymonty * *
|
|
select reverse('abc'),reverse('abcd');
|
|
reverse('abc') reverse('abcd')
|
|
cba dcba
|
|
select rpad('a',4,'1'),rpad('a',4,'12'),rpad('abcd',3,'12'), rpad(11, 10 , 22), rpad("ab", 10, 22);
|
|
rpad('a',4,'1') rpad('a',4,'12') rpad('abcd',3,'12') rpad(11, 10 , 22) rpad("ab", 10, 22)
|
|
a111 a121 abc 1122222222 ab22222222
|
|
select lpad('a',4,'1'),lpad('a',4,'12'),lpad('abcd',3,'12'), lpad(11, 10 , 22);
|
|
lpad('a',4,'1') lpad('a',4,'12') lpad('abcd',3,'12') lpad(11, 10 , 22)
|
|
111a 121a abc 2222222211
|
|
select rpad(741653838,17,'0'),lpad(741653838,17,'0');
|
|
rpad(741653838,17,'0') lpad(741653838,17,'0')
|
|
74165383800000000 00000000741653838
|
|
select rpad('abcd',7,'ab'),lpad('abcd',7,'ab');
|
|
rpad('abcd',7,'ab') lpad('abcd',7,'ab')
|
|
abcdaba abaabcd
|
|
select rpad('abcd',1,'ab'),lpad('abcd',1,'ab');
|
|
rpad('abcd',1,'ab') lpad('abcd',1,'ab')
|
|
a a
|
|
select rpad('STRING', 20, CONCAT('p','a','d') );
|
|
rpad('STRING', 20, CONCAT('p','a','d') )
|
|
STRINGpadpadpadpadpa
|
|
select lpad('STRING', 20, CONCAT('p','a','d') );
|
|
lpad('STRING', 20, CONCAT('p','a','d') )
|
|
padpadpadpadpaSTRING
|
|
select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD');
|
|
LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD') GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD')
|
|
HAROLD HARRY
|
|
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");
|
|
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")
|
|
33 4 1.0 1.0 1.1 9 B
|
|
select decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000);
|
|
decode(encode(repeat("a",100000),"monty"),"monty")=repeat("a",100000)
|
|
1
|
|
select decode(encode("abcdef","monty"),"monty")="abcdef";
|
|
decode(encode("abcdef","monty"),"monty")="abcdef"
|
|
1
|
|
select quote('\'\"\\test');
|
|
quote('\'\"\\test')
|
|
'\'"\\test'
|
|
select quote(concat('abc\'', '\\cba'));
|
|
quote(concat('abc\'', '\\cba'))
|
|
'abc\'\\cba'
|
|
select quote(1/0), quote('\0\Z');
|
|
quote(1/0) quote('\0\Z')
|
|
NULL '\0\Z'
|
|
select length(quote(concat(char(0),"test")));
|
|
length(quote(concat(char(0),"test")))
|
|
8
|
|
select hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))));
|
|
hex(quote(concat(char(224),char(227),char(230),char(231),char(232),char(234),char(235))))
|
|
27E0E3E6E7E8EAEB27
|
|
select concat('a', quote(NULL));
|
|
concat('a', quote(NULL))
|
|
aNULL
|
|
select reverse("");
|
|
reverse("")
|
|
|
|
select insert("aa",100,1,"b"),insert("aa",1,3,"b"),left("aa",-1),substring("a",1,2);
|
|
insert("aa",100,1,"b") insert("aa",1,3,"b") left("aa",-1) substring("a",1,2)
|
|
aa b a
|
|
select elt(2,1),field(NULL,"a","b","c"),reverse("");
|
|
elt(2,1) field(NULL,"a","b","c") reverse("")
|
|
NULL 0
|
|
select locate("a","b",2),locate("","a",1);
|
|
locate("a","b",2) locate("","a",1)
|
|
0 1
|
|
select ltrim("a"),rtrim("a"),trim(BOTH "" from "a"),trim(BOTH " " from "a");
|
|
ltrim("a") rtrim("a") trim(BOTH "" from "a") trim(BOTH " " from "a")
|
|
a a a a
|
|
select concat("1","2")|0,concat("1",".5")+0.0;
|
|
concat("1","2")|0 concat("1",".5")+0.0
|
|
12 1.5
|
|
select substring_index("www.tcx.se","",3);
|
|
substring_index("www.tcx.se","",3)
|
|
|
|
select length(repeat("a",100000000)),length(repeat("a",1000*64));
|
|
length(repeat("a",100000000)) length(repeat("a",1000*64))
|
|
NULL 64000
|
|
select position("0" in "baaa" in (1)),position("0" in "1" in (1,2,3)),position("sql" in ("mysql"));
|
|
position("0" in "baaa" in (1)) position("0" in "1" in (1,2,3)) position("sql" in ("mysql"))
|
|
1 0 3
|
|
select position(("1" in (1,2,3)) in "01");
|
|
position(("1" in (1,2,3)) in "01")
|
|
2
|
|
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)));
|
|
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)))
|
|
65500 64000 50000 60000
|
|
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)));
|
|
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)))
|
|
1000000 96000 160000 95000
|
|
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';
|
|
domain
|
|
hello.de
|
|
select domain from t1 where concat('@', trim(leading '.' from concat('.', domain))) = '@test.de';
|
|
domain
|
|
test.de
|
|
drop table t1;
|
|
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;
|
|
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter), '"')
|
|
"Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4"
|
|
SELECT CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"') FROM t1;
|
|
CONCAT('"',CONCAT_WS('";"',title,prio,category,program,bugstatus,submitter), '"')
|
|
"Link";"1";"1";"1";"0";"4"
|
|
SELECT CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter) FROM t1;
|
|
CONCAT_WS('";"',title,prio,category,program,bugdesc,created,modified,bugstatus,submitter)
|
|
Link";"1";"1";"1";"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";"2001-02-28 08:40:16";"20010228084016";"0";"4
|
|
SELECT bugdesc, REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb') from t1 group by bugdesc;
|
|
bugdesc REPLACE(bugdesc, 'xxxxxxxxxxxxxxxxxxxx', 'bbbbbbbbbbbbbbbbbbbb')
|
|
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
|
drop table t1;
|
|
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");
|
|
1
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (
|
|
wid int(10) unsigned NOT NULL auto_increment,
|
|
data_podp date default NULL,
|
|
status_wnio enum('nowy','podp','real','arch') NOT NULL default 'nowy',
|
|
PRIMARY KEY(wid)
|
|
);
|
|
INSERT INTO t1 VALUES (8,NULL,'real');
|
|
INSERT INTO t1 VALUES (9,NULL,'nowy');
|
|
SELECT elt(status_wnio,data_podp) FROM t1 GROUP BY wid;
|
|
elt(status_wnio,data_podp)
|
|
NULL
|
|
NULL
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (
|
|
title text
|
|
) TYPE=MyISAM;
|
|
INSERT INTO t1 VALUES ('Congress reconvenes in September to debate welfare and adult education');
|
|
INSERT INTO t1 VALUES ('House passes the CAREERS bill');
|
|
SELECT CONCAT("</a>",RPAD("",(55 - LENGTH(title)),".")) from t1;
|
|
CONCAT("</a>",RPAD("",(55 - LENGTH(title)),"."))
|
|
NULL
|
|
</a>..........................
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (i int, j int);
|
|
INSERT INTO t1 VALUES (1,1),(2,2);
|
|
SELECT DISTINCT i, ELT(j, '345', '34') FROM t1;
|
|
i ELT(j, '345', '34')
|
|
1 345
|
|
2 34
|
|
DROP TABLE t1;
|
|
create table t1(a char(4));
|
|
insert into t1 values ('one'),(NULL),('two'),('four');
|
|
select a, quote(a), isnull(quote(a)), quote(a) is null, ifnull(quote(a), 'n') from t1;
|
|
a quote(a) isnull(quote(a)) quote(a) is null ifnull(quote(a), 'n')
|
|
one 'one' 0 0 'one'
|
|
NULL NULL 0 0 NULL
|
|
two 'two' 0 0 'two'
|
|
four 'four' 0 0 'four'
|
|
drop table t1;
|
|
select trim(trailing 'foo' from 'foo');
|
|
trim(trailing 'foo' from 'foo')
|
|
|
|
select trim(leading 'foo' from 'foo');
|
|
trim(leading 'foo' from 'foo')
|
|
|
|
select quote(ltrim(concat(' ', 'a')));
|
|
quote(ltrim(concat(' ', 'a')))
|
|
'a'
|
|
select quote(trim(concat(' ', 'a')));
|
|
quote(trim(concat(' ', 'a')))
|
|
'a'
|
|
CREATE TABLE t1 SELECT 1 UNION SELECT 2 UNION SELECT 3;
|
|
SELECT QUOTE('A') FROM t1;
|
|
QUOTE('A')
|
|
'A'
|
|
'A'
|
|
'A'
|
|
DROP TABLE t1;
|
|
CREATE TABLE t1 (id int PRIMARY KEY, str char(255) NOT NULL);
|
|
CREATE TABLE t2 (id int NOT NULL UNIQUE);
|
|
INSERT INTO t2 VALUES (1),(2);
|
|
INSERT INTO t1 VALUES (1, aes_encrypt('foo', 'bar'));
|
|
INSERT INTO t1 VALUES (2, 'not valid');
|
|
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id;
|
|
id aes_decrypt(str, 'bar')
|
|
1 foo
|
|
2 NULL
|
|
SELECT t1.id, aes_decrypt(str, 'bar') FROM t1, t2 WHERE t1.id = t2.id
|
|
ORDER BY t1.id;
|
|
id aes_decrypt(str, 'bar')
|
|
1 foo
|
|
2 NULL
|
|
DROP TABLE t1, t2;
|