summaryrefslogtreecommitdiff
path: root/sql/sql_repl.cc
diff options
context:
space:
mode:
authorunknown <antony@ppcg5.local>2007-03-02 08:43:45 -0800
committerunknown <antony@ppcg5.local>2007-03-02 08:43:45 -0800
commit1fc7f2117bddfcf91e1220f22714beb86d26c544 (patch)
tree23fe49e9ab83f6badb4e173587f9e194490a3859 /sql/sql_repl.cc
parent1eb71c68cb1b2f335a8e6b393cdb3e724ea65a0a (diff)
downloadmariadb-git-1fc7f2117bddfcf91e1220f22714beb86d26c544.tar.gz
WL#2936
"Server Variables for Plugins" Implement support for plugins to declare server variables. Demonstrate functionality by removing InnoDB specific code from sql/* New feature for HASH - HASH_UNIQUE flag New feature for DYNAMIC_ARRAY - initializer accepts preallocated ptr. Completed support for plugin reference counting. include/hash.h: New flag for HASH HASH_UNIQUE include/my_getopt.h: New data types for options: ENUM and SET. Use typelib to enumerate possible values. New flag variable: my_getopt_skip_unknown include/my_sys.h: change to DYNAMIC_ARRAY init functions to support pre-allocated buffers include/mysql.h: relocate inclusion of typelib due to longlong requirement include/mysql/plugin.h: wl2936 New declarations for plugin server variable support. New functions for use by plugins include/mysys_err.h: new my_getopt return value: EXIT_ARGUMENT_INVALID include/typelib.h: new typelib function: find_typeset(), returns an int which is a SET of the elements in the typelib mysql-test/r/im_utils.result: change to more specific command line settings --skip-innodb => --skip-plugin-innodb etc. mysql-test/r/log_tables.result: set default storage engine to MEMORY so that test will succeed even when some of the other named storage engines are not present mysql-test/r/ndb_dd_basic.result: change in error message mysql-test/r/partition_innodb.result: change in results mysql-test/r/ps_1general.result: bdb doesn't exist, use myisam for a non-transactional engine mysql-test/r/variables.result: information schema doesn't sort row results for server variables. mysql-test/t/log_tables.test: set default storage engine to MEMORY so that test will succeed even when some of the other named storage engines are not present mysql-test/t/ndb_dd_basic.test: ALTER LOGFILE GROUP no longer silently fail here mysql-test/t/partition_innodb.test: ALTER TABLE no longer silently fails for unknown storage engine mysql-test/t/ps_1general.test: remove unneccessary parts use myisam as it is an always present non-transactional engine mysql-test/t/variables.test: information schema doesn't sort row results for server variables. mysql-test/t/warnings_engine_disabled-master.opt: use the new style command line option mysys/array.c: change to DYNAMIC_ARRAY init functions to support pre-allocated buffers mysys/hash.c: New flag for HASH HASH_UNIQUE Implement HASH_UNIQUE functionality by performing a hash_search mysys/my_getopt.c: New data types for options: ENUM and SET. Use typelib to enumerate possible values. New flag variable: my_getopt_skip_unknown mysys/typelib.c: new typelib function: find_typeset(), returns an int which is a SET of the elements in the typelib sql/ha_ndbcluster.cc: use ha_statistic_increment() method instead of statistic_increment() function ha_ndbcluster variable has gone away. sql/ha_partition.cc: fix for reference counting sql/ha_partition.h: fix for reference counting sql/handler.cc: fixes for reference counting sql/handler.h: fixes for reference counting some new methods to aid storage engine writers sql/item_func.cc: find_sys_var() function now requires thd sql/item_sum.cc: fixes for ref counting sql/mysql_priv.h: remove unneccessary globals. new lock: LOCK_system_variables_hash sql/mysqld.cc: Remove InnoBase specific code. Support plugin command line processing. sql/set_var.cc: Remove InnoBase specific declarations Remove redundant declarations changes to permit new variables at run time changes for ref counting sql/set_var.h: changes to permit new variables at run time changes for ref counting sql/sql_base.cc: changes for ref counting sql/sql_cache.cc: mark code as needing work in the future sql/sql_class.cc: new functions to aid plugin authors initialize variables for dynamic plugin variables sql/sql_class.h: remove InnoBase specific declarations New declarations for plugin variables. sql/sql_connect.cc: initialization and cleanup of plugin variables sql/sql_delete.cc: change for ref counting sql/sql_insert.cc: change for ref counting sql/sql_lex.cc: changes for ref counting and plugin variables sql/sql_lex.h: add properties for plugin ref counting, add to distructor to clean up sql/sql_partition.cc: changes for ref counting sql/sql_plugin.cc: WL2936 Plugin Variables New methods and code to support server variables for plugins. New code to complete plugin reference counting Debug code adds further indirection so that malloc debugging can be used to aid finding plugin ref count leaks sql/sql_plugin.h: WL2936 Plugin Variables New methods and code to support server variables for plugins. New code to complete plugin reference counting Debug code adds further indirection so that malloc debugging can be used to aid finding plugin ref count leaks sql/sql_repl.cc: replication system variables moved here from set_var.cc sql/sql_repl.h: new function to initialise replication server variables sql/sql_select.cc: changes for ref counting sql/sql_show.cc: changes for ref counting sql/sql_table.cc: changes for ref counting sql/sql_tablespace.cc: use supplied functions instead of digging into data structures manually sql/sql_yacc.yy: changes for ref counting find_sys_var() now requires thd parameter changes on reporting errors to keep user-visible behaviour the same. sql/structs.h: changes for ref counting sql/table.cc: changes for ref counting sql/table.h: changes for ref counting storage/federated/ha_federated.cc: use ha_statistic_increment() method instead of statistic_increment() function storage/heap/ha_heap.cc: use ha_statistic_increment() method instead of statistic_increment() function storage/innobase/handler/ha_innodb.cc: use ha_statistic_increment() method instead of statistic_increment() function WL2936 Move InnoBase specific code out of mysqld.cc and into here Declare all required server variables for InnoBase storage/innobase/include/trx0trx.h: store a bit more state so that InnoBase does not have to dig into mysqld internal data structures. storage/myisam/ha_myisam.cc: use ha_statistic_increment() method instead of statistic_increment() function storage/myisammrg/ha_myisammrg.cc: use ha_statistic_increment() method instead of statistic_increment() function
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r--sql/sql_repl.cc143
1 files changed, 143 insertions, 0 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 17163fb1940..589381ca61f 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1596,6 +1596,149 @@ int log_loaded_block(IO_CACHE* file)
return 0;
}
+/*
+ Replication System Variables
+*/
+
+class sys_var_slave_skip_counter :public sys_var
+{
+public:
+ sys_var_slave_skip_counter(sys_var_chain *chain, const char *name_arg)
+ :sys_var(name_arg)
+ { chain_sys_var(chain); }
+ bool check(THD *thd, set_var *var);
+ bool update(THD *thd, set_var *var);
+ bool check_type(enum_var_type type) { return type != OPT_GLOBAL; }
+ /*
+ We can't retrieve the value of this, so we don't have to define
+ type() or value_ptr()
+ */
+};
+
+class sys_var_sync_binlog_period :public sys_var_long_ptr
+{
+public:
+ sys_var_sync_binlog_period(sys_var_chain *chain, const char *name_arg,
+ ulong *value_ptr)
+ :sys_var_long_ptr(chain, name_arg,value_ptr) {}
+ bool update(THD *thd, set_var *var);
+};
+
+static sys_var_chain vars = { NULL, NULL };
+
+static sys_var_bool_ptr sys_relay_log_purge(&vars, "relay_log_purge",
+ &relay_log_purge);
+static sys_var_long_ptr sys_slave_net_timeout(&vars, "slave_net_timeout",
+ &slave_net_timeout);
+static sys_var_long_ptr sys_slave_trans_retries(&vars, "slave_transaction_retries",
+ &slave_trans_retries);
+static sys_var_sync_binlog_period sys_sync_binlog_period(&vars, "sync_binlog", &sync_binlog_period);
+static sys_var_slave_skip_counter sys_slave_skip_counter(&vars, "sql_slave_skip_counter");
+
+static int show_slave_skip_errors(THD *thd, SHOW_VAR *var, char *buff);
+
+
+static SHOW_VAR fixed_vars[]= {
+ {"log_slave_updates", (char*) &opt_log_slave_updates, SHOW_MY_BOOL},
+ {"relay_log_space_limit", (char*) &relay_log_space_limit, SHOW_LONGLONG},
+ {"slave_load_tmpdir", (char*) &slave_load_tmpdir, SHOW_CHAR_PTR},
+ {"slave_skip_errors", (char*) &show_slave_skip_errors, SHOW_FUNC},
+};
+
+static int show_slave_skip_errors(THD *thd, SHOW_VAR *var, char *buff)
+{
+ var->type=SHOW_CHAR;
+ var->value= buff;
+ if (!use_slave_mask || bitmap_is_clear_all(&slave_error_mask))
+ {
+ var->value= const_cast<char *>("OFF");
+ }
+ else if (bitmap_is_set_all(&slave_error_mask))
+ {
+ var->value= const_cast<char *>("ALL");
+ }
+ else
+ {
+ /* 10 is enough assuming errors are max 4 digits */
+ int i;
+ var->value= buff;
+ for (i= 1;
+ i < MAX_SLAVE_ERROR &&
+ (buff - var->value) < SHOW_VAR_FUNC_BUFF_SIZE;
+ i++)
+ {
+ if (bitmap_is_set(&slave_error_mask, i))
+ {
+ buff= int10_to_str(i, buff, 10);
+ *buff++= ',';
+ }
+ }
+ if (var->value != buff)
+ buff--; // Remove last ','
+ if (i < MAX_SLAVE_ERROR)
+ buff= strmov(buff, "..."); // Couldn't show all errors
+ *buff=0;
+ }
+ return 0;
+}
+
+bool sys_var_slave_skip_counter::check(THD *thd, set_var *var)
+{
+ int result= 0;
+ pthread_mutex_lock(&LOCK_active_mi);
+ pthread_mutex_lock(&active_mi->rli.run_lock);
+ if (active_mi->rli.slave_running)
+ {
+ my_message(ER_SLAVE_MUST_STOP, ER(ER_SLAVE_MUST_STOP), MYF(0));
+ result=1;
+ }
+ pthread_mutex_unlock(&active_mi->rli.run_lock);
+ pthread_mutex_unlock(&LOCK_active_mi);
+ var->save_result.ulong_value= (ulong) var->value->val_int();
+ return result;
+}
+
+
+bool sys_var_slave_skip_counter::update(THD *thd, set_var *var)
+{
+ pthread_mutex_lock(&LOCK_active_mi);
+ pthread_mutex_lock(&active_mi->rli.run_lock);
+ /*
+ The following test should normally never be true as we test this
+ in the check function; To be safe against multiple
+ SQL_SLAVE_SKIP_COUNTER request, we do the check anyway
+ */
+ if (!active_mi->rli.slave_running)
+ {
+ pthread_mutex_lock(&active_mi->rli.data_lock);
+ active_mi->rli.slave_skip_counter= var->save_result.ulong_value;
+ pthread_mutex_unlock(&active_mi->rli.data_lock);
+ }
+ pthread_mutex_unlock(&active_mi->rli.run_lock);
+ pthread_mutex_unlock(&LOCK_active_mi);
+ return 0;
+}
+
+
+bool sys_var_sync_binlog_period::update(THD *thd, set_var *var)
+{
+ sync_binlog_period= (ulong) var->save_result.ulonglong_value;
+ return 0;
+}
+
+int init_replication_sys_vars()
+{
+ mysql_append_static_vars(fixed_vars, sizeof(fixed_vars) / sizeof(SHOW_VAR));
+
+ if (mysql_add_sys_var_chain(vars.first, my_long_options))
+ {
+ /* should not happen */
+ fprintf(stderr, "failed to initialize replication system variables");
+ unireg_abort(1);
+ }
+ return 0;
+}
+
#endif /* HAVE_REPLICATION */