List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:November 6 2011 5:51am
Subject:bzr push into mysql-trunk-wl5461 branch (chris.powers:3424 to 3425) WL#5461
View as plain text  
 3425 Christopher Powers	2011-11-06
      WL#5461 PERFORMANCE_SCHEMA MY.CNF Default Setup
      
      Second phase of prototype with support for the following
      configuration option:
      
        pfs_instrument = '<instrument name> = <ON|TRUE|1|ENABLED|OFF|FALSE|0|DISABLED|COUNTED>'
      
      where
          ON = TRUE = 1 = ENABLED
      and
          OFF = FALSE = 0 = DISABLED
      and where
          ON  = timed, counted
          OFF = not timed, not counted
          COUNTED = not timed, counted
      
      This option is read-only. The effect of the option can only
      be seen in the SETUP_INSTRUMENTS table. It is not visible via
      SHOW GLOBAL VARIABLES. 

    modified:
      mysys/my_getopt.c
      sql/mysqld.cc
      sql/mysqld.h
      sql/sys_vars.cc
      storage/perfschema/pfs_instr_class.cc
      storage/perfschema/pfs_instr_class.h
      storage/perfschema/pfs_server.cc
      storage/perfschema/pfs_server.h
 3424 Christopher Powers	2011-11-02
      WL#5461 PERFORMANCE_SCHEMA MY.CNF Default Setup
      
      Line endings, comment change

    modified:
      sql/sys_vars.h
      storage/perfschema/pfs_server.cc
=== modified file 'mysys/my_getopt.c'
--- a/mysys/my_getopt.c	2011-07-19 15:11:15 +0000
+++ b/mysys/my_getopt.c	2011-11-06 05:19:53 +0000
@@ -53,7 +53,7 @@ enum enum_special_opt
 char *disabled_my_option= (char*) "0";
 char *enabled_my_option= (char*) "1";
 
-/* 
+/*
    This is a flag that can be set in client programs. 0 means that
    my_getopt will not print error messages, but the client should do
    it by itself
@@ -61,7 +61,7 @@ char *enabled_my_option= (char*) "1";
 
 my_bool my_getopt_print_errors= 1;
 
-/* 
+/*
    This is a flag that can be set in client programs. 1 means that
    my_getopt will skip over options it does not know how to handle.
 */
