Commit d7c47dcf authored by sasha@mysql.sashanet.com's avatar sasha@mysql.sashanet.com
Browse files

Added rpl_status. This is a midway commit to be able to pull so I can save

myself a run of compile-pentium-debug. I have not even tried to compile the 
new code
parent 7b06c3c3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc \
			sql_udf.cc sql_analyse.cc sql_analyse.h sql_cache.cc \
			slave.cc sql_repl.cc sql_union.cc \
			mini_client.cc mini_client_errors.c \
			stacktrace.c 
			stacktrace.c repl_failsafe.h repl_failsafe.cc
gen_lex_hash_SOURCES =	gen_lex_hash.cc
gen_lex_hash_LDADD =	$(LDADD) $(CXXLDFLAGS)

+17 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include "sql_acl.h"
#include "slave.h"
#include "sql_repl.h"
#include "repl_failsafe.h"
#include "stacktrace.h"
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
@@ -1698,6 +1699,7 @@ int main(int argc, char **argv)
  (void) pthread_mutex_init(&LOCK_slave, MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_server_id, MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_user_conn, MY_MUTEX_INIT_FAST);
  (void) pthread_mutex_init(&LOCK_rpl_status, MY_MUTEX_INIT_FAST);
  (void) pthread_cond_init(&COND_thread_count,NULL);
  (void) pthread_cond_init(&COND_refresh,NULL);
  (void) pthread_cond_init(&COND_thread_cache,NULL);
@@ -1706,6 +1708,7 @@ int main(int argc, char **argv)
  (void) pthread_cond_init(&COND_binlog_update, NULL);
  (void) pthread_cond_init(&COND_slave_stopped, NULL);
  (void) pthread_cond_init(&COND_slave_start, NULL);
  (void) pthread_cond_init(&COND_rpl_status, NULL);
  init_signals();

  if (set_default_charset_by_name(default_charset, MYF(MY_WME)))
@@ -2652,6 +2655,7 @@ static struct option long_options[] = {
  {"gemini-recovery",	    required_argument, 0, (int) OPT_GEMINI_RECOVER},
  {"gemini-unbuffered-io",  no_argument,       0, (int) OPT_GEMINI_UNBUFFERED_IO},
#endif
  {"init-rpl-role", required_argument, 0, (int) OPT_INIT_RPL_ROLE},
  /* We must always support this option to make scripts like mysqltest easier
     to do */
  {"innodb_data_file_path", required_argument, 0,
@@ -3101,6 +3105,8 @@ struct show_var_st status_vars[]= {
  {"Open_streams",             (char*) &my_stream_opened,       SHOW_INT_CONST},
  {"Opened_tables",            (char*) &opened_tables,          SHOW_LONG},
  {"Questions",                (char*) 0,                       SHOW_QUESTION},
  {"Rpl_status",               (char*) 0,
   SHOW_RPL_STATUS},
  {"Select_full_join",         (char*) &select_full_join_count, SHOW_LONG},
  {"Select_full_range_join",   (char*) &select_full_range_join_count, SHOW_LONG},
  {"Select_range",             (char*) &select_range_count, 	SHOW_LONG},
@@ -3548,6 +3554,17 @@ static void get_options(int argc,char **argv)
      opt_log_slave_updates = 1;
      break;

    case (int) OPT_INIT_RPL_ROLE:
    {
      int role;
      if ((role=find_type(optarg, &rpl_role_typelib, 2)) <= 0)
      {
	fprintf(stderr, "Unknown replication role: %s\n", optarg);
	exit(1);
      }
      rpl_status = (rpl_role == 1) ?  RPL_AUTH_MASTER : RPL_IDLE_SLAVE;
      break;
    }
    case (int)OPT_REPLICATE_IGNORE_DB:
      {
	i_string *db = new i_string(optarg);

sql/repl_failsafe.cc

0 → 100644
+36 −0
Original line number Diff line number Diff line
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB & Sasha

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */

// Sasha Pachev <sasha@mysql.com> is currently in charge of this file

#include "mysql_priv.h"
#include "repl_failsafe.h"

RPL_STATUS rpl_status=RPL_NULL;
pthread_mutex_t LOCK_rpl_status;
pthread_cond_t COND_rpl_status;

const char *rpl_role_type[] = {"","MASTER","SLAVE",NullS};
TYPELIB rpl_role_typelib = {array_elements(rpl_role_type)-4,"",
			    rpl_role_type+1};

const char* rpl_status_type[] = {"AUTH_MASTER","ACTIVE_SLAVE","IDLE_SLAVE",
				 "LOST_SOLDIER","TROOP_SOLDIER",
				 "RECOVERY_CAPTAIN","NULL",NullS};
TYPELIB rpl_status_typelib= {array_elements(rpl_status_type)-1,"",
			     rpl_status_type};

sql/repl_failsafe.h

0 → 100644
+13 −0
Original line number Diff line number Diff line
#ifndef REPL_FAILSAFE_H
#define REPL_FAILSAFE_H

typedef enum {RPL_AUTH_MASTER=0,RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE,
	      RPL_LOST_SOLDIER,RPL_TROOP_SOLDIER,
	      RPL_RECOVERY_CAPTAIN,RPL_NULL} RPL_STATUS;
extern RPL_STATUS rpl_status;

extern pthread_mutex_t LOCK_rpl_status;
extern pthread_cond_t COND_rpl_status;
extern TYPELIB rpl_role_typelib, rpl_status_typelib;
extern char* rpl_role_type[], *rpl_status_type;
#endif
+3 −0
Original line number Diff line number Diff line
@@ -1164,6 +1164,9 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables)
      case SHOW_QUESTION:
        net_store_data(&packet2,(uint32) thd->query_id);
        break;
      case SHOW_RPL_STATUS:
	net_store_data(&packet2, rpl_status_type[(int)rpl_status]);
	break;
      case SHOW_OPENTABLES:
        net_store_data(&packet2,(uint32) cached_tables());
        break;
Loading