List:Commits« Previous MessageNext Message »
From:antony Date:December 22 2006 1:54am
Subject:bk commit into 5.1 tree (antony:1.2361)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of antony. When antony does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-12-21 16:54:19-08:00, antony@stripped +23 -0
  WL#2936
    "Plugin Server Variables"
    Second-cut implementation for review (relative to 5.1-engines tree)

  include/my_getopt.h@stripped, 2006-12-21 16:54:07-08:00, antony@stripped +2 -1
    change app_type to a long so its safe for pointers on 64bit arch.
    new flag: my_getopt_skip_unknown

  include/mysql/plugin.h@stripped, 2006-12-21 16:54:08-08:00, antony@stripped +250 -3
    WL2936
      Introduce new structures to declare server variables for plugins

  mysql-test/mysql-test-run.pl@stripped, 2006-12-21 16:54:08-08:00, antony@stripped +11
-11
    change to use plugin-safe command line options

  mysys/my_getopt.c@stripped, 2006-12-21 16:54:08-08:00, antony@stripped +16 -0
    when my_getopt_skip_unknown is set, handle_options will skip and
    preserve unhandled options

  sql/ha_ndbcluster.cc@stripped, 2006-12-21 16:54:09-08:00, antony@stripped +11 -24
    use ha_statistic_increment where appropiate.
    remove have_ndbcluster

  sql/handler.cc@stripped, 2006-12-21 16:54:09-08:00, antony@stripped +1 -2
    use ha_statistic_increment where appropiate

  sql/mysql_priv.h@stripped, 2006-12-21 16:54:09-08:00, antony@stripped +1 -6
    remove some unneccessary globals.
    new func: reset_status_vars()

  sql/mysqld.cc@stripped, 2006-12-21 16:54:09-08:00, antony@stripped +58 -399
    WL2936
      remove some unneccessary declarations
      alter argument processing for plugins

  sql/set_var.cc@stripped, 2006-12-21 16:54:09-08:00, antony@stripped +330 -639
    WL2936
      Remove some unneccessary declarations
      change sys_var constructors to construct chain explicitly.
      new functions enumerate_sys_vars(), set_var_init()
        mysql_add_sys_var_chain(), mysql_del_sys_var_chain(),
        mysql_append_static_vars()

  sql/set_var.h@stripped, 2006-12-21 16:54:10-08:00, antony@stripped +171 -136
    WL2936
      change sys_var constructors to construct chain explicitly.
      new functions enumerate_sys_vars(), set_var_init(),
        mysql_add_sys_var_chain(), mysql_del_sys_var_chain(),
        mysql_append_static_vars()

  sql/sql_class.cc@stripped, 2006-12-21 16:54:10-08:00, antony@stripped +5 -0
    WL2936
      declarations for dynamic system variables

  sql/sql_class.h@stripped, 2006-12-21 16:54:10-08:00, antony@stripped +13 -2
    WL2936
      declarations for dynamic system variables

  sql/sql_parse.cc@stripped, 2006-12-21 16:54:10-08:00, antony@stripped +0 -1
    remove redundant code

  sql/sql_plugin.cc@stripped, 2006-12-21 16:54:10-08:00, antony@stripped +1359 -31
    WL2936
      declarations to implement plugin server variables

  sql/sql_plugin.h@stripped, 2006-12-21 16:54:11-08:00, antony@stripped +18 -1
    WL2936
      declarations to implement plugin server variables

  sql/sql_repl.cc@stripped, 2006-12-21 16:54:11-08:00, antony@stripped +142 -0
    relocate some replication specific code from mysqld.cc

  sql/sql_repl.h@stripped, 2006-12-21 16:54:11-08:00, antony@stripped +1 -0
    relocate some replication specific code from mysqld.cc

  sql/sql_show.cc@stripped, 2006-12-21 16:54:11-08:00, antony@stripped +15 -3
    WL2936
      new function reset_status_vars()
      make use of new server variable enumeration function

  storage/federated/ha_federated.cc@stripped, 2006-12-21 16:54:11-08:00, antony@stripped +4
-7
    use ha_statistic_increment where appropiate

  storage/heap/ha_heap.cc@stripped, 2006-12-21 16:54:12-08:00, antony@stripped +12 -21
    use ha_statistic_increment where appropiate

  storage/innobase/handler/ha_innodb.cc@stripped, 2006-12-21 16:54:12-08:00,
antony@stripped +227 -15
    WL2936
      use ha_statistic_increment where appropiate
      declare innodb server variables (moved from mysqld.cc)

  storage/myisam/ha_myisam.cc@stripped, 2006-12-21 16:54:12-08:00, antony@stripped +13 -23
    use ha_statistic_increment where appropiate

  storage/myisammrg/ha_myisammrg.cc@stripped, 2006-12-21 16:54:12-08:00, antony@stripped
+13 -23
    use ha_statistic_increment where appropiate

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	antony
# Host:	ppcg5.local
# Root:	/Users/antony/Work/wl2936.6