@@ -149,414 +149,414 @@ void my_getopt_register_get_addr(my_geto
   @return error in case of ambiguous or unknown options,
           0 on success.
 */
-int handle_options(int *argc, char ***argv, 
-		   const struct my_option *longopts,
+int handle_options(int *argc, char ***argv,
+                   const struct my_option *longopts,
                    my_get_one_option get_one_option)
 {
-  uint UNINIT_VAR(opt_found), argvpos= 0, length;
-  my_bool end_of_options= 0, must_be_var, set_maximum_value,
-          option_is_loose;
-  char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
-  const char *UNINIT_VAR(prev_found);
-  const struct my_option *optp;
-  void *value;
-  int error, i;
-  my_bool is_cmdline_arg= 1;
-
-  /* handle_options() assumes arg0 (program name) always exists */
-  DBUG_ASSERT(argc && *argc >= 1);
-  DBUG_ASSERT(argv && *argv);
-  (*argc)--; /* Skip the program name */
-  (*argv)++; /*      --- || ----      */
-  init_variables(longopts, init_one_value);
+uint UNINIT_VAR(opt_found), argvpos= 0, length;
+my_bool end_of_options= 0, must_be_var, set_maximum_value,
+option_is_loose;
+char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
+const char *UNINIT_VAR(prev_found);
+const struct my_option *optp;
+void *value;
+int error, i;
+my_bool is_cmdline_arg= 1;
+
+/* handle_options() assumes arg0 (program name) always exists */
+DBUG_ASSERT(argc && *argc >= 1);
+DBUG_ASSERT(argv && *argv);
+(*argc)--; /* Skip the program name */
+(*argv)++; /*      --- || ----      */
+init_variables(longopts, init_one_value);
 
-  /*
-    Search for args_separator, if found, then the first part of the
-    arguments are loaded from configs
-  */
-  for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
+/*
+  Search for args_separator, if found, then the first part of the
+  arguments are loaded from configs
+*/
+for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
+{
+  if (my_getopt_is_args_separator(*pos))
   {
-    if (my_getopt_is_args_separator(*pos))
-    {
-      is_cmdline_arg= 0;
-      break;
-    }
+    is_cmdline_arg= 0;
+    break;
   }
+}
 
-  for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
+for (pos= *argv, pos_end=pos+ *argc; pos != pos_end ; pos++)
+{
+  char **first= pos;
+  char *cur_arg= *pos;
+  opt_found= 0;
+  if (!is_cmdline_arg && (my_getopt_is_args_separator(cur_arg)))
   {
-    char **first= pos;
-    char *cur_arg= *pos;
-    opt_found= 0;
-    if (!is_cmdline_arg && (my_getopt_is_args_separator(cur_arg)))
-    {
-      is_cmdline_arg= 1;
+    is_cmdline_arg= 1;
 
-      /* save the separator too if skip unkown options  */
-      if (my_getopt_skip_unknown)
-        (*argv)[argvpos++]= cur_arg;
-      else
-        (*argc)--;
-      continue;
-    }
-    if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be opt */
+    /* save the separator too if skip unkown options  */
+    if (my_getopt_skip_unknown)
+      (*argv)[argvpos++]= cur_arg;
+    else
+      (*argc)--;
+    continue;
+  }
+  if (cur_arg[0] == '-' && cur_arg[1] && !end_of_options) /* must be opt */
+  {
+    char *argument=    0;
+    must_be_var=       0;
+    set_maximum_value= 0;
+    option_is_loose=   0;
+
+    cur_arg++;    /* skip '-' */
+    if (*cur_arg == '-')      /* check for long option, */
     {
-      char *argument=    0;
-      must_be_var=       0;
-      set_maximum_value= 0;
-      option_is_loose=   0;
+      if (!*++cur_arg)  /* skip the double dash */
+      {
+        /* '--' means end of options, look no further */
+        end_of_options= 1;
+        (*argc)--;
+        continue;
+      }
+      opt_str= check_struct_option(cur_arg, key_name);
+      optend= strcend(opt_str, '=');
+      length= (uint) (optend - opt_str);
+      if (*optend == '=')
+        optend++;
+      else
+        optend= 0;
 
-      cur_arg++;		/* skip '-' */
-      if (*cur_arg == '-')      /* check for long option, */
+      /*
+        Find first the right option. Return error in case of an ambiguous,
+        or unknown option
+      */
+      optp= longopts;
+      if (!(opt_found= findopt(opt_str, length, &optp, &prev_found)))
+      {
+        /*
+          Didn't find any matching option. Let's see if someone called
+          option with a special option prefix
+        */
+        if (!must_be_var)
+        {
+          if (optend)
+            must_be_var= 1; /* option is followed by an argument */
+          for (i= 0; special_opt_prefix[i]; i++)
+          {
+            if (!getopt_compare_strings(special_opt_prefix[i], opt_str,
+                                        special_opt_prefix_lengths[i]) &&
+                (opt_str[special_opt_prefix_lengths[i]] == '-' ||
+                 opt_str[special_opt_prefix_lengths[i]] == '_'))
+            {
+              /*
+                We were called with a special prefix, we can reuse opt_found
+              */
+              opt_str+= special_opt_prefix_lengths[i] + 1;
+              length-= special_opt_prefix_lengths[i] + 1;
+              if (i == OPT_LOOSE)
+                option_is_loose= 1;
+              if ((opt_found= findopt(opt_str, length, &optp, &prev_found)))
+              {
+                if (opt_found > 1)
+                {
+                  if (my_getopt_print_errors)
+                    my_getopt_error_reporter(ERROR_LEVEL,
+                                             "%s: ambiguous option '--%s-%s' (--%s-%s)",
+                                             my_progname, special_opt_prefix[i],
+                                             opt_str, special_opt_prefix[i],
+                                             prev_found);
+                  return (EXIT_AMBIGUOUS_OPTION);
+                }
+                switch (i) {
+                  case OPT_SKIP:
+                  case OPT_DISABLE: /* fall through */
+                    /*
+                      double negation is actually enable again,
+                      for example: --skip-option=0 -> option = TRUE
+                    */
+                    optend= (optend && *optend == '0' && !(*(optend + 1))) ?
+                            enabled_my_option : disabled_my_option;
+                    break;
+                  case OPT_ENABLE:
+                    optend= (optend && *optend == '0' && !(*(optend + 1))) ?
+                            disabled_my_option : enabled_my_option;
+                    break;
+                  case OPT_MAXIMUM:
+                    set_maximum_value= 1;
+                    must_be_var= 1;
+                    break;
+                }
+                break; /* break from the inner loop, main loop continues */
+              }
+              i= -1; /* restart the loop */
+            }
+          }
+        }
+        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)
+              my_getopt_error_reporter(option_is_loose ?
+                                       WARNING_LEVEL : ERROR_LEVEL,
+                                       "%s: unknown variable '%s'",
+                                       my_progname, cur_arg);
+            if (!option_is_loose)
+              return (EXIT_UNKNOWN_VARIABLE);
+          }
+          else
+          {
+            if (my_getopt_print_errors)
+              my_getopt_error_reporter(option_is_loose ?
+                                       WARNING_LEVEL : ERROR_LEVEL,
+                                       "%s: unknown option '--%s'",
+                                       my_progname, cur_arg);
+            if (!option_is_loose)
+              return (EXIT_UNKNOWN_OPTION);
+          }
+          if (option_is_loose)
+          {
+            (*argc)--;
+            continue;
+          }
+        }
+      }
+      if (opt_found > 1)
       {
-        if (!*++cur_arg)	/* skip the double dash */
+        if (must_be_var)
+        {
+          if (my_getopt_print_errors)
+            my_getopt_error_reporter(ERROR_LEVEL,
+                                     "%s: variable prefix '%s' is not unique",
+                                     my_progname, opt_str);
+          return (EXIT_VAR_PREFIX_NOT_UNIQUE);
+        }
+        else
+        {
+          if (my_getopt_print_errors)
+            my_getopt_error_reporter(ERROR_LEVEL,
+                                     "%s: ambiguous option '--%s' (%s, %s)",
+                                     my_progname, opt_str, prev_found,
+                                     optp->name);
+          return (EXIT_AMBIGUOUS_OPTION);
+        }
+      }
+      if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
+      {
+        if (my_getopt_print_errors)
+          fprintf(stderr,
+                  "%s: %s: Option '%s' used, but is disabled\n", my_progname,
+                  option_is_loose ? "WARNING" : "ERROR", opt_str);
+        if (option_is_loose)
         {
-          /* '--' means end of options, look no further */
-          end_of_options= 1;
           (*argc)--;
           continue;
         }
-	opt_str= check_struct_option(cur_arg, key_name);
-	optend= strcend(opt_str, '=');
-	length= (uint) (optend - opt_str);
-	if (*optend == '=')
-	  optend++;
-	else
-	  optend= 0;
-
-	/*
-	  Find first the right option. Return error in case of an ambiguous,
-	  or unknown option
-	*/
-	optp= longopts;
-	if (!(opt_found= findopt(opt_str, length, &optp, &prev_found)))
-	{
-	  /*
-	    Didn't find any matching option. Let's see if someone called
-	    option with a special option prefix
-	  */
-	  if (!must_be_var)
-	  {
-	    if (optend)
-	      must_be_var= 1; /* option is followed by an argument */
-	    for (i= 0; special_opt_prefix[i]; i++)
-	    {
-	      if (!getopt_compare_strings(special_opt_prefix[i], opt_str,
-					  special_opt_prefix_lengths[i]) &&
-		  (opt_str[special_opt_prefix_lengths[i]] == '-' ||
-		   opt_str[special_opt_prefix_lengths[i]] == '_'))
-	      {
-		/*
-		  We were called with a special prefix, we can reuse opt_found
-		*/
-		opt_str+= special_opt_prefix_lengths[i] + 1;
-                length-= special_opt_prefix_lengths[i] + 1;
-		if (i == OPT_LOOSE)
-		  option_is_loose= 1;
-		if ((opt_found= findopt(opt_str, length, &optp, &prev_found)))
-		{
-		  if (opt_found > 1)
-		  {
-		    if (my_getopt_print_errors)
-                      my_getopt_error_reporter(ERROR_LEVEL,
-                                               "%s: ambiguous option '--%s-%s' (--%s-%s)",
-                                               my_progname, special_opt_prefix[i],
-                                               opt_str, special_opt_prefix[i],
-                                               prev_found);
-		    return EXIT_AMBIGUOUS_OPTION;
-		  }
-		  switch (i) {
-		  case OPT_SKIP:
-		  case OPT_DISABLE: /* fall through */
-		    /*
-		      double negation is actually enable again,
-		      for example: --skip-option=0 -> option = TRUE
-		    */
-		    optend= (optend && *optend == '0' && !(*(optend + 1))) ?
-		      enabled_my_option : disabled_my_option;
-		    break;
-		  case OPT_ENABLE:
-		    optend= (optend && *optend == '0' && !(*(optend + 1))) ?
-                      disabled_my_option : enabled_my_option;
-		    break;
-		  case OPT_MAXIMUM:
-		    set_maximum_value= 1;
-		    must_be_var= 1;
-		    break;
-		  }
-		  break; /* break from the inner loop, main loop continues */
-		}
-                i= -1; /* restart the loop */
-	      }
-	    }
-	  }
-	  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)
-                my_getopt_error_reporter(option_is_loose ? 
-                                           WARNING_LEVEL : ERROR_LEVEL,
-                                         "%s: unknown variable '%s'",
-                                         my_progname, cur_arg);
-	      if (!option_is_loose)
-		return EXIT_UNKNOWN_VARIABLE;
-	    }
-	    else
-	    {
-	      if (my_getopt_print_errors)
-                my_getopt_error_reporter(option_is_loose ? 
-                                           WARNING_LEVEL : ERROR_LEVEL,
-                                         "%s: unknown option '--%s'", 
-                                         my_progname, cur_arg);
-	      if (!option_is_loose)
-		return EXIT_UNKNOWN_OPTION;
-	    }
-	    if (option_is_loose)
-	    {
-	      (*argc)--;
-	      continue;
-	    }
-	  }
-	}
-	if (opt_found > 1)
-	{
-	  if (must_be_var)
-	  {
-	    if (my_getopt_print_errors)
-              my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: variable prefix '%s' is not unique",
-                                       my_progname, opt_str);
-	    return EXIT_VAR_PREFIX_NOT_UNIQUE;
-	  }
-	  else
-	  {
-	    if (my_getopt_print_errors)
-              my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: ambiguous option '--%s' (%s, %s)",
-                                       my_progname, opt_str, prev_found, 
-                                       optp->name);
-	    return EXIT_AMBIGUOUS_OPTION;
-	  }
-	}
-	if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
-	{
-	  if (my_getopt_print_errors)
-	    fprintf(stderr,
-		    "%s: %s: Option '%s' used, but is disabled\n", my_progname,
-		    option_is_loose ? "WARNING" : "ERROR", opt_str);
-	  if (option_is_loose)
-	  {
-	    (*argc)--;
-	    continue;
-	  }
-	  return EXIT_OPTION_DISABLED;
-	}
-        error= 0;
-	value= optp->var_type & GET_ASK_ADDR ?
-	  (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) :
-          optp->value;
-        if (error)
-          return error;
+        return (EXIT_OPTION_DISABLED);
+      }
+      error= 0;
+      value= optp->var_type & GET_ASK_ADDR ?
+             (*getopt_get_addr)(key_name, (uint) strlen(key_name), optp, &error) :
+             optp->value;
+      if (error)
+        return (error);
 
