Commit b74dbcb1 authored by Sergei Golubchik's avatar Sergei Golubchik Committed by Oleksandr Byelkin

MDEV-23149 Server crashes in my_convert / ErrConvString::ptr /...

MDEV-23149 Server crashes in my_convert / ErrConvString::ptr / Item_char_typecast::check_truncation_with_warn

10.10 part
parent 9d2b28d7
drop table if exists t1,t2;
set @save_max_allowed_packet=@@global.max_allowed_packet; set @save_max_allowed_packet=@@global.max_allowed_packet;
set global max_allowed_packet=1048576; set global max_allowed_packet=1048576;
connect conn1,localhost,root,,; connect conn1,localhost,root,,;
...@@ -5405,7 +5404,7 @@ Warnings: ...@@ -5405,7 +5404,7 @@ Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'test' Warning 1292 Truncated incorrect INTEGER value: 'test'
Warning 1292 Truncated incorrect INTEGER value: 'test' Warning 1292 Truncated incorrect INTEGER value: 'test'
# #
# MDEV-29108: RANDOM_BYTES - assertion in Create_tmp_table::finalize # MDEV-29108 RANDOM_BYTES - assertion in Create_tmp_table::finalize
# #
CREATE TABLE t (a INT); CREATE TABLE t (a INT);
INSERT INTO t VALUES (1),(2); INSERT INTO t VALUES (1),(2);
...@@ -5415,7 +5414,7 @@ NULL 1 ...@@ -5415,7 +5414,7 @@ NULL 1
NULL 2 NULL 2
DROP TABLE t; DROP TABLE t;
# #
# MDEV-29154: Excessive warnings upon a call to RANDOM_BYTES # MDEV-29154 Excessive warnings upon a call to RANDOM_BYTES
# #
select length(random_bytes(cast('x' as unsigned)+1)); select length(random_bytes(cast('x' as unsigned)+1));
length(random_bytes(cast('x' as unsigned)+1)) length(random_bytes(cast('x' as unsigned)+1))
...@@ -5430,5 +5429,13 @@ Warnings: ...@@ -5430,5 +5429,13 @@ Warnings:
Warning 1292 Truncated incorrect INTEGER value: 'x' Warning 1292 Truncated incorrect INTEGER value: 'x'
Warning 1292 Truncated incorrect INTEGER value: 'x' Warning 1292 Truncated incorrect INTEGER value: 'x'
# #
# MDEV-23149 Server crashes in my_convert / ErrConvString::ptr / Item_char_typecast::check_truncation_with_warn
#
select "a" in ("abc", (convert(random_bytes(8) ,binary(2))));
"a" in ("abc", (convert(random_bytes(8) ,binary(2))))
0
Warnings:
Warning 1292 Truncated incorrect BINARY(2) value: '...random bytes...'
#
# End of 10.10 tests # End of 10.10 tests
# #
...@@ -3,10 +3,6 @@ ...@@ -3,10 +3,6 @@
# Testing string functions # Testing string functions
--source include/have_sequence.inc --source include/have_sequence.inc
--disable_warnings
drop table if exists t1,t2;
--enable_warnings
set @save_max_allowed_packet=@@global.max_allowed_packet; set @save_max_allowed_packet=@@global.max_allowed_packet;
set global max_allowed_packet=1048576; set global max_allowed_packet=1048576;
connect (conn1,localhost,root,,); connect (conn1,localhost,root,,);
...@@ -2261,7 +2257,7 @@ SELECT random_bytes('res'); ...@@ -2261,7 +2257,7 @@ SELECT random_bytes('res');
SELECT random_bytes('test'); SELECT random_bytes('test');
--echo # --echo #
--echo # MDEV-29108: RANDOM_BYTES - assertion in Create_tmp_table::finalize --echo # MDEV-29108 RANDOM_BYTES - assertion in Create_tmp_table::finalize
--echo # --echo #
CREATE TABLE t (a INT); CREATE TABLE t (a INT);
...@@ -2272,12 +2268,18 @@ SELECT RANDOM_BYTES(-10) f1, IFNULL(a,1) f2 FROM t GROUP BY f1, f2; ...@@ -2272,12 +2268,18 @@ SELECT RANDOM_BYTES(-10) f1, IFNULL(a,1) f2 FROM t GROUP BY f1, f2;
DROP TABLE t; DROP TABLE t;
--echo # --echo #
--echo # MDEV-29154: Excessive warnings upon a call to RANDOM_BYTES --echo # MDEV-29154 Excessive warnings upon a call to RANDOM_BYTES
--echo # --echo #
select length(random_bytes(cast('x' as unsigned)+1)); select length(random_bytes(cast('x' as unsigned)+1));
select repeat('.', cast('x' as unsigned)+1); select repeat('.', cast('x' as unsigned)+1);
--echo #
--echo # MDEV-23149 Server crashes in my_convert / ErrConvString::ptr / Item_char_typecast::check_truncation_with_warn
--echo #
--replace_regex /'.*'/'...random bytes...'/
select "a" in ("abc", (convert(random_bytes(8) ,binary(2))));
--echo # --echo #
--echo # End of 10.10 tests --echo # End of 10.10 tests
--echo # --echo #
...@@ -1517,6 +1517,7 @@ String *Item_func_random_bytes::val_str(String *str) ...@@ -1517,6 +1517,7 @@ String *Item_func_random_bytes::val_str(String *str)
goto err; goto err;
str->length(count); str->length(count);
str->set_charset(&my_charset_bin);
if (my_random_bytes((unsigned char *) str->ptr(), (int32) count)) if (my_random_bytes((unsigned char *) str->ptr(), (int32) count))
{ {
ulong ssl_err; ulong ssl_err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment