From e79ced8b06f6c17d8333d81593b348d33a0eb511 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 4 May 2006 14:38:42 -0400 Subject: [PATCH] BUG#19501: Data_Free incorrectly handled for partitioned tables mysql-test/r/partition.result: New test case mysql-test/t/partition.test: New test case sql/ha_partition.cc: Handle delete_length in info call (was forgotten) --- mysql-test/r/partition.result | 14 ++++++++++++++ mysql-test/t/partition.test | 15 +++++++++++++++ sql/ha_partition.cc | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result index 0da071374ea..83caa8fa0c4 100644 --- a/mysql-test/r/partition.result +++ b/mysql-test/r/partition.result @@ -886,4 +886,18 @@ s1 2 3 drop table t1; +CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a); +INSERT into t1 values (1), (2); +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 2 7 14 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +DELETE from t1 where a = 1; +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 14 14 0 0 7 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +ALTER TABLE t1 OPTIMIZE PARTITION p0; +SHOW TABLE STATUS; +Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment +t1 MyISAM 10 Fixed 1 7 7 0 1024 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned +DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 272cdc27af6..f8ecd7dc0e7 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1009,4 +1009,19 @@ select auto_increment from information_schema.tables where table_name='t1'; select * from t1; drop table t1; +# +# BUG 19501 Partitions: SHOW TABLE STATUS shows wrong Data_free +# +CREATE TABLE t1 (a int) ENGINE = MYISAM PARTITION BY KEY(a); +INSERT into t1 values (1), (2); +--replace_column 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DELETE from t1 where a = 1; +--replace_column 9 0 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +ALTER TABLE t1 OPTIMIZE PARTITION p0; +--replace_column 12 NULL 13 NULL 14 NULL +SHOW TABLE STATUS; +DROP TABLE t1; + --echo End of 5.1 tests diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 1ab2c4270fd..c58df5b2d3c 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -4169,6 +4169,8 @@ void ha_partition::info(uint flag) index_file_length: Length of index file, in principle bytes in indexes in the table We report sum + delete_length: Length of free space easily used by new records in table + We report sum mean_record_length:Mean record length in the table We calculate this check_time: Time of last check (only applicable to MyISAM) @@ -4178,6 +4180,7 @@ void ha_partition::info(uint flag) deleted= 0; data_file_length= 0; index_file_length= 0; + delete_length= 0; check_time= 0; file_array= m_file; do @@ -4190,6 +4193,7 @@ void ha_partition::info(uint flag) deleted+= file->deleted; data_file_length+= file->data_file_length; index_file_length+= file->index_file_length; + delete_length+= file->delete_length; if (file->check_time > check_time) check_time= file->check_time; }