-	if (optp->arg_type == NO_ARG)
-	{
-	  /*
-	    Due to historical reasons GET_BOOL var_types still accepts arguments
-	    despite the NO_ARG arg_type attribute. This can seems a bit unintuitive
-	    and care should be taken when refactoring this code.
-	  */
-	  if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL)
-	  {
-	    if (my_getopt_print_errors)
-              my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: option '--%s' cannot take an argument",
-                                       my_progname, optp->name);
-	    return EXIT_NO_ARGUMENT_ALLOWED;
-	  }
-	  if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL)
-	  {
-	    /*
-	      Set bool to 1 if no argument or if the user has used
-	      --enable-'option-name'.
-	      *optend was set to '0' if one used --disable-option
-	    */
-	    (*argc)--;
-	    if (!optend || *optend == '1' ||
-		!my_strcasecmp(&my_charset_latin1, optend, "true"))
-	      *((my_bool*) value)= (my_bool) 1;
-	    else if (*optend == '0' ||
-		     !my_strcasecmp(&my_charset_latin1, optend, "false"))
-	      *((my_bool*) value)= (my_bool) 0;
-	    else
-	    {
-	      my_getopt_error_reporter(WARNING_LEVEL,
-				       "%s: ignoring option '--%s' "
-                                       "due to invalid value '%s'",
-				       my_progname, optp->name, optend);
-	      continue;
-	    }
-            if (get_one_option && get_one_option(optp->id, optp,
-                               *((my_bool*) value) ?
-                               enabled_my_option : disabled_my_option))
-              return EXIT_ARGUMENT_INVALID;
-	    continue;
-	  }
-	  argument= optend;
-	}
-	else if (optp->arg_type == REQUIRED_ARG && !optend)
-	{
-	  /* Check if there are more arguments after this one,
-       Note: options loaded from config file that requires value
-       should always be in the form '--option=value'.
-    */
-	  if (!is_cmdline_arg || !*++pos)
-	  {
-	    if (my_getopt_print_errors)
-              my_getopt_error_reporter(ERROR_LEVEL,
-                                       "%s: option '--%s' requires an argument",
-                                       my_progname, optp->name);
-	    return EXIT_ARGUMENT_REQUIRED;
-	  }
-	  argument= *pos;
-	  (*argc)--;
-	}
-	else
-	  argument= optend;
+      if (optp->arg_type == NO_ARG)
+      {
+        /*
+          Due to historical reasons GET_BOOL var_types still accepts arguments
+          despite the NO_ARG arg_type attribute. This can seems a bit unintuitive
+          and care should be taken when refactoring this code.
+        */
+        if (optend && (optp->var_type & GET_TYPE_MASK) != GET_BOOL)
+        {
+          if (my_getopt_print_errors)
+            my_getopt_error_reporter(ERROR_LEVEL,
+                                     "%s: option '--%s' cannot take an argument",
+                                     my_progname, optp->name);
+          return (EXIT_NO_ARGUMENT_ALLOWED);
+        }
+        if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL)
+        {
+          /*
+            Set bool to 1 if no argument or if the user has used
+            --enable-'option-name'.
+            *optend was set to '0' if one used --disable-option
+          */
+          (*argc)--;
+          if (!optend || *optend == '1' ||
+              !my_strcasecmp(&my_charset_latin1, optend, "true"))
+            *((my_bool*) value)= (my_bool) 1;
+          else if (*optend == '0' ||
+                   !my_strcasecmp(&my_charset_latin1, optend, "false"))
+            *((my_bool*) value)= (my_bool) 0;
+          else
+          {
+            my_getopt_error_reporter(WARNING_LEVEL,
+                                     "%s: ignoring option '--%s' "
+                                     "due to invalid value '%s'",
+                                     my_progname, optp->name, optend);
+            continue;
+          }
+          if (get_one_option && get_one_option(optp->id, optp,
+                                               *((my_bool*) value) ?
+                                               enabled_my_option : disabled_my_option))
+            return (EXIT_ARGUMENT_INVALID);
+          continue;
+        }
+        argument= optend;
       }
-      else  /* must be short option */
+      else if (optp->arg_type == REQUIRED_ARG && !optend)
       {
-	for (optend= cur_arg; *optend; optend++)
-	{
-	  opt_found= 0;
-	  for (optp= longopts; optp->name; optp++)
-	  {
-	    if (optp->id && optp->id == (int) (uchar) *optend)
-	    {
-	      /* Option recognized. Find next what to do with it */
-	      opt_found= 1;
-	      if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
-	      {
-		if (my_getopt_print_errors)
-		  fprintf(stderr,
-			  "%s: ERROR: Option '-%c' used, but is disabled\n",
-			  my_progname, optp->id);
-		return EXIT_OPTION_DISABLED;
-	      }
-	      if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL &&
-		  optp->arg_type == NO_ARG)
-	      {
-		*((my_bool*) optp->value)= (my_bool) 1;
-                if (get_one_option && get_one_option(optp->id, optp, argument))
-                  return EXIT_UNSPECIFIED_ERROR;
-		continue;
-	      }
-	      else if (optp->arg_type == REQUIRED_ARG ||
-		       optp->arg_type == OPT_ARG)
-	      {
-		if (*(optend + 1))
-		{
-		  /* The rest of the option is option argument */
-		  argument= optend + 1;
-		  /* This is in effect a jump out of the outer loop */
-		  optend= (char*) " ";
-		}
-		else
-		{
-                  if (optp->arg_type == OPT_ARG)
-                  {
-                    if (optp->var_type == GET_BOOL)
-                      *((my_bool*) optp->value)= (my_bool) 1;
-                    if (get_one_option && get_one_option(optp->id, optp, argument))
-                      return EXIT_UNSPECIFIED_ERROR;
-                    continue;
-                  }
-		  /* Check if there are more arguments after this one */
-		  if (!pos[1])
-		  {
-                    if (my_getopt_print_errors)
-                      my_getopt_error_reporter(ERROR_LEVEL,
-                                               "%s: option '-%c' requires an argument",
-                                               my_progname, optp->id);
-                    return EXIT_ARGUMENT_REQUIRED;
-		  }
-		  argument= *++pos;
-		  (*argc)--;
-		  /* the other loop will break, because *optend + 1 == 0 */
-		}
-	      }
-	      if ((error= setval(optp, optp->value, argument,
-				 set_maximum_value)))
-		return error;
-              if (get_one_option && get_one_option(optp->id, optp, argument))
-                return EXIT_UNSPECIFIED_ERROR;
-	      break;
-	    }
-	  }
-	  if (!opt_found)
-	  {
-            if (my_getopt_skip_unknown)
+        /* Check if there are more arguments after this one,
+           Note: options loaded from config file that requires value
+           should always be in the form '--option=value'.
+        */
+        if (!is_cmdline_arg || !*++pos)
+        {
+          if (my_getopt_print_errors)
+            my_getopt_error_reporter(ERROR_LEVEL,
+                                     "%s: option '--%s' requires an argument",
+                                     my_progname, optp->name);
+          return (EXIT_ARGUMENT_REQUIRED);
+        }
+        argument= *pos;
+        (*argc)--;
+      }
+      else
+        argument= optend;
+    }
+    else
+    {  /* must be short option */
+      for (optend= cur_arg; *optend; optend++)
+      {
+        opt_found= 0;
+        for (optp= longopts; optp->name; optp++)
+        {
+          if (optp->id && optp->id == (int) (uchar) *optend)
+          {
+            /* Option recognized. Find next what to do with it */
+            opt_found= 1;
+            if ((optp->var_type & GET_TYPE_MASK) == GET_DISABLED)
             {
-              /*
-                We are currently parsing a single argv[] argument
-                of the form "-XYZ".
-                One or the argument found (say Y) is not an option.
-                Hack the string "-XYZ" to make a "-YZ" substring in it,
-                and push that to the output as an unrecognized parameter.
-              */
-              DBUG_ASSERT(optend > *pos);
-              DBUG_ASSERT(optend >= cur_arg);
-              DBUG_ASSERT(optend <= *pos + strlen(*pos));
-              DBUG_ASSERT(*optend);
-              optend--;
-              optend[0]= '-'; /* replace 'X' or '-' by '-' */
-              (*argv)[argvpos++]= optend;
-              /*
-                Do not continue to parse at the current "-XYZ" argument,
-                skip to the next argv[] argument instead.
-              */
-              optend= (char*) " ";
+              if (my_getopt_print_errors)
+                fprintf(stderr,
+                        "%s: ERROR: Option '-%c' used, but is disabled\n",
+                        my_progname, optp->id);
+              return (EXIT_OPTION_DISABLED);
             }
-            else
+            if ((optp->var_type & GET_TYPE_MASK) == GET_BOOL &&
+                optp->arg_type == NO_ARG)
             {
-              if (my_getopt_print_errors)
-                my_getopt_error_reporter(ERROR_LEVEL,
-                                         "%s: unknown option '-%c'",
-                                         my_progname, *optend);
-              return EXIT_UNKNOWN_OPTION;
+              *((my_bool*) optp->value)= (my_bool) 1;
+              if (get_one_option && get_one_option(optp->id, optp, argument))
+                return (EXIT_UNSPECIFIED_ERROR);
+              continue;
             }
-	  }
-	}
-        if (opt_found)
-          (*argc)--; /* option handled (short), decrease argument count */
-	continue;
+            else if (optp->arg_type == REQUIRED_ARG ||
+                     optp->arg_type == OPT_ARG)
+            {
+              if (*(optend + 1))
+              {
+                /* The rest of the option is option argument */
+                argument= optend + 1;
+                /* This is in effect a jump out of the outer loop */
+                optend= (char*) " ";
+              }
+              else
+              {
+                if (optp->arg_type == OPT_ARG)
+                {
+                  if (optp->var_type == GET_BOOL)
+                    *((my_bool*) optp->value)= (my_bool) 1;
+                  if (get_one_option && get_one_option(optp->id, optp, argument))
+                    return (EXIT_UNSPECIFIED_ERROR);
+                  continue;
+                }
+                /* Check if there are more arguments after this one */
+                if (!pos[1])
+                {
+                  if (my_getopt_print_errors)
+                    my_getopt_error_reporter(ERROR_LEVEL,
+                                             "%s: option '-%c' requires an argument",
+                                             my_progname, optp->id);
+                  return (EXIT_ARGUMENT_REQUIRED);
+                }
+                argument= *++pos;
+                (*argc)--;
+                /* the other loop will break, because *optend + 1 == 0 */
+              }
+            }
+            if ((error= setval(optp, optp->value, argument,
+                               set_maximum_value)))
+              return (error);
+            if (get_one_option && get_one_option(optp->id, optp, argument))
+              return (EXIT_UNSPECIFIED_ERROR);
+            break;
+          }
+        }
+        if (!opt_found)
+        {
+          if (my_getopt_skip_unknown)
+          {
+            /*
+              We are currently parsing a single argv[] argument
+              of the form "-XYZ".
+              One or the argument found (say Y) is not an option.
+              Hack the string "-XYZ" to make a "-YZ" substring in it,
+              and push that to the output as an unrecognized parameter.
+            */
+            DBUG_ASSERT(optend > *pos);
+            DBUG_ASSERT(optend >= cur_arg);
+            DBUG_ASSERT(optend <= *pos + strlen(*pos));
+            DBUG_ASSERT(*optend);
+            optend--;
+            optend[0]= '-'; /* replace 'X' or '-' by '-' */
+            (*argv)[argvpos++]= optend;
+            /*
+              Do not continue to parse at the current "-XYZ" argument,
+              skip to the next argv[] argument instead.
+            */
+            optend= (char*) " ";
+          }
+          else
+          {
+            if (my_getopt_print_errors)
+              my_getopt_error_reporter(ERROR_LEVEL,
+                                       "%s: unknown option '-%c'",
+                                       my_progname, *optend);
+            return (EXIT_UNKNOWN_OPTION);
+          }
+        }
       }
