List:Commits« Previous MessageNext Message »
From:Marc Alff Date:May 28 2009 9:35pm
Subject:bzr push into mysql-6.0-perfschema branch (marc.alff:3155 to 3156) WL#4876
View as plain text  
 3156 Marc Alff	2009-05-28
      WL#4876 Parse options before initializing mysys
      modified:
        include/my_pthread.h
        include/my_sys.h
        libmysqld/lib_sql.cc
        mysql-test/suite/perfschema/r/start_server32_off.result
        mysql-test/suite/perfschema/r/start_server64_off.result
        mysql-test/suite/perfschema/t/disabled.def
        mysys/my_init.c
        mysys/my_thr_init.c
        sql/mysqld.cc
        sql/sql_plugin.cc
        sql/sql_plugin.h

 3155 Marc Alff	2009-05-27
      Misc cleanup
      removed:
        include/mysql/psi/mysql_mutex.h
      added:
        include/mysql/psi/mysql_thread.h
      modified:
        include/Makefile.am
        include/my_pthread.h
        storage/perfschema/pfs.cc
        storage/perfschema/pfs.h
        storage/perfschema/pfs_engine_table.h
        storage/perfschema/pfs_events_waits.cc
        storage/perfschema/pfs_instr_class.cc
        storage/perfschema/pfs_instr_class.h
        storage/perfschema/pfs_server.cc
        storage/perfschema/pfs_stat.h
        storage/perfschema/table_all_instr.h
        storage/perfschema/table_events_waits.cc
        storage/perfschema/table_file_instances.cc
        storage/perfschema/table_file_instances.h

=== modified file 'include/my_pthread.h'
--- a/include/my_pthread.h	2009-05-27 20:50:25 +0000
+++ b/include/my_pthread.h	2009-05-28 21:33:45 +0000
@@ -621,6 +621,8 @@ extern pthread_mutexattr_t my_errorcheck
 typedef ulong my_thread_id;
 
 extern void my_threadattr_global_init(void);
+extern my_bool my_thread_basic_global_init(void);
+extern my_bool my_thread_basic_global_reinit(void);
 extern my_bool my_thread_global_init(void);
 extern void my_reinit_mutexes(void);
 extern void my_thread_global_end(void);

