summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAditya A <aditya.a@oracle.com>2012-11-06 18:35:03 +0530
committerAditya A <aditya.a@oracle.com>2012-11-06 18:35:03 +0530
commitcdf5f4538d8e3a27c1f7abd42dfb70be35994234 (patch)
treed4d5d46b92f004f364c7247517f236041ea7bb1c
parent0fb1de2cb7fab6c25add80093301f8d150a49989 (diff)
downloadmariadb-git-cdf5f4538d8e3a27c1f7abd42dfb70be35994234.tar.gz
Bug#11751825 - OPTIMIZE PARTITION RECREATES FULL TABLE INSTEAD JUST PARTITION
PROBLEM ------- optimize on partiton will recreate the whole table instead of just partition. ANALYSIS -------- At present innodb doesn't support optimize option ,so we do a rebuild of the whole table and then call analyze() on the table.Presently for any optimize() option (on table or partition) we display the following info to the user "Table does not support optimize, doing recreate + analyze instead". FIX --- It was decided for GA versions(5.1 and 5.5) whenever the user tries to optimize a partition(s) we will will display the following info the user "Table does not support optimize on partitions. All partitions will be rebuilt and analyzed." Earlier partitions were not analyzed.Now all partitions will be analyzed. If the user wants to optimize the whole table ,we will display the previous info to the user. i.e "Table does not support optimize, doing recreate + analyze instead" For 5.6+ versions we will raise a new bug to support optimize() options in innodb.
-rw-r--r--sql/sql_table.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index b8d57341e42..a0545bb5342 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -4908,6 +4908,11 @@ send_result_message:
case HA_ADMIN_TRY_ALTER:
{
+ uint save_flags;
+ Alter_info *alter_info= &lex->alter_info;
+
+ /* Store the original value of alter_info->flags */
+ save_flags= alter_info->flags;
/*
This is currently used only by InnoDB. ha_innobase::optimize() answers
"try with alter", so here we close the table, do an ALTER TABLE,
@@ -4915,9 +4920,18 @@ send_result_message:
We have to end the row, so analyze could return more rows.
*/
protocol->store(STRING_WITH_LEN("note"), system_charset_info);
- protocol->store(STRING_WITH_LEN(
- "Table does not support optimize, doing recreate + analyze instead"),
- system_charset_info);
+ if(alter_info->flags & ALTER_ADMIN_PARTITION)
+ {
+ protocol->store(STRING_WITH_LEN(
+ "Table does not support optimize on partitions. All partitions "
+ "will be rebuilt and analyzed."),system_charset_info);
+ }
+ else
+ {
+ protocol->store(STRING_WITH_LEN(
+ "Table does not support optimize, doing recreate + analyze instead"),
+ system_charset_info);
+ }
if (protocol->write())
goto err;
ha_autocommit_or_rollback(thd, 0);
@@ -4941,9 +4955,15 @@ send_result_message:
close_thread_tables(thd);
if (!result_code) // recreation went ok
{
+ /*
+ Reset the ALTER_ADMIN_PARTITION bit in alter_info->flags
+ to force analyze on all partitions.
+ */
+ alter_info->flags &= ~(ALTER_ADMIN_PARTITION);
if ((table->table= open_ltable(thd, table, lock_type, 0)) &&
((result_code= table->table->file->ha_analyze(thd, check_opt)) > 0))
result_code= 0; // analyze went ok
+ alter_info->flags= save_flags;
}
/* Start a new row for the final status row */
protocol->prepare_for_resend();