Bug #56996 Error in ALTER TABLE ... PARTITION causes memory leaks
Submitted: 24 Sep 2010 9:00 Modified: 1 Dec 2010 11:00
Reporter: Alexey Kopytov Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Partitions Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: CPU Architecture:Any
Tags: Leak, memory leak
Triage: Triaged: D1 (Critical) / R2 (Low) / E2 (Low)

[24 Sep 2010 9:00] Alexey Kopytov
Description:
Items created when parsing the partitioning expression in ALTER TABLE ... PARTITION are freed in closefrm(). However, if an error occurs before the actual creation of the .frm, closefrm() is obviously not called causing memory allocated by item tree corresponding to the partitioning expression to leak.

How to repeat:
mysql> CREATE TABLE t1 (a TIMESTAMP);

gdb> br mysql_unpack_partition
gdb> c

mysql> ALTER TABLE t1 PARTITION BY RANGE("1") (PARTITION p VALUES LESS THAN (1), PARTITION pmax VALUES LESS THAN MAXVALUE);

gdb> br Item_string::Item_string(char const*, unsigned int, charset_info_st*, Derivation, unsigned int)
gdb> c

gdb> set $addr=this
gdb> br Item_string::~Item_string() if this==$addr
gdb> c

mysql> ALTER TABLE t1 PARTITION BY RANGE(EXTRACT(DAY FROM a)) (PARTITION p VALUES LESS THAN (1), PARTITION pmax VALUES LESS THAN MAXVALUE);

gdb> br Item_extract::Item_extract(interval_type, Item*)
gdb> c

gdb> set $addr=this
gdb> br Item_string::~Item_string() if this==$addr
gdb> c
[15 Oct 2010 11:52] Libing Song
See also bug#46949
[1 Dec 2010 11:00] Mattias Jonsson
Duplicate of bug#46949 (and bug#56380).
[1 Dec 2010 11:03] Mattias Jonsson
Reported during review of bug#56709.