=== modified file 'include/my_sys.h'
--- a/include/my_sys.h	2009-05-18 15:36:08 +0000
+++ b/include/my_sys.h	2009-05-28 21:33:45 +0000
@@ -728,6 +728,7 @@ extern int my_error_register(const char
 extern const char **my_error_unregister(int first, int last);
 extern void my_message(uint my_err, const char *str,myf MyFlags);
 extern void my_message_no_curses(uint my_err, const char *str,myf MyFlags);
+extern my_bool my_basic_init(void);
 extern my_bool my_init(void);
 extern void my_end(int infoflag);
 extern int my_redel(const char *from, const char *to, int MyFlags);

=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2009-05-21 19:42:38 +0000
+++ b/libmysqld/lib_sql.cc	2009-05-28 21:33:45 +0000
@@ -498,7 +498,13 @@ int init_embedded_server(int argc, char
   */
   logger.init_base();
 
-  if (init_common_variables("my", *argcp, *argvp, (const char **)groups))
+  orig_argc= *argcp;
+  orig_argv= *argvp;
+  load_defaults("my", (const char **)groups, argcp, argvp);
+  defaults_argc= *argcp;
+  defaults_argv= *argvp;
+
+  if (init_common_variables())
   {
     mysql_server_end();
     return 1;

=== modified file 'mysql-test/suite/perfschema/r/start_server32_off.result'
--- a/mysql-test/suite/perfschema/r/start_server32_off.result	2009-04-17 18:44:53 +0000
+++ b/mysql-test/suite/perfschema/r/start_server32_off.result	2009-05-28 21:33:45 +0000
@@ -10,34 +10,34 @@ if (version() like "%perfschema%", "Comp
 Compiled In
 show engine PERFORMANCE_SCHEMA status;
 Type	Name	Status
-performance_schema	EVENTS_WAITS_CURRENT.ROW_SIZE	92
+performance_schema	EVENTS_WAITS_CURRENT.ROW_SIZE	84
 performance_schema	EVENTS_WAITS_CURRENT.ROW_COUNT	0
-performance_schema	EVENTS_WAITS_HISTORY.ROW_SIZE	84
+performance_schema	EVENTS_WAITS_HISTORY.ROW_SIZE	76
 performance_schema	EVENTS_WAITS_HISTORY.ROW_COUNT	0
 performance_schema	EVENTS_WAITS_HISTORY.MEMORY	0
-performance_schema	EVENTS_WAITS_HISTORY_LONG.ROW_SIZE	84
+performance_schema	EVENTS_WAITS_HISTORY_LONG.ROW_SIZE	76
 performance_schema	EVENTS_WAITS_HISTORY_LONG.ROW_COUNT	0
 performance_schema	EVENTS_WAITS_HISTORY_LONG.MEMORY	0
-performance_schema	(PFS_MUTEX_INFO).ROW_SIZE	228
-performance_schema	(PFS_MUTEX_INFO).ROW_COUNT	0
-performance_schema	(PFS_MUTEX_INFO).ROW_LOST	0
-performance_schema	(PFS_MUTEX_INFO).MEMORY	0
-performance_schema	(PFS_RWLOCK_INFO).ROW_SIZE	268
-performance_schema	(PFS_RWLOCK_INFO).ROW_COUNT	0
-performance_schema	(PFS_RWLOCK_INFO).ROW_LOST	0
-performance_schema	(PFS_RWLOCK_INFO).MEMORY	0
-performance_schema	(PFS_COND_INFO).ROW_SIZE	204
-performance_schema	(PFS_COND_INFO).ROW_COUNT	0
-performance_schema	(PFS_COND_INFO).ROW_LOST	0
-performance_schema	(PFS_COND_INFO).MEMORY	0
-performance_schema	(PFS_THREAD_INFO).ROW_SIZE	140
-performance_schema	(PFS_THREAD_INFO).ROW_COUNT	0
-performance_schema	(PFS_THREAD_INFO).ROW_LOST	0
-performance_schema	(PFS_THREAD_INFO).MEMORY	0
-performance_schema	(PFS_FILE_INFO).ROW_SIZE	220
-performance_schema	(PFS_FILE_INFO).ROW_COUNT	0
-performance_schema	(PFS_FILE_INFO).ROW_LOST	0
-performance_schema	(PFS_FILE_INFO).MEMORY	0
+performance_schema	(PFS_MUTEX_CLASS).ROW_SIZE	224
+performance_schema	(PFS_MUTEX_CLASS).ROW_COUNT	0
+performance_schema	(PFS_MUTEX_CLASS).ROW_LOST	0
+performance_schema	(PFS_MUTEX_CLASS).MEMORY	0
+performance_schema	(PFS_RWLOCK_CLASS).ROW_SIZE	264
+performance_schema	(PFS_RWLOCK_CLASS).ROW_COUNT	0
+performance_schema	(PFS_RWLOCK_CLASS).ROW_LOST	0
+performance_schema	(PFS_RWLOCK_CLASS).MEMORY	0
+performance_schema	(PFS_COND_CLASS).ROW_SIZE	200
+performance_schema	(PFS_COND_CLASS).ROW_COUNT	0
+performance_schema	(PFS_COND_CLASS).ROW_LOST	0
+performance_schema	(PFS_COND_CLASS).MEMORY	0
+performance_schema	(PFS_THREAD_CLASS).ROW_SIZE	136
+performance_schema	(PFS_THREAD_CLASS).ROW_COUNT	0
+performance_schema	(PFS_THREAD_CLASS).ROW_LOST	0
+performance_schema	(PFS_THREAD_CLASS).MEMORY	0
+performance_schema	(PFS_FILE_CLASS).ROW_SIZE	220
+performance_schema	(PFS_FILE_CLASS).ROW_COUNT	0
+performance_schema	(PFS_FILE_CLASS).ROW_LOST	0
+performance_schema	(PFS_FILE_CLASS).MEMORY	0
 performance_schema	(PFS_MUTEX).ROW_SIZE	108
 performance_schema	(PFS_MUTEX).ROW_COUNT	0
 performance_schema	(PFS_MUTEX).ROW_LOST	0
@@ -50,11 +50,11 @@ performance_schema	(PFS_COND).ROW_SIZE	7
 performance_schema	(PFS_COND).ROW_COUNT	0
 performance_schema	(PFS_COND).ROW_LOST	0
 performance_schema	(PFS_COND).MEMORY	0
-performance_schema	(PFS_THREAD).ROW_SIZE	332
+performance_schema	(PFS_THREAD).ROW_SIZE	304
 performance_schema	(PFS_THREAD).ROW_COUNT	0
 performance_schema	(PFS_THREAD).ROW_LOST	0
 performance_schema	(PFS_THREAD).MEMORY	0
-performance_schema	(PFS_FILE).ROW_SIZE	1124
+performance_schema	(PFS_FILE).ROW_SIZE	612
 performance_schema	(PFS_FILE).ROW_COUNT	0
 performance_schema	(PFS_FILE).ROW_LOST	0
 performance_schema	(PFS_FILE).MEMORY	0
@@ -91,8 +91,8 @@ select * from performance_schema.SETUP_T
 NAME	TIMER_NAME
 Wait	CYCLE
 select * from performance_schema.EVENTS_WAITS_CURRENT;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 select * from performance_schema.EVENTS_WAITS_HISTORY;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS
 select * from performance_schema.EVENTS_WAITS_HISTORY_LONG;
-THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES
+THREAD_ID	EVENT_ID	EVENT_NAME	SOURCE	TIMER_START	TIMER_END	TIMER_WAIT	SPINS	OBJECT_SCHEMA	OBJECT_NAME	OBJECT_TYPE	OBJECT_INSTANCE_BEGIN	NESTING_EVENT_ID	OPERATION	NUMBER_OF_BYTES	FLAGS

=== modified file 'mysql-test/suite/perfschema/r/start_server64_off.result'
--- a/mysql-test/suite/perfschema/r/start_server64_off.result	2009-04-17 18:44:53 +0000
+++ b/mysql-test/suite/perfschema/r/start_server64_off.result	2009-05-28 21:33:45 +0000
@@ -18,26 +18,26 @@ performance_schema	EVENTS_WAITS_HISTORY.
 performance_schema	EVENTS_WAITS_HISTORY_LONG.ROW_SIZE	120
 performance_schema	EVENTS_WAITS_HISTORY_LONG.ROW_COUNT	0
 performance_schema	EVENTS_WAITS_HISTORY_LONG.MEMORY	0
-performance_schema	(PFS_MUTEX_INFO).ROW_SIZE	248
-performance_schema	(PFS_MUTEX_INFO).ROW_COUNT	0
-performance_schema	(PFS_MUTEX_INFO).ROW_LOST	0
-performance_schema	(PFS_MUTEX_INFO).MEMORY	0
-performance_schema	(PFS_RWLOCK_INFO).ROW_SIZE	296
-performance_schema	(PFS_RWLOCK_INFO).ROW_COUNT	0
-performance_schema	(PFS_RWLOCK_INFO).ROW_LOST	0
-performance_schema	(PFS_RWLOCK_INFO).MEMORY	0
-performance_schema	(PFS_COND_INFO).ROW_SIZE	216
-performance_schema	(PFS_COND_INFO).ROW_COUNT	0
-performance_schema	(PFS_COND_INFO).ROW_LOST	0
-performance_schema	(PFS_COND_INFO).MEMORY	0
-performance_schema	(PFS_THREAD_INFO).ROW_SIZE	140
-performance_schema	(PFS_THREAD_INFO).ROW_COUNT	0
-performance_schema	(PFS_THREAD_INFO).ROW_LOST	0
-performance_schema	(PFS_THREAD_INFO).MEMORY	0
-performance_schema	(PFS_FILE_INFO).ROW_SIZE	240
-performance_schema	(PFS_FILE_INFO).ROW_COUNT	0
-performance_schema	(PFS_FILE_INFO).ROW_LOST	0
-performance_schema	(PFS_FILE_INFO).MEMORY	0
+performance_schema	(PFS_MUTEX_CLASS).ROW_SIZE	248
+performance_schema	(PFS_MUTEX_CLASS).ROW_COUNT	0
+performance_schema	(PFS_MUTEX_CLASS).ROW_LOST	0
+performance_schema	(PFS_MUTEX_CLASS).MEMORY	0
+performance_schema	(PFS_RWLOCK_CLASS).ROW_SIZE	296
+performance_schema	(PFS_RWLOCK_CLASS).ROW_COUNT	0
+performance_schema	(PFS_RWLOCK_CLASS).ROW_LOST	0
+performance_schema	(PFS_RWLOCK_CLASS).MEMORY	0
+performance_schema	(PFS_COND_CLASS).ROW_SIZE	216
+performance_schema	(PFS_COND_CLASS).ROW_COUNT	0
+performance_schema	(PFS_COND_CLASS).ROW_LOST	0
+performance_schema	(PFS_COND_CLASS).MEMORY	0
+performance_schema	(PFS_THREAD_CLASS).ROW_SIZE	136
+performance_schema	(PFS_THREAD_CLASS).ROW_COUNT	0
+performance_schema	(PFS_THREAD_CLASS).ROW_LOST	0
+performance_schema	(PFS_THREAD_CLASS).MEMORY	0
+performance_schema	(PFS_FILE_CLASS).ROW_SIZE	240
+performance_schema	(PFS_FILE_CLASS).ROW_COUNT	0
+performance_schema	(PFS_FILE_CLASS).ROW_LOST	0
+performance_schema	(PFS_FILE_CLASS).MEMORY	0
 performance_schema	(PFS_MUTEX).ROW_SIZE	136
 performance_schema	(PFS_MUTEX).ROW_COUNT	0
 performance_schema	(PFS_MUTEX).ROW_LOST	0
@@ -50,7 +50,7 @@ performance_schema	(PFS_COND).ROW_SIZE	8
 performance_schema	(PFS_COND).ROW_COUNT	0
 performance_schema	(PFS_COND).ROW_LOST	0
 performance_schema	(PFS_COND).MEMORY	0
-performance_schema	(PFS_THREAD).ROW_SIZE	496
+performance_schema	(PFS_THREAD).ROW_SIZE	488
 performance_schema	(PFS_THREAD).ROW_COUNT	0
 performance_schema	(PFS_THREAD).ROW_LOST	0
 performance_schema	(PFS_THREAD).MEMORY	0

=== modified file 'mysql-test/suite/perfschema/t/disabled.def'
--- a/mysql-test/suite/perfschema/t/disabled.def	2009-05-26 21:15:12 +0000
+++ b/mysql-test/suite/perfschema/t/disabled.def	2009-05-28 21:33:45 +0000
@@ -9,6 +9,4 @@
 #  Do not use any TAB characters for whitespace.
 #
 ##############################################################################
-start_server32_off  : WL#4876 Marc Need to parse command line
-start_server64_off  : WL#4876 Marc Need to parse command line
 

=== modified file 'mysys/my_init.c'
--- a/mysys/my_init.c	2009-05-07 06:42:31 +0000
+++ b/mysys/my_init.c	2009-05-28 21:33:45 +0000
@@ -43,6 +43,7 @@ static void netware_init();
 #endif
 
 my_bool my_init_done= 0;
+my_bool my_basic_init_done= 0;
 uint	mysys_usage_id= 0;              /* Incremented for each my_init() */
 ulong   my_thread_stack_size= 65536;
 
@@ -66,26 +67,11 @@ static MYSQL_FILE instrumented_stdout;
 static MYSQL_FILE instrumented_stderr;
 #endif
 
-/*
-  Init my_sys functions and my_sys variabels
-
-  SYNOPSIS
-    my_init()
-
-  RETURN
-    0  ok
-    1  Couldn't initialize environment
-*/
-
-my_bool my_init(void)
+my_bool my_basic_init(void)
 {
-  char * str;
-  if (my_init_done)
+  if (my_basic_init_done)
     return 0;
-  my_init_done=1;
-  mysys_usage_id++;
-  my_umask= 0660;                       /* Default umask for new files */
-  my_umask_dir= 0700;                   /* Default umask for new directories */
+  my_basic_init_done= 1;
 
 #ifdef HAVE_PSI_INTERFACE
   instrumented_stdin.m_file= stdin;
@@ -103,15 +89,10 @@ my_bool my_init(void)
   mysql_stderr= stderr;
 #endif
 
-  init_glob_errs();
-  my_progname_short= "unknown";
-  if (my_progname)
-    my_progname_short= my_progname + dirname_length(my_progname);
-
 #if defined(THREAD)
   (void) my_threadattr_global_init();
 #  if defined(SAFE_MUTEX)
-  safe_mutex_global_init();		/* Must be called early */
+  safe_mutex_global_init();             /* Must be called early */
 #  elif defined(MY_PTHREAD_FASTMUTEX)
   fastmutex_global_init();              /* Must be called early */
 #  endif
@@ -121,7 +102,44 @@ my_bool my_init(void)
 #if defined(HAVE_PTHREAD_INIT)
   pthread_init();                       /* Must be called before DBUG_ENTER */
 #endif
+  if (my_thread_basic_global_init())
+    return 1;
+#endif
 
+  return 0;
+}
+
+/*
+  Init my_sys functions and my_sys variabels
+
+  SYNOPSIS
+    my_init()
+
+  RETURN
+    0  ok
+    1  Couldn't initialize environment
+*/
+
+my_bool my_init(void)
+{
+  char * str;
+  if (my_init_done)
+    return 0;
+  my_init_done=1;
+
+  if (my_basic_init())
+    return 1;
+
+  mysys_usage_id++;
+  my_umask= 0660;                       /* Default umask for new files */
+  my_umask_dir= 0700;                   /* Default umask for new directories */
+
+  init_glob_errs();
+  my_progname_short= "unknown";
+  if (my_progname)
+    my_progname_short= my_progname + dirname_length(my_progname);
+
+#ifdef THREAD
   if (my_thread_global_init())
     return 1;
 #if !defined( __WIN__) && !defined(__NETWARE__)
@@ -276,6 +294,7 @@ Voluntary context switches %ld, Involunt
     WSACleanup();
 #endif /* __WIN__ */
   my_init_done=0;
+  my_basic_init_done= 0;
 } /* my_end */
 
 #ifndef DBUG_OFF

=== modified file 'mysys/my_thr_init.c'
--- a/mysys/my_thr_init.c	2009-05-12 03:15:02 +0000
+++ b/mysys/my_thr_init.c	2009-05-28 21:33:45 +0000
@@ -102,6 +102,77 @@ void my_threadattr_global_init(void)
 
 static uint get_thread_lib(void);
 
+static my_bool my_thread_basic_global_init_done= 0;
+
+my_bool my_thread_basic_global_init(void)
+{
+  int pth_ret;
+
+  if (my_thread_basic_global_init_done)
+    return 0;
+  my_thread_basic_global_init_done= 1;
+
+  /* Mutex used by my_thread_init() and after my_thread_destroy_mutex() */
+  mysql_mutex_init_extra(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST,
+                         "THR_LOCK_threads", MYF_NO_DEADLOCK_DETECTION);
+  mysql_mutex_init_extra(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST,
+                         "THR_LOCK_malloc", MYF_NO_DEADLOCK_DETECTION);
+  mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
+  mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST);
+
+  if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
+  {
+    fprintf(stderr, "Can't initialize threads: error %d\n", pth_ret);
+    return 1;
+  }
+
+  if (my_thread_init())
+    return 1;
+
+  return 0;
+}
+
+my_bool my_thread_basic_global_reinit(void)
+{
+  struct st_my_thread_var *tmp;
+
+  DBUG_ASSERT(my_thread_basic_global_init_done);
+
+  /*
+    These mutexes were initialized before the instrumentation.
+    Destroy + create them again, now that the instrumentation
+    is in place.
+    This is safe, since my_thread_basic_global_reinit()
+    is called before creating new threads, so the mutexes
+    are not in use.
+  */
+  mysql_mutex_destroy(&THR_LOCK_threads);
+  mysql_mutex_init_extra(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST,
+                         "THR_LOCK_threads", MYF_NO_DEADLOCK_DETECTION);
+
+  mysql_mutex_destroy(&THR_LOCK_malloc);
+  mysql_mutex_init_extra(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST,
+                         "THR_LOCK_malloc", MYF_NO_DEADLOCK_DETECTION);
+
+  mysql_mutex_destroy(&THR_LOCK_open);
+  mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
+
+  mysql_mutex_destroy(&THR_LOCK_charset);
+  mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST);
+
+  tmp= my_pthread_getspecific(struct st_my_thread_var*, THR_KEY_mysys);
+  DBUG_ASSERT(tmp);
+
+  mysql_mutex_destroy(&tmp->mutex);
+  mysql_mutex_init(key_my_thread_var_mutex, &tmp->mutex, MY_MUTEX_INIT_FAST);
+
+  mysql_cond_destroy(&tmp->suspend);
+  mysql_cond_init(key_my_thread_var_suspend, &tmp->suspend, NULL);
+
+  return 0;
+}
+
+
 /*
   initialize thread environment
 
@@ -115,14 +186,10 @@ static uint get_thread_lib(void);
 
 my_bool my_thread_global_init(void)
 {
-  int pth_ret;
-  thd_lib_detected= get_thread_lib();
-
-  if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0)
-  {
-    fprintf(stderr,"Can't initialize threads: error %d\n", pth_ret);
+  if (my_thread_basic_global_init())
     return 1;
-  }
+
+  thd_lib_detected= get_thread_lib();
 
 #ifdef TARGET_OS_LINUX
   /*
@@ -150,25 +217,13 @@ my_bool my_thread_global_init(void)
   }
 #endif /* TARGET_OS_LINUX */
 
-  /* Mutex used by my_thread_init() and after my_thread_destroy_mutex() */
-  mysql_mutex_init_extra(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST,
-                         "THR_LOCK_threads", MYF_NO_DEADLOCK_DETECTION);
-  mysql_mutex_init_extra(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST,
-                         "THR_LOCK_malloc", MYF_NO_DEADLOCK_DETECTION);
-
-  if (my_thread_init())
-    return 1;
-
-
   /* Mutex uses by mysys */
-  mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
   mysql_mutex_init(key_THR_LOCK_lock, &THR_LOCK_lock, MY_MUTEX_INIT_FAST);
   mysql_mutex_init(key_THR_LOCK_isam, &THR_LOCK_isam, MY_MUTEX_INIT_SLOW);
   mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW);
   mysql_mutex_init(key_THR_LOCK_myisam_log, &THR_LOCK_myisam_log, MY_MUTEX_INIT_SLOW);
   mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST);
   mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST);
