]> git.pld-linux.org Git - packages/mysql.git/blob - show_slave_status_nolock.patch
- make mysql.init a bit more lsb-compatible
[packages/mysql.git] / show_slave_status_nolock.patch
1 # name       : show_slave_status_nolock.patch
2 # introduced : 12
3 # maintainer : Oleg
4 #
5 #!!! notice !!!
6 # Any small change to this file in the main branch
7 # should be done or reviewed by the maintainer!
8 diff -ruN /dev/null b/patch_info/show_slave_status_nolock.patch
9 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
10 +++ b/patch_info/show_slave_status_nolock.patch 2011-04-10 11:29:06.000000000 +0400
11 @@ -0,0 +1,6 @@
12 +File=show_slave_status_nolock.patch
13 +Name= SHOW SLAVE STATUS NOLOCK
14 +Version=1.0
15 +Author=Percona <info@percona.com>
16 +License=GPL
17 +Comment= Implement SHOW SLAVE STATUS without lock (STOP SLAVE lock the same mutex what lock SHOW SLAVE STATUS)
18 diff -ruN a/sql/lex.h b/sql/lex.h
19 --- a/sql/lex.h 2011-04-10 11:29:05.000000000 +0400
20 +++ b/sql/lex.h 2011-04-10 11:29:06.000000000 +0400
21 @@ -378,6 +378,7 @@
22    { "NONE",            SYM(NONE_SYM)},
23    { "NOT",             SYM(NOT_SYM)},
24    { "NO_WRITE_TO_BINLOG",  SYM(NO_WRITE_TO_BINLOG)},
25 +  { "NOLOCK",           SYM(NOLOCK_SYM)},
26    { "NULL",            SYM(NULL_SYM)},
27    { "NUMERIC",         SYM(NUMERIC_SYM)},
28    { "NVARCHAR",                SYM(NVARCHAR_SYM)},
29 diff -ruN a/sql/mysqld.cc b/sql/mysqld.cc
30 --- a/sql/mysqld.cc     2011-04-10 11:29:05.000000000 +0400
31 +++ b/sql/mysqld.cc     2011-04-10 11:29:06.000000000 +0400
32 @@ -3071,6 +3071,7 @@
33    {"show_relaylog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_RELAYLOG_EVENTS]), SHOW_LONG_STATUS},
34    {"show_slave_hosts",     (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
35    {"show_slave_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
36 +  {"show_slave_status_nolock", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_NOLOCK_STAT]), SHOW_LONG_STATUS},
37    {"show_status",          (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
38    {"show_storage_engines", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STORAGE_ENGINES]), SHOW_LONG_STATUS},
39    {"show_table_status",    (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_TABLE_STATUS]), SHOW_LONG_STATUS},
40 diff -ruN a/sql/sql_lex.h b/sql/sql_lex.h
41 --- a/sql/sql_lex.h     2011-04-10 11:29:05.000000000 +0400
42 +++ b/sql/sql_lex.h     2011-04-10 11:29:06.000000000 +0400
43 @@ -190,6 +190,8 @@
44    SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
45    SQLCOM_SIGNAL, SQLCOM_RESIGNAL,
46    SQLCOM_SHOW_RELAYLOG_EVENTS, 
47 +  /* SHOW SLAVE STATUS NOLOCK */
48 +  SQLCOM_SHOW_SLAVE_NOLOCK_STAT,
49    /*
50      When a command is added here, be sure it's also added in mysqld.cc
51      in "struct show_var_st status_vars[]= {" ...
52 diff -ruN a/sql/sql_parse.cc b/sql/sql_parse.cc
53 --- a/sql/sql_parse.cc  2011-04-10 11:28:51.000000000 +0400
54 +++ b/sql/sql_parse.cc  2011-04-10 11:29:06.000000000 +0400
55 @@ -335,6 +335,7 @@
56    sql_command_flags[SQLCOM_SHOW_CREATE]=  CF_STATUS_COMMAND;
57    sql_command_flags[SQLCOM_SHOW_MASTER_STAT]= CF_STATUS_COMMAND;
58    sql_command_flags[SQLCOM_SHOW_SLAVE_STAT]=  CF_STATUS_COMMAND;
59 +  sql_command_flags[SQLCOM_SHOW_SLAVE_NOLOCK_STAT]=  CF_STATUS_COMMAND;
60    sql_command_flags[SQLCOM_SHOW_CREATE_PROC]= CF_STATUS_COMMAND;
61    sql_command_flags[SQLCOM_SHOW_CREATE_FUNC]= CF_STATUS_COMMAND;
62    sql_command_flags[SQLCOM_SHOW_CREATE_TRIGGER]=  CF_STATUS_COMMAND;
63 @@ -2293,12 +2294,16 @@
64      mysql_mutex_unlock(&LOCK_active_mi);
65      break;
66    }
67 +  case SQLCOM_SHOW_SLAVE_NOLOCK_STAT:
68    case SQLCOM_SHOW_SLAVE_STAT:
69    {
70      /* Accept one of two privileges */
71      if (check_global_access(thd, SUPER_ACL | REPL_CLIENT_ACL))
72        goto error;
73 -    mysql_mutex_lock(&LOCK_active_mi);
74 +    if(SQLCOM_SHOW_SLAVE_NOLOCK_STAT != lex->sql_command)
75 +    {
76 +      mysql_mutex_lock(&LOCK_active_mi);
77 +    }
78      if (active_mi != NULL)
79      {
80        res = show_master_info(thd, active_mi);
81 @@ -2309,7 +2314,10 @@
82                     WARN_NO_MASTER_INFO, ER(WARN_NO_MASTER_INFO));
83        my_ok(thd);
84      }
85 -    mysql_mutex_unlock(&LOCK_active_mi);
86 +    if(SQLCOM_SHOW_SLAVE_NOLOCK_STAT != lex->sql_command)
87 +    {
88 +      mysql_mutex_unlock(&LOCK_active_mi);
89 +    }
90      break;
91    }
92    case SQLCOM_SHOW_MASTER_STAT:
93 diff -ruN a/sql/sql_yacc.yy b/sql/sql_yacc.yy
94 --- a/sql/sql_yacc.yy   2011-04-10 11:29:05.000000000 +0400
95 +++ b/sql/sql_yacc.yy   2011-04-10 11:29:06.000000000 +0400
96 @@ -1292,6 +1292,7 @@
97  %token  STARTS_SYM
98  %token  START_SYM                     /* SQL-2003-R */
99  %token  STATUS_SYM
100 +%token  NOLOCK_SYM                    /* SHOW SLAVE STATUS NOLOCK */
101  %token  STDDEV_SAMP_SYM               /* SQL-2003-N */
102  %token  STD_SYM
103  %token  STOP_SYM
104 @@ -11082,6 +11083,10 @@
105            {
106              Lex->sql_command = SQLCOM_SHOW_SLAVE_STAT;
107            }
108 +        | SLAVE STATUS_SYM NOLOCK_SYM
109 +          {
110 +           Lex->sql_command = SQLCOM_SHOW_SLAVE_NOLOCK_STAT; //SQLCOM_SHOW_SLAVE_NOLOCK_STAT;
111 +          }
112          | QUERY_RESPONSE_TIME_SYM wild_and_where
113           {
114  #ifdef HAVE_RESPONSE_TIME_DISTRIBUTION
This page took 0.092717 seconds and 3 git commands to generate.