Commit 98db467e authored by Sachin's avatar Sachin

Better Alter Query

parent 2d12d739
...@@ -9421,8 +9421,8 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i ...@@ -9421,8 +9421,8 @@ static bool write_start_alter(THD *thd, bool* partial_alter, start_alter_info *i
{ {
char *send_query= (char *)thd->alloc(thd->query_length() + 20); char *send_query= (char *)thd->alloc(thd->query_length() + 20);
thd->gtid_flags3|= Gtid_log_event::FL_START_ALTER_E1; thd->gtid_flags3|= Gtid_log_event::FL_START_ALTER_E1;
sprintf(send_query, "/*!100001 %s, START %ld */", thd->query(), sprintf(send_query, "/*!105001 %s EXECUTE = UNTIL COMMIT %ld */",
(long)thd->thread_id); thd->query(), (long)thd->thread_id);
if (write_bin_log(thd, FALSE, send_query, strlen(send_query), true)) if (write_bin_log(thd, FALSE, send_query, strlen(send_query), true))
return true; return true;
*partial_alter= true; *partial_alter= true;
...@@ -10238,7 +10238,7 @@ do_continue:; ...@@ -10238,7 +10238,7 @@ do_continue:;
if (opt_binlog_split_alter) if (opt_binlog_split_alter)
{ {
thd->gtid_flags3|= Gtid_log_event::FL_ROLLBACK_ALTER_E1; thd->gtid_flags3|= Gtid_log_event::FL_ROLLBACK_ALTER_E1;
sprintf(send_query, "/*!100001 %s, ROLLBACK %ld */", thd->query(), sprintf(send_query, "/*!105001 %s EXECUTE = ROLLBACK %ld */", thd->query(),
(long)thd->thread_id); (long)thd->thread_id);
if(write_bin_log(thd, false, send_query, strlen(send_query), true, true)) if(write_bin_log(thd, false, send_query, strlen(send_query), true, true))
DBUG_RETURN(true); DBUG_RETURN(true);
...@@ -10403,7 +10403,7 @@ do_continue:; ...@@ -10403,7 +10403,7 @@ do_continue:;
if (partial_alter) if (partial_alter)
{ {
thd->gtid_flags3|= Gtid_log_event::FL_COMMIT_ALTER_E1; thd->gtid_flags3|= Gtid_log_event::FL_COMMIT_ALTER_E1;
sprintf(send_query, "%s /*!100001, COMMIT %ld */", thd->query(), sprintf(send_query, "%s /*!105001 EXECUTE = COMMIT %ld */", thd->query(),
(long)thd->thread_id); (long)thd->thread_id);
if(write_bin_log(thd, false, send_query, strlen(send_query))) if(write_bin_log(thd, false, send_query, strlen(send_query)))
DBUG_RETURN(true); DBUG_RETURN(true);
...@@ -10612,7 +10612,7 @@ do_continue:; ...@@ -10612,7 +10612,7 @@ do_continue:;
if (partial_alter) if (partial_alter)
{ {
thd->gtid_flags3|= Gtid_log_event::FL_COMMIT_ALTER_E1; thd->gtid_flags3|= Gtid_log_event::FL_COMMIT_ALTER_E1;
sprintf(send_query, "%s /*!100001, COMMIT %ld */", thd->query(), sprintf(send_query, "%s /*!105001 EXECUTE = COMMIT %ld */", thd->query(),
(long)thd->thread_id); (long)thd->thread_id);
if(write_bin_log(thd, false, send_query, strlen(send_query))) if(write_bin_log(thd, false, send_query, strlen(send_query)))
DBUG_RETURN(true); DBUG_RETURN(true);
...@@ -10681,7 +10681,7 @@ do_continue:; ...@@ -10681,7 +10681,7 @@ do_continue:;
else if (opt_binlog_split_alter) else if (opt_binlog_split_alter)
{ {
thd->gtid_flags3|= Gtid_log_event::FL_ROLLBACK_ALTER_E1; thd->gtid_flags3|= Gtid_log_event::FL_ROLLBACK_ALTER_E1;
sprintf(send_query, "/*!100001 %s, ROLLBACK %ld */", thd->query(), sprintf(send_query, "/*!105001 %s EXECUTE = ROLLBACK %ld */", thd->query(),
(long)thd->thread_id); (long)thd->thread_id);
if(write_bin_log(thd, false, send_query, strlen(send_query), true, true)) if(write_bin_log(thd, false, send_query, strlen(send_query), true, true))
DBUG_RETURN(true); DBUG_RETURN(true);
......
...@@ -7303,6 +7303,9 @@ alter_commands: ...@@ -7303,6 +7303,9 @@ alter_commands:
remove_partitioning remove_partitioning
| remove_partitioning | remove_partitioning
| partitioning | partitioning
| alter_list
alter_state
| alter_state
/* /*
This part was added for release 5.1 by Mikael Ronstrm. This part was added for release 5.1 by Mikael Ronstrm.
From here we insert a number of commands to manage the partitions of a From here we insert a number of commands to manage the partitions of a
...@@ -7676,7 +7679,6 @@ alter_list_item: ...@@ -7676,7 +7679,6 @@ alter_list_item:
} }
| alter_algorithm_option | alter_algorithm_option
| alter_lock_option | alter_lock_option
| alter_state
| ADD SYSTEM VERSIONING_SYM | ADD SYSTEM VERSIONING_SYM
{ {
Lex->alter_info.flags|= ALTER_ADD_SYSTEM_VERSIONING; Lex->alter_info.flags|= ALTER_ADD_SYSTEM_VERSIONING;
...@@ -7735,20 +7737,25 @@ alter_lock_option: ...@@ -7735,20 +7737,25 @@ alter_lock_option:
} }
; ;
alter_state: alter_state:
START_SYM ulong_num EXECUTE_SYM opt_equal DEFAULT
{
Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_NORMAL;
Lex->alter_info.alter_identifier= 0;
}
| EXECUTE_SYM opt_equal UNTIL_SYM COMMIT_SYM ulong_num
{ {
Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_START; Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_START;
Lex->alter_info.alter_identifier= $2; Lex->alter_info.alter_identifier= $5;
} }
| COMMIT_SYM ulong_num | EXECUTE_SYM opt_equal COMMIT_SYM ulong_num
{ {
Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_COMMIT; Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_COMMIT;
Lex->alter_info.alter_identifier= $2; Lex->alter_info.alter_identifier= $4;
} }
| ROLLBACK_SYM ulong_num | EXECUTE_SYM opt_equal ROLLBACK_SYM ulong_num
{ {
Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_ROLLBACK; Lex->alter_info.alter_state= Alter_info::ALTER_TABLE_ROLLBACK;
Lex->alter_info.alter_identifier= $2; Lex->alter_info.alter_identifier= $4;
} }
; ;
......
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