Commit 0d242648 authored by Sergey Glukhov's avatar Sergey Glukhov

Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings

Arg_comparator initializes 'comparators' array in case of
ROW comparison and does not free this array on destruction.
It leads to memory leaks.
The fix:
-added Arg_comparator::cleanup() method which frees
 'comparators' array.
-added Item_bool_func2::cleanup() method which calls 
 Arg_comparator::cleanup() method
parent 51880686
......@@ -2988,4 +2988,17 @@ select @plaintext;
bcd
deallocate prepare encode;
deallocate prepare decode;
#
# Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
#
CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
INSERT INTO t1 VALUES (0, 0),(0, 0);
PREPARE stmt FROM "SELECT 1 FROM t1 WHERE
ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234))";
EXECUTE stmt;
1
EXECUTE stmt;
1
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
End of 5.1 tests.
......@@ -457,3 +457,12 @@ abc 1 abc 1
select host,user from mysql.user where (host,user) = ('localhost','test');
host user
drop table t1,t2;
#
# Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
#
CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
INSERT INTO t1 VALUES (0, 0),(0, 0);
SELECT 1 FROM t1 WHERE ROW(a, b) >=
ROW('1', (SELECT 1 FROM t1 WHERE a > 1234));
1
DROP TABLE t1;
......@@ -3065,4 +3065,18 @@ select @plaintext;
deallocate prepare encode;
deallocate prepare decode;
--echo #
--echo # Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
--echo #
CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
INSERT INTO t1 VALUES (0, 0),(0, 0);
PREPARE stmt FROM "SELECT 1 FROM t1 WHERE
ROW(a, b) >= ROW('1', (SELECT 1 FROM t1 WHERE a > 1234))";
--disable_warnings
EXECUTE stmt;
EXECUTE stmt;
--enable_warnings
DEALLOCATE PREPARE stmt;
DROP TABLE t1;
--echo End of 5.1 tests.
......@@ -255,3 +255,14 @@ select * from t1,t2 where (a,b) = (c,d);
select host,user from mysql.user where (host,user) = ('localhost','test');
drop table t1,t2;
--echo #
--echo # Bug#52124 memory leaks like a sieve in datetime, timestamp, time, date fields + warnings
--echo #
CREATE TABLE t1 (a DATETIME NOT NULL, b TINYINT);
INSERT INTO t1 VALUES (0, 0),(0, 0);
--disable_warnings
SELECT 1 FROM t1 WHERE ROW(a, b) >=
ROW('1', (SELECT 1 FROM t1 WHERE a > 1234));
--enable_warnings
DROP TABLE t1;
......@@ -54,9 +54,9 @@ public:
/* Allow owner function to use string buffers. */
String value1, value2;
Arg_comparator(): thd(0), a_cache(0), b_cache(0), set_null(TRUE),
Arg_comparator(): comparators(0), thd(0), a_cache(0), b_cache(0), set_null(TRUE),
get_value_a_func(0), get_value_b_func(0) {};
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), thd(0),
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), comparators(0), thd(0),
a_cache(0), b_cache(0), set_null(TRUE),
get_value_a_func(0), get_value_b_func(0) {};
......@@ -112,6 +112,11 @@ public:
return (owner->type() == Item::FUNC_ITEM &&
((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC);
}
void cleanup()
{
delete [] comparators;
comparators= 0;
}
friend class Item_func;
};
......@@ -365,6 +370,11 @@ public:
CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }
uint decimal_precision() const { return 1; }
void top_level_item() { abort_on_null= TRUE; }
void cleanup()
{
Item_int_func::cleanup();
cmp.cleanup();
}
friend class Arg_comparator;
};
......
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