summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2020-04-17 18:55:48 +0300
committerMonty <monty@mariadb.org>2020-04-18 11:51:42 +0300
commita6d32976aee8e77caae66e1592011df248c7ffbb (patch)
tree8c1e74b0c5cd2395c774f7a0c8a10433f5e95157
parent70bb61414b7450aac6fccecb80cf7e6ffe2a4f4e (diff)
downloadmariadb-git-a6d32976aee8e77caae66e1592011df248c7ffbb.tar.gz
Fixed memory leak with fulltext indexes
MDEV-22275 Assertion `global_status_var.global_memory_used == 0' failed, bytes lost, or LeakSanitizer: detected memory leaks after using temporary table with fulltext key This affected MyISAM and Aria temporary tables
-rw-r--r--mysql-test/r/fulltext.result11
-rw-r--r--mysql-test/t/fulltext.test14
-rw-r--r--storage/maria/ma_close.c3
-rw-r--r--storage/myisam/mi_close.c4
4 files changed, 30 insertions, 2 deletions
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result
index 2844f053728..5118cc38fdf 100644
--- a/mysql-test/r/fulltext.result
+++ b/mysql-test/r/fulltext.result
@@ -776,3 +776,14 @@ CREATE FULLTEXT INDEX IF NOT EXISTS ft1 ON t1(title);
Warnings:
Note 1061 Duplicate key name 'ft1'
DROP TABLE t1;
+#
+# MDEV-22275 (Memory leak)
+#
+CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=MyISAM;
+ALTER TABLE tmp ADD FULLTEXT (a);
+INSERT INTO tmp VALUES ('foo');
+DROP TABLE tmp;
+CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=Aria;
+ALTER TABLE tmp ADD FULLTEXT (a);
+INSERT INTO tmp VALUES ('foo');
+DROP TABLE tmp;
diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test
index 2e53ce7f112..d52f13ab978 100644
--- a/mysql-test/t/fulltext.test
+++ b/mysql-test/t/fulltext.test
@@ -716,3 +716,17 @@ CREATE TABLE t1 (
CREATE FULLTEXT INDEX IF NOT EXISTS ft1 ON t1(title);
CREATE FULLTEXT INDEX IF NOT EXISTS ft1 ON t1(title);
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-22275 (Memory leak)
+--echo #
+
+CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=MyISAM;
+ALTER TABLE tmp ADD FULLTEXT (a);
+INSERT INTO tmp VALUES ('foo');
+DROP TABLE tmp;
+
+CREATE TEMPORARY TABLE tmp (a TEXT) ENGINE=Aria;
+ALTER TABLE tmp ADD FULLTEXT (a);
+INSERT INTO tmp VALUES ('foo');
+DROP TABLE tmp;
diff --git a/storage/maria/ma_close.c b/storage/maria/ma_close.c
index 03501dc49cf..7d4271c794c 100644
--- a/storage/maria/ma_close.c
+++ b/storage/maria/ma_close.c
@@ -20,7 +20,7 @@
to open other files during the time we flush the cache and close this file
*/
-#include "maria_def.h"
+#include "ma_ftdefs.h"
#include "ma_crypt.h"
int maria_close(register MARIA_HA *info)
@@ -86,6 +86,7 @@ int maria_close(register MARIA_HA *info)
share->open_list= list_delete(share->open_list, &info->share_list);
}
+ maria_ftparser_call_deinitializer(info);
my_free(info->rec_buff);
(*share->end)(info);
diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c
index e09219e1c85..ca5c7355812 100644
--- a/storage/myisam/mi_close.c
+++ b/storage/myisam/mi_close.c
@@ -20,7 +20,7 @@
to open other files during the time we flush the cache and close this file
*/
-#include "myisamdef.h"
+#include "ftdefs.h"
int mi_close(register MI_INFO *info)
{
@@ -60,6 +60,8 @@ int mi_close(register MI_INFO *info)
mysql_mutex_unlock(&share->intern_lock);
my_free(mi_get_rec_buff_ptr(info, info->rec_buff));
+ ftparser_call_deinitializer(info);
+
if (flag)
{
DBUG_EXECUTE_IF("crash_before_flush_keys",