From 89bd5623b00407c41cbaab26ab1ef234650f03c7 Mon Sep 17 00:00:00 2001
From: Sachin Setiya <sachin.setiya@mariadb.com>
Date: Tue, 8 Oct 2019 17:00:54 +0530
Subject: [PATCH] MDEV-20582 Asan failure in table_def::calc_field_size

MDEV-20591 Already solves this issue, Just enable the test case commented
parts
---
 .../binlog_table_map_optional_metadata.result | 21 ++++++++
 .../t/binlog_table_map_optional_metadata.test | 53 +++++++++----------
 2 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/mysql-test/suite/binlog/r/binlog_table_map_optional_metadata.result b/mysql-test/suite/binlog/r/binlog_table_map_optional_metadata.result
index ce0f6921931..cb34f48fb69 100644
--- a/mysql-test/suite/binlog/r/binlog_table_map_optional_metadata.result
+++ b/mysql-test/suite/binlog/r/binlog_table_map_optional_metadata.result
@@ -120,6 +120,27 @@ INSERT INTO t1 VALUES(1);
 DROP TABLE t1;
 RESET MASTER;
 #
+# Charsets can be printed correctly
+#
+CREATE TABLE t1(c_char_utf8 CHAR(10) CHARSET utf8,
+c_varchar_utf8 VARCHAR(10) CHARSET utf8,
+c_text_utf8 TEXT CHARSET utf8);
+INSERT INTO t1 VALUES("1", "2", "3");
+# Columns(`c_char_utf8` CHAR(10) CHARSET utf8 COLLATE utf8_general_ci,
+#         `c_varchar_utf8` VARCHAR(10) CHARSET utf8 COLLATE utf8_general_ci,
+#         `c_text_utf8` TEXT CHARSET utf8 COLLATE utf8_general_ci)
+DROP TABLE t1;
+RESET MASTER;
+CREATE TABLE t1(c_utf8mb4_520 CHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci,
+c_utf8mb4_0900 VARCHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_polish_ci,
+c_utf8mb4_def TEXT CHARSET utf8mb4);
+INSERT INTO t1 VALUES("1", "2", "3");
+# Columns(`c_utf8mb4_520` CHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci,
+#         `c_utf8mb4_0900` VARCHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_polish_ci,
+#         `c_utf8mb4_def` TEXT CHARSET utf8mb4 COLLATE utf8mb4_general_ci)
+DROP TABLE t1;
+RESET MASTER;
+#
 # Blob and binary columns can be printed correctly
 #
 CREATE TABLE t1(c_binary BINARY(10), c_varbinary VARBINARY(10),
diff --git a/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test b/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test
index 9b73974583b..9fd201e0cb9 100644
--- a/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test
+++ b/mysql-test/suite/binlog/t/binlog_table_map_optional_metadata.test
@@ -114,34 +114,33 @@ INSERT INTO t1 VALUES(1);
 --source include/print_optional_metadata.inc
 DROP TABLE t1;
 RESET MASTER;
-# Work around the memory leak of MDEV-20582
-#--echo #
-#--echo # Charsets can be printed correctly
-#--echo #
-#CREATE TABLE t1(c_char_utf8 CHAR(10) CHARSET utf8,
-#  c_varchar_utf8 VARCHAR(10) CHARSET utf8,
-#  c_text_utf8 TEXT CHARSET utf8);
-#
-#INSERT INTO t1 VALUES("1", "2", "3");
-#
-## Charset set is printed with Default charset
-#--source include/print_optional_metadata.inc
-#
-#DROP TABLE t1;
-#RESET MASTER;
-#
-## Test collation number less than 250 and collation number greater than 250
-#CREATE TABLE t1(c_utf8mb4_520 CHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci,
-#  c_utf8mb4_0900 VARCHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_polish_ci,
-#  c_utf8mb4_def TEXT CHARSET utf8mb4);
-#
-#INSERT INTO t1 VALUES("1", "2", "3");
+--echo #
+--echo # Charsets can be printed correctly
+--echo #
+CREATE TABLE t1(c_char_utf8 CHAR(10) CHARSET utf8,
+  c_varchar_utf8 VARCHAR(10) CHARSET utf8,
+  c_text_utf8 TEXT CHARSET utf8);
 
-## Charset set is printed without default charset
-#--source include/print_optional_metadata.inc
-#
-#DROP TABLE t1;
-#RESET MASTER;
+INSERT INTO t1 VALUES("1", "2", "3");
+
+# Charset set is printed with Default charset
+--source include/print_optional_metadata.inc
+
+DROP TABLE t1;
+RESET MASTER;
+
+# Test collation number less than 250 and collation number greater than 250
+CREATE TABLE t1(c_utf8mb4_520 CHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci,
+  c_utf8mb4_0900 VARCHAR(10) CHARSET utf8mb4 COLLATE utf8mb4_polish_ci,
+  c_utf8mb4_def TEXT CHARSET utf8mb4);
+
+INSERT INTO t1 VALUES("1", "2", "3");
+
+# Charset set is printed without default charset
+--source include/print_optional_metadata.inc
+
+DROP TABLE t1;
+RESET MASTER;
 
 --echo #
 --echo # Blob and binary columns can be printed correctly
-- 
2.30.9