diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 1f07ba0484f..763f7f1b8bf 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -201,6 +201,9 @@ hex(unhex("1")) hex(unhex("12")) hex(unhex("123")) hex(unhex("1234")) hex(unhex( select length(unhex(md5("abrakadabra"))); length(unhex(md5("abrakadabra"))) 16 +select concat('a', quote(NULL)); +concat('a', quote(NULL)) +aNULL select reverse(""); reverse("") @@ -312,7 +315,7 @@ 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 1 1 n +NULL NULL 0 0 NULL two 'two' 0 0 'two' four 'four' 0 0 'four' drop table t1; @@ -403,282 +406,3 @@ abcdabc select SUBSTRING_INDEX(_latin1'abcdabcdabcd',_latin2'd',2); ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'substring_index' select SUBSTRING_INDEX(_latin1'abcdabcdabcd' COLLATE latin1_general_ci,_latin1'd' COLLATE latin1_bin,2); -ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_bin,EXPLICIT) for operation 'substring_index' -select _latin1'B' between _latin1'a' and _latin1'c'; -_latin1'B' between _latin1'a' and _latin1'c' -1 -select _latin1'B' collate latin1_bin between _latin1'a' and _latin1'c'; -_latin1'B' collate latin1_bin between _latin1'a' and _latin1'c' -0 -select _latin1'B' between _latin1'a' collate latin1_bin and _latin1'c'; -_latin1'B' between _latin1'a' collate latin1_bin and _latin1'c' -0 -select _latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin; -_latin1'B' between _latin1'a' and _latin1'c' collate latin1_bin -0 -select _latin2'B' between _latin1'a' and _latin1'b'; -ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between' -select _latin1'B' between _latin2'a' and _latin1'b'; -ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation 'between' -select _latin1'B' between _latin1'a' and _latin2'b'; -ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation 'between' -select _latin1'B' collate latin1_general_ci between _latin1'a' collate latin1_bin and _latin1'b'; -ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation 'between' -select _latin1'B' in (_latin1'a',_latin1'b'); -_latin1'B' in (_latin1'a',_latin1'b') -1 -select _latin1'B' collate latin1_bin in (_latin1'a',_latin1'b'); -_latin1'B' collate latin1_bin in (_latin1'a',_latin1'b') -0 -select _latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b'); -_latin1'B' in (_latin1'a' collate latin1_bin,_latin1'b') -0 -select _latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin); -_latin1'B' in (_latin1'a',_latin1'b' collate latin1_bin) -0 -select _latin2'B' in (_latin1'a',_latin1'b'); -ERROR HY000: Illegal mix of collations (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' -select _latin1'B' in (_latin2'a',_latin1'b'); -ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' -select _latin1'B' in (_latin1'a',_latin2'b'); -ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE), (latin1_swedish_ci,COERCIBLE), (latin2_general_ci,COERCIBLE) for operation ' IN ' -select _latin1'B' COLLATE latin1_general_ci in (_latin1'a' COLLATE latin1_bin,_latin1'b'); -ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_bin,EXPLICIT), (latin1_swedish_ci,COERCIBLE) for operation ' IN ' -select _latin1'B' COLLATE latin1_general_ci in (_latin1'a',_latin1'b' COLLATE latin1_bin); -ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT), (latin1_swedish_ci,COERCIBLE), (latin1_bin,EXPLICIT) for operation ' IN ' -select collation(bin(130)), coercibility(bin(130)); -collation(bin(130)) coercibility(bin(130)) -latin1_swedish_ci 3 -select collation(oct(130)), coercibility(oct(130)); -collation(oct(130)) coercibility(oct(130)) -latin1_swedish_ci 3 -select collation(conv(130,16,10)), coercibility(conv(130,16,10)); -collation(conv(130,16,10)) coercibility(conv(130,16,10)) -latin1_swedish_ci 3 -select collation(hex(130)), coercibility(hex(130)); -collation(hex(130)) coercibility(hex(130)) -latin1_swedish_ci 3 -select collation(char(130)), coercibility(hex(130)); -collation(char(130)) coercibility(hex(130)) -binary 3 -select collation(format(130,10)), coercibility(format(130,10)); -collation(format(130,10)) coercibility(format(130,10)) -latin1_swedish_ci 3 -select collation(lcase(_latin2'a')), coercibility(lcase(_latin2'a')); -collation(lcase(_latin2'a')) coercibility(lcase(_latin2'a')) -latin2_general_ci 3 -select collation(ucase(_latin2'a')), coercibility(ucase(_latin2'a')); -collation(ucase(_latin2'a')) coercibility(ucase(_latin2'a')) -latin2_general_ci 3 -select collation(left(_latin2'a',1)), coercibility(left(_latin2'a',1)); -collation(left(_latin2'a',1)) coercibility(left(_latin2'a',1)) -latin2_general_ci 3 -select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1)); -collation(right(_latin2'a',1)) coercibility(right(_latin2'a',1)) -latin2_general_ci 3 -select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1)); -collation(substring(_latin2'a',1,1)) coercibility(substring(_latin2'a',1,1)) -latin2_general_ci 3 -select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b')); -collation(concat(_latin2'a',_latin2'b')) coercibility(concat(_latin2'a',_latin2'b')) -latin2_general_ci 3 -select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b')); -collation(lpad(_latin2'a',4,_latin2'b')) coercibility(lpad(_latin2'a',4,_latin2'b')) -latin2_general_ci 3 -select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b')); -collation(rpad(_latin2'a',4,_latin2'b')) coercibility(rpad(_latin2'a',4,_latin2'b')) -latin2_general_ci 3 -select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b')); -collation(concat_ws(_latin2'a',_latin2'b')) coercibility(concat_ws(_latin2'a',_latin2'b')) -latin2_general_ci 3 -select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')); -collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')) coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')) -latin2_general_ci 3 -select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')); -collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')) coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')) -binary 3 -select collation(trim(_latin2' a ')), coercibility(trim(_latin2' a ')); -collation(trim(_latin2' a ')) coercibility(trim(_latin2' a ')) -latin2_general_ci 3 -select collation(ltrim(_latin2' a ')), coercibility(ltrim(_latin2' a ')); -collation(ltrim(_latin2' a ')) coercibility(ltrim(_latin2' a ')) -latin2_general_ci 3 -select collation(rtrim(_latin2' a ')), coercibility(rtrim(_latin2' a ')); -collation(rtrim(_latin2' a ')) coercibility(rtrim(_latin2' a ')) -latin2_general_ci 3 -select collation(trim(LEADING _latin2' ' FROM _latin2'a')), coercibility(trim(LEADING _latin2'a' FROM _latin2'a')); -collation(trim(LEADING _latin2' ' FROM _latin2'a')) coercibility(trim(LEADING _latin2'a' FROM _latin2'a')) -latin2_general_ci 3 -select collation(trim(TRAILING _latin2' ' FROM _latin2'a')), coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')); -collation(trim(TRAILING _latin2' ' FROM _latin2'a')) coercibility(trim(TRAILING _latin2'a' FROM _latin2'a')) -latin2_general_ci 3 -select collation(trim(BOTH _latin2' ' FROM _latin2'a')), coercibility(trim(BOTH _latin2'a' FROM _latin2'a')); -collation(trim(BOTH _latin2' ' FROM _latin2'a')) coercibility(trim(BOTH _latin2'a' FROM _latin2'a')) -latin2_general_ci 3 -select collation(repeat(_latin2'a',10)), coercibility(repeat(_latin2'a',10)); -collation(repeat(_latin2'a',10)) coercibility(repeat(_latin2'a',10)) -latin2_general_ci 3 -select collation(reverse(_latin2'ab')), coercibility(reverse(_latin2'ab')); -collation(reverse(_latin2'ab')) coercibility(reverse(_latin2'ab')) -latin2_general_ci 3 -select collation(quote(_latin2'ab')), coercibility(quote(_latin2'ab')); -collation(quote(_latin2'ab')) coercibility(quote(_latin2'ab')) -latin2_general_ci 3 -select collation(soundex(_latin2'ab')), coercibility(soundex(_latin2'ab')); -collation(soundex(_latin2'ab')) coercibility(soundex(_latin2'ab')) -latin2_general_ci 3 -select collation(substring(_latin2'ab',1)), coercibility(substring(_latin2'ab',1)); -collation(substring(_latin2'ab',1)) coercibility(substring(_latin2'ab',1)) -latin2_general_ci 3 -select collation(insert(_latin2'abcd',2,3,_latin2'ef')), coercibility(insert(_latin2'abcd',2,3,_latin2'ef')); -collation(insert(_latin2'abcd',2,3,_latin2'ef')) coercibility(insert(_latin2'abcd',2,3,_latin2'ef')) -latin2_general_ci 3 -select collation(replace(_latin2'abcd',_latin2'b',_latin2'B')), coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B')); -collation(replace(_latin2'abcd',_latin2'b',_latin2'B')) coercibility(replace(_latin2'abcd',_latin2'b',_latin2'B')) -latin2_general_ci 3 -select collation(encode('abcd','ab')), coercibility(encode('abcd','ab')); -collation(encode('abcd','ab')) coercibility(encode('abcd','ab')) -binary 3 -create table t1 -select -bin(130), -oct(130), -conv(130,16,10), -hex(130), -char(130), -format(130,10), -left(_latin2'a',1), -right(_latin2'a',1), -lcase(_latin2'a'), -ucase(_latin2'a'), -substring(_latin2'a',1,1), -concat(_latin2'a',_latin2'b'), -lpad(_latin2'a',4,_latin2'b'), -rpad(_latin2'a',4,_latin2'b'), -concat_ws(_latin2'a',_latin2'b'), -make_set(255,_latin2'a',_latin2'b',_latin2'c'), -export_set(255,_latin2'y',_latin2'n',_latin2' '), -trim(_latin2' a '), -ltrim(_latin2' a '), -rtrim(_latin2' a '), -trim(LEADING _latin2' ' FROM _latin2' a '), -trim(TRAILING _latin2' ' FROM _latin2' a '), -trim(BOTH _latin2' ' FROM _latin2' a '), -repeat(_latin2'a',10), -reverse(_latin2'ab'), -quote(_latin2'ab'), -soundex(_latin2'ab'), -substring(_latin2'ab',1), -insert(_latin2'abcd',2,3,_latin2'ef'), -replace(_latin2'abcd',_latin2'b',_latin2'B'), -encode('abcd','ab') -; -Warnings: -Warning 1265 Data truncated for column 'format(130,10)' at row 1 -show create table t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `bin(130)` char(64) NOT NULL default '', - `oct(130)` char(64) NOT NULL default '', - `conv(130,16,10)` char(64) NOT NULL default '', - `hex(130)` char(6) NOT NULL default '', - `char(130)` char(1) NOT NULL default '', - `format(130,10)` char(4) NOT NULL default '', - `left(_latin2'a',1)` char(1) character set latin2 NOT NULL default '', - `right(_latin2'a',1)` char(1) character set latin2 NOT NULL default '', - `lcase(_latin2'a')` char(1) character set latin2 NOT NULL default '', - `ucase(_latin2'a')` char(1) character set latin2 NOT NULL default '', - `substring(_latin2'a',1,1)` char(1) character set latin2 NOT NULL default '', - `concat(_latin2'a',_latin2'b')` char(2) character set latin2 NOT NULL default '', - `lpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '', - `rpad(_latin2'a',4,_latin2'b')` char(4) character set latin2 NOT NULL default '', - `concat_ws(_latin2'a',_latin2'b')` char(1) character set latin2 NOT NULL default '', - `make_set(255,_latin2'a',_latin2'b',_latin2'c')` char(5) character set latin2 NOT NULL default '', - `export_set(255,_latin2'y',_latin2'n',_latin2' ')` char(127) character set latin2 NOT NULL default '', - `trim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', - `ltrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', - `rtrim(_latin2' a ')` char(3) character set latin2 NOT NULL default '', - `trim(LEADING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', - `trim(TRAILING _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', - `trim(BOTH _latin2' ' FROM _latin2' a ')` char(3) character set latin2 NOT NULL default '', - `repeat(_latin2'a',10)` char(10) character set latin2 NOT NULL default '', - `reverse(_latin2'ab')` char(2) character set latin2 NOT NULL default '', - `quote(_latin2'ab')` char(6) character set latin2 NOT NULL default '', - `soundex(_latin2'ab')` char(4) character set latin2 NOT NULL default '', - `substring(_latin2'ab',1)` char(2) character set latin2 NOT NULL default '', - `insert(_latin2'abcd',2,3,_latin2'ef')` char(6) character set latin2 NOT NULL default '', - `replace(_latin2'abcd',_latin2'b',_latin2'B')` char(4) character set latin2 NOT NULL default '', - `encode('abcd','ab')` binary(4) NOT NULL default '' -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -drop table t1; -select SUBSTR('abcdefg',3,2); -SUBSTR('abcdefg',3,2) -cd -select SUBSTRING('abcdefg',3,2); -SUBSTRING('abcdefg',3,2) -cd -select SUBSTR('abcdefg',-3,2) FROM DUAL; -SUBSTR('abcdefg',-3,2) -ef -select SUBSTR('abcdefg',-1,5) FROM DUAL; -SUBSTR('abcdefg',-1,5) -g -select SUBSTR('abcdefg',0,0) FROM DUAL; -SUBSTR('abcdefg',0,0) - -select SUBSTR('abcdefg',-1,-1) FROM DUAL; -SUBSTR('abcdefg',-1,-1) - -select SUBSTR('abcdefg',1,-1) FROM DUAL; -SUBSTR('abcdefg',1,-1) - -create table t7 (s1 char); -select * from t7 -where concat(s1 collate latin1_general_ci,s1 collate latin1_swedish_ci) = 'AA'; -ERROR HY000: Illegal mix of collations (latin1_general_ci,EXPLICIT) and (latin1_swedish_ci,EXPLICIT) for operation 'concat' -drop table t7; -select substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2); -substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2) substring_index("1abcd;2abcd;3abcd;4abcd", ';', -2) -1abcd;2abcd 3abcd;4abcd -explain extended select md5('hello'), sha('abc'), sha1('abc'), soundex(''), 'mood' sounds like 'mud', aes_decrypt(aes_encrypt('abc','1'),'1'),concat('*',space(5),'*'), reverse('abc'), rpad('a',4,'1'), lpad('a',4,'1'), concat_ws(',','',NULL,'a'),make_set(255,_latin2'a',_latin2'b',_latin2'c'),elt(2,1),locate("a","b",2),format(130,10),char(0),conv(130,16,10),hex(130),binary 'HE', export_set(255,_latin2'y',_latin2'n',_latin2' '),FIELD('b' COLLATE latin1_bin,'A','B'),FIND_IN_SET(_latin1'B',_latin1'a,b,c,d'),collation(conv(130,16,10)), coercibility(conv(130,16,10)),length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),bit_length('\n\t\r\b\0\_\%\\'),concat('monty',' was here ','again'),length('hello'),char(ascii('h')),ord('h'),quote(1/0),crc32("123"),replace('aaaa','a','b'),insert('txs',2,1,'hi'),left(_latin2'a',1),right(_latin2'a',1),lcase(_latin2'a'),ucase(_latin2'a'),SUBSTR('abcdefg',3,2),substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2),trim(_latin2' a '),ltrim(_latin2' a '),rtrim(_latin2' a '), decode(encode(repeat("a",100000),"monty"),"monty"); -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used -Warnings: -Note 1003 select md5(_latin1'hello') AS `md5('hello')`,sha(_latin1'abc') AS `sha('abc')`,sha(_latin1'abc') AS `sha1('abc')`,soundex(_latin1'') AS `soundex('')`,(soundex(_latin1'mood') = soundex(_latin1'mud')) AS `'mood' sounds like 'mud'`,aes_decrypt(aes_encrypt(_latin1'abc',_latin1'1'),_latin1'1') AS `aes_decrypt(aes_encrypt('abc','1'),'1')`,concat(_latin1'*',repeat(_latin1' ',5),_latin1'*') AS `concat('*',space(5),'*')`,reverse(_latin1'abc') AS `reverse('abc')`,rpad(_latin1'a',4,_latin1'1') AS `rpad('a',4,'1')`,lpad(_latin1'a',4,_latin1'1') AS `lpad('a',4,'1')`,concat_ws(_latin1',',_latin1'',NULL,_latin1'a') AS `concat_ws(',','',NULL,'a')`,make_set(255,_latin2'a',_latin2'b',_latin2'c') AS `make_set(255,_latin2'a',_latin2'b',_latin2'c')`,elt(2,1) AS `elt(2,1)`,locate(_latin1'a',_latin1'b',2) AS `locate("a","b",2)`,format(130,10) AS `format(130,10)`,char(0) AS `char(0)`,conv(130,16,10) AS `conv(130,16,10)`,hex(130) AS `hex(130)`,cast(_latin1'HE' as char charset binary) AS `binary 'HE'`,export_set(255,_latin2'y',_latin2'n',_latin2' ') AS `export_set(255,_latin2'y',_latin2'n',_latin2' ')`,field((_latin1'b' collate latin1_bin),_latin1'A',_latin1'B') AS `FIELD('b' COLLATE latin1_bin,'A','B')`,find_in_set(_latin1'B',_latin1'a,b,c,d') AS `FIND_IN_SET(_latin1'B',_latin1'a,b,c,d')`,collation(conv(130,16,10)) AS `collation(conv(130,16,10))`,coercibility(conv(130,16,10)) AS `coercibility(conv(130,16,10))`,length(_latin1'\n \r\0\\_\\%\\') AS `length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,bit_length(_latin1'\n \r\0\\_\\%\\') AS `bit_length('\n\t\r\b\0\_\%\\')`,concat(_latin1'monty',_latin1' was here ',_latin1'again') AS `concat('monty',' was here ','again')`,length(_latin1'hello') AS `length('hello')`,char(ascii(_latin1'h')) AS `char(ascii('h'))`,ord(_latin1'h') AS `ord('h')`,quote((1 / 0)) AS `quote(1/0)`,crc32(_latin1'123') AS `crc32("123")`,replace(_latin1'aaaa',_latin1'a',_latin1'b') AS `replace('aaaa','a','b')`,insert(_latin1'txs',2,1,_latin1'hi') AS `insert('txs',2,1,'hi')`,left(_latin2'a',1) AS `left(_latin2'a',1)`,right(_latin2'a',1) AS `right(_latin2'a',1)`,lcase(_latin2'a') AS `lcase(_latin2'a')`,ucase(_latin2'a') AS `ucase(_latin2'a')`,substr(_latin1'abcdefg',3,2) AS `SUBSTR('abcdefg',3,2)`,substring_index(_latin1'1abcd;2abcd;3abcd;4abcd',_latin1';',2) AS `substring_index("1abcd;2abcd;3abcd;4abcd", ';', 2)`,trim(_latin2' a ') AS `trim(_latin2' a ')`,ltrim(_latin2' a ') AS `ltrim(_latin2' a ')`,rtrim(_latin2' a ') AS `rtrim(_latin2' a ')`,decode(encode(repeat(_latin1'a',100000))) AS `decode(encode(repeat("a",100000),"monty"),"monty")` -SELECT lpad(12345, 5, "#"); -lpad(12345, 5, "#") -12345 -SELECT conv(71, 10, 36), conv('1Z', 36, 10); -conv(71, 10, 36) conv('1Z', 36, 10) -1Z 71 -create table t1 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; -insert into t1 values (1,'aaaaaaaaaa'), (2,'bbbbbbbbbb'); -create table t2 (id int(1), str varchar(10)) DEFAULT CHARSET=utf8; -insert into t2 values (1,'cccccccccc'), (2,'dddddddddd'); -select substring(concat(t1.str, t2.str), 1, 15) "name" from t1, t2 -where t2.id=t1.id order by name; -name -aaaaaaaaaaccccc -bbbbbbbbbbddddd -drop table t1, t2; -create table t1 (c1 INT, c2 INT UNSIGNED); -insert into t1 values ('21474836461','21474836461'); -Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -insert into t1 values ('-21474836461','-21474836461'); -Warnings: -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -show warnings; -Level Code Message -Warning 1264 Out of range value adjusted for column 'c1' at row 1 -Warning 1264 Out of range value adjusted for column 'c2' at row 1 -select * from t1; -c1 c2 -2147483647 4294967295 --2147483648 0 -drop table t1; -select left(1234, 3) + 0; -left(1234, 3) + 0 -123 diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 3eab694ee05..d5a3e80c417 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -82,6 +82,12 @@ select unhex(hex("foobar")), hex(unhex("1234567890ABCDEF")), unhex("345678"), un select hex(unhex("1")), hex(unhex("12")), hex(unhex("123")), hex(unhex("1234")), hex(unhex("12345")), hex(unhex("123456")); select length(unhex(md5("abrakadabra"))); +# +# Bug #6564: QUOTE(NULL +# + +select concat('a', quote(NULL)); + # # Wrong usage of functions # diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 2fcb64ce9d6..422a64ab976 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2574,9 +2574,12 @@ String* Item_func_inet_ntoa::val_str(String* str) This function is very useful when you want to generate SQL statements - RETURN VALUES + NOTE + QUOTE(NULL) returns the string 'NULL' (4 letters, without quotes). + + RETURN VALUES str Quoted string - NULL Argument to QUOTE() was NULL or out of memory. + NULL Out of memory. */ #define get_esc_bit(mask, num) (1 & (*((mask) + ((num) >> 3))) >> ((num) & 7)) @@ -2601,7 +2604,12 @@ String *Item_func_quote::val_str(String *str) String *arg= args[0]->val_str(str); uint arg_length, new_length; if (!arg) // Null argument - goto null; + { + str->copy("NULL", 4, collation.collation); // Return the string 'NULL' + null_value= 0; + return str; + } + arg_length= arg->length(); new_length= arg_length+2; /* for beginning and ending ' signs */ diff --git a/tests/client_test.c b/tests/client_test.c index c68e775241b..39969120608 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -12130,11 +12130,11 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), return 0; } -static void get_options(int argc, char **argv) +static void get_options(int *argc, char ***argv) { int ho_error; - if ((ho_error= handle_options(&argc, &argv, client_test_long_options, + if ((ho_error= handle_options(argc, argv, client_test_long_options, get_one_option))) exit(ho_error); @@ -12177,7 +12177,7 @@ int main(int argc, char **argv) load_defaults("my", client_test_load_default_groups, &argc, &argv); defaults_argv= argv; - get_options(argc, argv); + get_options(&argc, &argv); client_connect(); /* connect to server */ @@ -12187,30 +12187,28 @@ int main(int argc, char **argv) /* Start of tests */ test_count= 1; start_time= time((time_t *)0); - int i, name_ok; - if (!argv[1]) + if (!argc) { for (fptr= my_tests; fptr->name; fptr++) (*fptr->function)(); } else { - for (i= 1; argv[i]; i++) + for ( ; *argv ; argv++) { - name_ok= 0; for (fptr= my_tests; fptr->name; fptr++) { - if (!strcmp(fptr->name, argv[i])) + if (!strcmp(fptr->name, *argv)) { - name_ok= 1; (*fptr->function)(); + break; } } - if (!name_ok) + if (!fptr->name) { - printf("\n\nGiven test not found: '%s'\n", argv[i]); - printf("See legal test names with %s -T\n\nAborting!\n", - my_progname); + fprintf(stderr, "\n\nGiven test not found: '%s'\n", *argv); + fprintf(stderr, "See legal test names with %s -T\n\nAborting!\n", + my_progname); client_disconnect(); free_defaults(defaults_argv); exit(1);