List:Commits« Previous MessageNext Message »
From:antony Date:December 2 2006 6:32am
Subject:bk commit into 5.1 tree (antony:1.2371)
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-01 21:31:52-08:00, antony@stripped +10 -0
  Merge ppcg5.local:/Users/antony/Work/mysql-5.1-plugin.1
  into  ppcg5.local:/Users/antony/Work/mysql-5.1-plugin.3
  MERGE: 1.2353.22.1

  mysql-test/mysql-test-run.pl@stripped, 2006-12-01 21:26:43-08:00, antony@stripped +0 -0
    Auto merged
    MERGE: 1.232.2.1

  mysys/my_getopt.c@stripped, 2006-12-01 21:26:43-08:00, antony@stripped +0 -0
    Auto merged
    MERGE: 1.56.1.1

  sql/ha_ndbcluster.cc@stripped, 2006-12-01 21:26:43-08:00, antony@stripped +0 -0
    Auto merged
    MERGE: 1.369.1.1

  sql/mysql_priv.h@stripped, 2006-12-01 21:31:47-08:00, antony@stripped +0 -0
    manual merge
    MERGE: 1.457.4.1

  sql/mysqld.cc@stripped, 2006-12-01 21:31:48-08:00, antony@stripped +1 -3
    manual merge
    MERGE: 1.589.4.1

  sql/set_var.cc@stripped, 2006-12-01 21:31:48-08:00, antony@stripped +0 -0
    manual merge
    MERGE: 1.200.2.1

  sql/sql_plugin.cc@stripped, 2006-12-01 21:26:44-08:00, antony@stripped +0 -0
    Auto merged
    MERGE: 1.36.3.1

  storage/federated/ha_federated.cc@stripped, 2006-12-01 21:26:44-08:00, antony@stripped +0
-0
    Auto merged
    MERGE: 1.85.2.1

  storage/innobase/handler/ha_innodb.cc@stripped, 2006-12-01 21:26:44-08:00,
antony@stripped +0 -0
    Auto merged
    MERGE: 1.310.1.1

  storage/myisammrg/ha_myisammrg.cc@stripped, 2006-12-01 21:26:45-08:00, antony@stripped
+0 -1
    Auto merged
    MERGE: 1.107.2.1

# 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/mysql-5.1-plugin.3/RESYNC

