Commit d9347545 authored by unknown's avatar unknown

WL 2826: Error handling of ALTER TABLE for partitioning

Fixed up create_handler_files call


sql/ha_ndbcluster.cc:
  Fixed up create_handler_files call
sql/ha_partition.cc:
  Fixed up create_handler_files call
sql/handler.h:
  Fixed up create_handler_files call
sql/sql_table.cc:
  Fixed up create_handler_files call
sql/unireg.cc:
  Fixed up create_handler_files call
parent 73a66e27
...@@ -4726,7 +4726,7 @@ int ha_ndbcluster::create_handler_files(const char *file, ...@@ -4726,7 +4726,7 @@ int ha_ndbcluster::create_handler_files(const char *file,
DBUG_ENTER("create_handler_files"); DBUG_ENTER("create_handler_files");
if (action_flag) if (action_flag != CHF_INDEX_FLAG)
{ {
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
......
...@@ -505,7 +505,8 @@ int ha_partition::create_handler_files(const char *path, ...@@ -505,7 +505,8 @@ int ha_partition::create_handler_files(const char *path,
We need to update total number of parts since we might write the handler We need to update total number of parts since we might write the handler
file as part of a partition management command file as part of a partition management command
*/ */
if (action_flag) if (action_flag == CHF_DELETE_FLAG ||
action_flag == CHF_RENAME_FLAG)
{ {
char name[FN_REFLEN]; char name[FN_REFLEN];
char old_name[FN_REFLEN]; char old_name[FN_REFLEN];
...@@ -520,7 +521,7 @@ int ha_partition::create_handler_files(const char *path, ...@@ -520,7 +521,7 @@ int ha_partition::create_handler_files(const char *path,
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
} }
else else if (action_flag == CHF_CREATE_FLAG)
{ {
if (create_handler_file(path)) if (create_handler_file(path))
{ {
......
...@@ -1380,8 +1380,10 @@ class handler :public Sql_alloc ...@@ -1380,8 +1380,10 @@ class handler :public Sql_alloc
virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0; virtual int create(const char *name, TABLE *form, HA_CREATE_INFO *info)=0;
#define CHF_CREATE_FLAG 0
#define CHF_DELETE_FLAG 1 #define CHF_DELETE_FLAG 1
#define CHF_RENAME_FLAG 2 #define CHF_RENAME_FLAG 2
#define CHF_INDEX_FLAG 3
virtual int create_handler_files(const char *name, const char *old_name, virtual int create_handler_files(const char *name, const char *old_name,
int action_flag, HA_CREATE_INFO *info) int action_flag, HA_CREATE_INFO *info)
......
...@@ -1233,7 +1233,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) ...@@ -1233,7 +1233,8 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
lpt->table_name, lpt->create_info, lpt->table_name, lpt->create_info,
lpt->new_create_list, lpt->key_count, lpt->new_create_list, lpt->key_count,
lpt->key_info_buffer, lpt->table->file)) || lpt->key_info_buffer, lpt->table->file)) ||
lpt->table->file->create_handler_files(shadow_path, NULL, FALSE, lpt->table->file->create_handler_files(shadow_path, NULL,
CHF_CREATE_FLAG,
lpt->create_info)) lpt->create_info))
{ {
my_delete(shadow_frm_name, MYF(0)); my_delete(shadow_frm_name, MYF(0));
...@@ -1287,14 +1288,14 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) ...@@ -1287,14 +1288,14 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
if (my_delete(frm_name, MYF(MY_WME)) || if (my_delete(frm_name, MYF(MY_WME)) ||
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
lpt->table->file->create_handler_files(path, shadow_path, lpt->table->file->create_handler_files(path, shadow_path,
CHF_DELETE_FLAG) || CHF_DELETE_FLAG, NULL) ||
deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos) || deactivate_ddl_log_entry(part_info->frm_log_entry->entry_pos) ||
(sync_ddl_log(), FALSE) || (sync_ddl_log(), FALSE) ||
#endif #endif
#ifdef WITH_PARTITION_STORAGE_ENGINE #ifdef WITH_PARTITION_STORAGE_ENGINE
my_rename(shadow_frm_name, frm_name, MYF(MY_WME)) || my_rename(shadow_frm_name, frm_name, MYF(MY_WME)) ||
lpt->table->file->create_handler_files(path, shadow_path, lpt->table->file->create_handler_files(path, shadow_path,
CHF_RENAME_FLAG)) CHF_RENAME_FLAG, NULL))
#else #else
my_rename(shadow_frm_name, frm_name, MYF(MY_WME))) my_rename(shadow_frm_name, frm_name, MYF(MY_WME)))
#endif #endif
...@@ -5717,7 +5718,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -5717,7 +5718,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
error= (mysql_create_frm(thd, reg_path, db, table_name, error= (mysql_create_frm(thd, reg_path, db, table_name,
create_info, prepared_create_list, key_count, create_info, prepared_create_list, key_count,
key_info_buffer, table->file) || key_info_buffer, table->file) ||
table->file->create_handler_files(reg_path, NULL, FALSE, table->file->create_handler_files(reg_path, NULL, CHF_INDEX_FLAG,
create_info)); create_info));
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
if (error) if (error)
...@@ -5764,7 +5765,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -5764,7 +5765,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
error= (mysql_create_frm(thd, reg_path, db, table_name, error= (mysql_create_frm(thd, reg_path, db, table_name,
create_info, prepared_create_list, key_count, create_info, prepared_create_list, key_count,
key_info_buffer, table->file) || key_info_buffer, table->file) ||
table->file->create_handler_files(reg_path, NULL, FALSE, table->file->create_handler_files(reg_path, NULL, CHF_INDEX_FLAG,
create_info)); create_info));
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
if (error) if (error)
...@@ -5989,7 +5990,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -5989,7 +5990,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
} }
/* Tell the handler that a new frm file is in place. */ /* Tell the handler that a new frm file is in place. */
if (table->file->create_handler_files(reg_path, NULL, FALSE, if (table->file->create_handler_files(reg_path, NULL, CHF_INDEX_FLAG,
create_info)) create_info))
{ {
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
......
...@@ -323,7 +323,7 @@ int rea_create_table(THD *thd, const char *path, ...@@ -323,7 +323,7 @@ int rea_create_table(THD *thd, const char *path,
// Make sure mysql_create_frm din't remove extension // Make sure mysql_create_frm din't remove extension
DBUG_ASSERT(*fn_rext(frm_name)); DBUG_ASSERT(*fn_rext(frm_name));
if (file->create_handler_files(path, NULL, FALSE, create_info)) if (file->create_handler_files(path, NULL, CHF_CREATE_FLAG, create_info))
goto err_handler; goto err_handler;
if (!create_info->frm_only && ha_create_table(thd, path, db, table_name, if (!create_info->frm_only && ha_create_table(thd, path, db, table_name,
create_info,0)) create_info,0))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment