Skip to content

Commit

Permalink
Merge branch 'halfspawn-bb-10.2-ext' into bb-10.2-ext
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Barkov committed May 4, 2017
2 parents 736a1d2 + 850d3ba commit 7a70641
Show file tree
Hide file tree
Showing 5 changed files with 344 additions and 20 deletions.
184 changes: 184 additions & 0 deletions mysql-test/r/func_str.result
Expand Up @@ -297,6 +297,9 @@ STRINGpadpadpadpadpa
select lpad('STRING', 20, CONCAT('p','a','d') );
lpad('STRING', 20, CONCAT('p','a','d') )
padpadpadpadpaSTRING
select rpad('abcd',7),lpad('abcd',7);
rpad('abcd',7) lpad('abcd',7)
abcd abcd
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')
NULL NULL
Expand Down Expand Up @@ -637,9 +640,15 @@ latin2_general_ci 4
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 4
select collation(lpad(_latin2'a',4)), coercibility(lpad(_latin2'a',4));
collation(lpad(_latin2'a',4)) coercibility(lpad(_latin2'a',4))
latin2_general_ci 4
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 4
select collation(rpad(_latin2'a',4)), coercibility(rpad(_latin2'a',4));
collation(rpad(_latin2'a',4)) coercibility(rpad(_latin2'a',4))
latin2_general_ci 4
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 4
Expand Down Expand Up @@ -707,6 +716,8 @@ substring(_latin2'a',1,1),
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' '),
Expand Down Expand Up @@ -742,6 +753,8 @@ t1 CREATE TABLE `t1` (
`concat(_latin2'a',_latin2'b')` varchar(2) CHARACTER SET latin2 DEFAULT NULL,
`lpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`rpad(_latin2'a',4,_latin2'b')` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`lpad(_latin2'a',4)` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`rpad(_latin2'a',4)` varchar(4) CHARACTER SET latin2 DEFAULT NULL,
`concat_ws(_latin2'a',_latin2'b')` varchar(1) CHARACTER SET latin2 DEFAULT NULL,
`make_set(255,_latin2'a',_latin2'b',_latin2'c')` varchar(5) CHARACTER SET latin2 DEFAULT NULL,
`export_set(255,_latin2'y',_latin2'n',_latin2' ')` varchar(127) CHARACTER SET latin2 DEFAULT NULL,
Expand Down Expand Up @@ -869,6 +882,16 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select lpad('a',4,'1') AS `lpad('a',4,'1')`
explain extended select rpad('a',4);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select rpad('a',4) AS `rpad('a',4)`
explain extended select lpad('a',4);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 select lpad('a',4) AS `lpad('a',4)`
explain extended select concat_ws(',','',NULL,'a');
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Expand Down Expand Up @@ -2213,6 +2236,76 @@ Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -1);
rpad('hello', -1)
NULL
select rpad('hello', -4294967295);
rpad('hello', -4294967295)
NULL
select rpad('hello', 4294967295);
rpad('hello', 4294967295)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -4294967296);
rpad('hello', -4294967296)
NULL
select rpad('hello', 4294967296);
rpad('hello', 4294967296)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -4294967297);
rpad('hello', -4294967297)
NULL
select rpad('hello', 4294967297);
rpad('hello', 4294967297)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551615);
rpad('hello', -18446744073709551615)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
select rpad('hello', 18446744073709551615);
rpad('hello', 18446744073709551615)
NULL
Warnings:
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551616);
rpad('hello', -18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
select rpad('hello', 18446744073709551616);
rpad('hello', 18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', -18446744073709551617);
rpad('hello', -18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
select rpad('hello', 18446744073709551617);
rpad('hello', 18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of rpad() was larger than max_allowed_packet (1048576) - truncated
select rpad('hello', 0, 'x');
rpad('hello', 0, 'x')

select rpad('hello', 0);
rpad('hello', 0)

select lpad('hello', -1, '1');
lpad('hello', -1, '1')
NULL
Expand Down Expand Up @@ -2277,6 +2370,85 @@ Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -1);
lpad('hello', -1)
NULL
select lpad('hello', -4294967295);
lpad('hello', -4294967295)
NULL
select lpad('hello', 4294967295);
lpad('hello', 4294967295)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -4294967296);
lpad('hello', -4294967296)
NULL
select lpad('hello', 4294967296);
lpad('hello', 4294967296)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -4294967297);
lpad('hello', -4294967297)
NULL
select lpad('hello', 4294967297);
lpad('hello', 4294967297)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551615);
lpad('hello', -18446744073709551615)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551615' to INT. Value truncated
select lpad('hello', 18446744073709551615);
lpad('hello', 18446744073709551615)
NULL
Warnings:
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551616);
lpad('hello', -18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551616' to INT. Value truncated
select lpad('hello', 18446744073709551616);
lpad('hello', 18446744073709551616)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551616' to INT. Value truncated
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', -18446744073709551617);
lpad('hello', -18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '-18446744073709551617' to INT. Value truncated
select lpad('hello', 18446744073709551617);
lpad('hello', 18446744073709551617)
NULL
Warnings:
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1916 Got overflow when converting '18446744073709551617' to INT. Value truncated
Warning 1301 Result of lpad() was larger than max_allowed_packet (1048576) - truncated
select lpad('hello', 0, 'x');
lpad('hello', 0, 'x')

select lpad('hello', 0);
lpad('hello', 0)

Check parameters count rpad / lpad
select rpad('x');
ERROR 42000: Incorrect parameter count in the call to native function 'rpad'
select rpad('x',2,'.','z');
ERROR 42000: Incorrect parameter count in the call to native function 'rpad'
select lpad('x');
ERROR 42000: Incorrect parameter count in the call to native function 'lpad'
select lpad('x',2,'.','z');
ERROR 42000: Incorrect parameter count in the call to native function 'lpad'
SET @orig_sql_mode = @@SQL_MODE;
SET SQL_MODE=traditional;
SELECT CHAR(0xff,0x8f USING utf8);
Expand All @@ -2302,6 +2474,12 @@ abcxx
select lpad('abc', cast(5 as unsigned integer), 'x');
lpad('abc', cast(5 as unsigned integer), 'x')
xxabc
select rpad('abc', cast(5 as unsigned integer));
rpad('abc', cast(5 as unsigned integer))
abc
select lpad('abc', cast(5 as unsigned integer));
lpad('abc', cast(5 as unsigned integer))
abc
create table t1(f1 longtext);
insert into t1 values ("123"),("456");
select substring(f1,1,1) from t1 group by 1;
Expand Down Expand Up @@ -2663,6 +2841,12 @@ NULL
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?')
NULL
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)));
RPAD('hi', DAY(FROM_UNIXTIME(-1)))
NULL
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)));
LPAD('hi', DAY(FROM_UNIXTIME(-1)))
NULL
create table t1 (i int);
insert into t1 values (null),(8);
select group_concat( i ), make_set( i, 'a', 'b' ) field from t1 group by field;
Expand Down
53 changes: 52 additions & 1 deletion mysql-test/t/func_str.test
Expand Up @@ -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");
Expand Down Expand Up @@ -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' '));
Expand Down Expand Up @@ -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' '),
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7a70641

Please sign in to comment.