-  mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST);
   mysql_mutex_init(key_THR_LOCK_time, &THR_LOCK_time, MY_MUTEX_INIT_FAST);
   mysql_cond_init(key_THR_COND_threads, &THR_COND_threads, NULL);
 
@@ -181,57 +236,6 @@ my_bool my_thread_global_init(void)
   return 0;
 }
 
-/* temporary, while waiting for WL#4876 */
-void my_reinit_mutexes(void)
-{
-  mysql_mutex_destroy(&THR_LOCK_threads);
-  mysql_mutex_init_extra(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST,
-                         "THR_LOCK_threads", MYF_NO_DEADLOCK_DETECTION);
-
-  mysql_mutex_destroy(&THR_LOCK_malloc);
-  mysql_mutex_init_extra(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST,
-                         "THR_LOCK_malloc", MYF_NO_DEADLOCK_DETECTION);
-
-  mysql_mutex_destroy(&THR_LOCK_open);
-  mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST);
-
-  mysql_mutex_destroy(&THR_LOCK_lock);
-  mysql_mutex_init(key_THR_LOCK_lock, &THR_LOCK_lock, MY_MUTEX_INIT_FAST);
-
-  mysql_mutex_destroy(&THR_LOCK_isam);
-  mysql_mutex_init(key_THR_LOCK_isam, &THR_LOCK_isam, MY_MUTEX_INIT_SLOW);
-
-  mysql_mutex_destroy(&THR_LOCK_myisam);
-  mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW);
-
-  mysql_mutex_destroy(&THR_LOCK_myisam_log);
-  mysql_mutex_init(key_THR_LOCK_myisam_log, &THR_LOCK_myisam_log, MY_MUTEX_INIT_SLOW);
-
-  mysql_mutex_destroy(&THR_LOCK_heap);
-  mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST);
-
-  mysql_mutex_destroy(&THR_LOCK_net);
-  mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST);
-
-  mysql_mutex_destroy(&THR_LOCK_charset);
-  mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST);
-
-  mysql_mutex_destroy(&THR_LOCK_time);
-  mysql_mutex_init(key_THR_LOCK_time, &THR_LOCK_time, MY_MUTEX_INIT_FAST);
-
-  mysql_cond_destroy(&THR_COND_threads);
-  mysql_cond_init(key_THR_COND_threads, &THR_COND_threads, NULL);
-
-#if !defined(HAVE_LOCALTIME_R) || !defined(HAVE_GMTIME_R)
-  mysql_mutex_destroy(&LOCK_localtime_r);
-  mysql_mutex_init(key_LOCK_localtime_r, &LOCK_localtime_r, MY_MUTEX_INIT_SLOW);
-#endif
-#ifndef HAVE_GETHOSTBYNAME_R
-  mysql_mutex_destroy(&LOCK_gethostbyname_r);
-  mysql_mutex_init(key_LOCK_gethostbyname_r, &LOCK_gethostbyname_r, MY_MUTEX_INIT_SLOW);
-#endif
-}
-
 /**
    Wait for all threads in system to die
    @fn    my_wait_for_other_threads_to_die()

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-05-26 21:15:12 +0000
+++ b/sql/mysqld.cc	2009-05-28 21:33:45 +0000
@@ -877,6 +877,7 @@ uint connection_count= 0;
 
 pthread_handler_t signal_hand(void *arg);
 static int mysql_init_variables(void);
+extern "C" void option_error_reporter(enum loglevel level, const char *format, ...);
 static int get_options(int *argc,char **argv);
 extern "C" my_bool mysqld_get_one_option(int, const struct my_option *, char *);
 static void set_server_version(void);
@@ -3324,8 +3325,7 @@ SHOW_VAR com_status_vars[]= {
   {NullS, NullS, SHOW_LONG}
 };
 
-static int init_common_variables(const char *conf_file_name, int argc,
-				 char **argv, const char **groups)
+static int init_common_variables()
 {
   char buff[FN_REFLEN], *s;
   umask(((~my_umask) & 0666));
@@ -3420,11 +3420,6 @@ static int init_common_variables(const c
                      SQLCOM_END + 8);
 #endif
 
-  orig_argc=argc;
-  orig_argv=argv;
-  load_defaults(conf_file_name, groups, &argc, &argv);
-  defaults_argv=argv;
-  defaults_argc=argc;
   if (get_options(&defaults_argc, defaults_argv))
     return 1;
   set_server_version();
@@ -4501,6 +4496,14 @@ static void test_lc_time_sz()
 }
 #endif//DBUG_OFF
 
+#ifdef HAVE_PERFORMANCE_SCHEMA
+extern struct my_option my_long_perfschema_options[];
+
+my_bool get_one_perfschema_option(int, const struct my_option *, char *)
+{
+  return 0;
+}
+#endif
 
 #ifdef __WIN__
 int win_main(int argc, char **argv)
@@ -4508,33 +4511,54 @@ int win_main(int argc, char **argv)
 int main(int argc, char **argv)
 #endif
 {
-  MY_INIT(argv[0]);		// init my_sys library & pthreads
-  /* nothing should come before this line ^^^ */
+  /* Perform basic thread library and malloc initialization. */
+  if (my_basic_init())
+  {
+    fprintf(stderr, "my_basic_init() failed.");
+    return 1;
+  }
+
+  orig_argc= argc;
+  orig_argv= argv;
+  load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv);
+  defaults_argc= argc;
+  defaults_argv= argv;
 
 #ifdef HAVE_PERFORMANCE_SCHEMA
