Skip to content
Permalink
Browse files

MDEV-19776: Assertion `to_len >= 8' failed in convert_to_printable wi…

…th optimizer trace enabled

Introduced the convert_to_printable_required_length to return the correct length(taking into
consideration of dots in the case of error messages).
  • Loading branch information...
varunraiko committed Jun 20, 2019
1 parent cfbd714 commit 8b576616b442d061356bc5a2abd410f478e98ee7
Showing with 25 additions and 1 deletion.
  1. +8 −0 mysql-test/main/opt_trace.result
  2. +10 −0 mysql-test/main/opt_trace.test
  3. +1 −0 sql/field.cc
  4. +5 −1 sql/sql_string.cc
  5. +1 −0 sql/sql_string.h
@@ -6554,4 +6554,12 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
}
]
drop table t1, t0, one_k;
#
# MDEV-19776: Assertion `to_len >= 8' failed in convert_to_printable with optimizer trace enabled
#
CREATE TABLE t1 (f VARBINARY(16) NOT NULL, KEY(f));
INSERT INTO t1 VALUES ('a'),('b');
SET optimizer_trace = 'enabled=on';
DELETE FROM t1 WHERE f = 'x';
DROP TABLE t1;
set optimizer_trace='enabled=off';
@@ -498,4 +498,14 @@ explain format=json select * from t1 force index(start_date) where start_date >=
select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
drop table t1, t0, one_k;

--echo #
--echo # MDEV-19776: Assertion `to_len >= 8' failed in convert_to_printable with optimizer trace enabled
--echo #

CREATE TABLE t1 (f VARBINARY(16) NOT NULL, KEY(f));
INSERT INTO t1 VALUES ('a'),('b');
SET optimizer_trace = 'enabled=on';
DELETE FROM t1 WHERE f = 'x';
DROP TABLE t1;

set optimizer_trace='enabled=off';
@@ -6949,6 +6949,7 @@ Field_longstr::check_string_copy_error(const String_copier *copier,

if (!is_stat_field)
{
DBUG_ASSERT(sizeof(tmp) >= convert_to_printable_required_length(6));
convert_to_printable(tmp, sizeof(tmp), pos, (end - pos), cs, 6);
set_warning_truncated_wrong_value("string", tmp);
}
@@ -1197,10 +1197,14 @@ uint convert_to_printable(char *to, size_t to_len,
return (uint) (t - to);
}

size_t convert_to_printable_required_length(uint len)
{
return static_cast<size_t>(len) * 4 + 3/*dots*/ + 1/*trailing \0 */;
}

bool String::append_semi_hex(const char *s, uint len, CHARSET_INFO *cs)
{
size_t dst_len= len * 4 + 1; //extra length for the '\0' character
size_t dst_len= convert_to_printable_required_length(len);
if (reserve(dst_len))
return true;
uint nbytes= convert_to_printable(Ptr + str_length, dst_len, s, len, cs);
@@ -126,6 +126,7 @@ size_t my_copy_with_hex_escaping(CHARSET_INFO *cs,
uint convert_to_printable(char *to, size_t to_len,
const char *from, size_t from_len,
CHARSET_INFO *from_cs, size_t nbytes= 0);
size_t convert_to_printable_required_length(uint len);


class Charset

0 comments on commit 8b57661

Please sign in to comment.
You can’t perform that action at this time.