--- 1.462/sql/mysql_priv.h	2006-12-01 21:32:01 -08:00
+++ 1.463/sql/mysql_priv.h	2006-12-01 21:32:01 -08:00
@@ -1651,11 +1651,6 @@
 
 /* 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;
 extern handlerton *heap_hton;

--- 1.595/sql/mysqld.cc	2006-12-01 21:32:01 -08:00
+++ 1.596/sql/mysqld.cc	2006-12-01 21:32:02 -08:00
@@ -316,7 +316,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,14 +358,13 @@
 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;
+handlerton *heap_hton= NULL;
+handlerton *myisam_hton= NULL;
+handlerton *partition_hton= NULL;
 
 #ifdef WITH_INNOBASE_STORAGE_ENGINE
 extern ulong innobase_fast_shutdown;
@@ -706,6 +704,7 @@
 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);
@@ -3214,12 +3213,39 @@
     using_update_log=1;
   }
 
-  if (plugin_init(opt_bootstrap))
+  if (plugin_init(opt_bootstrap, defaults_argv))
   {
     sql_print_error("Failed to init plugins.");
     return 1;
   }
 
+  /* we don't mind ignoring all the --skip-xyz options but
+     we do want to exit if there are any other unknown options */
+  if (defaults_argv && *defaults_argv)
+  {
+    int argc= 0;
+    char **argv= defaults_argv;
+   
+    my_option no_opts[]= {
+      { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }
+    };
+
+    for (char** p=argv; *p; p++, argc++);
+
+    my_getopt_unknown_flags= MY_GETOPT_CONSUME_BOOL_FALSE;
+
+    if (handle_options(&argc, &argv, no_opts, get_one_option))
+      return 1;
+
+    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? */
+      return 1;
+    }
+  }
+
+
   /* We have to initialize the storage engines before CSV logging */
   if (ha_init())
   {
@@ -3248,7 +3274,8 @@
   else
   {
     /* fall back to the log files if tables are not present */
-    if (have_csv_db == SHOW_OPTION_NO)
+    LEX_STRING csv_name={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 "
@@ -5082,10 +5109,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,
@@ -5341,10 +5364,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.",
@@ -7024,41 +7043,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;
@@ -7532,14 +7528,7 @@
   }
   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:
@@ -7589,12 +7578,6 @@
     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
@@ -7750,29 +7733,16 @@
   strmake(def_ft_boolean_syntax, ft_boolean_syntax,
 	  sizeof(ft_boolean_syntax)-1);
   my_getopt_error_reporter= option_error_reporter;
+  my_getopt_unknown_flags= MY_GETOPT_IGNORE_BOOL; /* ignore unknown bools */
+
   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();
@@ -8108,14 +8078,6 @@
 /*****************************************************************************
   Instantiate have_xyx 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;

--- 1.57/mysys/my_getopt.c	2006-12-01 21:32:02 -08:00
+++ 1.58/mysys/my_getopt.c	2006-12-01 21:32:02 -08:00
@@ -959,8 +959,8 @@
 		  (*getopt_get_addr)("", 0, optp) : optp->value);
     if (value)
     {
-      printf("%s", optp->name);
-      length= (uint) strlen(optp->name);
+      printf("%s ", optp->name);
+      length= (uint) strlen(optp->name)+1;
       for (; length < name_space; length++)
 	putchar(' ');
       switch ((optp->var_type & GET_TYPE_MASK)) {

--- 1.240/mysql-test/mysql-test-run.pl	2006-12-01 21:32:02 -08:00
+++ 1.241/mysql-test/mysql-test-run.pl	2006-12-01 21:32:02 -08:00
@@ -2751,8 +2751,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");
 
@@ -2851,8 +2851,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 )
@@ -3471,18 +3471,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 )
@@ -3520,8 +3520,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"
@@ -3557,11 +3557,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.372/sql/ha_ndbcluster.cc	2006-12-01 21:32:02 -08:00
+++ 1.373/sql/ha_ndbcluster.cc	2006-12-01 21:32:02 -08:00
@@ -6471,7 +6471,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;
@@ -6493,9 +6493,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();
 
@@ -6598,7 +6595,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);
@@ -9792,10 +9788,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-01 21:32:02 -08:00
+++ 1.314/storage/innobase/handler/ha_innodb.cc	2006-12-01 21:32:02 -08:00
@@ -1354,7 +1354,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,9 +1379,6 @@
         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
-
 	ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
 
 #ifdef UNIV_DEBUG
@@ -1619,7 +1616,6 @@
 
 	DBUG_RETURN(FALSE);
 error:
-	have_innodb= SHOW_OPTION_DISABLED;	// If we couldn't use handler
 	DBUG_RETURN(TRUE);
 }
 
@@ -6512,10 +6508,6 @@
 	ulint			trx_list_end = ULINT_UNDEFINED;
 
 	DBUG_ENTER("innodb_show_status");
-
-	if (have_innodb != SHOW_OPTION_YES) {
-		DBUG_RETURN(FALSE);
-	}
 
 	trx = check_trx_exists(hton, thd);
 

--- 1.205/sql/set_var.cc	2006-12-01 21:32:02 -08:00
+++ 1.206/sql/set_var.cc	2006-12-01 21:32:02 -08:00
@@ -658,14 +658,9 @@
 
 sys_var_have_variable sys_have_compress("have_compress", &have_compress);
 sys_var_have_variable sys_have_crypt("have_crypt", &have_crypt);
-sys_var_have_variable sys_have_csv_db("have_csv", &have_csv_db);
 sys_var_have_variable sys_have_dlopen("have_dynamic_loading", &have_dlopen);
 sys_var_have_variable sys_have_geometry("have_geometry", &have_geometry);
-sys_var_have_variable sys_have_innodb("have_innodb", &have_innodb);
-sys_var_have_variable sys_have_ndbcluster("have_ndbcluster", &have_ndbcluster);
 sys_var_have_variable sys_have_openssl("have_openssl", &have_openssl);
-sys_var_have_variable sys_have_partition_db("have_partitioning",
-                                            &have_partition_db);
 sys_var_have_variable sys_have_query_cache("have_query_cache",
                                            &have_query_cache);
 sys_var_have_variable sys_have_rtree_keys("have_rtree_keys", &have_rtree_keys);
@@ -784,13 +779,9 @@
   {sys_group_concat_max_len.name, (char*) &sys_group_concat_max_len,  SHOW_SYS},
   {sys_have_compress.name,    (char*) &have_compress,               SHOW_HAVE},
   {sys_have_crypt.name,       (char*) &have_crypt,                  SHOW_HAVE},
-  {sys_have_csv_db.name,      (char*) &have_csv_db,                 SHOW_HAVE},
   {sys_have_dlopen.name,      (char*) &have_dlopen,                 SHOW_HAVE},
   {sys_have_geometry.name,    (char*) &have_geometry,               SHOW_HAVE},
-  {sys_have_innodb.name,      (char*) &have_innodb,                 SHOW_HAVE},
-  {sys_have_ndbcluster.name,  (char*) &have_ndbcluster,             SHOW_HAVE},
   {sys_have_openssl.name,     (char*) &have_openssl,                SHOW_HAVE},
-  {sys_have_partition_db.name,(char*) &have_partition_db,           SHOW_HAVE},
   {sys_have_query_cache.name, (char*) &have_query_cache,            SHOW_HAVE},
   {sys_have_row_based_replication.name, (char*) &have_row_based_replication,
SHOW_HAVE},
   {sys_have_rtree_keys.name,  (char*) &have_rtree_keys,             SHOW_HAVE},
@@ -1328,7 +1319,8 @@
   /*
     Cluster does not support changing the binlog format on the fly yet.
   */
-  if (opt_bin_log && (have_ndbcluster == SHOW_OPTION_YES))
+  LEX_STRING ndb_name= {STRING_WITH_LEN("ndbcluster")};
+  if (opt_bin_log && plugin_is_ready(&ndb_name, MYSQL_STORAGE_ENGINE_PLUGIN))
   {
     my_error(ER_NDB_CANT_SWITCH_BINLOG_FORMAT, MYF(0));
     return 1;

--- 1.38/sql/sql_plugin.cc	2006-12-01 21:32:02 -08:00
+++ 1.39/sql/sql_plugin.cc	2006-12-01 21:32:02 -08:00
@@ -16,6 +16,7 @@
 
 #include "mysql_priv.h"
 #include <my_pthread.h>
+#include <my_getopt.h>
 #define REPORT_TO_LOG  1
 #define REPORT_TO_USER 2
 
@@ -80,6 +81,8 @@
 /* prototypes */
 my_bool plugin_register_builtin(struct st_mysql_plugin *plugin);
 void plugin_load(void);
+static my_bool register_builtin(struct st_mysql_plugin *plugin, 
+				struct st_plugin_int **ptr);
 
 static struct st_plugin_dl *plugin_dl_find(const LEX_STRING *dl)
 {
@@ -560,6 +563,71 @@
 }
 
 
+static my_bool get_one_option(int optid __attribute__((unused)),
+			const struct my_option *opt __attribute__((unused)),
+	       		char *argument __attribute__((unused)))
+{
+  return 0;
+}
+
+/*
+  RETURNS:
+    0 SUCCESS - plugin should be enabled/loaded
+*/
+static int test_plugin_enabled(const char *name, char **argv, bool def_enabled)
+{
+  my_bool enabled= def_enabled ? TRUE : FALSE;
+
+  if (argv && *argv)
+  {
+    int ho_error, argc= 0;
+    my_option options[3];
+    uint namelen= strlen(name);
+    char *name1= (char*) my_alloca(namelen * 2 + 10);
+    char *name2= name1 + namelen + 1;
+    
+    /* support --skip-plugin-foo syntax */
+    strxmov(name1, name, NullS);
+    my_casedn_str(&my_charset_latin1, name1);
+    strxmov(name2, "plugin-", name1, NullS);
+    
+    bzero(options, sizeof(options));
+    options[0].name= name1;
+    options[1].name= name2;
+    options[0].id= options[1].id= 1;
+    options[0].value= options[0].u_max_value=
+    options[1].value= options[1].u_max_value= (gptr*)&enabled;
+    options[0].var_type= options[1].var_type= GET_BOOL;
+    options[0].arg_type= options[1].arg_type= NO_ARG;
+    options[0].def_value= options[1].def_value= def_enabled ? 1 : 0;
+    
+    for (char** p= argv; *p; p++, argc++);
+    
+    ho_error= handle_options(&argc, &argv, options, get_one_option);
+
+    my_afree(name1);
+
+    if (ho_error)
+    {
+       sql_print_error("Parsing options for plugin '%s' failed.", name);
+       return ho_error;
+    }
+  }
+  
+  if (enabled)
+    return 0;
+
+  if (!my_strcasecmp(&my_charset_latin1, name, "MYISAM") ||
+      !my_strcasecmp(&my_charset_latin1, name, "MEMORY"))
+  {
+    sql_print_error("Plugin '%s' cannot be disabled", name);
+    return 0;
+  }
+
+  sql_print_information("Plugin '%s' disabled by command line option", name);
+  return 1;
+}
+
 static int plugin_initialize(struct st_plugin_int *plugin)
 {
   DBUG_ENTER("plugin_initialize");
@@ -627,7 +695,7 @@
 
   Finally we inializie everything, aka the dynamic that have yet to initialize.
 */
-int plugin_init(int skip_dynamic_loading)
+int plugin_init(int skip_dynamic_loading, char **argv)
 {
   uint i;
   struct st_mysql_plugin **builtins;
@@ -661,11 +729,14 @@
     {
 //      if (!(strcmp(plugin->name, "MyISAM")))
       {
-        if (plugin_register_builtin(plugin))
+        /* by default, ndbcluster is disabled */
+        bool def_enabled= 
+	  my_strcasecmp(&my_charset_latin1, plugin->name, "NDBCLUSTER") != 0;
+        if (test_plugin_enabled(plugin->name, argv, def_enabled))
+	  continue;
+	struct st_plugin_int *tmp;
+        if (register_builtin(plugin, &tmp))
           goto err;
-        struct st_plugin_int *tmp= dynamic_element(&plugin_array,
-                                                   plugin_array.elements-1,
-                                                   struct st_plugin_int *);
         if (plugin_initialize(tmp))
           goto err;
       }
@@ -687,6 +758,12 @@
                                                struct st_plugin_int *);
     if (tmp->state == PLUGIN_IS_UNINITIALIZED)
     {
+      /* by default, all dynamically loaded plugins are enabled */
+      if (test_plugin_enabled(tmp->name.str, argv, true))
+      {
+        plugin_del(tmp);
+	continue;
+      }
       if (plugin_initialize(tmp))
       {
         plugin_deinitialize(tmp);
@@ -702,7 +779,8 @@
 }
 
 
-my_bool plugin_register_builtin(struct st_mysql_plugin *plugin)
+static my_bool register_builtin(struct st_mysql_plugin *plugin, 
+				struct st_plugin_int **ptr)
 {
   struct st_plugin_int tmp;
   DBUG_ENTER("plugin_register_builtin");
@@ -719,13 +797,19 @@
   if (insert_dynamic(&plugin_array, (gptr)&tmp))
     DBUG_RETURN(1);
 
-  if (my_hash_insert(&plugin_hash[plugin->type],
-                     (byte*)dynamic_element(&plugin_array,
-                                            plugin_array.elements - 1,
-                                            struct st_plugin_int *)))
+  *ptr= dynamic_element(&plugin_array, plugin_array.elements - 1,
+                        struct st_plugin_int *);
+
+  if (my_hash_insert(&plugin_hash[plugin->type],(byte*) *ptr))
     DBUG_RETURN(1);
 
   DBUG_RETURN(0);
+}
+
+my_bool plugin_register_builtin(struct st_mysql_plugin *plugin)
+{
+  struct st_plugin_int *tmp;
+  return register_builtin(plugin, &tmp);
 }
 
 
Thread
bk commit into 5.1 tree (antony:1.2371)antony2 Dec