-      if ((error= setval(optp, value, argument, set_maximum_value)))
-	return error;
-      if (get_one_option && get_one_option(optp->id, optp, argument))
-        return EXIT_UNSPECIFIED_ERROR;
-
-      (*argc)--; /* option handled (long), decrease argument count */
+      if (opt_found)
+        (*argc)--; /* option handled (short), decrease argument count */
+      continue;
     }
-    else /* non-option found */
-      (*argv)[argvpos++]= cur_arg;
+    if ((error= setval(optp, value, argument, set_maximum_value)))
+      return (error);
+    if (get_one_option && get_one_option(optp->id, optp, argument))
+      return (EXIT_UNSPECIFIED_ERROR);
+
+    (*argc)--; /* option handled (long), decrease argument count */
   }
-  /*
-    Destroy the first, already handled option, so that programs that look
-    for arguments in 'argv', without checking 'argc', know when to stop.
-    Items in argv, before the destroyed one, are all non-option -arguments
-    to the program, yet to be (possibly) handled.
-  */
-  (*argv)[argvpos]= 0;
-  return 0;
+  else /* non-option found */
+    (*argv)[argvpos++]= cur_arg;
+}
+/*
+  Destroy the first, already handled option, so that programs that look
+  for arguments in 'argv', without checking 'argc', know when to stop.
+  Items in argv, before the destroyed one, are all non-option -arguments
+  to the program, yet to be (possibly) handled.
+*/
+(*argv)[argvpos]= 0;
+return (0);
 }
 
 
@@ -581,7 +581,7 @@ static char *check_struct_option(char *c
   ptr= strcend(cur_arg + 1, '.'); /* Skip the first character */
   end= strcend(cur_arg, '=');
 
-  /* 
+  /*
      If the first dot is after an equal sign, then it is part
      of a variable value and the option is not a struct option.
      Also, if the last character in the string before the ending
@@ -637,7 +637,7 @@ static my_bool get_bool_argument(const s
 */
 
 static int setval(const struct my_option *opts, void *value, char *argument,
-		  my_bool set_maximum_value)
+      my_bool set_maximum_value)
 {
   int err= 0, res= 0;
 
@@ -737,7 +737,7 @@ static int setval(const struct my_option
         uint error_len;
 
         *((ulonglong*)value)=
-              find_set_from_flags(opts->typelib, opts->typelib->count, 
+              find_set_from_flags(opts->typelib, opts->typelib->count,
                                   *(ulonglong *)value, opts->def_value,
                                   argument, strlen(argument),
                                   &error, &error_len);
@@ -768,15 +768,15 @@ ret:
 }
 
 
-/* 
+/*
   Find option
 
   SYNOPSIS
     findopt()
-    optpat	Prefix of option to find (with - or _)
-    length	Length of optpat
-    opt_res	Options
-    ffname	Place for pointer to first found name
+    optpat  Prefix of option to find (with - or _)
+    length  Length of optpat
+    opt_res Options
+    ffname  Place for pointer to first found name
 
   IMPLEMENTATION
     Go through all options in the my_option struct. Return number
@@ -791,8 +791,8 @@ ret:
 */
 
 static int findopt(char *optpat, uint length,
-		   const struct my_option **opt_res,
-		   const char **ffname)
+       const struct my_option **opt_res,
+       const char **ffname)
 {
   uint count;
   const struct my_option *opt= *opt_res;
@@ -802,21 +802,21 @@ static int findopt(char *optpat, uint le
     if (!getopt_compare_strings(opt->name, optpat, length)) /* match found */
     {
       (*opt_res)= opt;
-      if (!opt->name[length])		/* Exact match */
-	return 1;
+      if (!opt->name[length])   /* Exact match */
+  return 1;
       if (!count)
       {
         /* We only need to know one prev */
-	count= 1;
-	*ffname= opt->name;
+  count= 1;
+  *ffname= opt->name;
       }
       else if (strcmp(*ffname, opt->name))
       {
-	/*
-	  The above test is to not count same option twice
-	  (see mysql.cc, option "help")
-	*/
-	count++;
+  /*
+    The above test is to not count same option twice
+    (see mysql.cc, option "help")
+  */
+  count++;
       }
     }
   }
@@ -824,7 +824,7 @@ static int findopt(char *optpat, uint le
 }
 
 
-/* 
+/*
   function: compare_strings
 
   Works like strncmp, other than 1.) considers '-' and '_' the same.
@@ -832,7 +832,7 @@ static int findopt(char *optpat, uint le
 */
 
 my_bool getopt_compare_strings(register const char *s, register const char *t,
-			       uint length)
+             uint length)
 {
   char const *end= s + length;
   for (;s != end ; s++, t++)
@@ -854,7 +854,7 @@ static longlong eval_num_suffix(char *ar
 {
   char *endchar;
   longlong num;
-  
+
   *error= 0;
   errno= 0;
   num= strtoll(argument, &endchar, 10);
@@ -874,15 +874,15 @@ static longlong eval_num_suffix(char *ar
   else if (*endchar)
   {
     fprintf(stderr,
-	    "Unknown suffix '%c' used for variable '%s' (value '%s')\n",
-	    *endchar, option_name, argument);
+      "Unknown suffix '%c' used for variable '%s' (value '%s')\n",
+      *endchar, option_name, argument);
     *error= 1;
     return 0;
   }
   return num;
 }
 
-/* 
+/*
   function: getopt_ll
 
   Evaluates and returns the value that user gave as an argument
@@ -1093,12 +1093,12 @@ static double getopt_double(char *arg, c
 
   SYNOPSIS
     init_one_value()
-    option		Option to initialize
-    value		Pointer to variable
+    option    Option to initialize
+    value   Pointer to variable
 */
 
 static void init_one_value(const struct my_option *option, void *variable,
-			   longlong value)
+         longlong value)
 {
   DBUG_ENTER("init_one_value");
   switch ((option->var_type & GET_TYPE_MASK)) {
@@ -1169,12 +1169,12 @@ static void init_one_value(const struct
 
   SYNOPSIS
     init_one_value()
-    option		Option to initialize
-    value		Pointer to variable
+    option    Option to initialize
+    value   Pointer to variable
 */
 
 static void fini_one_value(const struct my_option *option, void *variable,
-			   longlong value __attribute__ ((unused)))
+         longlong value __attribute__ ((unused)))
 {
   DBUG_ENTER("fini_one_value");
   switch ((option->var_type & GET_TYPE_MASK)) {
@@ -1195,12 +1195,12 @@ void my_cleanup_options(const struct my_
 }
 
 
-/* 
+/*
   initialize all variables to their default values
 
   SYNOPSIS
     init_variables()
-    options		Array of options
+    options   Array of options
 
   NOTES
     We will initialize the value that is pointed to by options->value.
@@ -1224,7 +1224,7 @@ static void init_variables(const struct
     if (options->u_max_value)
       init_one_value(options, options->u_max_value, options->max_value);
     value= (options->var_type & GET_ASK_ADDR ?
-		  (*getopt_get_addr)("", 0, options, 0) : options->value);
+      (*getopt_get_addr)("", 0, options, 0) : options->value);
     if (value)
       init_one_value(options, value, options->def_value);
   }
@@ -1269,10 +1269,10 @@ void my_print_help(const struct my_optio
       printf("--");
       col+= 2 + print_name(optp);
       if (optp->arg_type == NO_ARG ||
-	  (optp->var_type & GET_TYPE_MASK) == GET_BOOL)
+    (optp->var_type & GET_TYPE_MASK) == GET_BOOL)
       {
-	putchar(' ');
-	col++;
+  putchar(' ');
+  col++;
       }
       else if ((optp->var_type & GET_TYPE_MASK) == GET_STR       ||
                (optp->var_type & GET_TYPE_MASK) == GET_STR_ALLOC ||
@@ -1280,20 +1280,20 @@ void my_print_help(const struct my_optio
                (optp->var_type & GET_TYPE_MASK) == GET_SET       ||
                (optp->var_type & GET_TYPE_MASK) == GET_FLAGSET    )
       {
-	printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "",
-	       optp->arg_type == OPT_ARG ? "]" : "");
-	col+= (optp->arg_type == OPT_ARG) ? 8 : 6;
+  printf("%s=name%s ", optp->arg_type == OPT_ARG ? "[" : "",
+         optp->arg_type == OPT_ARG ? "]" : "");
+  col+= (optp->arg_type == OPT_ARG) ? 8 : 6;
       }
       else
       {
-	printf("%s=#%s ", optp->arg_type == OPT_ARG ? "[" : "",
-	       optp->arg_type == OPT_ARG ? "]" : "");
-	col+= (optp->arg_type == OPT_ARG) ? 5 : 3;
+  printf("%s=#%s ", optp->arg_type == OPT_ARG ? "[" : "",
+         optp->arg_type == OPT_ARG ? "]" : "");
+  col+= (optp->arg_type == OPT_ARG) ? 5 : 3;
       }
       if (col > name_space && optp->comment && *optp->comment)
       {
-	putchar('\n');
-	col= 0;
+  putchar('\n');
+  col= 0;
       }
     }
     for (; col < name_space; col++)
@@ -1304,13 +1304,13 @@ void my_print_help(const struct my_optio
 
       while ((uint) (end - comment) > comment_space)
       {
-	for (line_end= comment + comment_space; *line_end != ' '; line_end--);
-	for (; comment != line_end; comment++)
-	  putchar(*comment);
-	comment++; /* skip the space, as a newline will take it's place now */
-	putchar('\n');
-	for (col= 0; col < name_space; col++)
-	  putchar(' ');
+  for (line_end= comment + comment_space; *line_end != ' '; line_end--);
+  for (; comment != line_end; comment++)
+    putchar(*comment);
+  comment++; /* skip the space, as a newline will take it's place now */
+  putchar('\n');
+  for (col= 0; col < name_space; col++)
+    putchar(' ');
       }
       printf("%s", comment);
     }
@@ -1354,75 +1354,75 @@ void my_print_variables(const struct my_
   for (length=1; length < 75; length++)
     putchar(length == name_space ? ' ' : '-');
   putchar('\n');
-  
+
   for (optp= options; optp->name; optp++)
   {
     void *value= (optp->var_type & GET_ASK_ADDR ?
-		  (*getopt_get_addr)("", 0, optp, 0) : optp->value);
+      (*getopt_get_addr)("", 0, optp, 0) : optp->value);
     if (value)
     {
       length= print_name(optp);
       for (; length < name_space; length++)
-	putchar(' ');
+  putchar(' ');
       switch ((optp->var_type & GET_TYPE_MASK)) {
       case GET_SET:
         if (!(llvalue= *(ulonglong*) value))
-	  printf("%s\n", "");
-	else
+    printf("%s\n", "");
+  else
         for (nr= 0; llvalue && nr < optp->typelib->count; nr++, llvalue >>=1)
-	{
-	  if (llvalue & 1)
+  {
+    if (llvalue & 1)
             printf( llvalue > 1 ? "%s," : "%s\n", get_type(optp->typelib, nr));
-	}
-	break;
+  }
+  break;
       case GET_FLAGSET:
         llvalue= *(ulonglong*) value;
         for (nr= 0; llvalue && nr < optp->typelib->count; nr++, llvalue >>=1)
-	{
+  {
           printf("%s%s=", (nr ? "," : ""), get_type(optp->typelib, nr));
-	  printf(llvalue & 1 ? "on" : "off");
-	}
+    printf(llvalue & 1 ? "on" : "off");
+  }
         printf("\n");
-	break;
+  break;
       case GET_ENUM:
         printf("%s\n", get_type(optp->typelib, *(ulong*) value));
-	break;
+  break;
       case GET_STR:
       case GET_STR_ALLOC:                    /* fall through */
-	printf("%s\n", *((char**) value) ? *((char**) value) :
-	       "(No default value)");
-	break;
+  printf("%s\n", *((char**) value) ? *((char**) value) :
+         "(No default value)");
+  break;
       case GET_BOOL:
-	printf("%s\n", *((my_bool*) value) ? "TRUE" : "FALSE");
-	break;
+  printf("%s\n", *((my_bool*) value) ? "TRUE" : "FALSE");
+  break;
       case GET_INT:
-	printf("%d\n", *((int*) value));
-	break;
+  printf("%d\n", *((int*) value));
+  break;
       case GET_UINT:
-	printf("%d\n", *((uint*) value));
-	break;
+  printf("%d\n", *((uint*) value));
+  break;
       case GET_LONG:
-	printf("%ld\n", *((long*) value));
-	break;
+  printf("%ld\n", *((long*) value));
+  break;
       case GET_ULONG:
-	printf("%lu\n", *((ulong*) value));
-	break;
+  printf("%lu\n", *((ulong*) value));
+  break;
       case GET_LL:
-	printf("%s\n", llstr(*((longlong*) value), buff));
-	break;
+  printf("%s\n", llstr(*((longlong*) value), buff));
+  break;
       case GET_ULL:
-	longlong2str(*((ulonglong*) value), buff, 10);
-	printf("%s\n", buff);
-	break;
+  longlong2str(*((ulonglong*) value), buff, 10);
+  printf("%s\n", buff);
+  break;
       case GET_DOUBLE:
-	printf("%g\n", *(double*) value);
-	break;
+  printf("%g\n", *(double*) value);
+  break;
       case GET_NO_ARG:
-	printf("(No default value)\n");
-	break;
+  printf("(No default value)\n");
+  break;
       default:
-	printf("(Disabled)\n");
-	break;
+  printf("(Disabled)\n");
+  break;
       }
     }
   }

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2011-11-01 16:33:58 +0000
+++ b/sql/mysqld.cc	2011-11-06 05:19:53 +0000
@@ -4761,8 +4761,14 @@ int mysqld_main(int argc, char **argv)
   my_getopt_error_reporter= buffered_option_error_reporter;
   my_charset_error_reporter= buffered_option_error_reporter;
 
+  /*
+    Initialize the array of performance schema instrument configurations.
+  */
+  init_pfs_instrument_array();
+
   ho_error= handle_options(&remaining_argc, &remaining_argv,
-                           (my_option*)(all_early_options.buffer), NULL);
+                           (my_option*)(all_early_options.buffer),
+                           mysqld_get_one_option);
   delete_dynamic(&all_early_options);
   if (ho_error == 0)
   {
@@ -7827,6 +7833,12 @@ mysqld_get_one_option(int optid,
   case OPT_PLUGIN_LOAD_ADD:
     opt_plugin_load_list_ptr->push_back(new i_string(argument));
     break;
+
+  case OPT_PFS_INSTRUMENT:
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+    add_pfs_instr_to_array(argument);
+#endif
+    break;
   }
   return 0;
 }

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2011-11-01 16:33:58 +0000
+++ b/sql/mysqld.h	2011-11-06 05:19:53 +0000
@@ -558,7 +558,8 @@ enum options_mysqld
   OPT_PLUGIN_LOAD,
   OPT_PLUGIN_LOAD_ADD,
   OPT_SSL_CRL,
-  OPT_SSL_CRLPATH
+  OPT_SSL_CRLPATH,
+  OPT_PFS_INSTRUMENT
 };
 
 

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2011-11-02 20:43:37 +0000
+++ b/sql/sys_vars.cc	2011-11-06 05:19:53 +0000
@@ -85,6 +85,15 @@ static Sys_var_mybool Sys_pfs_enabled(
        CMD_LINE(OPT_ARG), DEFAULT(FALSE),
        PFS_TRAILING_PROPERTIES);
 
+static Sys_var_charptr Sys_pfs_instrument(
+       "pfs_instrument",
+       "Enable pfs instrument.",
+       READ_ONLY NOT_VISIBLE GLOBAL_VAR(pfs_param.m_pfs_instrument),
+       CMD_LINE(OPT_ARG, OPT_PFS_INSTRUMENT),
+       IN_FS_CHARSET,
+       DEFAULT(""),
+       PFS_TRAILING_PROPERTIES);
+
 static Sys_var_mybool Sys_pfs_consumer_events_stages_current(
        "performance_schema_consumer_events_stages_current",
        "Enable the events_stages_current consumer.",

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2011-10-19 17:56:04 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2011-11-06 05:19:53 +0000
@@ -46,6 +46,8 @@
 */
 my_bool pfs_enabled= TRUE;
 
+DYNAMIC_ARRAY pfs_instr_init_array;
+
 /**
   Current number of elements in mutex_class_array.
   This global variable is written to during:
@@ -585,6 +587,29 @@ static void init_instr_class(PFS_instr_c
   klass->m_type= class_type;
 }
 
+/**
+  Set user-defined configuration values for an instrument
+*/
+static void config_instr_class(PFS_instr_class *entry)
+{
+  for (uint i= 0; i < pfs_instr_init_array.elements; i++)
+  {
+    PFS_instr_init* e;
+    get_dynamic(&pfs_instr_init_array, (uchar*)&e, i);
+
+    if (!e->m_set && (e->m_name_length == entry->m_name_length))
+    {
+      if (!strncmp(e->m_name, entry->m_name, e->m_name_length))
+      {
+        entry->m_enabled= e->m_enabled;
+        entry->m_timed= e->m_timed;
+        e->m_set= true;
+        break;
+      }
+    }
+  }
+}
+
 #define REGISTER_CLASS_BODY_PART(INDEX, ARRAY, MAX, NAME, NAME_LENGTH) \
   for (INDEX= 0; INDEX < MAX; INDEX++)                                 \
   {                                                                    \
@@ -650,6 +675,10 @@ PFS_sync_key register_mutex_class(const
     entry->m_lock_stat.reset();
     entry->m_event_name_index= mutex_class_start + index;
     entry->m_singleton= NULL;
+
+    /* Set user-defined configuration options for this instrument */
+    config_instr_class(entry);
+
     /*
       Now that this entry is populated, advertise it
 

=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h	2011-10-19 17:56:04 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2011-11-06 05:19:53 +0000
@@ -39,6 +39,7 @@
 #define PFS_MAX_FULL_PREFIX_NAME_LENGTH 32
 
 #include <my_global.h>
+#include <my_sys.h>
 #include <mysql/psi/psi.h>
 #include "pfs_lock.h"
 #include "pfs_stat.h"
@@ -78,6 +79,27 @@ enum PFS_class_type
   PFS_CLASS_SOCKET= 8
 };
 
+/** User-defined instrument configuration. */
+struct PFS_instr_init
+{
+  /* Instrument name */
+  char *m_name;
+  /* Name length */
+  uint m_name_length;
+  /* Instrument option value: ON, OFF, TIMED */
+  char *m_value;
+  /* Value length */
+  uint m_value_length;
+  /** Enabled flag. */
+  bool m_enabled;
+  /** Timed flag. */
+  bool m_timed;
+  /** True if value has been applied*/
+  bool m_set;
+};
+
+extern DYNAMIC_ARRAY pfs_instr_init_array;
+
 struct PFS_thread;
 
 extern uint mutex_class_start;

=== modified file 'storage/perfschema/pfs_server.cc'
--- a/storage/perfschema/pfs_server.cc	2011-11-02 21:31:56 +0000
+++ b/storage/perfschema/pfs_server.cc	2011-11-06 05:19:53 +0000
@@ -109,7 +109,6 @@ initialize_performance_schema(const PFS_
 
   /** Default values for SETUP_CONSUMERS */
   flag_events_stages_current=          param->m_consumer_events_stages_current_enabled;
-  flag_events_stages_current=          param->m_consumer_events_stages_current_enabled;
   flag_events_stages_history=          param->m_consumer_events_stages_history_enabled;
   flag_events_stages_history_long=     param->m_consumer_events_stages_history_long_enabled;
   flag_events_statements_current=      param->m_consumer_events_statements_current_enabled;
@@ -188,4 +187,80 @@ void shutdown_performance_schema(void)
   }
 }
 
+/**
+  Initialize the dynamic array used to hold PFS_INSTRUMENT configuration
+  options.
+*/
+void init_pfs_instrument_array()
+{
+  my_init_dynamic_array(&pfs_instr_init_array, sizeof(PFS_instr_init*), 10, 10);
+}
+
+/**
+  Process one PFS_INSTRUMENT configuration string. Isolate the instrument name,
+  evaluate the option value, and store both in a dynamic array.
+*/
+bool add_pfs_instr_to_array(const char* instr_arg)
+{
+  const char* eq = strchr(instr_arg, '=');
+  if (!eq) return 1;
+  int arg_len= strlen(instr_arg);
+  int name_length= eq - instr_arg;      /* instrument name without '=' */
+  int value_length= arg_len - name_length - 1;
+  if (value_length <= 0) return 1;      /* option value required */
+    
+  /* Allocate structure plus string buffer plus null terminator */
+  PFS_instr_init* e = (PFS_instr_init*)my_malloc(sizeof(PFS_instr_init)
+                       + arg_len + 1, MYF(MY_WME));
+  if (!e) return 1;
+  
+  /* Copy the entire argument string into the string buffer */
+  e->m_name= (char*)e + sizeof(PFS_instr_init);
+  memcpy(e->m_name, instr_arg, arg_len);
+  e->m_name_length= name_length;
+  
+  /* Process the option value */
+  e->m_value= e->m_name + e->m_name_length + 1; /* one char past the '=' */
+  e->m_value_length= value_length;
+
+  /* Set null terminators */
+  e->m_name[e->m_name_length]= '\0'; /* zap '=' */
+  e->m_value[e->m_value_length]= '\0';
+  
+  /* Set flags accordingly */
+  e->m_enabled= true;
+  e->m_timed= true;
+  e->m_set= false;
+
+  if (!my_strcasecmp(&my_charset_latin1, e->m_value, "counted"))
+  {
+    e->m_enabled= true;
+    e->m_timed= false;
+  }
+  else
+  if (!my_strcasecmp(&my_charset_latin1, e->m_value, "true") ||
+      !my_strcasecmp(&my_charset_latin1, e->m_value, "on") ||
+      !my_strcasecmp(&my_charset_latin1, e->m_value, "1") ||
+      !my_strcasecmp(&my_charset_latin1, e->m_value, "enabled"))
+  {
+    e->m_enabled= true;
+    e->m_timed= true;
+  }
+  else
+  if (!my_strcasecmp(&my_charset_latin1, e->m_value, "false") ||
+      !my_strcasecmp(&my_charset_latin1, e->m_value, "off") ||
+      !my_strcasecmp(&my_charset_latin1, e->m_value, "0") ||
+      !my_strcasecmp(&my_charset_latin1, e->m_value, "disabled"))
+  {
+    e->m_enabled= false;
+    e->m_timed= false;
+  }
+
+  if (insert_dynamic(&pfs_instr_init_array, &e))
+  {
+    my_free(e);
+    return 1;
+  }
+  return 0;
+}
 

=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h	2011-11-02 20:43:37 +0000
+++ b/storage/perfschema/pfs_server.h	2011-11-06 05:19:53 +0000
@@ -123,6 +123,8 @@ struct PFS_global_param
   bool m_consumer_events_waits_history_long_enabled;
   bool m_consumer_global_instrumentation_enabled;
   bool m_consumer_thread_instrumentation_enabled;
+
+  char *m_pfs_instrument; //cwp test
   /**
     Maximum number of instrumented mutex classes.
     @sa mutex_class_lost.
@@ -260,6 +262,17 @@ void initialize_performance_schema_acl(b
 void check_performance_schema();
 
 /**
+  Initialize the dynamic array holding individual instrument settings collected
+  from the server configuration options.
+*/
+void init_pfs_instrument_array();
+
+/**
+  Process one PFS_INSTRUMENT configuration string.
+*/
+bool add_pfs_instr_to_array(const char* instr_arg);
+
+/**
   Shutdown the performance schema.
 */
 void shutdown_performance_schema();

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk-wl5461 branch (chris.powers:3424 to 3425) WL#5461Christopher Powers7 Nov