Skip to content

Commit d11d420

Browse files
authored
Fix panic miss Free in PartitionBy.reset for SUBPARTITION DDL (#23168)
Fix `panic miss Free` in `PartitionBy.reset()` when parsing SUBPARTITION DDL statements. **Root Cause:** In `sub_partition_opt`, `sub_partition_method` returns `*PartitionBy`, but we only need the `PType` field. The temporary `*PartitionBy` object must be freed after extracting `PType`, otherwise it leaks and causes panic in `reset()` when the object is recycled. **Solution:** - Extract `PType` from `*PartitionBy` before freeing - Set `PType` to nil to avoid double-free - Free the temporary `*PartitionBy` object properly **Changes:** - `pkg/sql/parsers/dialect/mysql/mysql_sql.y`: Fix `sub_partition_opt` to extract `PType` and free temporary object - `pkg/sql/parsers/dialect/mysql/mysql_sql.go`: Regenerated parser code **Testing:** The fix resolves the panic for SUBPARTITION DDL statements like: ```sql CREATE TABLE test_subpartition ( id INT, created_date DATE, region VARCHAR(50) ) PARTITION BY RANGE (YEAR(created_date)) SUBPARTITION BY HASH(region) ( PARTITION p2022 VALUES LESS THAN (2023) ( SUBPARTITION s1, SUBPARTITION s2 ) ); ``` Approved by: @iamlinjunhong
1 parent a630c55 commit d11d420

File tree

2 files changed

+515
-511
lines changed

2 files changed

+515
-511
lines changed

0 commit comments

Comments
 (0)