--- 1.104/storage/heap/ha_heap.cc	2006-12-21 16:54:34 -08:00
+++ 1.105/storage/heap/ha_heap.cc	2006-12-21 16:54:34 -08:00
@@ -182,7 +182,7 @@
 int ha_heap::write_row(byte * buf)
 {
   int res;
-  statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_write_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
   if (table->next_number_field && buf == table->record[0])
@@ -206,7 +206,7 @@
 int ha_heap::update_row(const byte * old_data, byte * new_data)
 {
   int res;
-  statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   res= heap_update(file,old_data,new_data);
@@ -225,7 +225,7 @@
 int ha_heap::delete_row(const byte * buf)
 {
   int res;
-  statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_delete_count);
   res= heap_delete(file,buf);
   if (!res && table->s->tmp_table == NO_TMP_TABLE && 
       ++records_changed*HEAP_STATS_UPDATE_THRESHOLD > file->s->records)
@@ -243,8 +243,7 @@
 			enum ha_rkey_function find_flag)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error = heap_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status = error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -253,8 +252,7 @@
 int ha_heap::index_read_last(byte *buf, const byte *key, uint key_len)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error= heap_rkey(file, buf, active_index, key, key_len,
 		       HA_READ_PREFIX_LAST);
   table->status= error ? STATUS_NOT_FOUND : 0;
@@ -264,8 +262,7 @@
 int ha_heap::index_read_idx(byte * buf, uint index, const byte * key,
 			    uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error = heap_rkey(file, buf, index, key, key_len, find_flag);
   table->status = error ? STATUS_NOT_FOUND : 0;
   return error;
@@ -274,8 +271,7 @@
 int ha_heap::index_next(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_next_count);
   int error=heap_rnext(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -284,8 +280,7 @@
 int ha_heap::index_prev(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_prev_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_prev_count);
   int error=heap_rprev(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -294,8 +289,7 @@
 int ha_heap::index_first(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_first_count);
   int error=heap_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -304,8 +298,7 @@
 int ha_heap::index_last(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_last_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_last_count);
   int error=heap_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -318,8 +311,7 @@
 
 int ha_heap::rnd_next(byte *buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error=heap_scan(file, buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -329,8 +321,7 @@
 {
   int error;
   HEAP_PTR position;
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_count);
   memcpy_fixed((char*) &position,pos,sizeof(HEAP_PTR));
   error=heap_rrnd(file, buf, position);
   table->status=error ? STATUS_NOT_FOUND: 0;

--- 1.202/storage/myisam/ha_myisam.cc	2006-12-21 16:54:34 -08:00
+++ 1.203/storage/myisam/ha_myisam.cc	2006-12-21 16:54:34 -08:00
@@ -334,7 +334,7 @@
 
 int ha_myisam::write_row(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_write_count);
 
   /* If we have a timestamp column, update it to the current time */
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
@@ -1192,7 +1192,7 @@
 
 int ha_myisam::update_row(const byte * old_data, byte * new_data)
 {
-  statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   return mi_update(file,old_data,new_data);
@@ -1200,7 +1200,7 @@
 
 int ha_myisam::delete_row(const byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_delete_count);
   return mi_delete(file,buf);
 }
 
@@ -1208,8 +1208,7 @@
 			  uint key_len, enum ha_rkey_function find_flag)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1218,8 +1217,7 @@
 int ha_myisam::index_read_idx(byte * buf, uint index, const byte * key,
 			      uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error=mi_rkey(file,buf,index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1229,8 +1227,7 @@
 {
   DBUG_ENTER("ha_myisam::index_read_last");
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
   table->status=error ? STATUS_NOT_FOUND: 0;
   DBUG_RETURN(error);
@@ -1239,8 +1236,7 @@
 int ha_myisam::index_next(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_next_count);
   int error=mi_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1249,8 +1245,7 @@
 int ha_myisam::index_prev(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_prev_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_prev_count);
   int error=mi_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1259,8 +1254,7 @@
 int ha_myisam::index_first(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_first_count);
   int error=mi_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1269,8 +1263,7 @@
 int ha_myisam::index_last(byte * buf)
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_last_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_last_count);
   int error=mi_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1281,8 +1274,7 @@
 			       uint length __attribute__((unused)))
 {
   DBUG_ASSERT(inited==INDEX);
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_next_count);
   int error=mi_rnext_same(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1298,8 +1290,7 @@
 
 int ha_myisam::rnd_next(byte *buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error=mi_scan(file, buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -1312,8 +1303,7 @@
 
 int ha_myisam::rnd_pos(byte * buf, byte *pos)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_count);
   int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length));
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;

--- 1.109/storage/myisammrg/ha_myisammrg.cc	2006-12-21 16:54:34 -08:00
+++ 1.110/storage/myisammrg/ha_myisammrg.cc	2006-12-21 16:54:34 -08:00
@@ -115,7 +115,7 @@
 
 int ha_myisammrg::write_row(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_write_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_write_count);
 
   if (file->merge_insert_method == MERGE_INSERT_DISABLED || !file->tables)
     return (HA_ERR_TABLE_READONLY);
@@ -133,7 +133,7 @@
 
 int ha_myisammrg::update_row(const byte * old_data, byte * new_data)
 {
-  statistic_increment(table->in_use->status_var.ha_update_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
     table->timestamp_field->set_time();
   return myrg_update(file,old_data,new_data);
@@ -141,15 +141,14 @@
 
 int ha_myisammrg::delete_row(const byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_delete_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_delete_count);
   return myrg_delete(file,buf);
 }
 
 int ha_myisammrg::index_read(byte * buf, const byte * key,
 			  uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -158,8 +157,7 @@
 int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
 				 uint key_len, enum ha_rkey_function find_flag)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error=myrg_rkey(file,buf,index, key, key_len, find_flag);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -167,8 +165,7 @@
 
 int ha_myisammrg::index_read_last(byte * buf, const byte * key, uint key_len)
 {
-  statistic_increment(table->in_use->status_var.ha_read_key_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   int error=myrg_rkey(file,buf,active_index, key, key_len,
 		      HA_READ_PREFIX_LAST);
   table->status=error ? STATUS_NOT_FOUND: 0;
@@ -177,8 +174,7 @@
 
 int ha_myisammrg::index_next(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_next_count);
   int error=myrg_rnext(file,buf,active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -186,8 +182,7 @@
 
 int ha_myisammrg::index_prev(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_prev_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_prev_count);
   int error=myrg_rprev(file,buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -195,8 +190,7 @@
 
 int ha_myisammrg::index_first(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_first_count);
   int error=myrg_rfirst(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -204,8 +198,7 @@
 
 int ha_myisammrg::index_last(byte * buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_last_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_last_count);
   int error=myrg_rlast(file, buf, active_index);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -215,8 +208,7 @@
                                   const byte *key __attribute__((unused)),
                                   uint length __attribute__((unused)))
 {
-  statistic_increment(table->in_use->status_var.ha_read_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_next_count);
   int error=myrg_rnext_same(file,buf);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -231,8 +223,7 @@
 
 int ha_myisammrg::rnd_next(byte *buf)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
   int error=myrg_rrnd(file, buf, HA_OFFSET_ERROR);
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;
@@ -241,8 +232,7 @@
 
 int ha_myisammrg::rnd_pos(byte * buf, byte *pos)
 {
-  statistic_increment(table->in_use->status_var.ha_read_rnd_count,
-		      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_count);
   int error=myrg_rrnd(file, buf, my_get_ptr(pos,ref_length));
   table->status=error ? STATUS_NOT_FOUND: 0;
   return error;

--- 1.287/sql/handler.cc	2006-12-21 16:54:34 -08:00
+++ 1.288/sql/handler.cc	2006-12-21 16:54:34 -08:00
@@ -1564,8 +1564,7 @@
   register int error;
   DBUG_ENTER("handler::read_first_row");
 
-  statistic_increment(table->in_use->status_var.ha_read_first_count,
-                      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_first_count);
 
   /*
     If there is very few deleted rows in the table, find the first row by

--- 1.464/sql/mysql_priv.h	2006-12-21 16:54:34 -08:00
+++ 1.465/sql/mysql_priv.h	2006-12-21 16:54:34 -08:00
@@ -1070,6 +1070,7 @@
 void remove_status_vars(SHOW_VAR *list);
 void init_status_vars();
 void free_status_vars();
+void reset_status_vars();
 
 /* information schema */
 extern LEX_STRING information_schema_name;
@@ -1632,7 +1633,6 @@
 extern MY_BITMAP temp_pool;
 extern String my_empty_string;
 extern const String my_null_string;
-extern SHOW_VAR init_vars[], status_vars[], internal_vars[];
 extern struct system_variables global_system_variables;
 extern struct system_variables max_system_variables;
 extern struct system_status_var global_status_var;
@@ -1651,11 +1651,6 @@
 extern TYPELIB log_output_typelib;
 
 /* optional things, have_* variables */
-
-extern SHOW_COMP_OPTION have_innodb;
-extern SHOW_COMP_OPTION have_csv_db;
-extern SHOW_COMP_OPTION have_ndbcluster;
-extern SHOW_COMP_OPTION have_partition_db;
 
 extern handlerton *partition_hton;
 extern handlerton *myisam_hton;

--- 1.599/sql/mysqld.cc	2006-12-21 16:54:34 -08:00
+++ 1.600/sql/mysqld.cc	2006-12-21 16:54:34 -08:00
@@ -32,22 +32,13 @@
 #include "rpl_injector.h"
 #endif
 
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-#define OPT_INNODB_DEFAULT 1
-#else
-#define OPT_INNODB_DEFAULT 0
-#endif
-#define OPT_BDB_DEFAULT 0
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
-#define OPT_NDBCLUSTER_DEFAULT 0
 #if defined(NOT_ENOUGH_TESTED) \
   && defined(NDB_SHM_TRANSPORTER) && MYSQL_VERSION_ID >= 50000
 #define OPT_NDB_SHM_DEFAULT 1
 #else
 #define OPT_NDB_SHM_DEFAULT 0
 #endif
-#else
-#define OPT_NDBCLUSTER_DEFAULT 0
 #endif
 
 #include <thr_alarm.h>
@@ -316,7 +307,6 @@
 static bool volatile select_thread_in_use, signal_thread_in_use;
 static bool volatile ready_to_exit;
 static my_bool opt_debugging= 0, opt_external_locking= 0, opt_console= 0;
-static my_bool opt_ndbcluster;
 static my_bool opt_short_log_format= 0;
 static uint kill_cached_threads, wake_thread;
 static ulong killed_threads, thread_created;
@@ -359,51 +349,14 @@
 my_bool opt_safe_user_create = 0, opt_no_mix_types = 0;
 my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0;
 my_bool opt_log_slave_updates= 0;
-my_bool	opt_innodb;
 
 /*
   Legacy global handlerton. These will be removed (please do not add more).
 */
-handlerton *heap_hton;
-handlerton *myisam_hton;
-handlerton *partition_hton;
-
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-extern ulong innobase_fast_shutdown;
-extern ulong innobase_large_page_size;
-extern char *innobase_home, *innobase_tmpdir, *innobase_logdir;
-extern long innobase_lock_scan_time;
-extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
-extern longlong innobase_log_file_size;
-extern long innobase_log_buffer_size;
-extern longlong innobase_buffer_pool_size;
-extern long innobase_additional_mem_pool_size;
-extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-extern long innobase_force_recovery;
-extern long innobase_open_files;
-extern char *innobase_data_home_dir, *innobase_data_file_path;
-extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
-extern char *innobase_unix_file_flush_method;
-/* The following variables have to be my_bool for SHOW VARIABLES to work */
-extern my_bool innobase_log_archive,
-               innobase_use_doublewrite,
-               innobase_use_checksums,
-               innobase_use_large_pages,
-               innobase_use_native_aio,
-               innobase_file_per_table, innobase_locks_unsafe_for_binlog,
-               innobase_create_status_file;
-extern "C" {
-extern ulong srv_max_buf_pool_modified_pct;
-extern ulong srv_max_purge_lag;
-extern ulong srv_auto_extend_increment;
-extern ulong srv_n_spin_wait_rounds;
-extern ulong srv_n_free_tickets_to_enter;
-extern ulong srv_thread_sleep_delay;
-extern ulong srv_thread_concurrency;
-extern ulong srv_commit_concurrency;
-extern ulong srv_flush_log_at_trx_commit;
-}
-#endif
+handlerton *heap_hton= NULL;
+handlerton *myisam_hton= NULL;
+handlerton *partition_hton= NULL;
+
 
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
 const char *opt_ndbcluster_connectstring= 0;
@@ -702,10 +655,13 @@
 
 /* Function declarations */
 
+static void usage(void);
+static int setup_status_vars(void);
 static void start_signal_handler(void);
 pthread_handler_t signal_hand(void *arg);
 static void mysql_init_variables(void);
 static void get_options(int argc,char **argv);
+static my_bool get_one_option(int, const struct my_option *, char *);
 static void set_server_version(void);
 static int init_thread_environment();
 static char *get_relative_path(const char *path);
@@ -1143,6 +1099,8 @@
 extern "C" void unireg_abort(int exit_code)
 {
   DBUG_ENTER("unireg_abort");
+  if (opt_help)
+    usage();
   if (exit_code)
     sql_print_error("Aborting\n");
   clean_up(exit_code || !opt_bootstrap); /* purecov: inspected */
@@ -2654,7 +2612,7 @@
     Later, in plugin_init, and mysql_install_plugin
     new entries could be added to that list.
   */
-  if (add_status_vars(status_vars))
+  if (setup_status_vars())
     return 1; // an error was already reported
 
   load_defaults(conf_file_name, groups, &argc, &argv);
@@ -2671,10 +2629,6 @@
   {
       my_use_large_pages= 1;
       my_large_page_size= opt_large_page_size;
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-      innobase_use_large_pages= 1;
-      innobase_large_page_size= opt_large_page_size;
-#endif
   }
 #endif /* HAVE_LARGE_PAGES */
 
@@ -2737,7 +2691,12 @@
   if (item_create_init())
     return 1;
   item_init();
-  set_var_init();
+  if (set_var_init())
+    return 1;
+#ifdef HAVE_REPLICATION
+  if (init_replication_sys_vars())
+    return 1;
+#endif
   mysys_uses_curses=0;
 #ifdef USE_REGEX
   my_regex_init(&my_charset_latin1);
@@ -3225,10 +3184,22 @@
     using_update_log=1;
   }
 
-  if (plugin_init(opt_bootstrap))
+  if (plugin_init(defaults_argv, 
+                  (opt_noacl ? PLUGIN_INIT_SKIP_PLUGIN_TABLE : 0) |
+                  (opt_help ? PLUGIN_INIT_SKIP_INITIALIZATION : 0)))
   {
     sql_print_error("Failed to init plugins.");
-    return 1;
+    unireg_abort(1);
+  }
+
+  if (opt_help)
+    unireg_abort(0);
+
+  /* we do want to exit if there are any other unknown options */
+  if (defaults_argv && defaults_argv[1]) /* position 0 is the program name */
+  {
+    fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a
list of available options\n", my_progname, defaults_argv[1]);
+    unireg_abort(1);
   }
 
   /* We have to initialize the storage engines before CSV logging */
@@ -3259,7 +3230,8 @@
   else
   {
     /* fall back to the log files if tables are not present */
-    if (have_csv_db == SHOW_OPTION_NO)
+    LEX_STRING csv_name={C_STRING_WITH_LEN("csv")};
+    if (!plugin_is_ready(&csv_name, MYSQL_STORAGE_ENGINE_PLUGIN))
     {
       /* purecov: begin inspected */
       sql_print_error("CSV engine is not present, falling back to the "
@@ -4689,11 +4661,6 @@
   OPT_STORAGE_ENGINE,          OPT_INIT_FILE,
   OPT_DELAY_KEY_WRITE_ALL,     OPT_SLOW_QUERY_LOG,
   OPT_DELAY_KEY_WRITE,	       OPT_CHARSETS_DIR,
-  OPT_BDB_HOME,                OPT_BDB_LOG,
-  OPT_BDB_TMP,                 OPT_BDB_SYNC,
-  OPT_BDB_LOCK,                OPT_BDB,
-  OPT_BDB_NO_RECOVER,          OPT_BDB_SHARED,
-  OPT_BDB_DATA_DIRECT,         OPT_BDB_LOG_DIRECT,
   OPT_MASTER_HOST,             OPT_MASTER_USER,
   OPT_MASTER_PASSWORD,         OPT_MASTER_PORT,
   OPT_MASTER_INFO_FILE,        OPT_MASTER_CONNECT_RETRY,
@@ -4714,29 +4681,15 @@
   OPT_WANT_CORE,               OPT_CONCURRENT_INSERT,
   OPT_MEMLOCK,                 OPT_MYISAM_RECOVER,
   OPT_REPLICATE_REWRITE_DB,    OPT_SERVER_ID,
-  OPT_SKIP_SLAVE_START,        OPT_SKIP_INNOBASE,
+  OPT_SKIP_SLAVE_START,        OPT_SAFE_SHOW_DB, 
   OPT_SAFEMALLOC_MEM_LIMIT,    OPT_REPLICATE_DO_TABLE,
   OPT_REPLICATE_IGNORE_TABLE,  OPT_REPLICATE_WILD_DO_TABLE,
   OPT_REPLICATE_WILD_IGNORE_TABLE, OPT_REPLICATE_SAME_SERVER_ID,
   OPT_DISCONNECT_SLAVE_EVENT_COUNT, OPT_TC_HEURISTIC_RECOVER,
   OPT_ABORT_SLAVE_EVENT_COUNT,
-  OPT_INNODB_DATA_HOME_DIR,
-  OPT_INNODB_DATA_FILE_PATH,
-  OPT_INNODB_LOG_GROUP_HOME_DIR,
-  OPT_INNODB_LOG_ARCH_DIR,
-  OPT_INNODB_LOG_ARCHIVE,
-  OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT,
-  OPT_INNODB_FLUSH_METHOD,
-  OPT_INNODB_DOUBLEWRITE,
-  OPT_INNODB_CHECKSUMS,
-  OPT_INNODB_FAST_SHUTDOWN,
-  OPT_INNODB_FILE_PER_TABLE, OPT_CRASH_BINLOG_INNODB,
-  OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG,
   OPT_LOG_BIN_TRUST_FUNCTION_CREATORS,
-  OPT_SAFE_SHOW_DB, OPT_INNODB_SAFE_BINLOG,
-  OPT_INNODB, OPT_ISAM,
   OPT_ENGINE_CONDITION_PUSHDOWN,
-  OPT_NDBCLUSTER, OPT_NDB_CONNECTSTRING, OPT_NDB_USE_EXACT_COUNT,
+  OPT_NDB_CONNECTSTRING, OPT_NDB_USE_EXACT_COUNT,
   OPT_NDB_FORCE_SEND, OPT_NDB_AUTOINCREMENT_PREFETCH_SZ,
   OPT_NDB_SHM, OPT_NDB_OPTIMIZED_NODE_SELECTION, OPT_NDB_CACHE_CHECK_TIME,
   OPT_NDB_MGMD, OPT_NDB_NODEID,
@@ -4798,33 +4751,6 @@
   OPT_THREAD_CONCURRENCY, OPT_THREAD_CACHE_SIZE,
   OPT_TMP_TABLE_SIZE, OPT_THREAD_STACK,
   OPT_WAIT_TIMEOUT, OPT_MYISAM_REPAIR_THREADS,
-  OPT_INNODB_MIRRORED_LOG_GROUPS,
-  OPT_INNODB_LOG_FILES_IN_GROUP,
-  OPT_INNODB_LOG_FILE_SIZE,
-  OPT_INNODB_LOG_BUFFER_SIZE,
-  OPT_INNODB_BUFFER_POOL_SIZE,
-  OPT_INNODB_BUFFER_POOL_AWE_MEM_MB,
-  OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
-  OPT_INNODB_MAX_PURGE_LAG,
-  OPT_INNODB_FILE_IO_THREADS,
-  OPT_INNODB_LOCK_WAIT_TIMEOUT,
-  OPT_INNODB_THREAD_CONCURRENCY,
-  OPT_INNODB_COMMIT_CONCURRENCY,
-  OPT_INNODB_FORCE_RECOVERY,
-  OPT_INNODB_STATUS_FILE,
-  OPT_INNODB_MAX_DIRTY_PAGES_PCT,
-  OPT_INNODB_TABLE_LOCKS,
-  OPT_INNODB_SUPPORT_XA,
-  OPT_INNODB_OPEN_FILES,
-  OPT_INNODB_AUTOEXTEND_INCREMENT,
-  OPT_INNODB_SYNC_SPIN_LOOPS,
-  OPT_INNODB_CONCURRENCY_TICKETS,
-  OPT_INNODB_THREAD_SLEEP_DELAY,
-  OPT_BDB_CACHE_SIZE,
-  OPT_BDB_CACHE_PARTS,
-  OPT_BDB_LOG_BUFFER_SIZE,
-  OPT_BDB_MAX_LOCK,
-  OPT_BDB_REGION_SIZE,
   OPT_ERROR_LOG_FILE,
   OPT_DEFAULT_WEEK_FORMAT,
   OPT_RANGE_ALLOC_BLOCK_SIZE, OPT_ALLOW_SUSPICIOUS_UDFS,
@@ -4834,7 +4760,6 @@
   OPT_SYNC_REPLICATION,
   OPT_SYNC_REPLICATION_SLAVE_ID,
   OPT_SYNC_REPLICATION_TIMEOUT,
-  OPT_BDB_NOSYNC,
   OPT_ENABLE_SHARED_MEMORY,
   OPT_SHARED_MEMORY_BASE_NAME,
   OPT_OLD_PASSWORDS,
@@ -4864,12 +4789,12 @@
   OPT_OLD_STYLE_USER_LIMITS,
   OPT_LOG_SLOW_ADMIN_STATEMENTS,
   OPT_TABLE_LOCK_WAIT_TIMEOUT,
+  OPT_PLUGIN_LOAD,
   OPT_PLUGIN_DIR,
   OPT_LOG_OUTPUT,
   OPT_PORT_OPEN_TIMEOUT,
   OPT_GENERAL_LOG,
   OPT_SLOW_LOG,
-  OPT_MERGE
 };
 
 
@@ -5093,90 +5018,6 @@
   {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to
this master",
    (gptr*) &opt_init_slave, (gptr*) &opt_init_slave, 0, GET_STR_ALLOC,
    REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"innodb", OPT_INNODB, "Enable InnoDB (if this version of MySQL supports it). \
-Disable with --skip-innodb (will save memory).",
-   (gptr*) &opt_innodb, (gptr*) &opt_innodb, 0, GET_BOOL, NO_ARG,
OPT_INNODB_DEFAULT, 0, 0,
-   0, 0, 0},
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-  {"innodb_checksums", OPT_INNODB_CHECKSUMS, "Enable InnoDB checksums validation (enabled
by default). \
-Disable with --skip-innodb-checksums.", (gptr*) &innobase_use_checksums,
-   (gptr*) &innobase_use_checksums, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
-#endif
-  {"innodb_data_file_path", OPT_INNODB_DATA_FILE_PATH,
-   "Path to individual files and their sizes.",
-   0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-  {"innodb_data_home_dir", OPT_INNODB_DATA_HOME_DIR,
-   "The common part for InnoDB table spaces.", (gptr*) &innobase_data_home_dir,
-   (gptr*) &innobase_data_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0,
-   0},
-  {"innodb_doublewrite", OPT_INNODB_DOUBLEWRITE, "Enable InnoDB doublewrite buffer
(enabled by default). \
-Disable with --skip-innodb-doublewrite.", (gptr*) &innobase_use_doublewrite,
-   (gptr*) &innobase_use_doublewrite, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0},
-  {"innodb_fast_shutdown", OPT_INNODB_FAST_SHUTDOWN,
-   "Speeds up the shutdown process of the InnoDB storage engine. Possible "
-   "values are 0, 1 (faster)"
-   /*
-     NetWare can't close unclosed files, can't automatically kill remaining
-     threads, etc, so on this OS we disable the crash-like InnoDB shutdown.
-   */
-#ifndef __NETWARE__
-   " or 2 (fastest - crash-like)"
-#endif
-   ".",
-   (gptr*) &innobase_fast_shutdown,
-   (gptr*) &innobase_fast_shutdown, 0, GET_ULONG, OPT_ARG, 1, 0,
-   IF_NETWARE(1,2), 0, 0, 0},
-  {"innodb_file_per_table", OPT_INNODB_FILE_PER_TABLE,
-   "Stores each InnoDB table to an .ibd file in the database dir.",
-   (gptr*) &innobase_file_per_table,
-   (gptr*) &innobase_file_per_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"innodb_flush_log_at_trx_commit", OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT,
-   "Set to 0 (write and flush once per second), 1 (write and flush at each commit) or 2
(write at commit, flush once per second).",
-   (gptr*) &srv_flush_log_at_trx_commit,
-   (gptr*) &srv_flush_log_at_trx_commit,
-   0, GET_ULONG, OPT_ARG,  1, 0, 2, 0, 0, 0},
-  {"innodb_flush_method", OPT_INNODB_FLUSH_METHOD,
-   "With which method to flush data.", (gptr*) &innobase_unix_file_flush_method,
-   (gptr*) &innobase_unix_file_flush_method, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
-   0, 0, 0},
-  {"innodb_locks_unsafe_for_binlog", OPT_INNODB_LOCKS_UNSAFE_FOR_BINLOG,
-   "Force InnoDB to not use next-key locking, to use only row-level locking.",
-   (gptr*) &innobase_locks_unsafe_for_binlog,
-   (gptr*) &innobase_locks_unsafe_for_binlog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"innodb_log_arch_dir", OPT_INNODB_LOG_ARCH_DIR,
-   "Where full logs should be archived.", (gptr*) &innobase_log_arch_dir,
-   (gptr*) &innobase_log_arch_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"innodb_log_archive", OPT_INNODB_LOG_ARCHIVE,
-   "Set to 1 if you want to have logs archived.", 0, 0, 0, GET_LONG, OPT_ARG,
-   0, 0, 0, 0, 0, 0},
-  {"innodb_log_group_home_dir", OPT_INNODB_LOG_GROUP_HOME_DIR,
-   "Path to InnoDB log files.", (gptr*) &innobase_log_group_home_dir,
-   (gptr*) &innobase_log_group_home_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0,
-   0, 0},
-  {"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT,
-   "Percentage of dirty pages allowed in bufferpool.", (gptr*)
&srv_max_buf_pool_modified_pct,
-   (gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0,
0, 0},
-  {"innodb_max_purge_lag", OPT_INNODB_MAX_PURGE_LAG,
-   "Desired maximum length of the purge queue (0 = no limit)",
-   (gptr*) &srv_max_purge_lag,
-   (gptr*) &srv_max_purge_lag, 0, GET_LONG, REQUIRED_ARG, 0, 0, ~0L,
-   0, 1L, 0},
-  {"innodb_status_file", OPT_INNODB_STATUS_FILE,
-   "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
-   (gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file,
-   0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
-  {"innodb_support_xa", OPT_INNODB_SUPPORT_XA,
-   "Enable InnoDB support for the XA two-phase commit",
-   (gptr*) &global_system_variables.innodb_support_xa,
-   (gptr*) &global_system_variables.innodb_support_xa,
-   0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-  {"innodb_table_locks", OPT_INNODB_TABLE_LOCKS,
-   "Enable InnoDB locking in LOCK TABLES",
-   (gptr*) &global_system_variables.innodb_table_locks,
-   (gptr*) &global_system_variables.innodb_table_locks,
-   0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
-#endif /* End WITH_INNOBASE_STORAGE_ENGINE */
    {"language", 'L',
    "Client error messages in given language. May be given as a full path.",
    (gptr*) &language_ptr, (gptr*) &language_ptr, 0, GET_STR, REQUIRED_ARG,
@@ -5352,10 +5193,6 @@
    "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP,
FORCE or QUICK.",
    (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0,
    GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
-  {"ndbcluster", OPT_NDBCLUSTER, "Enable NDB Cluster (if this version of MySQL supports
it). \
-Disable with --skip-ndbcluster (will save memory).",
-   (gptr*) &opt_ndbcluster, (gptr*) &opt_ndbcluster, 0, GET_BOOL, NO_ARG,
-   OPT_NDBCLUSTER_DEFAULT, 0, 0, 0, 0, 0},
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
   {"ndb-connectstring", OPT_NDB_CONNECTSTRING,
    "Connect string for ndbcluster.",
@@ -5795,84 +5632,6 @@
     (gptr*) &global_system_variables.group_concat_max_len,
     (gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG,
     REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0},
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-  {"innodb_additional_mem_pool_size", OPT_INNODB_ADDITIONAL_MEM_POOL_SIZE,
-   "Size of a memory pool InnoDB uses to store data dictionary information and other
internal data structures.",
-   (gptr*) &innobase_additional_mem_pool_size,
-   (gptr*) &innobase_additional_mem_pool_size, 0, GET_LONG, REQUIRED_ARG,
-   1*1024*1024L, 512*1024L, ~0L, 0, 1024, 0},
-  {"innodb_autoextend_increment", OPT_INNODB_AUTOEXTEND_INCREMENT,
-   "Data file autoextend increment in megabytes",
-   (gptr*) &srv_auto_extend_increment,
-   (gptr*) &srv_auto_extend_increment,
-   0, GET_LONG, REQUIRED_ARG, 8L, 1L, 1000L, 0, 1L, 0},
-  {"innodb_buffer_pool_size", OPT_INNODB_BUFFER_POOL_SIZE,
-   "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
-   (gptr*) &innobase_buffer_pool_size, (gptr*) &innobase_buffer_pool_size, 0,
-   GET_LL, REQUIRED_ARG, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 0,
-   1024*1024L, 0},
-  {"innodb_commit_concurrency", OPT_INNODB_COMMIT_CONCURRENCY,
-   "Helps in performance tuning in heavily concurrent environments.",
-   (gptr*) &srv_commit_concurrency, (gptr*) &srv_commit_concurrency,
-   0, GET_LONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0},
-  {"innodb_concurrency_tickets", OPT_INNODB_CONCURRENCY_TICKETS,
-   "Number of times a thread is allowed to enter InnoDB within the same \
-    SQL query after it has once got the ticket",
-   (gptr*) &srv_n_free_tickets_to_enter,
-   (gptr*) &srv_n_free_tickets_to_enter,
-   0, GET_LONG, REQUIRED_ARG, 500L, 1L, ~0L, 0, 1L, 0},
-  {"innodb_file_io_threads", OPT_INNODB_FILE_IO_THREADS,
-   "Number of file I/O threads in InnoDB.", (gptr*) &innobase_file_io_threads,
-   (gptr*) &innobase_file_io_threads, 0, GET_LONG, REQUIRED_ARG, 4, 4, 64, 0,
-   1, 0},
-  {"innodb_force_recovery", OPT_INNODB_FORCE_RECOVERY,
-   "Helps to save your data in case the disk image of the database becomes corrupt.",
-   (gptr*) &innobase_force_recovery, (gptr*) &innobase_force_recovery, 0,
-   GET_LONG, REQUIRED_ARG, 0, 0, 6, 0, 1, 0},
-  {"innodb_lock_wait_timeout", OPT_INNODB_LOCK_WAIT_TIMEOUT,
-   "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled
back.",
-   (gptr*) &innobase_lock_wait_timeout, (gptr*) &innobase_lock_wait_timeout,
-   0, GET_LONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0},
-  {"innodb_log_buffer_size", OPT_INNODB_LOG_BUFFER_SIZE,
-   "The size of the buffer which InnoDB uses to write log to the log files on disk.",
-   (gptr*) &innobase_log_buffer_size, (gptr*) &innobase_log_buffer_size, 0,
-   GET_LONG, REQUIRED_ARG, 1024*1024L, 256*1024L, ~0L, 0, 1024, 0},
-  {"innodb_log_file_size", OPT_INNODB_LOG_FILE_SIZE,
-   "Size of each log file in a log group.",
-   (gptr*) &innobase_log_file_size, (gptr*) &innobase_log_file_size, 0,
-   GET_LL, REQUIRED_ARG, 5*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 0,
-   1024*1024L, 0},
-  {"innodb_log_files_in_group", OPT_INNODB_LOG_FILES_IN_GROUP,
-   "Number of log files in the log group. InnoDB writes to the files in a circular
fashion. Value 3 is recommended here.",
-   (gptr*) &innobase_log_files_in_group, (gptr*) &innobase_log_files_in_group,
-   0, GET_LONG, REQUIRED_ARG, 2, 2, 100, 0, 1, 0},
-  {"innodb_mirrored_log_groups", OPT_INNODB_MIRRORED_LOG_GROUPS,
-   "Number of identical copies of log groups we keep for the database. Currently this
should be set to 1.",
-   (gptr*) &innobase_mirrored_log_groups,
-   (gptr*) &innobase_mirrored_log_groups, 0, GET_LONG, REQUIRED_ARG, 1, 1, 10,
-   0, 1, 0},
-  {"innodb_open_files", OPT_INNODB_OPEN_FILES,
-   "How many files at the maximum InnoDB keeps open at the same time.",
-   (gptr*) &innobase_open_files, (gptr*) &innobase_open_files, 0,
-   GET_LONG, REQUIRED_ARG, 300L, 10L, ~0L, 0, 1L, 0},
-  {"innodb_sync_spin_loops", OPT_INNODB_SYNC_SPIN_LOOPS,
-   "Count of spin-loop rounds in InnoDB mutexes",
-   (gptr*) &srv_n_spin_wait_rounds,
-   (gptr*) &srv_n_spin_wait_rounds,
-   0, GET_LONG, REQUIRED_ARG, 20L, 0L, ~0L, 0, 1L, 0},
-  {"innodb_thread_concurrency", OPT_INNODB_THREAD_CONCURRENCY,
-   "Helps in performance tuning in heavily concurrent environments. "
-   "Sets the maximum number of threads allowed inside InnoDB. Value 0"
-   " will disable the thread throttling.",
-   (gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency,
-   0, GET_LONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
-  {"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY,
-   "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0"
-    " disable a sleep",
-   (gptr*) &srv_thread_sleep_delay,
-   (gptr*) &srv_thread_sleep_delay,
-   0, GET_LONG, REQUIRED_ARG, 10000L, 0L, ~0L, 0, 1L, 0},
-#endif /* WITH_INNOBASE_STORAGE_ENGINE */
   {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT,
    "The number of seconds the server waits for activity on an interactive connection
before closing it.",
    (gptr*) &global_system_variables.net_interactive_timeout,
@@ -6098,6 +5857,11 @@
    "Directory for plugins.",
    (gptr*) &opt_plugin_dir_ptr, (gptr*) &opt_plugin_dir_ptr, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
+  {"plugin_load", OPT_PLUGIN_LOAD,
+   "Optional colon seperated list of plugins to load, where each plugin is "
+   "identified by name and path to library seperated by an equals.",
+   (gptr*) &opt_plugin_load, (gptr*) &opt_plugin_load, 0,
+   GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
    {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE,
     "The size of the buffer that is allocated when preloading indexes",
     (gptr*) &global_system_variables.preload_buff_size,
@@ -6613,7 +6377,7 @@
   Variables shown by SHOW STATUS in alphabetical order
 */
 
-SHOW_VAR status_vars[]= {
+static SHOW_VAR status_vars[]= {
   {"Aborted_clients",          (char*) &aborted_threads,        SHOW_LONG},
   {"Aborted_connects",         (char*) &aborted_connects,       SHOW_LONG},
   {"Binlog_cache_disk_use",    (char*) &binlog_cache_disk_use,  SHOW_LONG},
@@ -6887,8 +6651,8 @@
   fix_paths();
   set_ports();
 
-  my_print_help(my_long_options);
-  my_print_variables(my_long_options);
+  /* Print out all the options including plugin supplied options */
+  my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));
 
   puts("\n\
 To see what values a running MySQL server is using, type\n\
@@ -7038,41 +6802,18 @@
 			     "d:t:i:o,/tmp/mysqld.trace");
 #endif
   opt_error_log= IF_WIN(1,0);
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-  have_innodb= SHOW_OPTION_YES;
-#else
-  have_innodb= SHOW_OPTION_NO;
-#endif
-#ifdef WITH_CSV_STORAGE_ENGINE
-  have_csv_db= SHOW_OPTION_YES;
-#else
-  have_csv_db= SHOW_OPTION_NO;
-#endif
-#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
-    have_ndbcluster= SHOW_OPTION_DISABLED;
-#else
-    have_ndbcluster= SHOW_OPTION_NO;
-#endif
-#ifdef WITH_PARTITION_STORAGE_ENGINE
-    have_partition_db= SHOW_OPTION_YES;
-#else
-    have_partition_db= SHOW_OPTION_NO;
-#endif
 #ifdef HAVE_ROW_BASED_REPLICATION
   have_row_based_replication= SHOW_OPTION_YES;
 #else
   have_row_based_replication= SHOW_OPTION_NO;
 #endif
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
-  have_ndbcluster=SHOW_OPTION_DISABLED;
   global_system_variables.ndb_index_stat_enable=FALSE;
   max_system_variables.ndb_index_stat_enable=TRUE;
   global_system_variables.ndb_index_stat_cache_entries=32;
   max_system_variables.ndb_index_stat_cache_entries=~0L;
   global_system_variables.ndb_index_stat_update_freq=20;
   max_system_variables.ndb_index_stat_update_freq=~0L;
-#else
-  have_ndbcluster=SHOW_OPTION_NO;
 #endif
 #ifdef HAVE_OPENSSL
   have_openssl=SHOW_OPTION_YES;
@@ -7544,17 +7285,6 @@
     global_system_variables.tx_isolation= (type-1);
     break;
   }
-  case OPT_MERGE:
-  case OPT_BDB:
-    break;
-  case OPT_NDBCLUSTER:
-#ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
-    if (opt_ndbcluster)
-      have_ndbcluster= SHOW_OPTION_YES;
-    else
-      have_ndbcluster= SHOW_OPTION_DISABLED;
-#endif
-    break;
 #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE
   case OPT_NDB_MGMD:
   case OPT_NDB_NODEID:
@@ -7602,24 +7332,6 @@
       ndb_extra_logging= atoi(argument);
     break;
 #endif
-  case OPT_INNODB:
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-    if (opt_innodb)
-      have_innodb= SHOW_OPTION_YES;
-    else
-      have_innodb= SHOW_OPTION_DISABLED;
-#endif
-    break;
-  case OPT_INNODB_DATA_FILE_PATH:
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-    innobase_data_file_path= argument;
-#endif
-    break;
-#ifdef WITH_INNOBASE_STORAGE_ENGINE
-  case OPT_INNODB_LOG_ARCHIVE:
-    innobase_log_archive= argument ? test(atoi(argument)) : 1;
-    break;
-#endif /* WITH_INNOBASE_STORAGE_ENGINE */
   case OPT_MYISAM_RECOVER:
   {
     if (!argument || !argument[0])
@@ -7764,34 +7476,18 @@
   strmake(def_ft_boolean_syntax, ft_boolean_syntax,
 	  sizeof(ft_boolean_syntax)-1);
   my_getopt_error_reporter= option_error_reporter;
+
+  /* Skip unknown options so that they may be processed later by plugins */
+  my_getopt_skip_unknown= TRUE;
+
   if ((ho_error= handle_options(&argc, &argv, my_long_options,
                                 get_one_option)))
     exit(ho_error);
 
-#ifndef WITH_NDBCLUSTER_STORAGE_ENGINE
-  if (opt_ndbcluster)
-    sql_print_warning("this binary does not contain NDBCLUSTER storage engine");
-#endif
-#ifndef WITH_INNOBASE_STORAGE_ENGINE
-  if (opt_innodb)
-    sql_print_warning("this binary does not contain INNODB storage engine");
-#endif
   if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes) &&
       !opt_slow_log)
     sql_print_warning("options --log-slow-admin-statements and
--log-queries-not-using-indexes have no effect if --log-slow-queries is not set");
 
-  if (argc > 0)
-  {
-    fprintf(stderr, "%s: Too many arguments (first extra is '%s').\nUse --help to get a
list of available options\n", my_progname, *argv);
-    /* FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code? */
-    exit(1);
-  }
-
-  if (opt_help)
-  {
-    usage();
-    exit(0);
-  }
 #if defined(HAVE_BROKEN_REALPATH)
   my_use_symdir=0;
   my_disable_symlinks=1;
@@ -8084,6 +7780,15 @@
 }
 
 
+static int setup_status_vars(void)
+{
+  /*
+    eventually, this will have more, where specific status vars are moved
+    to relevent source files.
+  */
+  return add_status_vars(status_vars);
+}
+
 /* Clear most status variables */
 void refresh_status(THD *thd)
 {
@@ -8096,12 +7801,7 @@
   bzero((char*) &thd->status_var, sizeof(thd->status_var));
 
   /* Reset some global variables */
-  for (SHOW_VAR *ptr= status_vars; ptr->name; ptr++)
-  {
-    /* Note that SHOW_LONG_NOFLUSH variables are not reset */
-    if (ptr->type == SHOW_LONG)
-      *(ulong*) ptr->value= 0;
-  }
+  reset_status_vars();
 
   /* Reset the counters of all key caches (default and named). */
   process_key_caches(reset_key_cache_counters);
@@ -8120,49 +7820,8 @@
 
 
 /*****************************************************************************
-  Instantiate have_xyx for missing storage engines
+  Instantiate variables for missing storage engines
 *****************************************************************************/
-#undef have_innodb
-#undef have_ndbcluster
-#undef have_csv_db
-
-SHOW_COMP_OPTION have_innodb= SHOW_OPTION_NO;
-SHOW_COMP_OPTION have_ndbcluster= SHOW_OPTION_NO;
-SHOW_COMP_OPTION have_csv_db= SHOW_OPTION_NO;
-SHOW_COMP_OPTION have_partition_db= SHOW_OPTION_NO;
-
-#ifndef WITH_INNOBASE_STORAGE_ENGINE
-uint innobase_flush_log_at_trx_commit;
-ulong innobase_fast_shutdown;
-long innobase_mirrored_log_groups, innobase_log_files_in_group;
-longlong innobase_log_file_size;
-long innobase_log_buffer_size;
-longlong innobase_buffer_pool_size;
-long innobase_additional_mem_pool_size;
-long innobase_file_io_threads, innobase_lock_wait_timeout;
-long innobase_force_recovery;
-long innobase_open_files;
-char *innobase_data_home_dir, *innobase_data_file_path;
-char *innobase_log_group_home_dir, *innobase_log_arch_dir;
-char *innobase_unix_file_flush_method;
-my_bool innobase_log_archive,
-        innobase_use_doublewrite,
-        innobase_use_checksums,
-        innobase_file_per_table,
-        innobase_locks_unsafe_for_binlog;
-
-extern "C" {
-ulong srv_max_buf_pool_modified_pct;
-ulong srv_max_purge_lag;
-ulong srv_auto_extend_increment;
-ulong srv_n_spin_wait_rounds;
-ulong srv_n_free_tickets_to_enter;
-ulong srv_thread_sleep_delay;
-ulong srv_thread_concurrency;
-ulong srv_commit_concurrency;
-}
-
-#endif
 
 #ifndef WITH_NDBCLUSTER_STORAGE_ENGINE
 ulong ndb_cache_check_time;

--- 1.304/sql/sql_class.cc	2006-12-21 16:54:34 -08:00
+++ 1.305/sql/sql_class.cc	2006-12-21 16:54:34 -08:00
@@ -326,6 +326,10 @@
 {
   pthread_mutex_lock(&LOCK_global_system_variables);
   variables= global_system_variables;
+  /* we are going to allocate these lazily */
+  variables.dynamic_variables_version= 0;
+  variables.dynamic_variables_size= 0;
+  variables.dynamic_variables_ptr= 0;
   variables.time_format= date_time_format_copy((THD*) 0,
 					       variables.time_format);
   variables.date_format= date_time_format_copy((THD*) 0,
@@ -475,6 +479,7 @@
     cleanup();
 
   ha_close_connection(this);
+  mysql_pluginvar_cleanup(this);
 
   DBUG_PRINT("info", ("freeing security context"));
   main_security_ctx.destroy();

--- 1.332/sql/sql_class.h	2006-12-21 16:54:34 -08:00
+++ 1.333/sql/sql_class.h	2006-12-21 16:54:34 -08:00
@@ -181,6 +181,19 @@
 
 struct system_variables
 {
+  /*
+    How dynamically allocated system variables are handled:
+    
+    The global_system_variables and max_system_variables are "authoritative"
+    They both should have the same 'version' and 'size'.
+    When attempting to access a dynamic variable, if the session version
+    is out of date, then the session version is updated and realloced if
+    neccessary and bytes copied from global to make up for missing data.
+  */ 
+  ulong dynamic_variables_version;
+  char* dynamic_variables_ptr;
+  uint dynamic_variables_size;
+  
   ulonglong myisam_max_extra_sort_file_size;
   ulonglong myisam_max_sort_file_size;
   ulonglong max_heap_table_size;
@@ -242,8 +255,6 @@
   my_bool new_mode;
   my_bool query_cache_wlock_invalidate;
   my_bool engine_condition_pushdown;
-  my_bool innodb_table_locks;
-  my_bool innodb_support_xa;
   my_bool ndb_force_send;
   my_bool ndb_use_copying_alter_table;
   my_bool ndb_use_exact_count;

--- 1.612/sql/sql_parse.cc	2006-12-21 16:54:34 -08:00
+++ 1.613/sql/sql_parse.cc	2006-12-21 16:54:34 -08:00
@@ -1905,7 +1905,6 @@
     TABLE_LIST table_list;
     LEX_STRING conv_name;
     /* Saved variable value */
-    my_bool old_innodb_table_locks=  thd->variables.innodb_table_locks;
     uint dummy;
 
     /* used as fields initializator */

--- 1.379/sql/sql_show.cc	2006-12-21 16:54:34 -08:00
+++ 1.380/sql/sql_show.cc	2006-12-21 16:54:34 -08:00
@@ -1936,6 +1936,18 @@
   sort_dynamic(&all_status_vars, show_var_cmp);
 }
 
+void reset_status_vars()
+{
+  SHOW_VAR *ptr= (SHOW_VAR*) all_status_vars.buffer;
+  SHOW_VAR *last= ptr + all_status_vars.elements;
+  for (; ptr < last; ptr++)
+  {
+    /* Note that SHOW_LONG_NOFLUSH variables are not reset */
+    if (ptr->type == SHOW_LONG)
+      *(ulong*) ptr->value= 0;
+  }  
+}
+
 /*
   catch-all cleanup function, cleans up everything no matter what
 
@@ -4416,7 +4428,7 @@
   LEX *lex= thd->lex;
   const char *wild= lex->wild ? lex->wild->ptr() : NullS;
   pthread_mutex_lock(&LOCK_global_system_variables);
-  res= show_status_array(thd, wild, init_vars,
+  res= show_status_array(thd, wild, enumerate_sys_vars(thd, TRUE),
                          lex->option_type, 0, "", tables->table, 0);
   pthread_mutex_unlock(&LOCK_global_system_variables);
   DBUG_RETURN(res);
@@ -5187,7 +5199,7 @@
   DBUG_ENTER("fill_schema_global_variables");
   
   pthread_mutex_lock(&LOCK_global_system_variables);
-  res= show_status_array(thd, "", init_vars, OPT_GLOBAL,
+  res= show_status_array(thd, "", enumerate_sys_vars(thd, FALSE), OPT_GLOBAL,
                          NULL, "", tables->table, 1);
   pthread_mutex_unlock(&LOCK_global_system_variables);
   
@@ -5200,7 +5212,7 @@
   DBUG_ENTER("fill_schema_session_variables");
   
   pthread_mutex_lock(&LOCK_global_system_variables);
-  res= show_status_array(thd, "", init_vars, OPT_SESSION,
+  res= show_status_array(thd, "", enumerate_sys_vars(thd, FALSE), OPT_SESSION,
                          NULL, "", tables->table, 1);
   pthread_mutex_unlock(&LOCK_global_system_variables);
   

--- 1.17/include/my_getopt.h	2006-12-21 16:54:34 -08:00
+++ 1.18/include/my_getopt.h	2006-12-21 16:54:34 -08:00
@@ -51,7 +51,7 @@
   longlong   max_value;                 /* Max allowed value */
   longlong   sub_size;                  /* Subtract this from given value */
   long       block_size;                /* Value should be a mult. of this */
-  int        app_type;                  /* To be used by an application */
+  long       app_type;                  /* To be used by an application */
 };
 
 typedef my_bool (* my_get_one_option) (int, const struct my_option *, char * );
@@ -59,6 +59,7 @@
 
 extern char *disabled_my_option;
 extern my_bool my_getopt_print_errors;
+extern my_bool my_getopt_skip_unknown;
 extern my_error_reporter my_getopt_error_reporter;
 
 extern int handle_options (int *argc, char ***argv, 

--- 1.59/mysys/my_getopt.c	2006-12-21 16:54:34 -08:00
+++ 1.60/mysys/my_getopt.c	2006-12-21 16:54:34 -08:00
@@ -59,6 +59,13 @@
 
 my_bool my_getopt_print_errors= 1;
 
+/* 
+   This is a flag that can be set in client programs. 1 neabs rgar
+   my_getopt will skip over options it does not know how to handle.
+*/
+
+my_bool my_getopt_skip_unknown= 0;
+
 static void default_reporter(enum loglevel level,
                              const char *format, ...)
 {
@@ -111,6 +118,7 @@
 
   for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
   {
+    char **first= pos;
     char *cur_arg= *pos;
     if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be
opt */
     {
@@ -259,6 +267,14 @@
 	  }
 	  if (!opt_found)
 	  {
+            if (my_getopt_skip_unknown)
+            {
+              /* preserve all the components of this unknown option */
+              do {
+                (*argv)[argvpos++]= *first++;
+              } while (first <= pos);
+              continue;
+            }
 	    if (must_be_var)
 	    {
 	      if (my_getopt_print_errors)

--- 1.254/mysql-test/mysql-test-run.pl	2006-12-21 16:54:34 -08:00
+++ 1.255/mysql-test/mysql-test-run.pl	2006-12-21 16:54:34 -08:00
@@ -2850,8 +2850,8 @@
   mtr_add_arg($args, "--skip-grant-tables");
   mtr_add_arg($args, "--basedir=%s", $path_my_basedir);
   mtr_add_arg($args, "--datadir=%s", $data_dir);
-  mtr_add_arg($args, "--skip-innodb");
-  mtr_add_arg($args, "--skip-ndbcluster");
+  mtr_add_arg($args, "--skip-plugin-innodb");
+  mtr_add_arg($args, "--skip-plugin-ndbcluster");
   mtr_add_arg($args, "--tmpdir=.");
   mtr_add_arg($args, "--core-file");
 
@@ -2950,8 +2950,8 @@
 basedir             = $path_my_basedir
 server_id           = $server_id
 skip-stack-trace
-skip-innodb
-skip-ndbcluster
+skip-plugin-innodb
+skip-plugin-ndbcluster
 EOF
 ;
     if ( $mysql_version_id < 50100 )
@@ -3580,18 +3580,18 @@
 
     if ( $idx > 0 or !$use_innodb)
     {
-      mtr_add_arg($args, "%s--skip-innodb", $prefix);
+      mtr_add_arg($args, "%s--skip-plugin-innodb", $prefix);
     }
 
     my $cluster= $clusters->[$master->[$idx]->{'cluster'}];
     if ( $opt_skip_ndbcluster ||
 	 !$cluster->{'pid'})
     {
-      mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
+      mtr_add_arg($args, "%s--skip-plugin-ndbcluster", $prefix);
     }
     else
     {
-      mtr_add_arg($args, "%s--ndbcluster", $prefix);
+      mtr_add_arg($args, "%s--enable-plugin-ndbcluster", $prefix);
       mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
 		  $cluster->{'connect_string'});
       if ( $mysql_version_id >= 50100 )
@@ -3638,8 +3638,8 @@
     mtr_add_arg($args, "%s--report-port=%d", $prefix,
                 $slave->[$idx]->{'port'});
     mtr_add_arg($args, "%s--report-user=root", $prefix);
-    mtr_add_arg($args, "%s--skip-innodb", $prefix);
-    mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
+    mtr_add_arg($args, "%s--skip-plugin-innodb", $prefix);
+    mtr_add_arg($args, "%s--skip-plugin-ndbcluster", $prefix);
     mtr_add_arg($args, "%s--skip-slave-start", $prefix);
 
     # Directory where slaves find the dumps generated by "load data"
@@ -3675,11 +3675,11 @@
          $slave->[$idx]->{'cluster'} == -1 ||
 	 !$clusters->[$slave->[$idx]->{'cluster'}]->{'pid'} )
     {
-      mtr_add_arg($args, "%s--skip-ndbcluster", $prefix);
+      mtr_add_arg($args, "%s--skip-plugin-ndbcluster", $prefix);
     }
     else
     {
-      mtr_add_arg($args, "%s--ndbcluster", $prefix);
+      mtr_add_arg($args, "%s--enable-plugin-ndbcluster", $prefix);
       mtr_add_arg($args, "%s--ndb-connectstring=%s", $prefix,
 		  $clusters->[$slave->[$idx]->{'cluster'}]->{'connect_string'});
       if ( $mysql_version_id >= 50100 )

--- 1.375/sql/ha_ndbcluster.cc	2006-12-21 16:54:34 -08:00
+++ 1.376/sql/ha_ndbcluster.cc	2006-12-21 16:54:34 -08:00
@@ -2633,7 +2633,7 @@
       DBUG_RETURN(peek_res);
   }
 
-  statistic_increment(thd->status_var.ha_write_count, &LOCK_status);
+  ha_statistic_increment(&SSV::ha_write_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
     table->timestamp_field->set_time();
 
@@ -2853,7 +2853,7 @@
       DBUG_RETURN(peek_res);
   }
 
-  statistic_increment(thd->status_var.ha_update_count, &LOCK_status);
+  ha_statistic_increment(&SSV::ha_update_count);
   if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
   {
     table->timestamp_field->set_time();
@@ -3020,7 +3020,7 @@
   DBUG_ENTER("delete_row");
   m_write_op= TRUE;
 
-  statistic_increment(thd->status_var.ha_delete_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_delete_count);
   m_rows_changed++;
 
   if (m_use_partition_function &&
@@ -3378,7 +3378,7 @@
                               const byte *key, uint key_len, 
                               enum ha_rkey_function find_flag)
 {
-  statistic_increment(current_thd->status_var.ha_read_key_count, &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_key_count);
   DBUG_ENTER("ha_ndbcluster::index_read_idx");
   DBUG_PRINT("enter", ("index_no: %u, key_len: %u", index_no, key_len));  
   close_scan();
@@ -3390,8 +3390,7 @@
 int ha_ndbcluster::index_next(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_next");
-  statistic_increment(current_thd->status_var.ha_read_next_count,
-                      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_next_count);
   DBUG_RETURN(next_result(buf));
 }
 
@@ -3399,8 +3398,7 @@
 int ha_ndbcluster::index_prev(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_prev");
-  statistic_increment(current_thd->status_var.ha_read_prev_count,
-                      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_prev_count);
   DBUG_RETURN(next_result(buf));
 }
 
@@ -3408,8 +3406,7 @@
 int ha_ndbcluster::index_first(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_first");
-  statistic_increment(current_thd->status_var.ha_read_first_count,
-                      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_first_count);
   // Start the ordered index scan and fetch the first row
 
   // Only HA_READ_ORDER indexes get called by index_first
@@ -3420,7 +3417,7 @@
 int ha_ndbcluster::index_last(byte *buf)
 {
   DBUG_ENTER("ha_ndbcluster::index_last");
-  statistic_increment(current_thd->status_var.ha_read_last_count,&LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_last_count);
   DBUG_RETURN(ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL));
 }
 
@@ -3603,8 +3600,7 @@
 int ha_ndbcluster::rnd_next(byte *buf)
 {
   DBUG_ENTER("rnd_next");
-  statistic_increment(current_thd->status_var.ha_read_rnd_next_count,
-                      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_next_count);
 
   if (!m_active_cursor)
     DBUG_RETURN(full_table_scan(buf));
@@ -3622,8 +3618,7 @@
 int ha_ndbcluster::rnd_pos(byte *buf, byte *pos)
 {
   DBUG_ENTER("rnd_pos");
-  statistic_increment(current_thd->status_var.ha_read_rnd_count,
-                      &LOCK_status);
+  ha_statistic_increment(&SSV::ha_read_rnd_count);
   // The primary key for the record is stored in pos
   // Perform a pk_read using primary key "index"
   {
@@ -6600,7 +6595,7 @@
 
   {
     handlerton *h= ndbcluster_hton;
-    h->state=            have_ndbcluster;
+    h->state=            SHOW_OPTION_YES;
     h->db_type=          DB_TYPE_NDBCLUSTER;
     h->close_connection= ndbcluster_close_connection;
     h->commit=           ndbcluster_commit;
@@ -6622,9 +6617,6 @@
     h->table_exists_in_engine= ndbcluster_table_exists_in_engine;
   }
 
-  if (have_ndbcluster != SHOW_OPTION_YES)
-    DBUG_RETURN(0); // nothing else to do
-
   // Initialize ndb interface
   ndb_init_internal();
 
@@ -6727,7 +6719,6 @@
   if (g_ndb_cluster_connection)
     delete g_ndb_cluster_connection;
   g_ndb_cluster_connection= NULL;
-  have_ndbcluster= SHOW_OPTION_DISABLED;	// If we couldn't use handler
   ndbcluster_hton->state= SHOW_OPTION_DISABLED;               // If we couldn't use
handler
 
   DBUG_RETURN(TRUE);
@@ -9989,10 +9980,6 @@
   uint buflen;
   DBUG_ENTER("ndbcluster_show_status");
   
-  if (have_ndbcluster != SHOW_OPTION_YES) 
-  {
-    DBUG_RETURN(FALSE);
-  }
   if (stat_type != HA_ENGINE_STATUS)
   {
     DBUG_RETURN(FALSE);

--- 1.313/storage/innobase/handler/ha_innodb.cc	2006-12-21 16:54:34 -08:00
+++ 1.314/storage/innobase/handler/ha_innodb.cc	2006-12-21 16:54:34 -08:00
@@ -217,6 +217,17 @@
 
 static const char innobase_hton_name[]= "InnoDB";
 
+
+static MYSQL_THDVAR_BOOL(support_xa, PLUGIN_VAR_OPCMDARG,
+  "Enable InnoDB support for the XA two-phase commit",
+  /* check_func */ NULL, /* update_func */ NULL,
+  /* default */ TRUE);
+
+static MYSQL_THDVAR_BOOL(table_locks, PLUGIN_VAR_OPCMDARG,
+  "Enable InnoDB locking in LOCK TABLES",
+  /* check_func */ NULL, /* update_func */ NULL,
+  /* default */ TRUE);
+
 static handler *innobase_create_handler(handlerton *hton,
                                         TABLE_SHARE *table, 
                                         MEM_ROOT *mem_root)
@@ -870,7 +881,7 @@
 
 		/* Update the info whether we should skip XA steps that eat
 		CPU time */
-		trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
+		trx->support_xa = THDVAR(thd, support_xa);
 
 		thd->ha_data[hton->slot] = trx;
 	} else {
@@ -1354,7 +1365,7 @@
         handlerton *innobase_hton= (handlerton *)p;
         legacy_innodb_hton= innobase_hton;
 
-        innobase_hton->state=have_innodb;
+        innobase_hton->state= SHOW_OPTION_YES;
         innobase_hton->db_type= DB_TYPE_INNODB;
         innobase_hton->savepoint_offset=sizeof(trx_named_savept_t);
         innobase_hton->close_connection=innobase_close_connection;
@@ -1379,8 +1390,13 @@
         innobase_hton->flags=HTON_NO_FLAGS;
         innobase_hton->release_temporary_latches=innobase_release_temporary_latches;
 
-	 if (have_innodb != SHOW_OPTION_YES)
-	   DBUG_RETURN(0); // nothing else to do
+#ifdef HAVE_LARGE_PAGES
+	if (my_use_large_pages)
+	{
+		innobase_use_large_pages= 1;
+		innobase_large_page_size= opt_large_page_size;
+	}
+#endif
 
 	ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
 
@@ -1619,7 +1635,6 @@
 
 	DBUG_RETURN(FALSE);
 error:
-	have_innodb= SHOW_OPTION_DISABLED;	// If we couldn't use handler
 	DBUG_RETURN(TRUE);
 }
 
@@ -1762,7 +1777,7 @@
 	trx = check_trx_exists(hton, thd);
 
 	/* Update the info whether we should skip XA steps that eat CPU time */
-	trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
+	trx->support_xa = THDVAR(thd, support_xa);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
 	reserve the kernel mutex, we have to release the search system latch
@@ -1995,7 +2010,7 @@
 	trx = check_trx_exists(hton, thd);
 
 	/* Update the info whether we should skip XA steps that eat CPU time */
-	trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
+	trx->support_xa = THDVAR(thd, support_xa);
 
 	/* Release a possible FIFO ticket and search latch. Since we will
 	reserve the kernel mutex, we have to release the search system latch
@@ -6332,7 +6347,7 @@
 
 			if (thd->in_lock_tables &&
 				thd->lex->sql_command == SQLCOM_LOCK_TABLES &&
-				thd->variables.innodb_table_locks &&
+				THDVAR(thd, table_locks) &&
 				(thd->options & OPTION_NOT_AUTOCOMMIT)) {
 
 				ulint	error = row_lock_table_for_mysql(
@@ -6457,7 +6472,7 @@
 		trx->active_trans = 1;
 	}
 
-	if (thd->in_lock_tables && thd->variables.innodb_table_locks) {
+	if (thd->in_lock_tables && THDVAR(thd, table_locks)) {
 		ulint	error = DB_SUCCESS;
 
 		error = row_lock_table_for_mysql(prebuilt, NULL, 0);
@@ -6513,10 +6528,6 @@
 
 	DBUG_ENTER("innodb_show_status");
 
-	if (have_innodb != SHOW_OPTION_YES) {
-		DBUG_RETURN(FALSE);
-	}
-
 	trx = check_trx_exists(hton, thd);
 
 	innobase_release_stat_resources(trx);
@@ -7424,7 +7435,7 @@
 		trx->active_trans = 2;
 	}
 
-	if (!thd->variables.innodb_support_xa) {
+	if (!THDVAR(thd, support_xa)) {
 
 		return(0);
 	}
@@ -7634,6 +7645,207 @@
 struct st_mysql_storage_engine innobase_storage_engine=
 { MYSQL_HANDLERTON_INTERFACE_VERSION };
 
+/* plugin options */
+static MYSQL_SYSVAR_BOOL_REF(checksums, innobase_use_checksums,
+  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
+  "Enable InnoDB checksums validation (enabled by default). "
+  "Disable with --skip-innodb-checksums.",
+  NULL, NULL, TRUE);
+
+static MYSQL_SYSVAR_STR_REF(data_home_dir, innobase_data_home_dir,
+  PLUGIN_VAR_READONLY,
+  "The common part for InnoDB table spaces.",
+  NULL, NULL, NULL);
+
+static MYSQL_SYSVAR_BOOL_REF(doublewrite, innobase_use_doublewrite,
+  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
+  "Enable InnoDB doublewrite buffer (enabled by default). "
+  "Disable with --skip-innodb-doublewrite.",
+  NULL, NULL, TRUE);
+
+static MYSQL_SYSVAR_ULONG_REF(fast_shutdown, innobase_fast_shutdown,
+  PLUGIN_VAR_OPCMDARG,
+  "Speeds up the shutdown process of the InnoDB storage engine. Possible "
+  "values are 0, 1 (faster)"
+  /*
+    NetWare can't close unclosed files, can't automatically kill remaining
+    threads, etc, so on this OS we disable the crash-like InnoDB shutdown.
+  */
+#ifndef __NETWARE__
+  " or 2 (fastest - crash-like)"
+#endif
+  ".",
+  NULL, NULL, 1, 0, IF_NETWARE(1,2), 0);
+
+static MYSQL_SYSVAR_BOOL_REF(file_per_table, innobase_file_per_table,
+  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
+  "Stores each InnoDB table to an .ibd file in the database dir.",
+  NULL, NULL, FALSE);
+
+static MYSQL_SYSVAR_ULONG_REF(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
+  PLUGIN_VAR_OPCMDARG,
+ "Set to 0 (write and flush once per second), 1 (write and flush at each commit)\
+ or 2 (write at commit, flush once per second).",
+  NULL, NULL, 1, 0, 2, 0);
+
+static MYSQL_SYSVAR_STR_REF(flush_method, innobase_unix_file_flush_method,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "With which method to flush data.", NULL, NULL, NULL);
+
+static MYSQL_SYSVAR_BOOL_REF(locks_unsafe_for_binlog, innobase_locks_unsafe_for_binlog,
+  PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
+  "Force InnoDB to not use next-key locking, to use only row-level locking.",
+  NULL, NULL, FALSE);
+
+static MYSQL_SYSVAR_STR_REF(log_arch_dir, innobase_log_arch_dir,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Where full logs should be archived.", NULL, NULL, NULL);
+
+static MYSQL_SYSVAR_BOOL_REF(log_archive, innobase_log_archive,
+  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
+  "Set to 1 if you want to have logs archived.", NULL, NULL, FALSE);
+
+static MYSQL_SYSVAR_STR_REF(log_group_home_dir, innobase_log_group_home_dir,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Path to InnoDB log files.", NULL, NULL, NULL);
+
+static MYSQL_SYSVAR_ULONG_REF(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
+  PLUGIN_VAR_RQCMDARG,
+  "Percentage of dirty pages allowed in bufferpool.",
+  NULL, NULL, 90, 0, 100, 0);
+
+static MYSQL_SYSVAR_ULONG_REF(max_purge_lag, srv_max_purge_lag,
+  PLUGIN_VAR_RQCMDARG,
+  "Desired maximum length of the purge queue (0 = no limit)",
+  NULL, NULL, 0, 0, ~0L, 0);
+
+static MYSQL_SYSVAR_BOOL_REF(status_file, innobase_create_status_file,
+  PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_NOSYSVAR,
+  "Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
+  NULL, NULL, FALSE);
+
+static MYSQL_SYSVAR_LONG_REF(additional_mem_pool_size, innobase_additional_mem_pool_size,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Size of a memory pool InnoDB uses to store data dictionary information and other
internal data structures.",
+  NULL, NULL, 1*1024*1024L, 512*1024L, ~0L, 1024);
+
+static MYSQL_SYSVAR_ULONG_REF(autoextend_increment, srv_auto_extend_increment,
+  PLUGIN_VAR_RQCMDARG,
+  "Data file autoextend increment in megabytes",
+  NULL, NULL, 8L, 1L, 1000L, 0);
+
+static MYSQL_SYSVAR_LONGLONG_REF(buffer_pool_size, innobase_buffer_pool_size,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "The size of the memory buffer InnoDB uses to cache data and indexes of its tables.",
+  NULL, NULL, 8*1024*1024L, 1024*1024L, LONGLONG_MAX, 1024*1024L);
+
+static MYSQL_SYSVAR_ULONG_REF(commit_concurrency, srv_commit_concurrency,
+  PLUGIN_VAR_RQCMDARG,
+  "Helps in performance tuning in heavily concurrent environments.",
+  NULL, NULL, 0, 0, 1000, 0);
+
+static MYSQL_SYSVAR_ULONG_REF(concurrency_tickets, srv_n_free_tickets_to_enter,
+  PLUGIN_VAR_RQCMDARG,
+  "Number of times a thread is allowed to enter InnoDB within the same SQL query after it
has once got the ticket",
+  NULL, NULL, 500L, 1L, ~0L, 0);
+
+static MYSQL_SYSVAR_LONG_REF(file_io_threads, innobase_file_io_threads,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Number of file I/O threads in InnoDB.",
+  NULL, NULL, 4, 4, 64, 0);
+
+static MYSQL_SYSVAR_LONG_REF(force_recovery, innobase_force_recovery,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Helps to save your data in case the disk image of the database becomes corrupt.",
+  NULL, NULL, 0, 0, 6, 0);
+
+static MYSQL_SYSVAR_LONG_REF(lock_wait_timeout, innobase_lock_wait_timeout,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Timeout in seconds an InnoDB transaction may wait for a lock before being rolled
back.",
+  NULL, NULL, 50, 1, 1024 * 1024 * 1024, 0);
+
+static MYSQL_SYSVAR_LONG_REF(log_buffer_size, innobase_log_buffer_size,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "The size of the buffer which InnoDB uses to write log to the log files on disk.",
+  NULL, NULL, 1024*1024L, 256*1024L, ~0L, 1024);
+
+static MYSQL_SYSVAR_LONGLONG_REF(log_file_size, innobase_log_file_size,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Size of each log file in a log group.",
+  NULL, NULL, 5*1024*1024L, 1*1024*1024L, LONGLONG_MAX, 1024*1024L);
+
+static MYSQL_SYSVAR_LONG_REF(log_files_in_group, innobase_log_files_in_group,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Number of log files in the log group. InnoDB writes to the files in a circular
fashion. Value 3 is recommended here.",
+  NULL, NULL, 2, 2, 100, 0);
+
+static MYSQL_SYSVAR_LONG_REF(mirrored_log_groups, innobase_mirrored_log_groups,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Number of identical copies of log groups we keep for the database. Currently this
should be set to 1.",
+  NULL, NULL, 1, 1, 10, 0);
+
+static MYSQL_SYSVAR_LONG_REF(open_files, innobase_open_files,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "How many files at the maximum InnoDB keeps open at the same time.",
+  NULL, NULL, 300L, 10L, ~0L, 0);
+
+static MYSQL_SYSVAR_ULONG_REF(sync_spin_loops, srv_n_spin_wait_rounds,
+  PLUGIN_VAR_RQCMDARG,
+  "Count of spin-loop rounds in InnoDB mutexes",
+  NULL, NULL, 20L, 0L, ~0L, 0);
+
+static MYSQL_SYSVAR_ULONG_REF(thread_concurrency, srv_thread_concurrency,
+  PLUGIN_VAR_RQCMDARG,
+  "Helps in performance tuning in heavily concurrent environments. Sets the maximum
number of threads allowed inside InnoDB. Value 0 will disable the thread throttling.",
+  NULL, NULL, 8, 0, 1000, 0);
+
+static MYSQL_SYSVAR_ULONG_REF(thread_sleep_delay, srv_thread_sleep_delay,
+  PLUGIN_VAR_RQCMDARG,
+  "Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0 disable a
sleep",
+  NULL, NULL, 10000L, 0L, ~0L, 0);
+
+static MYSQL_SYSVAR_STR_REF(data_file_path, innobase_data_file_path,
+  PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+  "Path to individual files and their sizes.",
+  NULL, NULL, NULL);
+
+static struct st_mysql_sys_var* innobase_system_variables[]= {
+  MYSQL_SYSVAR(checksums),
+  MYSQL_SYSVAR(data_home_dir),
+  MYSQL_SYSVAR(doublewrite),
+  MYSQL_SYSVAR(fast_shutdown),
+  MYSQL_SYSVAR(file_per_table),
+  MYSQL_SYSVAR(flush_log_at_trx_commit),
+  MYSQL_SYSVAR(flush_method),
+  MYSQL_SYSVAR(locks_unsafe_for_binlog),
+  MYSQL_SYSVAR(log_arch_dir),
+  MYSQL_SYSVAR(log_archive),
+  MYSQL_SYSVAR(log_group_home_dir),
+  MYSQL_SYSVAR(max_dirty_pages_pct),
+  MYSQL_SYSVAR(max_purge_lag),
+  MYSQL_SYSVAR(status_file),
+  MYSQL_SYSVAR(support_xa),
+  MYSQL_SYSVAR(table_locks),
+  MYSQL_SYSVAR(additional_mem_pool_size),
+  MYSQL_SYSVAR(autoextend_increment),
+  MYSQL_SYSVAR(buffer_pool_size),
+  MYSQL_SYSVAR(commit_concurrency),
+  MYSQL_SYSVAR(concurrency_tickets),
+  MYSQL_SYSVAR(file_io_threads),
+  MYSQL_SYSVAR(force_recovery),
+  MYSQL_SYSVAR(lock_wait_timeout),
+  MYSQL_SYSVAR(log_buffer_size),
+  MYSQL_SYSVAR(log_file_size),
+  MYSQL_SYSVAR(log_files_in_group),
+  MYSQL_SYSVAR(mirrored_log_groups),
+  MYSQL_SYSVAR(open_files),
+  MYSQL_SYSVAR(sync_spin_loops),
+  MYSQL_SYSVAR(thread_concurrency),
+  MYSQL_SYSVAR(thread_sleep_delay),
+  MYSQL_SYSVAR(data_file_path),
+  NULL
+};
+
 mysql_declare_plugin(innobase)
 {
   MYSQL_STORAGE_ENGINE_PLUGIN,
@@ -7646,7 +7858,7 @@
   NULL, /* Plugin Deinit */
   0x0100 /* 1.0 */,
   innodb_status_variables_export,/* status variables             */
-  NULL,                       /* system variables                */
+  innobase_system_variables, /* system variables */
   NULL                        /* config options                  */
 }
 mysql_declare_plugin_end;

--- 1.206/sql/set_var.cc	2006-12-21 16:54:34 -08:00
+++ 1.207/sql/set_var.cc	2006-12-21 16:54:34 -08:00
@@ -59,38 +59,6 @@
 
 #include "events.h"
 
-/* WITH_INNOBASE_STORAGE_ENGINE */
-extern uint innobase_flush_log_at_trx_commit;
-extern ulong innobase_fast_shutdown;
-extern long innobase_mirrored_log_groups, innobase_log_files_in_group;
-extern longlong innobase_log_file_size;
-extern long innobase_log_buffer_size;
-extern longlong innobase_buffer_pool_size;
-extern long innobase_additional_mem_pool_size;
-extern long innobase_file_io_threads, innobase_lock_wait_timeout;
-extern long innobase_force_recovery;
-extern long innobase_open_files;
-extern char *innobase_data_home_dir, *innobase_data_file_path;
-extern char *innobase_log_group_home_dir, *innobase_log_arch_dir;
-extern char *innobase_unix_file_flush_method;
-/* The following variables have to be my_bool for SHOW VARIABLES to work */
-extern my_bool innobase_log_archive,
-               innobase_use_doublewrite,
-               innobase_use_checksums,
-               innobase_file_per_table,
-               innobase_locks_unsafe_for_binlog;
-
-extern "C" {
-extern ulong srv_max_buf_pool_modified_pct;
-extern ulong srv_max_purge_lag;
-extern ulong srv_auto_extend_increment;
-extern ulong srv_n_spin_wait_rounds;
-extern ulong srv_n_free_tickets_to_enter;
-extern ulong srv_thread_sleep_delay;
-extern ulong srv_thread_concurrency;
-extern ulong srv_commit_concurrency;
-extern ulong srv_flush_log_at_trx_commit;
-}
 
 /* WITH_NDBCLUSTER_STORAGE_ENGINE */
 extern ulong ndb_cache_check_time;
@@ -100,8 +68,7 @@
 extern ulong ndb_report_thresh_binlog_mem_usage;
 #endif
 
-
-
+static DYNAMIC_ARRAY fixed_show_vars;
 static HASH system_variable_hash;
 const char *bool_type_names[]= { "OFF", "ON", NullS };
 TYPELIB bool_typelib=
@@ -172,864 +139,534 @@
   it in the constructor (see sys_var class for details).
 */
 
-sys_var *sys_var::first= NULL;
-uint sys_var::sys_vars= 0;
+static sys_var_chain vars = { NULL, NULL };
 
-sys_var_thd_ulong	sys_auto_increment_increment("auto_increment_increment",
+static sys_var_thd_ulong	sys_auto_increment_increment(vars, "auto_increment_increment",
                                                      &SV::auto_increment_increment);
-sys_var_thd_ulong	sys_auto_increment_offset("auto_increment_offset",
+static sys_var_thd_ulong	sys_auto_increment_offset(vars, "auto_increment_offset",
                                                   &SV::auto_increment_offset);
 
-sys_var_bool_ptr	sys_automatic_sp_privileges("automatic_sp_privileges",
+static sys_var_bool_ptr	sys_automatic_sp_privileges(vars, "automatic_sp_privileges",
 					      &sp_automatic_privileges);
 
-sys_var_const_str       sys_basedir("basedir", mysql_home);
-sys_var_long_ptr	sys_binlog_cache_size("binlog_cache_size",
+static sys_var_const_str       sys_basedir(vars, "basedir", mysql_home);
+static sys_var_long_ptr	sys_binlog_cache_size(vars, "binlog_cache_size",
 					      &binlog_cache_size);
-sys_var_thd_binlog_format sys_binlog_format("binlog_format",
+static sys_var_thd_binlog_format sys_binlog_format(vars, "binlog_format",
                                             &SV::binlog_format);
-sys_var_thd_ulong	sys_bulk_insert_buff_size("bulk_insert_buffer_size",
+static sys_var_thd_ulong	sys_bulk_insert_buff_size(vars, "bulk_insert_buffer_size",
 						  &SV::bulk_insert_buff_size);
-sys_var_character_set_server	sys_character_set_server("character_set_server");
-sys_var_const_str       sys_charset_system("character_set_system",
+static sys_var_character_set_server	sys_character_set_server(vars,
"character_set_server");
+sys_var_const_str       sys_charset_system(vars, "character_set_system",
                                            (char *)my_charset_utf8_general_ci.name);
-sys_var_character_set_database	sys_character_set_database("character_set_database");
-sys_var_character_set_client  sys_character_set_client("character_set_client");
-sys_var_character_set_connection 
sys_character_set_connection("character_set_connection");
-sys_var_character_set_results sys_character_set_results("character_set_results");
-sys_var_character_set_filesystem 
sys_character_set_filesystem("character_set_filesystem");
-sys_var_thd_ulong	sys_completion_type("completion_type",
+static sys_var_character_set_database	sys_character_set_database(vars,
"character_set_database");
+static sys_var_character_set_client  sys_character_set_client(vars,
"character_set_client");
+static sys_var_character_set_connection  sys_character_set_connection(vars,
"character_set_connection");
+static sys_var_character_set_results sys_character_set_results(vars,
"character_set_results");
+static sys_var_character_set_filesystem  sys_character_set_filesystem(vars,
"character_set_filesystem");
+static sys_var_thd_ulong	sys_completion_type(vars, "completion_type",
 					 &SV::completion_type,
 					 check_completion_type,
 					 fix_completion_type);
-sys_var_collation_connection sys_collation_connection("collation_connection");
-sys_var_collation_database sys_collation_database("collation_database");
-sys_var_collation_server sys_collation_server("collation_server");
-sys_var_long_ptr	sys_concurrent_insert("concurrent_insert",
+static sys_var_collation_connection sys_collation_connection(vars,
"collation_connection");
+static sys_var_collation_database sys_collation_database(vars, "collation_database");
+static sys_var_collation_server sys_collation_server(vars, "collation_server");
+static sys_var_long_ptr	sys_concurrent_insert(vars, "concurrent_insert",
                                               &myisam_concurrent_insert);
-sys_var_long_ptr	sys_connect_timeout("connect_timeout",
+static sys_var_long_ptr	sys_connect_timeout(vars, "connect_timeout",
 					    &connect_timeout);
-sys_var_const_str       sys_datadir("datadir", mysql_real_data_home);
+static sys_var_const_str       sys_datadir(vars, "datadir", mysql_real_data_home);
 #ifndef DBUG_OFF
-sys_var_thd_dbug        sys_dbug("debug");
+static sys_var_thd_dbug        sys_dbug(vars, "debug");
 #endif
-sys_var_enum		sys_delay_key_write("delay_key_write",
+static sys_var_enum		sys_delay_key_write(vars, "delay_key_write",
 					    &delay_key_write_options,
 					    &delay_key_write_typelib,
 					    fix_delay_key_write);
-sys_var_long_ptr	sys_delayed_insert_limit("delayed_insert_limit",
+static sys_var_long_ptr	sys_delayed_insert_limit(vars, "delayed_insert_limit",
 						 &delayed_insert_limit);
-sys_var_long_ptr	sys_delayed_insert_timeout("delayed_insert_timeout",
+static sys_var_long_ptr	sys_delayed_insert_timeout(vars, "delayed_insert_timeout",
 						   &delayed_insert_timeout);
-sys_var_long_ptr	sys_delayed_queue_size("delayed_queue_size",
+static sys_var_long_ptr	sys_delayed_queue_size(vars, "delayed_queue_size",
 					       &delayed_queue_size);
 
-sys_var_event_scheduler sys_event_scheduler("event_scheduler");
-sys_var_long_ptr	sys_expire_logs_days("expire_logs_days",
+static sys_var_event_scheduler sys_event_scheduler(vars, "event_scheduler");
+static sys_var_long_ptr	sys_expire_logs_days(vars, "expire_logs_days",
 					     &expire_logs_days);
-sys_var_bool_ptr	sys_flush("flush", &myisam_flush);
-sys_var_long_ptr	sys_flush_time("flush_time", &flush_time);
-sys_var_str             sys_ft_boolean_syntax("ft_boolean_syntax",
+static sys_var_bool_ptr	sys_flush(vars, "flush", &myisam_flush);
+static sys_var_long_ptr	sys_flush_time(vars, "flush_time", &flush_time);
+static sys_var_str             sys_ft_boolean_syntax(vars, "ft_boolean_syntax",
                                          sys_check_ftb_syntax,
                                          sys_update_ftb_syntax,
                                          sys_default_ftb_syntax,
                                          ft_boolean_syntax);
-sys_var_str             sys_init_connect("init_connect", 0,
+sys_var_str             sys_init_connect(vars, "init_connect", 0,
                                          sys_update_init_connect,
                                          sys_default_init_connect,0);
-sys_var_str             sys_init_slave("init_slave", 0,
+sys_var_str             sys_init_slave(vars, "init_slave", 0,
                                        sys_update_init_slave,
                                        sys_default_init_slave,0);
-sys_var_thd_ulong	sys_interactive_timeout("interactive_timeout",
+static sys_var_thd_ulong	sys_interactive_timeout(vars, "interactive_timeout",
 						&SV::net_interactive_timeout);
-sys_var_thd_ulong	sys_join_buffer_size("join_buffer_size",
+static sys_var_thd_ulong	sys_join_buffer_size(vars, "join_buffer_size",
 					     &SV::join_buff_size);
-sys_var_key_buffer_size	sys_key_buffer_size("key_buffer_size");
-sys_var_key_cache_long  sys_key_cache_block_size("key_cache_block_size",
+static sys_var_key_buffer_size	sys_key_buffer_size(vars, "key_buffer_size");
+static sys_var_key_cache_long  sys_key_cache_block_size(vars, "key_cache_block_size",
 						 offsetof(KEY_CACHE,
 							  param_block_size));
-sys_var_key_cache_long	sys_key_cache_division_limit("key_cache_division_limit",
+static sys_var_key_cache_long	sys_key_cache_division_limit(vars,
"key_cache_division_limit",
 						     offsetof(KEY_CACHE,
 							      param_division_limit));
-sys_var_key_cache_long  sys_key_cache_age_threshold("key_cache_age_threshold",
+static sys_var_key_cache_long  sys_key_cache_age_threshold(vars,
"key_cache_age_threshold",
 						     offsetof(KEY_CACHE,
 							      param_age_threshold));
-sys_var_bool_ptr	sys_local_infile("local_infile",
+static sys_var_bool_ptr	sys_local_infile(vars, "local_infile",
 					 &opt_local_infile);
-sys_var_trust_routine_creators
-sys_trust_routine_creators("log_bin_trust_routine_creators",
+static sys_var_trust_routine_creators
+sys_trust_routine_creators(vars, "log_bin_trust_routine_creators",
                            &trust_function_creators);
-sys_var_bool_ptr       
-sys_trust_function_creators("log_bin_trust_function_creators",
+static sys_var_bool_ptr       
+sys_trust_function_creators(vars, "log_bin_trust_function_creators",
                             &trust_function_creators);
-sys_var_bool_ptr
-  sys_log_queries_not_using_indexes("log_queries_not_using_indexes",
+static sys_var_bool_ptr
+  sys_log_queries_not_using_indexes(vars, "log_queries_not_using_indexes",
                                     &opt_log_queries_not_using_indexes);
-sys_var_thd_ulong	sys_log_warnings("log_warnings", &SV::log_warnings);
-sys_var_thd_ulong	sys_long_query_time("long_query_time",
+static sys_var_thd_ulong	sys_log_warnings(vars, "log_warnings", &SV::log_warnings);
+static sys_var_thd_ulong	sys_long_query_time(vars, "long_query_time",
 					     &SV::long_query_time);
-sys_var_thd_bool	sys_low_priority_updates("low_priority_updates",
+static sys_var_thd_bool	sys_low_priority_updates(vars, "low_priority_updates",
 						 &SV::low_priority_updates,
 						 fix_low_priority_updates);
 #ifndef TO_BE_DELETED	/* Alias for the low_priority_updates */
-sys_var_thd_bool	sys_sql_low_priority_updates("sql_low_priority_updates",
+static sys_var_thd_bool	sys_sql_low_priority_updates(vars, "sql_low_priority_updates",
 						     &SV::low_priority_updates,
 						     fix_low_priority_updates);
 #endif
-sys_var_thd_ulong	sys_max_allowed_packet("max_allowed_packet",
+static sys_var_thd_ulong	sys_max_allowed_packet(vars, "max_allowed_packet",
 					       &SV::max_allowed_packet);
-sys_var_long_ptr	sys_max_binlog_cache_size("max_binlog_cache_size",
+static sys_var_long_ptr	sys_max_binlog_cache_size(vars, "max_binlog_cache_size",
 						  &max_binlog_cache_size);
-sys_var_long_ptr	sys_max_binlog_size("max_binlog_size",
+static sys_var_long_ptr	sys_max_binlog_size(vars, "max_binlog_size",
 					    &max_binlog_size,
                                             fix_max_binlog_size);
-sys_var_long_ptr	sys_max_connections("max_connections",
+static sys_var_long_ptr	sys_max_connections(vars, "max_connections",
 					    &max_connections,
                                             fix_max_connections);
-sys_var_long_ptr	sys_max_connect_errors("max_connect_errors",
+static sys_var_long_ptr	sys_max_connect_errors(vars, "max_connect_errors",
 					       &max_connect_errors);
-sys_var_thd_ulong       sys_max_insert_delayed_threads("max_insert_delayed_threads",
+static sys_var_thd_ulong       sys_max_insert_delayed_threads(vars,
"max_insert_delayed_threads",
 						       &SV::max_insert_delayed_threads,
                                                        check_max_delayed_threads,
                                                        fix_max_connections);
-sys_var_thd_ulong	sys_max_delayed_threads("max_delayed_threads",
+static sys_var_thd_ulong	sys_max_delayed_threads(vars, "max_delayed_threads",
 						&SV::max_insert_delayed_threads,
                                                 check_max_delayed_threads,
                                                 fix_max_connections);
-sys_var_thd_ulong	sys_max_error_count("max_error_count",
+static sys_var_thd_ulong	sys_max_error_count(vars, "max_error_count",
 					    &SV::max_error_count);
-sys_var_thd_ulonglong	sys_max_heap_table_size("max_heap_table_size",
+static sys_var_thd_ulonglong	sys_max_heap_table_size(vars, "max_heap_table_size",
 						&SV::max_heap_table_size);
-sys_var_thd_ulong       sys_pseudo_thread_id("pseudo_thread_id",
+static sys_var_thd_ulong       sys_pseudo_thread_id(vars, "pseudo_thread_id",
 					     &SV::pseudo_thread_id,
                                              check_pseudo_thread_id, 0);
-sys_var_thd_ha_rows	sys_max_join_size("max_join_size",
+static sys_var_thd_ha_rows	sys_max_join_size(vars, "max_join_size",
 					  &SV::max_join_size,
 					  fix_max_join_size);
-sys_var_thd_ulong	sys_max_seeks_for_key("max_seeks_for_key",
+static sys_var_thd_ulong	sys_max_seeks_for_key(vars, "max_seeks_for_key",
 					      &SV::max_seeks_for_key);
-sys_var_thd_ulong   sys_max_length_for_sort_data("max_length_for_sort_data",
+static sys_var_thd_ulong   sys_max_length_for_sort_data(vars, "max_length_for_sort_data",
                                                  &SV::max_length_for_sort_data);
 #ifndef TO_BE_DELETED	/* Alias for max_join_size */
-sys_var_thd_ha_rows	sys_sql_max_join_size("sql_max_join_size",
+static sys_var_thd_ha_rows	sys_sql_max_join_size(vars, "sql_max_join_size",
 					      &SV::max_join_size,
 					      fix_max_join_size);
 #endif
 static sys_var_long_ptr_global
-sys_max_prepared_stmt_count("max_prepared_stmt_count",
+sys_max_prepared_stmt_count(vars, "max_prepared_stmt_count",
                             &max_prepared_stmt_count,
                             &LOCK_prepared_stmt_count);
-sys_var_long_ptr	sys_max_relay_log_size("max_relay_log_size",
+static sys_var_long_ptr	sys_max_relay_log_size(vars, "max_relay_log_size",
                                                &max_relay_log_size,
                                                fix_max_relay_log_size);
-sys_var_thd_ulong	sys_max_sort_length("max_sort_length",
+static sys_var_thd_ulong	sys_max_sort_length(vars, "max_sort_length",
 					    &SV::max_sort_length);
-sys_var_thd_ulong	sys_max_sp_recursion_depth("max_sp_recursion_depth",
+static sys_var_thd_ulong	sys_max_sp_recursion_depth(vars, "max_sp_recursion_depth",
                                                    &SV::max_sp_recursion_depth);
-sys_var_max_user_conn   sys_max_user_connections("max_user_connections");
-sys_var_thd_ulong	sys_max_tmp_tables("max_tmp_tables",
+static sys_var_max_user_conn   sys_max_user_connections(vars, "max_user_connections");
+static sys_var_thd_ulong	sys_max_tmp_tables(vars, "max_tmp_tables",
 					   &SV::max_tmp_tables);
-sys_var_long_ptr	sys_max_write_lock_count("max_write_lock_count",
+static sys_var_long_ptr	sys_max_write_lock_count(vars, "max_write_lock_count",
 						 &max_write_lock_count);
-sys_var_thd_ulong       sys_multi_range_count("multi_range_count",
+static sys_var_thd_ulong       sys_multi_range_count(vars, "multi_range_count",
                                               &SV::multi_range_count);
-sys_var_long_ptr	sys_myisam_data_pointer_size("myisam_data_pointer_size",
+static sys_var_long_ptr	sys_myisam_data_pointer_size(vars, "myisam_data_pointer_size",
                                                     &myisam_data_pointer_size);
-sys_var_thd_ulonglong	sys_myisam_max_sort_file_size("myisam_max_sort_file_size",
&SV::myisam_max_sort_file_size, fix_myisam_max_sort_file_size, 1);
-sys_var_thd_ulong       sys_myisam_repair_threads("myisam_repair_threads",
&SV::myisam_repair_threads);
-sys_var_thd_ulong	sys_myisam_sort_buffer_size("myisam_sort_buffer_size",
&SV::myisam_sort_buff_size);
-sys_var_bool_ptr	sys_myisam_use_mmap("myisam_use_mmap", 
+static sys_var_thd_ulonglong	sys_myisam_max_sort_file_size(vars,
"myisam_max_sort_file_size", &SV::myisam_max_sort_file_size,
fix_myisam_max_sort_file_size, 1);
+static sys_var_thd_ulong       sys_myisam_repair_threads(vars, "myisam_repair_threads",
&SV::myisam_repair_threads);
+static sys_var_thd_ulong	sys_myisam_sort_buffer_size(vars, "myisam_sort_buffer_size",
&SV::myisam_sort_buff_size);
+static sys_var_bool_ptr	sys_myisam_use_mmap(vars, "myisam_use_mmap", 
                                             &opt_myisam_use_mmap);
 
-sys_var_thd_enum        sys_myisam_stats_method("myisam_stats_method",
+static sys_var_thd_enum        sys_myisam_stats_method(vars, "myisam_stats_method",
                                                 &SV::myisam_stats_method,
                                                 &myisam_stats_method_typelib,
                                                 NULL);
 
-sys_var_thd_ulong	sys_net_buffer_length("net_buffer_length",
+static sys_var_thd_ulong	sys_net_buffer_length(vars, "net_buffer_length",
 					      &SV::net_buffer_length);
-sys_var_thd_ulong	sys_net_read_timeout("net_read_timeout",
+static sys_var_thd_ulong	sys_net_read_timeout(vars, "net_read_timeout",
 					     &SV::net_read_timeout,
 					     0, fix_net_read_timeout);
-sys_var_thd_ulong	sys_net_write_timeout("net_write_timeout",
+static sys_var_thd_ulong	sys_net_write_timeout(vars, "net_write_timeout",
 					      &SV::net_write_timeout,
 					      0, fix_net_write_timeout);
-sys_var_thd_ulong	sys_net_retry_count("net_retry_count",
+static sys_var_thd_ulong	sys_net_retry_count(vars, "net_retry_count",
 					    &SV::net_retry_count,
 					    0, fix_net_retry_count);
-sys_var_thd_bool	sys_new_mode("new", &SV::new_mode);
-sys_var_thd_bool	sys_old_alter_table("old_alter_table",
+static sys_var_thd_bool	sys_new_mode(vars, "new", &SV::new_mode);
+sys_var_thd_bool	sys_old_alter_table(vars, "old_alter_table",
 					    &SV::old_alter_table);