-#ifndef HAVE_WL4876
+  {
+    int ho_error;
+
+    my_getopt_register_get_addr(NULL);
+    my_getopt_error_reporter= option_error_reporter;
+
+    /* Skip unknown options so that they may be processed later */
+    my_getopt_skip_unknown= TRUE;
+
+    if ((ho_error= handle_options(&argc, &argv, my_long_perfschema_options,
+                                  get_one_perfschema_option)))
+      return ho_error;
+    /* Add back the program name handle_options removes */
+    argc++;
+    argv--;
+    /* Remove the performance schema options parsed. */
+    defaults_argc= argc;
+    defaults_argv= argv;
+
+    PSI_hook= initialize_performance_schema(& pfs_param);
+  }
+#else
   /*
-    WL#4876 is not implemented yet, so performance schema parameters
-    are currently *not* parsed from the server command line or my.cnf file.
-    This code is temporary, while waiting for the implementation of WL#4876.
-  */
-  pfs_param.m_enabled= true;
-  pfs_param.m_mutex_class_sizing= PFS_MAX_MUTEX_CLASS;
-  pfs_param.m_rwlock_class_sizing= PFS_MAX_RWLOCK_CLASS;
-  pfs_param.m_cond_class_sizing= PFS_MAX_COND_CLASS;
-  pfs_param.m_thread_class_sizing= PFS_MAX_THREAD_CLASS;
-  pfs_param.m_table_share_sizing= PFS_MAX_TABLE_SHARE;
-  pfs_param.m_file_class_sizing= PFS_MAX_FILE_CLASS;
-  pfs_param.m_mutex_sizing= PFS_MAX_MUTEX;
-  pfs_param.m_rwlock_sizing= PFS_MAX_RWLOCK;
-  pfs_param.m_cond_sizing= PFS_MAX_COND;
-  pfs_param.m_thread_sizing= PFS_MAX_THREAD;
-  pfs_param.m_table_sizing= PFS_MAX_TABLE;
-  pfs_param.m_file_sizing= PFS_MAX_FILE;
-  pfs_param.m_events_waits_history_sizing= PFS_WAITS_HISTORY_SIZE;
-  pfs_param.m_events_waits_history_long_sizing= PFS_WAITS_HISTORY_LONG_SIZE;
-#endif /* HAVE_WL4876 */
-  PSI_hook= initialize_performance_schema(& pfs_param);
+    Other provider of the instrumentation interface should
+    initialize PSI_hook here:
+    - HAVE_PSI_INTERFACE is for the instrumentation interface
+    - HAVE_PERFORMANCE_SCHEMA is for one implementation of the interface,
+    but there could be alternate implementations, which is why
+    these two defines are kept separate.
+    TODO:
+    One possible alternate implementation is: enforce a mutex lock order,
+    not between mutex instances as in safe mutex, but between mutex classes,
+    and according to a dependency graph declared explicitly.
+  */
 #endif /* HAVE_PERFORMANCE_SCHEMA */
 
 #ifdef HAVE_PSI_INTERFACE
