summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/ps.result13
-rw-r--r--mysql-test/r/row.result9
-rw-r--r--mysql-test/t/ps.test14
-rw-r--r--mysql-test/t/row.test11
-rw-r--r--sql/item_cmpfunc.h14
5 files changed, 59 insertions, 2 deletions
diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result
index cf08d763e5c..37ac3426e43 100644
--- a/mysql-test/r/ps.result
+++ b/mysql-test/r/ps.result
@@ -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.
diff --git a/mysql-test/r/row.result b/mysql-test/r/row.result
index 2eaec67c547..2962123fcb2 100644
--- a/mysql-test/r/row.result
+++ b/mysql-test/r/row.result
@@ -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;
diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test
index d5f7eda5032..4390b70e9e9 100644
--- a/mysql-test/t/ps.test
+++ b/mysql-test/t/ps.test
@@ -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.
diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test
index fcc4259168b..cec44078279 100644
--- a/mysql-test/t/row.test
+++ b/mysql-test/t/row.test
@@ -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;
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index f7d222a47d1..4eb27988984 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -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;
};