Commit 65b4a2af authored by Andrew Hutchings's avatar Andrew Hutchings Committed by GitHub

MDEV-29426 Fix memory leak in CONNECT JSON/BSON (#2255)

* MDEV-29426 Fix memory leak in CONNECT JSON/BSON

If information is being gathered on JSON/BSON tables we leak the heap
allocated to the table class. With this fix we close and cleanup
instead, just as we do for XML tables.
parent 5e959bc3
...@@ -546,7 +546,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort) ...@@ -546,7 +546,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
if (!tdbp) if (!tdbp)
return rc; // Nothing to do return rc; // Nothing to do
else if (tdbp->GetUse() != USE_OPEN) { else if (tdbp->GetUse() != USE_OPEN) {
if (tdbp->GetAmType() == TYPE_AM_XML) if (tdbp->GetAmType() == TYPE_AM_XML ||
tdbp->GetAmType() == TYPE_AM_JSN)
tdbp->CloseDB(g); // Opened by GetMaxSize tdbp->CloseDB(g); // Opened by GetMaxSize
return rc; return rc;
......
...@@ -515,3 +515,27 @@ Beth 4 Food 17.00 ...@@ -515,3 +515,27 @@ Beth 4 Food 17.00
Beth 4 Beer 15.00 Beth 4 Beer 15.00
Janet 4 Car 17.00 Janet 4 Car 17.00
DROP TABLE t1, t2, t3, t4; DROP TABLE t1, t2, t3, t4;
#
# MDEV-29426 memory leak on "SHOW INDEX"
#
CREATE TABLE t1
(
ISBN CHAR(15) NOT NULL,
Language CHAR(2) JPATH='$.LANG',
Subject CHAR(32) JPATH='$.SUBJECT',
AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME',
AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME',
Title CHAR(32) JPATH='$.TITLE',
Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX',
TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME',
TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME',
Publisher CHAR(20) JPATH='$.PUBLISHER.NAME',
Location CHAR(16) JPATH='$.PUBLISHER.PLACE',
Year int(4) JPATH='$.DATEPUB',
INDEX IX(ISBN)
)
ENGINE=CONNECT TABLE_TYPE=BSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 IX 1 ISBN A NULL NULL NULL XINDEX
DROP TABLE t1;
...@@ -515,3 +515,27 @@ Beth 4 Food 17.00 ...@@ -515,3 +515,27 @@ Beth 4 Food 17.00
Beth 4 Beer 15.00 Beth 4 Beer 15.00
Janet 4 Car 17.00 Janet 4 Car 17.00
DROP TABLE t1, t2, t3, t4; DROP TABLE t1, t2, t3, t4;
#
# MDEV-29426 memory leak on "SHOW INDEX"
#
CREATE TABLE t1
(
ISBN CHAR(15) NOT NULL,
Language CHAR(2) JPATH='$.LANG',
Subject CHAR(32) JPATH='$.SUBJECT',
AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME',
AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME',
Title CHAR(32) JPATH='$.TITLE',
Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX',
TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME',
TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME',
Publisher CHAR(20) JPATH='$.PUBLISHER.NAME',
Location CHAR(16) JPATH='$.PUBLISHER.PLACE',
Year int(4) JPATH='$.DATEPUB',
INDEX IX(ISBN)
)
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
SHOW INDEX FROM t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 1 IX 1 ISBN A NULL NULL NULL XINDEX
DROP TABLE t1;
...@@ -282,6 +282,29 @@ SELECT * FROM t1; ...@@ -282,6 +282,29 @@ SELECT * FROM t1;
SELECT * FROM t1 WHERE WEEK = 4; SELECT * FROM t1 WHERE WEEK = 4;
DROP TABLE t1, t2, t3, t4; DROP TABLE t1, t2, t3, t4;
--echo #
--echo # MDEV-29426 memory leak on "SHOW INDEX"
--echo #
CREATE TABLE t1
(
ISBN CHAR(15) NOT NULL,
Language CHAR(2) JPATH='$.LANG',
Subject CHAR(32) JPATH='$.SUBJECT',
AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME',
AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME',
Title CHAR(32) JPATH='$.TITLE',
Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX',
TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME',
TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME',
Publisher CHAR(20) JPATH='$.PUBLISHER.NAME',
Location CHAR(16) JPATH='$.PUBLISHER.PLACE',
Year int(4) JPATH='$.DATEPUB',
INDEX IX(ISBN)
)
ENGINE=CONNECT TABLE_TYPE=BSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
SHOW INDEX FROM t1;
DROP TABLE t1;
# #
# Clean up # Clean up
# #
......
...@@ -282,6 +282,30 @@ SELECT * FROM t1; ...@@ -282,6 +282,30 @@ SELECT * FROM t1;
SELECT * FROM t1 WHERE WEEK = 4; SELECT * FROM t1 WHERE WEEK = 4;
DROP TABLE t1, t2, t3, t4; DROP TABLE t1, t2, t3, t4;
--echo #
--echo # MDEV-29426 memory leak on "SHOW INDEX"
--echo #
CREATE TABLE t1
(
ISBN CHAR(15) NOT NULL,
Language CHAR(2) JPATH='$.LANG',
Subject CHAR(32) JPATH='$.SUBJECT',
AuthorFN CHAR(128) JPATH='$.AUTHOR[*].FIRSTNAME',
AuthorLN CHAR(128) JPATH='$.AUTHOR[*].LASTNAME',
Title CHAR(32) JPATH='$.TITLE',
Translation CHAR(32) JPATH='$.TRANSLATED.PREFIX',
TranslatorFN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.FIRSTNAME',
TranslatorLN CHAR(80) JPATH='$.TRANSLATED.TRANSLATOR.LASTNAME',
Publisher CHAR(20) JPATH='$.PUBLISHER.NAME',
Location CHAR(16) JPATH='$.PUBLISHER.PLACE',
Year int(4) JPATH='$.DATEPUB',
INDEX IX(ISBN)
)
ENGINE=CONNECT TABLE_TYPE=JSON FILE_NAME='bib0.json' LRECL=320 OPTION_LIST='Pretty=0';
SHOW INDEX FROM t1;
DROP TABLE t1;
# #
# Clean up # Clean up
# #
......
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