@@ -4560,13 +4584,13 @@ int main(int argc, char **argv)
     if (psi)
       PSI_server->set_thread(psi);
 
-#ifndef HAVE_WL4876
-    /* TODO: remove with WL#4876: rework the out of order mysys initialization */
-    my_reinit_mutexes();
-#endif /* HAVE_WL4876 */
+    if (my_thread_basic_global_reinit())
+      return 1;
   }
 #endif /* HAVE_PSI_INTERFACE */
 
+  MY_INIT(orig_argv[0]);                       // init my_sys library & pthreads
+
   /* Initialize audit interface globals. Audit plugins are inited later. */
   mysql_audit_initialize();
 
@@ -4600,8 +4624,7 @@ int main(int argc, char **argv)
   }
 #endif /* __WIN__ */
 
-  if (init_common_variables(MYSQL_CONFIG_NAME,
-			    argc, argv, load_default_groups))
+  if (init_common_variables())
     unireg_abort(1);				// Will do exit
 
   init_signals();
@@ -7195,83 +7218,6 @@ The minimum value for this variable is 4
    (uchar**) &optimizer_switch_str, (uchar**) &optimizer_switch_str, 0, GET_STR, REQUIRED_ARG, 
    /*OPTIMIZER_SWITCH_DEFAULT*/0,
    0, 0, 0, 0, 0},
