Skip to content

Instantly share code, notes, and snippets.

@MarkLeith
Created May 27, 2015 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkLeith/39d199c6d1ad7c90a7d3 to your computer and use it in GitHub Desktop.
Save MarkLeith/39d199c6d1ad7c90a7d3 to your computer and use it in GitHub Desktop.
Add REPLICA synonym for SLAVE in MySQL commands
diff --git a/sql/lex.h b/sql/lex.h
index 5f0b5b2..72c3b5d 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -487,6 +487,7 @@ static const SYMBOL symbols[] = {
{ SYM("REORGANIZE", REORGANIZE_SYM)},
{ SYM("REPAIR", REPAIR)},
{ SYM("REPEATABLE", REPEATABLE_SYM)},
+ { SYM("REPLICA", REPLICA_SYM)},
{ SYM("REPLICATION", REPLICATION)},
{ SYM("REPLICATE_DO_DB", REPLICATE_DO_DB)},
{ SYM("REPLICATE_IGNORE_DB", REPLICATE_IGNORE_DB)},
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index a562cce..98addc9 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -925,6 +925,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, YYLTYPE **c, ulong *yystacksize);
%token REPEATABLE_SYM /* SQL-2003-N */
%token REPEAT_SYM /* MYSQL-FUNC */
%token REPLACE /* MYSQL-FUNC */
+%token REPLICA_SYM
%token REPLICATION
%token REPLICATE_DO_DB
%token REPLICATE_IGNORE_DB
@@ -8329,7 +8330,7 @@ group_replication:
slave:
slave_start start_slave_opts{}
- | STOP_SYM SLAVE opt_slave_thread_option_list opt_channel
+ | STOP_SYM slave_or_replica opt_slave_thread_option_list opt_channel
{
LEX *lex=Lex;
lex->sql_command = SQLCOM_SLAVE_STOP;
@@ -8339,7 +8340,7 @@ slave:
;
slave_start:
- START_SYM SLAVE opt_slave_thread_option_list
+ START_SYM slave_or_replica opt_slave_thread_option_list
{
LEX *lex=Lex;
/* Clean previous slave connection values */
@@ -11730,7 +11731,7 @@ show_param:
{
Lex->sql_command = SQLCOM_SHOW_BINLOGS;
}
- | SLAVE HOSTS_SYM
+ | slave_or_replica HOSTS_SYM
{
Lex->sql_command = SQLCOM_SHOW_SLAVE_HOSTS;
}
@@ -11951,7 +11952,7 @@ show_param:
{
Lex->sql_command = SQLCOM_SHOW_MASTER_STAT;
}
- | SLAVE STATUS_SYM opt_channel
+ | slave_or_replica STATUS_SYM opt_channel
{
Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
}
@@ -12025,6 +12026,11 @@ master_or_binary:
| BINARY
;
+slave_or_replica:
+ SLAVE
+ | REPLICA_SYM
+ ;
+
opt_storage:
/* empty */
| STORAGE_SYM
@@ -12331,7 +12337,7 @@ reset_options:
;
reset_option:
- SLAVE { Lex->type|= REFRESH_SLAVE; }
+ slave_or_replica { Lex->type|= REFRESH_SLAVE; }
slave_reset_options opt_channel
| MASTER_SYM { Lex->type|= REFRESH_MASTER; }
| QUERY_SYM CACHE_SYM { Lex->type|= REFRESH_QUERY_CACHE;}
@@ -13422,6 +13428,7 @@ keyword_sp:
| RELOAD {}
| REORGANIZE_SYM {}
| REPEATABLE_SYM {}
+ | REPLICA_SYM {}
| REPLICATION {}
| REPLICATE_DO_DB {}
| REPLICATE_IGNORE_DB {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment