diff options
Diffstat (limited to 'mysql-test/main/func_str.test')
-rw-r--r-- | mysql-test/main/func_str.test | 108 |
1 files changed, 104 insertions, 4 deletions
diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 390b5199cec..1c8839f24a2 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -1,10 +1,7 @@ # Description # ----------- # Testing string functions - ---disable_warnings -drop table if exists t1,t2; ---enable_warnings +--source include/have_sequence.inc set @save_max_allowed_packet=@@global.max_allowed_packet; set global max_allowed_packet=1048576; @@ -2314,3 +2311,106 @@ SELECT GROUP_CONCAT( UpdateXML( '<a>new year</a>', '/a', '2019-01-01 00:00:00' ) --echo # --echo # End of 10.4 tests --echo # + +--echo # +--echo # MDEV-25704 Function random_bytes +--echo # + +create table t1 as select random_bytes(100); +show create table t1; +drop table t1; + +--echo # The sequence starts at 17 so that the probability of test failure is small enough (about 2^(-136)) +select count(*) from seq_17_to_1024 where random_bytes(seq) <=> random_bytes(seq); + +select count(*) from seq_1_to_1024 where length(random_bytes(seq)) = seq; + +select random_bytes(`0`),`1` from (values (0,1),(null,2),(0,3)) t1; + +--echo # +--echo # Test NULL output for NULL input +--echo # + +SELECT random_bytes(NULL); + +--echo # +--echo # Test For values outside range from 1 to 1024 return NULL +--echo # + +SELECT random_bytes(0); +SELECT random_bytes(-1); +SELECT random_bytes(-100); +SELECT random_bytes(-26); +SELECT random_bytes(-132); +SELECT random_bytes(1025); +SELECT random_bytes(11111); +SELECT random_bytes(2056); + +#double warning for view protocol +--disable_view_protocol +SELECT length(random_bytes(10.0)); +SELECT length(random_bytes(10.1)); +SELECT length(random_bytes(+1e1)); +SELECT length(random_bytes(time("00:01"))); +SELECT length(random_bytes("10.0")); +SELECT length(random_bytes("10.1")); +SELECT length(random_bytes("+1e1")); +SELECT length(random_bytes("10.0bunnies")); +SELECT length(random_bytes("10.1chickens")); +SELECT length(random_bytes("+1e1rabbits")); +--enable_view_protocol + +--delimiter | +create procedure p1() +begin + declare r ROW (c1 INT); + set r.c1= 10; + select random_bytes(r); +end| +--delimiter ; +--error 1241 +call p1(); +drop procedure p1; + +--echo # +--echo # Test For invalid argument return NULL +--echo # +#double warning for view protocol +--disable_view_protocol +SELECT random_bytes('s'); +SELECT random_bytes('r'); +SELECT random_bytes('res'); +SELECT random_bytes('test'); +--enable_view_protocol + +--echo # +--echo # MDEV-29108 RANDOM_BYTES - assertion in Create_tmp_table::finalize +--echo # + +CREATE TABLE t (a INT); +INSERT INTO t VALUES (1),(2); +SELECT RANDOM_BYTES(-10) f1, IFNULL(a,1) f2 FROM t GROUP BY f1, f2; + +# Cleanup +DROP TABLE t; + +--echo # +--echo # MDEV-29154 Excessive warnings upon a call to RANDOM_BYTES +--echo # +#double warning for view protocol +--disable_view_protocol +select length(random_bytes(cast('x' as unsigned)+1)); +select repeat('.', cast('x' as unsigned)+1); +--enable_view_protocol + +--echo # +--echo # MDEV-23149 Server crashes in my_convert / ErrConvString::ptr / Item_char_typecast::check_truncation_with_warn +--echo # +#double warning for view protocol +--disable_view_protocol +--replace_regex /'.*'/'...random bytes...'/ +select "a" in ("abc", (convert(random_bytes(8) ,binary(2)))); +--enable_view_protocol +--echo # +--echo # End of 10.10 tests +--echo # |