-#ifdef HAVE_PERFORMANCE_SCHEMA
-  {"performance_schema", OPT_PFS_ENABLED,
-   "Enable the performance schema.",
-   (uchar**) &pfs_param.m_enabled,
-   (uchar**) &pfs_param.m_enabled,
-   NULL, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, NULL},
-  {"performance_schema_events_waits_history_long_size", OPT_PFS_EVENTS_WAITS_HISTORY_LONG,
-   "Number of rows in EVENTS_WAITS_HISTORY_LONG.",
-   (uchar**) &pfs_param.m_events_waits_history_long_sizing,
-   (uchar**) &pfs_param.m_events_waits_history_long_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_WAITS_HISTORY_LONG_SIZE, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_events_waits_history_size", OPT_PFS_EVENTS_WAITS_HISTORY,
-   "Number of rows per thread in EVENTS_WAITS_HISTORY.",
-   (uchar**) &pfs_param.m_events_waits_history_sizing,
-   (uchar**) &pfs_param.m_events_waits_history_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_WAITS_HISTORY_SIZE, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_cond", OPT_PFS_MAX_COND,
-   "Maximum number of instrumented condition objects.",
-   (uchar**) &pfs_param.m_cond_sizing,
-   (uchar**) &pfs_param.m_cond_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_COND, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_cond_instruments", OPT_PFS_MAX_COND_INSTRUMENTS,
-   "Maximum number of condition instruments.",
-   (uchar**) &pfs_param.m_cond_class_sizing,
-   (uchar**) &pfs_param.m_cond_class_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_COND_CLASS, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_file", OPT_PFS_MAX_FILE,
-   "Maximum number of instrumented files.",
-   (uchar**) &pfs_param.m_file_sizing,
-   (uchar**) &pfs_param.m_file_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_FILE, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_file_instruments", OPT_PFS_MAX_FILE_INSTRUMENTS,
-   "Maximum number of file instruments.",
-   (uchar**) &pfs_param.m_file_class_sizing,
-   (uchar**) &pfs_param.m_file_class_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_FILE_CLASS, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_mutex", OPT_PFS_MAX_MUTEX,
-   "Maximum number of instrumented MUTEX objects.",
-   (uchar**) &pfs_param.m_mutex_sizing,
-   (uchar**) &pfs_param.m_mutex_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_MUTEX, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_mutex_instruments", OPT_PFS_MAX_MUTEX_INSTRUMENTS,
-   "Maximum number of mutex instruments.",
-   (uchar**) &pfs_param.m_mutex_class_sizing,
-   (uchar**) &pfs_param.m_mutex_class_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_MUTEX_CLASS, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_rwlock", OPT_PFS_MAX_RWLOCK,
-   "Maximum number of instrumented RWLOCK objects.",
-   (uchar**) &pfs_param.m_rwlock_sizing,
-   (uchar**) &pfs_param.m_rwlock_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_RWLOCK, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_rwlock_instruments", OPT_PFS_MAX_RWLOCK_INSTRUMENTS,
-   "Maximum number of rwlock instruments.",
-   (uchar**) &pfs_param.m_rwlock_class_sizing,
-   (uchar**) &pfs_param.m_rwlock_class_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_RWLOCK_CLASS, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_table", OPT_PFS_MAX_TABLE,
-   "Maximum number of instrumented tables.",
-   (uchar**) &pfs_param.m_table_sizing,
-   (uchar**) &pfs_param.m_table_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_TABLE, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_table_instruments", OPT_PFS_MAX_TABLE_INSTRUMENTS,
-   "Maximum number of table instruments.",
-   (uchar**) &pfs_param.m_table_share_sizing,
-   (uchar**) &pfs_param.m_table_share_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_TABLE_SHARE, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_thread", OPT_PFS_MAX_THREAD,
-   "Maximum number of instrumented threads.",
-   (uchar**) &pfs_param.m_thread_sizing,
-   (uchar**) &pfs_param.m_thread_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_THREAD, 0, ULONG_MAX, 0, 1, NULL},
-  {"performance_schema_max_thread_instruments", OPT_PFS_MAX_THREAD_INSTRUMENTS,
-   "Maximum number of thread instruments.",
-   (uchar**) &pfs_param.m_thread_class_sizing,
-   (uchar**) &pfs_param.m_thread_class_sizing,
-   NULL, GET_ULONG, OPT_ARG, PFS_MAX_THREAD_CLASS, 0, ULONG_MAX, 0, 1, NULL},
-#endif /* HAVE_PERFORMANCE_SCHEMA */
   {"plugin_dir", OPT_PLUGIN_DIR,
    "Directory for plugins.",
    (uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0,
@@ -7502,6 +7448,87 @@ The minimum value for this variable is 4
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 
+#ifdef HAVE_PERFORMANCE_SCHEMA
+struct my_option my_long_perfschema_options[] =
+{
+  {"performance_schema", OPT_PFS_ENABLED,
+   "Enable the performance schema.",
+   (uchar**) &pfs_param.m_enabled,
+   (uchar**) &pfs_param.m_enabled,
+   NULL, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, NULL},
+  {"performance_schema_events_waits_history_long_size", OPT_PFS_EVENTS_WAITS_HISTORY_LONG,
+   "Number of rows in EVENTS_WAITS_HISTORY_LONG.",
+   (uchar**) &pfs_param.m_events_waits_history_long_sizing,
+   (uchar**) &pfs_param.m_events_waits_history_long_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_WAITS_HISTORY_LONG_SIZE, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_events_waits_history_size", OPT_PFS_EVENTS_WAITS_HISTORY,
+   "Number of rows per thread in EVENTS_WAITS_HISTORY.",
+   (uchar**) &pfs_param.m_events_waits_history_sizing,
+   (uchar**) &pfs_param.m_events_waits_history_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_WAITS_HISTORY_SIZE, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_cond", OPT_PFS_MAX_COND,
+   "Maximum number of instrumented condition objects.",
+   (uchar**) &pfs_param.m_cond_sizing,
+   (uchar**) &pfs_param.m_cond_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_COND, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_cond_instruments", OPT_PFS_MAX_COND_INSTRUMENTS,
+   "Maximum number of condition instruments.",
+   (uchar**) &pfs_param.m_cond_class_sizing,
+   (uchar**) &pfs_param.m_cond_class_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_COND_CLASS, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_file", OPT_PFS_MAX_FILE,
+   "Maximum number of instrumented files.",
+   (uchar**) &pfs_param.m_file_sizing,
+   (uchar**) &pfs_param.m_file_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_FILE, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_file_instruments", OPT_PFS_MAX_FILE_INSTRUMENTS,
+   "Maximum number of file instruments.",
+   (uchar**) &pfs_param.m_file_class_sizing,
+   (uchar**) &pfs_param.m_file_class_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_FILE_CLASS, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_mutex", OPT_PFS_MAX_MUTEX,
+   "Maximum number of instrumented MUTEX objects.",
+   (uchar**) &pfs_param.m_mutex_sizing,
+   (uchar**) &pfs_param.m_mutex_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_MUTEX, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_mutex_instruments", OPT_PFS_MAX_MUTEX_INSTRUMENTS,
+   "Maximum number of mutex instruments.",
+   (uchar**) &pfs_param.m_mutex_class_sizing,
+   (uchar**) &pfs_param.m_mutex_class_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_MUTEX_CLASS, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_rwlock", OPT_PFS_MAX_RWLOCK,
+   "Maximum number of instrumented RWLOCK objects.",
+   (uchar**) &pfs_param.m_rwlock_sizing,
+   (uchar**) &pfs_param.m_rwlock_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_RWLOCK, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_rwlock_instruments", OPT_PFS_MAX_RWLOCK_INSTRUMENTS,
+   "Maximum number of rwlock instruments.",
+   (uchar**) &pfs_param.m_rwlock_class_sizing,
+   (uchar**) &pfs_param.m_rwlock_class_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_RWLOCK_CLASS, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_table", OPT_PFS_MAX_TABLE,
+   "Maximum number of instrumented tables.",
+   (uchar**) &pfs_param.m_table_sizing,
+   (uchar**) &pfs_param.m_table_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_TABLE, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_table_instruments", OPT_PFS_MAX_TABLE_INSTRUMENTS,
+   "Maximum number of table instruments.",
+   (uchar**) &pfs_param.m_table_share_sizing,
+   (uchar**) &pfs_param.m_table_share_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_TABLE_SHARE, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_thread", OPT_PFS_MAX_THREAD,
+   "Maximum number of instrumented threads.",
+   (uchar**) &pfs_param.m_thread_sizing,
+   (uchar**) &pfs_param.m_thread_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_THREAD, 0, ULONG_MAX, 0, 1, NULL},
+  {"performance_schema_max_thread_instruments", OPT_PFS_MAX_THREAD_INSTRUMENTS,
+   "Maximum number of thread instruments.",
+   (uchar**) &pfs_param.m_thread_class_sizing,
+   (uchar**) &pfs_param.m_thread_class_sizing,
+   NULL, GET_ULONG, OPT_ARG, PFS_MAX_THREAD_CLASS, 0, ULONG_MAX, 0, 1, NULL},
+  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+#endif /* HAVE_PERFORMANCE_SCHEMA */
 
 static int show_queries(THD *thd, SHOW_VAR *var, char *buff)
 {
@@ -8079,8 +8106,17 @@ Starts the MySQL database server\n");
   puts("");
   set_ports();
 
+  my_option *more_options= NULL;
+  uint more_option_size= 0;
+
+#ifdef HAVE_PERFORMANCE_SCHEMA
+  more_options= my_long_perfschema_options;
+  more_option_size= array_elements(my_long_perfschema_options);
+#endif
+
   /* Print out all the options including plugin supplied options */
-  my_print_help_inc_plugins(my_long_options, sizeof(my_long_options)/sizeof(my_option));
+  my_print_help_inc_plugins(my_long_options, array_elements(my_long_options),
+                            more_options, more_option_size);
 
   if (! plugins_are_initialized)
   {
@@ -8139,8 +8175,6 @@ static int mysql_init_variables(void)
   mqh_used= 0;
   segfaulted= kill_in_progress= 0;
   cleanup_done= 0;
-  defaults_argc= 0;
-  defaults_argv= 0;
   server_id_supplied= 0;
   test_flags= select_errors= dropping_tables= ha_open_options=0;
   thread_count= thread_running= kill_cached_threads= wake_thread=0;
@@ -8984,9 +9018,6 @@ mysql_getopt_value(const char *keyname,
   return option->value;
 }
 
-
-extern "C" void option_error_reporter(enum loglevel level, const char *format, ...);
-
 void option_error_reporter(enum loglevel level, const char *format, ...)
 {
   va_list args;

=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc	2009-05-21 19:42:38 +0000
+++ b/sql/sql_plugin.cc	2009-05-28 21:33:45 +0000
@@ -3298,12 +3298,14 @@ static int option_cmp(my_option *a, my_o
 }
 
 
-void my_print_help_inc_plugins(my_option *main_options, uint size)
+void my_print_help_inc_plugins(my_option *main_options, uint main_options_size,
+                               my_option *more_options, uint more_options_size)
 {
   DYNAMIC_ARRAY all_options;
   struct st_plugin_int *p;
   MEM_ROOT mem_root;
   my_option *opt;
+  uint size= main_options_size + more_options_size;
 
   init_alloc_root(&mem_root, 4096, 4096);
   my_init_dynamic_array(&all_options, sizeof(my_option), size, size/4);
@@ -3326,6 +3328,10 @@ void my_print_help_inc_plugins(my_option
   for (;main_options->id; main_options++)
     insert_dynamic(&all_options, (uchar*) main_options);
 
+  if (more_options)
+    for ( ; more_options->id; more_options++)
+      insert_dynamic(&all_options, (uchar*) more_options);
+
   sort_dynamic(&all_options, (qsort_cmp) option_cmp);
 
   /* main_options now points to the empty option terminator */

=== modified file 'sql/sql_plugin.h'
--- a/sql/sql_plugin.h	2009-05-04 17:14:38 +0000
+++ b/sql/sql_plugin.h	2009-05-28 21:33:45 +0000
@@ -111,7 +111,8 @@ extern const LEX_STRING plugin_type_name
 
 extern int plugin_init(int *argc, char **argv, int init_flags);
 extern void plugin_shutdown(void);
-extern void my_print_help_inc_plugins(struct my_option *options, uint size);
+extern void my_print_help_inc_plugins(struct my_option *main_options, uint main_options_size,
+                                      struct my_option *more_options, uint more_options_size);
 extern bool plugin_is_ready(const LEX_STRING *name, int type);
 #define my_plugin_lock_by_name(A,B,C) plugin_lock_by_name(A,B,C CALLER_INFO)
 #define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)

Thread
bzr push into mysql-6.0-perfschema branch (marc.alff:3155 to 3156) WL#4876Marc Alff28 May