mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
WL#1689 "Map OPTIMIZE TABLE to ALTER TABLE for InnoDB"
exactly it's mapped to "ALTER TABLE t; ANALYZE TABLE t;" sql/ha_innodb.cc: ::optimize() now returns "try ALTER and then analyze" instead of only analyze. sql/handler.h: new code to say "try alter and analyze". sql/mysql_priv.h: as we may now use mysql_alter_table() internally to ::optimize we must prevent it from talking to the client. New function mysql_recreate_table() which is the same as ALTER TABLE t; sql/sql_parse.cc: the big block removed here is moved into mysql_recreate_table(). sql/sql_table.cc: In mysql_admin_table(): if the handler returns HA_ADMIN_TRY_ALTER, we close the table, recreate it, then open it and analyze it. This is currently used only for OPTIMIZE TABLE of an InnoDB table.
This commit is contained in:
@@ -2598,24 +2598,9 @@ unsent_create_error:
|
||||
check_table_access(thd,SELECT_ACL | INSERT_ACL, tables,0))
|
||||
goto error; /* purecov: inspected */
|
||||
thd->slow_command=TRUE;
|
||||
if (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC))
|
||||
{
|
||||
/* Use ALTER TABLE */
|
||||
lex->create_list.empty();
|
||||
lex->key_list.empty();
|
||||
lex->col_list.empty();
|
||||
lex->alter_info.reset();
|
||||
bzero((char*) &create_info,sizeof(create_info));
|
||||
create_info.db_type=DB_TYPE_DEFAULT;
|
||||
create_info.row_type=ROW_TYPE_DEFAULT;
|
||||
create_info.default_table_charset=default_charset_info;
|
||||
res= mysql_alter_table(thd, NullS, NullS, &create_info,
|
||||
tables, lex->create_list,
|
||||
lex->key_list, 0, (ORDER *) 0,
|
||||
DUP_ERROR, &lex->alter_info);
|
||||
}
|
||||
else
|
||||
res = mysql_optimize_table(thd, tables, &lex->check_opt);
|
||||
res= (specialflag & (SPECIAL_SAFE_MODE | SPECIAL_NO_NEW_FUNC)) ?
|
||||
mysql_recreate_table(thd, tables, 1) :
|
||||
mysql_optimize_table(thd, tables, &lex->check_opt);
|
||||
/* ! we write after unlocking the table */
|
||||
if (!res && !lex->no_write_to_binlog)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user