Commit 5d5eba2d authored by unknown's avatar unknown

WL 2826: Error handling of ALTER TABLE for partitioning

Introduce log entry to handle replace of frm file


sql/handler.h:
  Introduce log entry to handle replace of frm file
sql/sql_partition.cc:
  Introduce log entry to handle replace of frm file
sql/sql_table.cc:
  Introduce log entry to handle replace of frm file
parent b517dbf7
...@@ -852,6 +852,7 @@ class partition_info : public Sql_alloc ...@@ -852,6 +852,7 @@ class partition_info : public Sql_alloc
st_table_log_memory_entry *first_log_entry; st_table_log_memory_entry *first_log_entry;
st_table_log_memory_entry *exec_log_entry; st_table_log_memory_entry *exec_log_entry;
st_table_log_memory_entry *frm_log_entry;
/* /*
A bitmap of partitions used by the current query. A bitmap of partitions used by the current query.
Usage pattern: Usage pattern:
...@@ -963,7 +964,7 @@ class partition_info : public Sql_alloc ...@@ -963,7 +964,7 @@ class partition_info : public Sql_alloc
part_field_array(NULL), subpart_field_array(NULL), part_field_array(NULL), subpart_field_array(NULL),
full_part_field_array(NULL), full_part_field_array(NULL),
part_expr(NULL), subpart_expr(NULL), item_free_list(NULL), part_expr(NULL), subpart_expr(NULL), item_free_list(NULL),
first_log_entry(NULL), exec_log_entry(NULL), first_log_entry(NULL), exec_log_entry(NULL), frm_log_entry(NULL),
list_array(NULL), list_array(NULL),
part_info_string(NULL), part_info_string(NULL),
part_func_string(NULL), subpart_func_string(NULL), part_func_string(NULL), subpart_func_string(NULL),
......
...@@ -5109,7 +5109,7 @@ release_part_info_log_entries(TABLE_LOG_MEMORY_ENTRY *log_entry) ...@@ -5109,7 +5109,7 @@ release_part_info_log_entries(TABLE_LOG_MEMORY_ENTRY *log_entry)
/* /*
Log an delete/rename frm file Log an delete/rename frm file
SYNOPSIS SYNOPSIS
write_log_rename_delete_frm() write_log_replace_delete_frm()
lpt Struct for parameters lpt Struct for parameters
next_entry Next reference to use in log record next_entry Next reference to use in log record
path Name to rename from path Name to rename from
...@@ -5118,30 +5118,30 @@ release_part_info_log_entries(TABLE_LOG_MEMORY_ENTRY *log_entry) ...@@ -5118,30 +5118,30 @@ release_part_info_log_entries(TABLE_LOG_MEMORY_ENTRY *log_entry)
TRUE Error TRUE Error
FALSE Success FALSE Success
DESCRIPTION DESCRIPTION
Support routine that writes a rename or delete of an frm file into the Support routine that writes a replace or delete of an frm file into the
table log. It also inserts an entry that keeps track of used space into table log. It also inserts an entry that keeps track of used space into
the partition info object the partition info object
*/ */
bool bool
write_log_rename_delete_frm(ALTER_PARTITION_PARAM_TYPE *lpt, write_log_replace_delete_frm(ALTER_PARTITION_PARAM_TYPE *lpt,
uint next_entry, uint next_entry,
const char *from_path, const char *from_path,
const char *to_path, const char *to_path,
bool rename_flag) bool replace_flag)
{ {
TABLE_LOG_ENTRY table_log_entry; TABLE_LOG_ENTRY table_log_entry;
TABLE_LOG_MEMORY_ENTRY *log_entry; TABLE_LOG_MEMORY_ENTRY *log_entry;
DBUG_ENTER("write_log_rename_frm"); DBUG_ENTER("write_log_replace_frm");
if (rename_flag) if (replace_flag)
table_log_entry.action_type= TLOG_RENAME_ACTION_CODE; table_log_entry.action_type= TLOG_REPLACE_ACTION_CODE;
else else
table_log_entry.action_type= TLOG_DELETE_ACTION_CODE; table_log_entry.action_type= TLOG_DELETE_ACTION_CODE;
table_log_entry.next_entry= next_entry; table_log_entry.next_entry= next_entry;
table_log_entry.handler_type= "frm"; table_log_entry.handler_type= "frm";
table_log_entry.name= to_path; table_log_entry.name= to_path;
if (rename_flag) if (replace_flag)
table_log_entry.from_name= from_path; table_log_entry.from_name= from_path;
if (write_table_log_entry(&table_log_entry, &log_entry)) if (write_table_log_entry(&table_log_entry, &log_entry))
{ {
...@@ -5468,6 +5468,7 @@ write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5468,6 +5468,7 @@ write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
if (write_log_rename_delete_frm(lpt, 0UL, path, shadow_path, FALSE)) if (write_log_rename_delete_frm(lpt, 0UL, path, shadow_path, FALSE))
break; break;
log_entry= part_info->first_log_entry; log_entry= part_info->first_log_entry;
part_info->frm_log_entry= log_entry;
if (write_execute_table_log_entry(log_entry->entry_pos, if (write_execute_table_log_entry(log_entry->entry_pos,
FALSE, &exec_log_entry)) FALSE, &exec_log_entry))
break; break;
...@@ -5478,6 +5479,7 @@ write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5478,6 +5479,7 @@ write_log_rename_frm(ALTER_PARTITION_PARAM_TYPE *lpt)
release_part_info_log_entries(part_info->first_log_entry); release_part_info_log_entries(part_info->first_log_entry);
unlock_global_table_log(); unlock_global_table_log();
part_info->first_log_entry= old_first_log_entry; part_info->first_log_entry= old_first_log_entry;
part_info->frm_log_entry= NULL;
my_error(ER_TABLE_LOG_ERROR, MYF(0)); my_error(ER_TABLE_LOG_ERROR, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -5527,6 +5529,7 @@ write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5527,6 +5529,7 @@ write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
(const char*)tmp_path, TRUE)) (const char*)tmp_path, TRUE))
break; break;
log_entry= part_info->first_log_entry; log_entry= part_info->first_log_entry;
part_info->frm_log_entry= log_entry;
if (write_execute_table_log_entry(log_entry->entry_pos, if (write_execute_table_log_entry(log_entry->entry_pos,
FALSE, &exec_log_entry)) FALSE, &exec_log_entry))
break; break;
...@@ -5537,6 +5540,7 @@ write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5537,6 +5540,7 @@ write_log_drop_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
release_part_info_log_entries(part_info->first_log_entry); release_part_info_log_entries(part_info->first_log_entry);
unlock_global_table_log(); unlock_global_table_log();
part_info->first_log_entry= old_first_log_entry; part_info->first_log_entry= old_first_log_entry;
part_info->frm_log_entry= NULL;
my_error(ER_TABLE_LOG_ERROR, MYF(0)); my_error(ER_TABLE_LOG_ERROR, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
...@@ -5646,6 +5650,7 @@ write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5646,6 +5650,7 @@ write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
if (write_log_rename_delete_frm(lpt, 0UL, path, shadow_path, FALSE)) if (write_log_rename_delete_frm(lpt, 0UL, path, shadow_path, FALSE))
break; break;
log_entry= part_info->first_log_entry; log_entry= part_info->first_log_entry;
part_info->frm_log_entry= log_entry;
if (write_execute_table_log_entry(log_entry->entry_pos, if (write_execute_table_log_entry(log_entry->entry_pos,
FALSE, &exec_log_entry)) FALSE, &exec_log_entry))
break; break;
...@@ -5656,6 +5661,7 @@ write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt) ...@@ -5656,6 +5661,7 @@ write_log_final_change_partition(ALTER_PARTITION_PARAM_TYPE *lpt)
release_part_info_log_entries(part_info->first_log_entry); release_part_info_log_entries(part_info->first_log_entry);
unlock_global_table_log(); unlock_global_table_log();
part_info->first_log_entry= old_first_log_entry; part_info->first_log_entry= old_first_log_entry;
part_info->frm_log_entry= NULL;
my_error(ER_TABLE_LOG_ERROR, MYF(0)); my_error(ER_TABLE_LOG_ERROR, MYF(0));
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
......
...@@ -1136,12 +1136,17 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) ...@@ -1136,12 +1136,17 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags)
*/ */
VOID(pthread_mutex_lock(&LOCK_open)); VOID(pthread_mutex_lock(&LOCK_open));
if (my_delete(frm_name, MYF(MY_WME)) || if (my_delete(frm_name, MYF(MY_WME)) ||
inactivate_table_log_entry(part_info->frm_log_entry->entry_pos) ||
sync_table_log() ||
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, TRUE)) lpt->table->file->create_handler_files(path, shadow_path, TRUE))
{ {
error= 1; error= 1;
} }
VOID(pthread_mutex_unlock(&LOCK_open)); VOID(pthread_mutex_unlock(&LOCK_open));
inactivate_table_log_entry(part_info->frm_log_entry->entry_pos);
part_info->frm_log_entry= NULL;
VOID(sync_table_log());
} }
end: end:
......
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