diff options
Diffstat (limited to 'mysql-test/t/func_str.test')
-rw-r--r-- | mysql-test/t/func_str.test | 102 |
1 files changed, 101 insertions, 1 deletions
diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index e039e48a888..a75330ab981 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -119,6 +119,7 @@ select rpad('abcd',7,'ab'),lpad('abcd',7,'ab'); select rpad('abcd',1,'ab'),lpad('abcd',1,'ab'); select rpad('STRING', 20, CONCAT('p','a','d') ); select lpad('STRING', 20, CONCAT('p','a','d') ); +select rpad('abcd',7),lpad('abcd',7); select LEAST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'),GREATEST(NULL,'HARRY','HARRIOT',NULL,'HAROLD'); 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"); @@ -373,7 +374,9 @@ select collation(right(_latin2'a',1)), coercibility(right(_latin2'a',1)); select collation(substring(_latin2'a',1,1)), coercibility(substring(_latin2'a',1,1)); select collation(concat(_latin2'a',_latin2'b')), coercibility(concat(_latin2'a',_latin2'b')); select collation(lpad(_latin2'a',4,_latin2'b')), coercibility(lpad(_latin2'a',4,_latin2'b')); +select collation(lpad(_latin2'a',4)), coercibility(lpad(_latin2'a',4)); select collation(rpad(_latin2'a',4,_latin2'b')), coercibility(rpad(_latin2'a',4,_latin2'b')); +select collation(rpad(_latin2'a',4)), coercibility(rpad(_latin2'a',4)); select collation(concat_ws(_latin2'a',_latin2'b')), coercibility(concat_ws(_latin2'a',_latin2'b')); select collation(make_set(255,_latin2'a',_latin2'b',_latin2'c')), coercibility(make_set(255,_latin2'a',_latin2'b',_latin2'c')); select collation(export_set(255,_latin2'y',_latin2'n',_latin2' ')), coercibility(export_set(255,_latin2'y',_latin2'n',_latin2' ')); @@ -408,6 +411,8 @@ select concat(_latin2'a',_latin2'b'), lpad(_latin2'a',4,_latin2'b'), rpad(_latin2'a',4,_latin2'b'), + lpad(_latin2'a',4), + rpad(_latin2'a',4), concat_ws(_latin2'a',_latin2'b'), make_set(255,_latin2'a',_latin2'b',_latin2'c'), export_set(255,_latin2'y',_latin2'n',_latin2' '), @@ -485,6 +490,8 @@ explain extended select concat('*',space(5),'*'); explain extended select reverse('abc'); explain extended select rpad('a',4,'1'); explain extended select lpad('a',4,'1'); +explain extended select rpad('a',4); +explain extended select lpad('a',4); explain extended select concat_ws(',','',NULL,'a'); explain extended select make_set(255,_latin2'a', _latin2'b', _latin2'c'); explain extended select elt(2,1); @@ -1105,6 +1112,21 @@ select rpad('hello', -18446744073709551616, '1'); select rpad('hello', 18446744073709551616, '1'); select rpad('hello', -18446744073709551617, '1'); select rpad('hello', 18446744073709551617, '1'); +select rpad('hello', -1); +select rpad('hello', -4294967295); +select rpad('hello', 4294967295); +select rpad('hello', -4294967296); +select rpad('hello', 4294967296); +select rpad('hello', -4294967297); +select rpad('hello', 4294967297); +select rpad('hello', -18446744073709551615); +select rpad('hello', 18446744073709551615); +select rpad('hello', -18446744073709551616); +select rpad('hello', 18446744073709551616); +select rpad('hello', -18446744073709551617); +select rpad('hello', 18446744073709551617); +select rpad('hello', 0, 'x'); +select rpad('hello', 0); select lpad('hello', -1, '1'); select lpad('hello', -4294967295, '1'); @@ -1119,7 +1141,32 @@ select lpad('hello', -18446744073709551616, '1'); select lpad('hello', 18446744073709551616, '1'); select lpad('hello', -18446744073709551617, '1'); select lpad('hello', 18446744073709551617, '1'); - +select lpad('hello', -1); +select lpad('hello', -4294967295); +select lpad('hello', 4294967295); +select lpad('hello', -4294967296); +select lpad('hello', 4294967296); +select lpad('hello', -4294967297); +select lpad('hello', 4294967297); +select lpad('hello', -18446744073709551615); +select lpad('hello', 18446744073709551615); +select lpad('hello', -18446744073709551616); +select lpad('hello', 18446744073709551616); +select lpad('hello', -18446744073709551617); +select lpad('hello', 18446744073709551617); +select lpad('hello', 0, 'x'); +select lpad('hello', 0); + +--echo Check parameters count rpad / lpad +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select rpad('x'); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select rpad('x',2,'.','z'); + +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select lpad('x'); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +select lpad('x',2,'.','z'); # # BUG#17047: CHAR() and IN() can return NULL without signaling NULL @@ -1141,6 +1188,8 @@ select substring('abc', cast(2 as unsigned int)); select repeat('a', cast(2 as unsigned int)); select rpad('abc', cast(5 as unsigned integer), 'x'); select lpad('abc', cast(5 as unsigned integer), 'x'); +select rpad('abc', cast(5 as unsigned integer)); +select lpad('abc', cast(5 as unsigned integer)); # # Bug#15757: Wrong SUBSTRING() result when a tmp table was employed. @@ -1403,6 +1452,8 @@ SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1))); SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1))); SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?'); SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?'); +SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1))); +SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1))); # # MDEV-4289 Assertion `0' fails in make_sortkey with GROUP_CONCAT, MAKE_SET, GROUP BY @@ -1554,6 +1605,8 @@ format(rpad('111111111.1', # But in mysqltest --disable_prepare_warnings affects SELECT queries only # and can't suppress prepare time warnings for DO. # + +--error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION SELECT round( concat( ( @@ -1800,7 +1853,54 @@ SELECT f1,HEX(f2) FROM t1 WHERE f1='YQ==' AND (f2= from_base64( SELECT f1,HEX(f2) FROM t1 WHERE f1='YQ==' AND (f2= from_base64("Yq==") OR f2= from_base64("YQ==")); DROP TABLE t1; +--echo # +--echo # MDEV-12685 Oracle-compatible function CHR() +--echo # +select chr(65); +create database mysqltest1 CHARACTER SET = 'utf8' COLLATE = 'utf8_bin'; +use mysqltest1; +select charset(chr(65)), length(chr(65)),char_length(chr(65)); +select charset(chr(14844588)), length(chr(14844588)),char_length(chr(14844588)); +drop database mysqltest1; +use test; --echo # --echo # End of 10.1 tests --echo # + + +--echo # +--echo # Start of 10.3 tests +--echo # + +--echo # +--echo # MDEV-12592 Illegal mix of collations with the HEX function +--echo # + +SET NAMES utf8; +CREATE TABLE t1 (a VARCHAR(10) CHARACTER SET latin1); +INSERT INTO t1 VALUES (0x09),('a'); +SELECT IF(a<' ',HEX(a),a) FROM t1 ORDER BY a; +DROP TABLE t1; + +--echo # +--echo # MDEV-12783 sql_mode=ORACLE: Functions LENGTH() and LENGTHB() +--echo # +SELECT LENGTHB('a'), LENGTHB(_utf8 0xC39F), LENGTHB(123), LENGTH(null); +EXPLAIN EXTENDED SELECT LENGTH('a'), LENGTHB('a'); + + +--echo # +--echo # MDEV-13555 Assertion `!item->null_value' failed in Type_handler::Item_send_str +--echo # + +CREATE TABLE t1 (c VARCHAR(8)); +INSERT INTO t1 VALUES (NULL),('bar'); +SELECT LPAD( c, 0, '?' ) FROM t1; +SELECT RPAD( c, 0, '?' ) FROM t1; +DROP TABLE t1; + + +--echo # +--echo # End of 10.3 tests +--echo # |