[Commits] 4d5382504d6: MDEV-20349: Assertion `to_len >= 8' failed in convert_to_printable
revision-id: 4d5382504d61ec27ace2d0dd4dd6cc71442ce067 (mariadb-10.4.7-24-g4d5382504d6) parent(s): c221bcdce7714a74b89a02de941e8d8df2994ce3 author: Varun Gupta committer: Varun Gupta timestamp: 2019-08-16 16:49:12 +0530 message: MDEV-20349: Assertion `to_len >= 8' failed in convert_to_printable Use convert_to_printable function to write only non-empty ranges to the optimizer trace --- mysql-test/main/opt_trace.result | 42 ++++++++++++++++++++++++++++++++++++++++ mysql-test/main/opt_trace.test | 13 +++++++++++++ sql/sql_string.cc | 2 ++ 3 files changed, 57 insertions(+) diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index e315b0212f7..518da2888cc 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -6984,4 +6984,46 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) ] ] drop table t0, one_k; +# +# Assertion `to_len >= 8' failed in convert_to_printable +# +CREATE TABLE t1 ( a blob, KEY (a(255))); +insert into t1 values ('foo'), ('bar'); +EXPLAIN SELECT * FROM t1 WHERE a= REPEAT('a', 0); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 258 const 1 Using where +SELECT * FROM t1 WHERE a= REPEAT('a', 0); +a +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; +JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) +[ + + { + "range_scan_alternatives": + [ + + { + "index": "a", + "ranges": + [ + "() <= (a) <= ()" + ], + "rowid_ordered": false, + "using_mrr": false, + "index_only": false, + "rows": 1, + "cost": 2.4265, + "chosen": true + } + ], + "analyzing_roworder_intersect": + { + "cause": "too few roworder scans" + }, + "analyzing_index_merge_union": + [ + ] + } +] +DROP TABLE t1; set optimizer_trace='enabled=off'; diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index e5d635db042..085b7e0aea8 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -536,4 +536,17 @@ explain select * from t0 A, one_k B where A.a=B.b and B.a<800; select JSON_DETAILED(JSON_EXTRACT(trace, '$**.considered_execution_plans')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; drop table t0, one_k; +--echo # +--echo # Assertion `to_len >= 8' failed in convert_to_printable +--echo # + +CREATE TABLE t1 ( a blob, KEY (a(255))); +insert into t1 values ('foo'), ('bar'); + +EXPLAIN SELECT * FROM t1 WHERE a= REPEAT('a', 0); +SELECT * FROM t1 WHERE a= REPEAT('a', 0); +select JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) from INFORMATION_SCHEMA.OPTIMIZER_TRACE; + +DROP TABLE t1; + set optimizer_trace='enabled=off'; diff --git a/sql/sql_string.cc b/sql/sql_string.cc index a4050c579d0..483eb4fcbec 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1204,6 +1204,8 @@ size_t convert_to_printable_required_length(uint len) bool String::append_semi_hex(const char *s, uint len, CHARSET_INFO *cs) { + if (!len) + return false; size_t dst_len= convert_to_printable_required_length(len); if (reserve(dst_len)) return true;
participants (1)
-
Varun