List:Commits« Previous MessageNext Message »
From:Christopher Powers Date:December 2 2010 6:45pm
Subject:bzr push into mysql-trunk-wl4896 branch (chris.powers:3207 to 3208)
View as plain text  
 3208 Christopher Powers	2010-12-02 [merge]
      merge

    removed:
      Doxyfile-wl4895
      mysql-test/suite/perfschema/r/schema.result
    added:
      Doxyfile-perfschema
      mysql-test/suite/perfschema/r/ddl_os_global_by_type.result
      mysql-test/suite/perfschema/r/ddl_setup_objects.result
      mysql-test/suite/perfschema/r/dml_os_global_by_type.result
      mysql-test/suite/perfschema/r/dml_setup_objects.result
      mysql-test/suite/perfschema/r/setup_objects.result
      mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
      mysql-test/suite/perfschema/t/ddl_os_global_by_type.test
      mysql-test/suite/perfschema/t/ddl_setup_objects.test
      mysql-test/suite/perfschema/t/dml_os_global_by_type.test
      mysql-test/suite/perfschema/t/dml_setup_objects.test
      mysql-test/suite/perfschema/t/setup_objects.test
      mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt
      mysql-test/suite/perfschema/t/start_server_no_setup_objects.test
      mysql-test/suite/sys_vars/r/pfs_setup_objects_size_basic.result
      mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic-master.opt
      mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic.test
      storage/perfschema/pfs_setup_object.cc
      storage/perfschema/pfs_setup_object.h
      storage/perfschema/table_ews_by_thread_by_event_name.cc
      storage/perfschema/table_ews_by_thread_by_event_name.h
      storage/perfschema/table_helper.cc
      storage/perfschema/table_os_global_by_type.cc
      storage/perfschema/table_os_global_by_type.h
      storage/perfschema/table_setup_objects.cc
      storage/perfschema/table_setup_objects.h
      storage/perfschema/unittest/stub_pfs_defaults.h
      storage/perfschema/unittest/stub_server_misc.h
    modified:
      .bzrignore
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/suite/perfschema/include/schema.inc
      mysql-test/suite/perfschema/include/start_server_common.inc
      mysql-test/suite/perfschema/r/dml_setup_consumers.result
      mysql-test/suite/perfschema/r/information_schema.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result
      mysql-test/suite/perfschema/r/privilege_table_io.result
      mysql-test/suite/perfschema/r/schema_lc0.result
      mysql-test/suite/perfschema/r/schema_lc1.result
      mysql-test/suite/perfschema/r/schema_lc2.result
      mysql-test/suite/perfschema/r/start_server_no_cond_class.result
      mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
      mysql-test/suite/perfschema/r/start_server_no_file_class.result
      mysql-test/suite/perfschema/r/start_server_no_file_inst.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
      mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
      mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
      mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
      mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
      mysql-test/suite/perfschema/r/start_server_no_table_inst.result
      mysql-test/suite/perfschema/r/start_server_no_thread_class.result
      mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
      mysql-test/suite/perfschema/r/start_server_nothing.result
      mysql-test/suite/perfschema/r/start_server_off.result
      mysql-test/suite/perfschema/r/start_server_on.result
      mysql-test/suite/perfschema_stress/r/modify.result
      mysql-test/suite/perfschema_stress/r/read.result
      mysql-test/suite/perfschema_stress/t/modify.test
      mysql-test/suite/perfschema_stress/t/read.test
      mysql-test/suite/perfschema_stress/t/setup.test
      scripts/mysql_system_tables.sql
      sql/sys_vars.cc
      storage/perfschema/CMakeLists.txt
      storage/perfschema/Makefile.am
      storage/perfschema/pfs.cc
      storage/perfschema/pfs_defaults.cc
      storage/perfschema/pfs_engine_table.cc
      storage/perfschema/pfs_events_waits.cc
      storage/perfschema/pfs_events_waits.h
      storage/perfschema/pfs_instr.cc
      storage/perfschema/pfs_instr.h
      storage/perfschema/pfs_instr_class.cc
      storage/perfschema/pfs_instr_class.h
      storage/perfschema/pfs_server.cc
      storage/perfschema/pfs_server.h
      storage/perfschema/pfs_stat.h
      storage/perfschema/pfs_timer.cc
      storage/perfschema/pfs_timer.h
      storage/perfschema/table_all_instr.cc
      storage/perfschema/table_all_instr.h
      storage/perfschema/table_events_waits.cc
      storage/perfschema/table_events_waits.h
      storage/perfschema/table_events_waits_summary.cc
      storage/perfschema/table_events_waits_summary.h
      storage/perfschema/table_ews_global_by_event_name.cc
      storage/perfschema/table_ews_global_by_event_name.h
      storage/perfschema/table_file_summary.cc
      storage/perfschema/table_file_summary.h
      storage/perfschema/table_helper.h
      storage/perfschema/table_setup_consumers.cc
      storage/perfschema/table_setup_instruments.cc
      storage/perfschema/unittest/pfs-t.cc
      storage/perfschema/unittest/pfs_instr-oom-t.cc
      storage/perfschema/unittest/pfs_instr-t.cc
      storage/perfschema/unittest/pfs_instr_class-oom-t.cc
      storage/perfschema/unittest/pfs_instr_class-t.cc
 3207 Christopher Powers	2010-12-01 [merge]
      merge

    added:
      mysql-test/collections/mysql-next-mr-wl2540.push
      mysql-test/collections/mysql-trunk.daily
      mysql-test/collections/mysql-trunk.weekly
      mysql-test/extra/rpl_tests/rpl_change_master.test
      mysql-test/extra/rpl_tests/rpl_crash_safe.inc
      mysql-test/extra/rpl_tests/rpl_crash_safe.test
      mysql-test/include/have_binlog_checksum_off.inc
      mysql-test/include/not_master_info_table.inc
      mysql-test/include/not_relay_log_info_table.inc
      mysql-test/suite/binlog/r/binlog_checksum.result
      mysql-test/suite/binlog/t/binlog_checksum.test
      mysql-test/suite/rpl/extension/README.checksum
      mysql-test/suite/rpl/extension/checksum.pl
      mysql-test/suite/rpl/r/rpl_change_master_crash_safe.result
      mysql-test/suite/rpl/r/rpl_checksum.result
      mysql-test/suite/rpl/r/rpl_checksum_cache.result
      mysql-test/suite/rpl/r/rpl_corruption.result
      mysql-test/suite/rpl/r/rpl_migration_crash_safe.result
      mysql-test/suite/rpl/r/rpl_mixed_crash_safe.result
      mysql-test/suite/rpl/r/rpl_row_crash_safe.result
      mysql-test/suite/rpl/r/rpl_stm_crash_safe.result
      mysql-test/suite/rpl/t/rpl_change_master_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_change_master_crash_safe.test
      mysql-test/suite/rpl/t/rpl_checksum-master.opt
      mysql-test/suite/rpl/t/rpl_checksum.test
      mysql-test/suite/rpl/t/rpl_checksum_cache.test
      mysql-test/suite/rpl/t/rpl_corruption-master.opt
      mysql-test/suite/rpl/t/rpl_corruption-slave.opt
      mysql-test/suite/rpl/t/rpl_corruption.test
      mysql-test/suite/rpl/t/rpl_migration_crash_safe.test
      mysql-test/suite/rpl/t/rpl_mixed_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_mixed_crash_safe.test
      mysql-test/suite/rpl/t/rpl_row_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_row_crash_safe.test
      mysql-test/suite/rpl/t/rpl_stm_crash_safe-slave.opt
      mysql-test/suite/rpl/t/rpl_stm_crash_safe.test
      mysql-test/suite/sys_vars/r/binlog_checksum_basic.result
      mysql-test/suite/sys_vars/r/master_verify_checksum_basic.result
      mysql-test/suite/sys_vars/r/slave_sql_verify_checksum_basic.result
      mysql-test/suite/sys_vars/t/binlog_checksum_basic.test
      mysql-test/suite/sys_vars/t/master_verify_checksum_basic.test
      mysql-test/suite/sys_vars/t/slave_sql_verify_checksum_basic.test
      sql/rpl_info_table.cc
      sql/rpl_info_table.h
      sql/rpl_info_table_access.cc
      sql/rpl_info_table_access.h
      sql/rpl_info_values.cc
      sql/rpl_info_values.h
    modified:
      client/mysqlbinlog.cc
      client/mysqldump.c
      libmysqld/CMakeLists.txt
      libmysqld/Makefile.am
      mysql-test/collections/default.experimental
      mysql-test/extra/binlog_tests/binlog.test
      mysql-test/extra/binlog_tests/mix_innodb_myisam_binlog.test
      mysql-test/extra/rpl_tests/rpl_conflicts.test
      mysql-test/extra/rpl_tests/rpl_flsh_tbls.test
      mysql-test/extra/rpl_tests/rpl_reset_slave.test
      mysql-test/extra/rpl_tests/rpl_start_stop_slave.test
      mysql-test/include/mtr_warnings.sql
      mysql-test/r/1st.result
      mysql-test/r/connect.result
      mysql-test/r/information_schema.result
      mysql-test/r/log_tables.result
      mysql-test/r/log_tables_upgrade.result
      mysql-test/r/mysql_upgrade.result
      mysql-test/r/mysql_upgrade_ssl.result
      mysql-test/r/mysqlcheck.result
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      mysql-test/r/system_mysql_db.result
      mysql-test/suite/binlog/r/binlog_killed.result
      mysql-test/suite/binlog/r/binlog_old_versions.result
      mysql-test/suite/binlog/r/binlog_row_binlog.result
      mysql-test/suite/binlog/r/binlog_stm_binlog.result
      mysql-test/suite/binlog/t/binlog_killed.test
      mysql-test/suite/binlog/t/binlog_old_versions.test
      mysql-test/suite/binlog/t/disabled.def
      mysql-test/suite/funcs_1/r/is_columns_mysql.result
      mysql-test/suite/funcs_1/r/is_key_column_usage.result
      mysql-test/suite/funcs_1/r/is_statistics.result
      mysql-test/suite/funcs_1/r/is_statistics_mysql.result
      mysql-test/suite/funcs_1/r/is_table_constraints.result
      mysql-test/suite/funcs_1/r/is_table_constraints_mysql.result
      mysql-test/suite/funcs_1/r/is_tables_mysql.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result
      mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result
      mysql-test/suite/rpl/r/rpl_change_master.result
      mysql-test/suite/rpl/r/rpl_heartbeat_basic.result
      mysql-test/suite/rpl/r/rpl_rotate_logs.result
      mysql-test/suite/rpl/r/rpl_row_conflicts.result
      mysql-test/suite/rpl/r/rpl_server_uuid.result
      mysql-test/suite/rpl/t/disabled.def
      mysql-test/suite/rpl/t/rpl_change_master.test
      mysql-test/suite/rpl/t/rpl_flushlog_loop.test
      mysql-test/suite/rpl/t/rpl_heartbeat_basic.test
      mysql-test/suite/rpl/t/rpl_known_bugs_detection.test
      mysql-test/suite/rpl/t/rpl_rotate_logs.test
      mysql-test/suite/rpl/t/rpl_row_ignorable_event.test
      mysql-test/suite/rpl/t/rpl_row_mysqlbinlog.test
      mysql-test/suite/rpl/t/rpl_seconds_behind_master.test
      mysql-test/suite/rpl/t/rpl_server_uuid.test
      mysql-test/suite/rpl/t/rpl_show_master_info_file.test
      mysql-test/suite/rpl/t/rpl_stm_flsh_tbls.test
      mysql-test/suite/rpl/t/rpl_sync.test
      mysql-test/suite/rpl_ndb/t/rpl_ndb_multi.test
      mysql-test/suite/sys_vars/t/all_vars.test
      mysql-test/suite/sys_vars/t/master_info_repository_basic.test
      mysql-test/suite/sys_vars/t/relay_log_info_repository_basic.test
      mysql-test/t/mysqlbinlog2.test
      mysql-test/t/system_mysql_db_fix40123.test
      mysql-test/t/system_mysql_db_fix50030.test
      mysql-test/t/system_mysql_db_fix50117.test
      scripts/mysql_install_db.pl.in
      scripts/mysql_install_db.sh
      scripts/mysql_system_tables.sql
      sql/CMakeLists.txt
      sql/Makefile.am
      sql/binlog.cc
      sql/binlog.h
      sql/lock.cc
      sql/log.cc
      sql/log_event.cc
      sql/log_event.h
      sql/mysqld.cc
      sql/mysqld.h
      sql/rpl_info.h
      sql/rpl_info_factory.cc
      sql/rpl_info_factory.h
      sql/rpl_info_file.cc
      sql/rpl_info_file.h
      sql/rpl_info_handler.cc
      sql/rpl_info_handler.h
      sql/rpl_master.cc
      sql/rpl_mi.cc
      sql/rpl_mi.h
      sql/rpl_rli.cc
      sql/rpl_rli.h
      sql/rpl_slave.cc
      sql/rpl_slave.h
      sql/rpl_utility.cc
      sql/server_ids.h
      sql/share/errmsg-utf8.txt
      sql/sql_base.cc
      sql/sql_base.h
      sql/sql_binlog.cc
      sql/sql_class.h
      sql/sql_parse.cc
      sql/sql_parse.h
      sql/sys_vars.cc
      sql/sys_vars.h
      sql/table.cc
      sql/table.h
=== modified file '.bzrignore'
--- a/.bzrignore	2010-11-04 13:02:10 +0000
+++ b/.bzrignore	2010-11-15 07:40:07 +0000
@@ -3138,3 +3138,5 @@ mysys/thr_lock
 libmysqld/binlog.cc
 libmysqld/sql_alter.cc
 libmysqld/sql_partition_admin.cc
+generated
+doxyerror.log

=== added file 'Doxyfile-perfschema'
--- a/Doxyfile-perfschema	1970-01-01 00:00:00 +0000
+++ b/Doxyfile-perfschema	2010-11-15 07:40:07 +0000
@@ -0,0 +1,1561 @@
+#
+# MySQL Doxyfile for the performance_schema.
+#
+# To run doxygen:
+# - mkdir -p ./generated/doxygen
+# - doxygen Doxyfile-perfschema
+# - see the logs in ./doxyerror.log
+# - see the doc in ./generated/doxygen/html/index.html
+
+#===========================================================================
+# Doxyfile 1.6.2
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = "PERFORMANCE SCHEMA"
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER         =
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = generated/doxygen
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       =
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = NO
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = NO
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = YES
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC         = YES
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = YES
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = NO
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = NO
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = NO
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
+# will list include files with double quotes in the documentation
+# rather than with sharp brackets.
+
+FORCE_LOCAL_INCLUDES   = NO
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE            =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE           = doxyerror.log
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT                  = .
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          =
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE              = YES
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                = extra libmysql libmysql_r libmysqld mysql-test storage/innodb storage/ndb support-files unittest zlib
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       =
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH           =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS       =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH             =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        =
+
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
+# page will contain the date and time when the page was generated. Setting
+# this to NO can help when comparing the output of multiple runs.
+
+HTML_TIMESTAMP         = NO
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE               =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          = org.doxygen.Project
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
+#  will be generated, which together with the HTML files, form an Eclipse help
+#  plugin. To install this plugin and make it available under the help contents
+# menu in Eclipse, the contents of the directory containing the HTML and XML
+# files needs to be copied into the plugins directory of eclipse. The name of
+# the directory within the plugins directory should be the same as
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
+
+GENERATE_ECLIPSEHELP   = NO
+
+# A unique identifier for the eclipse help plugin. When installing the plugin
+# the directory name containing the HTML and XML files should also have
+# this name.
+
+ECLIPSE_DOC_ID         = org.doxygen.Project
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NO
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
+# typically be disabled. For large projects the javascript based search engine
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
+
+SEARCHENGINE           = YES
+
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
+# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
+# and does not have live searching capabilities.
+
+SERVER_BASED_SEARCH    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX         = NO
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+# Note that when enabling USE_PDFLATEX this option is only used for
+# generating bitmaps for formulas in the HTML output, but not in the
+# Makefile that is written to the output directory.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN           = NO
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA             =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = NO
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = NO
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH           = . include include/mysql sql
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS  =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED             = WITH_PERFSCHEMA_STORAGE_ENGINE HAVE_PSI_INTERFACE HAVE_PSI_1 HAVE_PSI_2 USE_PSI_1
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS           =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = NO
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP            = YES

=== removed file 'Doxyfile-wl4895'
--- a/Doxyfile-wl4895	2010-10-04 12:06:54 +0000
+++ b/Doxyfile-wl4895	1970-01-01 00:00:00 +0000
@@ -1,1551 +0,0 @@
-# Doxyfile 1.6.2
-
-# This file describes the settings to be used by the documentation system
-# doxygen (www.doxygen.org) for a project
-#
-# All text after a hash (#) is considered a comment and will be ignored
-# The format is:
-#       TAG = value [value, ...]
-# For lists items can also be appended using:
-#       TAG += value [value, ...]
-# Values that contain spaces should be placed between quotes (" ")
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-
-# This tag specifies the encoding used for all characters in the config file
-# that follow. The default is UTF-8 which is also the encoding used for all
-# text before the first occurrence of this tag. Doxygen uses libiconv (or the
-# iconv built into libc) for the transcoding. See
-# http://www.gnu.org/software/libiconv for the list of possible encodings.
-
-DOXYFILE_ENCODING      = UTF-8
-
-# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
-# by quotes) that should identify the project.
-
-PROJECT_NAME           = WL#4895
-
-# The PROJECT_NUMBER tag can be used to enter a project or revision number.
-# This could be handy for archiving the generated documentation or
-# if some version control system is used.
-
-PROJECT_NUMBER         =
-
-# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
-# base path where the generated documentation will be put.
-# If a relative path is entered, it will be relative to the location
-# where doxygen was started. If left blank the current directory will be used.
-
-OUTPUT_DIRECTORY       = generated/doxygen
-
-# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
-# 4096 sub-directories (in 2 levels) under the output directory of each output
-# format and will distribute the generated files over these directories.
-# Enabling this option can be useful when feeding doxygen a huge amount of
-# source files, where putting all generated files in the same directory would
-# otherwise cause performance problems for the file system.
-
-CREATE_SUBDIRS         = NO
-
-# The OUTPUT_LANGUAGE tag is used to specify the language in which all
-# documentation generated by doxygen is written. Doxygen will use this
-# information to generate all constant output in the proper language.
-# The default language is English, other supported languages are:
-# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
-# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
-# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
-# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
-# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
-# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
-
-OUTPUT_LANGUAGE        = English
-
-# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
-# include brief member descriptions after the members that are listed in
-# the file and class documentation (similar to JavaDoc).
-# Set to NO to disable this.
-
-BRIEF_MEMBER_DESC      = YES
-
-# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
-# the brief description of a member or function before the detailed description.
-# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
-# brief descriptions will be completely suppressed.
-
-REPEAT_BRIEF           = YES
-
-# This tag implements a quasi-intelligent brief description abbreviator
-# that is used to form the text in various listings. Each string
-# in this list, if found as the leading text of the brief description, will be
-# stripped from the text and the result after processing the whole list, is
-# used as the annotated text. Otherwise, the brief description is used as-is.
-# If left blank, the following values are used ("$name" is automatically
-# replaced with the name of the entity): "The $name class" "The $name widget"
-# "The $name file" "is" "provides" "specifies" "contains"
-# "represents" "a" "an" "the"
-
-ABBREVIATE_BRIEF       =
-
-# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
-# Doxygen will generate a detailed section even if there is only a brief
-# description.
-
-ALWAYS_DETAILED_SEC    = NO
-
-# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
-# inherited members of a class in the documentation of that class as if those
-# members were ordinary class members. Constructors, destructors and assignment
-# operators of the base classes will not be shown.
-
-INLINE_INHERITED_MEMB  = NO
-
-# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
-# path before files name in the file list and in the header files. If set
-# to NO the shortest path that makes the file name unique will be used.
-
-FULL_PATH_NAMES        = YES
-
-# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
-# can be used to strip a user-defined part of the path. Stripping is
-# only done if one of the specified strings matches the left-hand part of
-# the path. The tag can be used to show relative paths in the file list.
-# If left blank the directory from which doxygen is run is used as the
-# path to strip.
-
-STRIP_FROM_PATH        =
-
-# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
-# the path mentioned in the documentation of a class, which tells
-# the reader which header file to include in order to use a class.
-# If left blank only the name of the header file containing the class
-# definition is used. Otherwise one should specify the include paths that
-# are normally passed to the compiler using the -I flag.
-
-STRIP_FROM_INC_PATH    =
-
-# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
-# (but less readable) file names. This can be useful is your file systems
-# doesn't support long names like on DOS, Mac, or CD-ROM.
-
-SHORT_NAMES            = NO
-
-# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
-# will interpret the first line (until the first dot) of a JavaDoc-style
-# comment as the brief description. If set to NO, the JavaDoc
-# comments will behave just like regular Qt-style comments
-# (thus requiring an explicit @brief command for a brief description.)
-
-JAVADOC_AUTOBRIEF      = NO
-
-# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
-# interpret the first line (until the first dot) of a Qt-style
-# comment as the brief description. If set to NO, the comments
-# will behave just like regular Qt-style comments (thus requiring
-# an explicit \brief command for a brief description.)
-
-QT_AUTOBRIEF           = NO
-
-# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
-# treat a multi-line C++ special comment block (i.e. a block of //! or ///
-# comments) as a brief description. This used to be the default behaviour.
-# The new default is to treat a multi-line C++ comment block as a detailed
-# description. Set this tag to YES if you prefer the old behaviour instead.
-
-MULTILINE_CPP_IS_BRIEF = NO
-
-# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
-# member inherits the documentation from any documented member that it
-# re-implements.
-
-INHERIT_DOCS           = YES
-
-# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
-# a new page for each member. If set to NO, the documentation of a member will
-# be part of the file/class/namespace that contains it.
-
-SEPARATE_MEMBER_PAGES  = NO
-
-# The TAB_SIZE tag can be used to set the number of spaces in a tab.
-# Doxygen uses this value to replace tabs by spaces in code fragments.
-
-TAB_SIZE               = 8
-
-# This tag can be used to specify a number of aliases that acts
-# as commands in the documentation. An alias has the form "name=value".
-# For example adding "sideeffect=\par Side Effects:\n" will allow you to
-# put the command \sideeffect (or @sideeffect) in the documentation, which
-# will result in a user-defined paragraph with heading "Side Effects:".
-# You can put \n's in the value part of an alias to insert newlines.
-
-ALIASES                =
-
-# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
-# sources only. Doxygen will then generate output that is more tailored for C.
-# For instance, some of the names that are used will be different. The list
-# of all members will be omitted, etc.
-
-OPTIMIZE_OUTPUT_FOR_C  = NO
-
-# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
-# sources only. Doxygen will then generate output that is more tailored for
-# Java. For instance, namespaces will be presented as packages, qualified
-# scopes will look different, etc.
-
-OPTIMIZE_OUTPUT_JAVA   = NO
-
-# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
-# sources only. Doxygen will then generate output that is more tailored for
-# Fortran.
-
-OPTIMIZE_FOR_FORTRAN   = NO
-
-# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
-# sources. Doxygen will then generate output that is tailored for
-# VHDL.
-
-OPTIMIZE_OUTPUT_VHDL   = NO
-
-# Doxygen selects the parser to use depending on the extension of the files it parses.
-# With this tag you can assign which parser to use for a given extension.
-# Doxygen has a built-in mapping, but you can override or extend it using this tag.
-# The format is ext=language, where ext is a file extension, and language is one of
-# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
-# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
-# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
-# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
-
-EXTENSION_MAPPING      =
-
-# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
-# to include (a tag file for) the STL sources as input, then you should
-# set this tag to YES in order to let doxygen match functions declarations and
-# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
-# func(std::string) {}). This also make the inheritance and collaboration
-# diagrams that involve STL classes more complete and accurate.
-
-BUILTIN_STL_SUPPORT    = NO
-
-# If you use Microsoft's C++/CLI language, you should set this option to YES to
-# enable parsing support.
-
-CPP_CLI_SUPPORT        = NO
-
-# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
-# Doxygen will parse them like normal C++ but will assume all classes use public
-# instead of private inheritance when no explicit protection keyword is present.
-
-SIP_SUPPORT            = NO
-
-# For Microsoft's IDL there are propget and propput attributes to indicate getter
-# and setter methods for a property. Setting this option to YES (the default)
-# will make doxygen to replace the get and set methods by a property in the
-# documentation. This will only work if the methods are indeed getting or
-# setting a simple type. If this is not the case, or you want to show the
-# methods anyway, you should set this option to NO.
-
-IDL_PROPERTY_SUPPORT   = YES
-
-# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
-# tag is set to YES, then doxygen will reuse the documentation of the first
-# member in the group (if any) for the other members of the group. By default
-# all members of a group must be documented explicitly.
-
-DISTRIBUTE_GROUP_DOC   = NO
-
-# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
-# the same type (for instance a group of public functions) to be put as a
-# subgroup of that type (e.g. under the Public Functions section). Set it to
-# NO to prevent subgrouping. Alternatively, this can be done per class using
-# the \nosubgrouping command.
-
-SUBGROUPING            = YES
-
-# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
-# is documented as struct, union, or enum with the name of the typedef. So
-# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
-# with name TypeT. When disabled the typedef will appear as a member of a file,
-# namespace, or class. And the struct will be named TypeS. This can typically
-# be useful for C code in case the coding convention dictates that all compound
-# types are typedef'ed and only the typedef is referenced, never the tag name.
-
-TYPEDEF_HIDES_STRUCT   = NO
-
-# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
-# determine which symbols to keep in memory and which to flush to disk.
-# When the cache is full, less often used symbols will be written to disk.
-# For small to medium size projects (<1000 input files) the default value is
-# probably good enough. For larger projects a too small cache size can cause
-# doxygen to be busy swapping symbols to and from disk most of the time
-# causing a significant performance penality.
-# If the system has enough physical memory increasing the cache will improve the
-# performance by keeping more symbols in memory. Note that the value works on
-# a logarithmic scale so increasing the size by one will rougly double the
-# memory usage. The cache size is given by this formula:
-# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
-# corresponding to a cache size of 2^16 = 65536 symbols
-
-SYMBOL_CACHE_SIZE      = 0
-
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-
-# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
-# documentation are documented, even if no documentation was available.
-# Private class members and static file members will be hidden unless
-# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
-
-EXTRACT_ALL            = NO
-
-# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
-# will be included in the documentation.
-
-EXTRACT_PRIVATE        = YES
-
-# If the EXTRACT_STATIC tag is set to YES all static members of a file
-# will be included in the documentation.
-
-EXTRACT_STATIC         = YES
-
-# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
-# defined locally in source files will be included in the documentation.
-# If set to NO only classes defined in header files are included.
-
-EXTRACT_LOCAL_CLASSES  = YES
-
-# This flag is only useful for Objective-C code. When set to YES local
-# methods, which are defined in the implementation section but not in
-# the interface are included in the documentation.
-# If set to NO (the default) only methods in the interface are included.
-
-EXTRACT_LOCAL_METHODS  = NO
-
-# If this flag is set to YES, the members of anonymous namespaces will be
-# extracted and appear in the documentation as a namespace called
-# 'anonymous_namespace{file}', where file will be replaced with the base
-# name of the file that contains the anonymous namespace. By default
-# anonymous namespace are hidden.
-
-EXTRACT_ANON_NSPACES   = NO
-
-# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
-# undocumented members of documented classes, files or namespaces.
-# If set to NO (the default) these members will be included in the
-# various overviews, but no documentation section is generated.
-# This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_MEMBERS     = NO
-
-# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
-# undocumented classes that are normally visible in the class hierarchy.
-# If set to NO (the default) these classes will be included in the various
-# overviews. This option has no effect if EXTRACT_ALL is enabled.
-
-HIDE_UNDOC_CLASSES     = NO
-
-# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
-# friend (class|struct|union) declarations.
-# If set to NO (the default) these declarations will be included in the
-# documentation.
-
-HIDE_FRIEND_COMPOUNDS  = NO
-
-# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
-# documentation blocks found inside the body of a function.
-# If set to NO (the default) these blocks will be appended to the
-# function's detailed documentation block.
-
-HIDE_IN_BODY_DOCS      = NO
-
-# The INTERNAL_DOCS tag determines if documentation
-# that is typed after a \internal command is included. If the tag is set
-# to NO (the default) then the documentation will be excluded.
-# Set it to YES to include the internal documentation.
-
-INTERNAL_DOCS          = NO
-
-# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
-# file names in lower-case letters. If set to YES upper-case letters are also
-# allowed. This is useful if you have classes or files whose names only differ
-# in case and if your file system supports case sensitive file names. Windows
-# and Mac users are advised to set this option to NO.
-
-CASE_SENSE_NAMES       = NO
-
-# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
-# will show members with their full class and namespace scopes in the
-# documentation. If set to YES the scope will be hidden.
-
-HIDE_SCOPE_NAMES       = NO
-
-# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
-# will put a list of the files that are included by a file in the documentation
-# of that file.
-
-SHOW_INCLUDE_FILES     = YES
-
-# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen
-# will list include files with double quotes in the documentation
-# rather than with sharp brackets.
-
-FORCE_LOCAL_INCLUDES   = NO
-
-# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
-# is inserted in the documentation for inline members.
-
-INLINE_INFO            = YES
-
-# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
-# will sort the (detailed) documentation of file and class members
-# alphabetically by member name. If set to NO the members will appear in
-# declaration order.
-
-SORT_MEMBER_DOCS       = YES
-
-# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
-# brief documentation of file, namespace and class members alphabetically
-# by member name. If set to NO (the default) the members will appear in
-# declaration order.
-
-SORT_BRIEF_DOCS        = NO
-
-# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
-
-SORT_MEMBERS_CTORS_1ST = NO
-
-# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
-# hierarchy of group names into alphabetical order. If set to NO (the default)
-# the group names will appear in their defined order.
-
-SORT_GROUP_NAMES       = NO
-
-# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
-# sorted by fully-qualified names, including namespaces. If set to
-# NO (the default), the class list will be sorted only by class name,
-# not including the namespace part.
-# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
-# Note: This option applies only to the class list, not to the
-# alphabetical list.
-
-SORT_BY_SCOPE_NAME     = NO
-
-# The GENERATE_TODOLIST tag can be used to enable (YES) or
-# disable (NO) the todo list. This list is created by putting \todo
-# commands in the documentation.
-
-GENERATE_TODOLIST      = YES
-
-# The GENERATE_TESTLIST tag can be used to enable (YES) or
-# disable (NO) the test list. This list is created by putting \test
-# commands in the documentation.
-
-GENERATE_TESTLIST      = YES
-
-# The GENERATE_BUGLIST tag can be used to enable (YES) or
-# disable (NO) the bug list. This list is created by putting \bug
-# commands in the documentation.
-
-GENERATE_BUGLIST       = YES
-
-# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
-# disable (NO) the deprecated list. This list is created by putting
-# \deprecated commands in the documentation.
-
-GENERATE_DEPRECATEDLIST= YES
-
-# The ENABLED_SECTIONS tag can be used to enable conditional
-# documentation sections, marked by \if sectionname ... \endif.
-
-ENABLED_SECTIONS       =
-
-# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
-# the initial value of a variable or define consists of for it to appear in
-# the documentation. If the initializer consists of more lines than specified
-# here it will be hidden. Use a value of 0 to hide initializers completely.
-# The appearance of the initializer of individual variables and defines in the
-# documentation can be controlled using \showinitializer or \hideinitializer
-# command in the documentation regardless of this setting.
-
-MAX_INITIALIZER_LINES  = 30
-
-# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
-# at the bottom of the documentation of classes and structs. If set to YES the
-# list will mention the files that were used to generate the documentation.
-
-SHOW_USED_FILES        = YES
-
-# If the sources in your project are distributed over multiple directories
-# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
-# in the documentation. The default is NO.
-
-SHOW_DIRECTORIES       = NO
-
-# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
-# This will remove the Files entry from the Quick Index and from the
-# Folder Tree View (if specified). The default is YES.
-
-SHOW_FILES             = YES
-
-# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
-# Namespaces page.
-# This will remove the Namespaces entry from the Quick Index
-# and from the Folder Tree View (if specified). The default is YES.
-
-SHOW_NAMESPACES        = YES
-
-# The FILE_VERSION_FILTER tag can be used to specify a program or script that
-# doxygen should invoke to get the current version for each file (typically from
-# the version control system). Doxygen will invoke the program by executing (via
-# popen()) the command <command> <input-file>, where <command> is the value of
-# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
-# provided by doxygen. Whatever the program writes to standard output
-# is used as the file version. See the manual for examples.
-
-FILE_VERSION_FILTER    =
-
-# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
-# doxygen. The layout file controls the global structure of the generated output files
-# in an output format independent way. The create the layout file that represents
-# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
-# file name after the option, if omitted DoxygenLayout.xml will be used as the name
-# of the layout file.
-
-LAYOUT_FILE            =
-
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-
-# The QUIET tag can be used to turn on/off the messages that are generated
-# by doxygen. Possible values are YES and NO. If left blank NO is used.
-
-QUIET                  = NO
-
-# The WARNINGS tag can be used to turn on/off the warning messages that are
-# generated by doxygen. Possible values are YES and NO. If left blank
-# NO is used.
-
-WARNINGS               = YES
-
-# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
-# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
-# automatically be disabled.
-
-WARN_IF_UNDOCUMENTED   = YES
-
-# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
-# potential errors in the documentation, such as not documenting some
-# parameters in a documented function, or documenting parameters that
-# don't exist or using markup commands wrongly.
-
-WARN_IF_DOC_ERROR      = YES
-
-# This WARN_NO_PARAMDOC option can be abled to get warnings for
-# functions that are documented, but have no documentation for their parameters
-# or return value. If set to NO (the default) doxygen will only warn about
-# wrong or incomplete parameter documentation, but not about the absence of
-# documentation.
-
-WARN_NO_PARAMDOC       = NO
-
-# The WARN_FORMAT tag determines the format of the warning messages that
-# doxygen can produce. The string should contain the $file, $line, and $text
-# tags, which will be replaced by the file and line number from which the
-# warning originated and the warning text. Optionally the format may contain
-# $version, which will be replaced by the version of the file (if it could
-# be obtained via FILE_VERSION_FILTER)
-
-WARN_FORMAT            = "$file:$line: $text"
-
-# The WARN_LOGFILE tag can be used to specify a file to which warning
-# and error messages should be written. If left blank the output is written
-# to stderr.
-
-WARN_LOGFILE           = doxyerror.log
-
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-
-# The INPUT tag can be used to specify the files and/or directories that contain
-# documented source files. You may enter file names like "myfile.cpp" or
-# directories like "/usr/src/myproject". Separate the files or directories
-# with spaces.
-
-INPUT                  = .
-
-# This tag can be used to specify the character encoding of the source files
-# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
-# also the default input encoding. Doxygen uses libiconv (or the iconv built
-# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
-# the list of possible encodings.
-
-INPUT_ENCODING         = UTF-8
-
-# If the value of the INPUT tag contains directories, you can use the
-# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank the following patterns are tested:
-# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
-# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-
-FILE_PATTERNS          =
-
-# The RECURSIVE tag can be used to turn specify whether or not subdirectories
-# should be searched for input files as well. Possible values are YES and NO.
-# If left blank NO is used.
-
-RECURSIVE              = YES
-
-# The EXCLUDE tag can be used to specify files and/or directories that should
-# excluded from the INPUT source files. This way you can easily exclude a
-# subdirectory from a directory tree whose root is specified with the INPUT tag.
-
-EXCLUDE                = extra libmysql libmysql_r libmysqld mysql-test storage/ibmdb2i storage/innodb storage/ndb support-files unittest zlib
-
-# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
-# directories that are symbolic links (a Unix filesystem feature) are excluded
-# from the input.
-
-EXCLUDE_SYMLINKS       = NO
-
-# If the value of the INPUT tag contains directories, you can use the
-# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
-# certain files from those directories. Note that the wildcards are matched
-# against the file with absolute path, so to exclude all test directories
-# for example use the pattern */test/*
-
-EXCLUDE_PATTERNS       =
-
-# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
-# (namespaces, classes, functions, etc.) that should be excluded from the
-# output. The symbol name can be a fully qualified name, a word, or if the
-# wildcard * is used, a substring. Examples: ANamespace, AClass,
-# AClass::ANamespace, ANamespace::*Test
-
-EXCLUDE_SYMBOLS        =
-
-# The EXAMPLE_PATH tag can be used to specify one or more files or
-# directories that contain example code fragments that are included (see
-# the \include command).
-
-EXAMPLE_PATH           =
-
-# If the value of the EXAMPLE_PATH tag contains directories, you can use the
-# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
-# and *.h) to filter out the source-files in the directories. If left
-# blank all files are included.
-
-EXAMPLE_PATTERNS       =
-
-# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
-# searched for input files to be used with the \include or \dontinclude
-# commands irrespective of the value of the RECURSIVE tag.
-# Possible values are YES and NO. If left blank NO is used.
-
-EXAMPLE_RECURSIVE      = NO
-
-# The IMAGE_PATH tag can be used to specify one or more files or
-# directories that contain image that are included in the documentation (see
-# the \image command).
-
-IMAGE_PATH             =
-
-# The INPUT_FILTER tag can be used to specify a program that doxygen should
-# invoke to filter for each input file. Doxygen will invoke the filter program
-# by executing (via popen()) the command <filter> <input-file>, where <filter>
-# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
-# input file. Doxygen will then use the output that the filter program writes
-# to standard output.
-# If FILTER_PATTERNS is specified, this tag will be
-# ignored.
-
-INPUT_FILTER           =
-
-# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
-# basis.
-# Doxygen will compare the file name with each pattern and apply the
-# filter if there is a match.
-# The filters are a list of the form:
-# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
-# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
-# is applied to all files.
-
-FILTER_PATTERNS        =
-
-# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
-# INPUT_FILTER) will be used to filter the input files when producing source
-# files to browse (i.e. when SOURCE_BROWSER is set to YES).
-
-FILTER_SOURCE_FILES    = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-
-# If the SOURCE_BROWSER tag is set to YES then a list of source files will
-# be generated. Documented entities will be cross-referenced with these sources.
-# Note: To get rid of all source code in the generated output, make sure also
-# VERBATIM_HEADERS is set to NO.
-
-SOURCE_BROWSER         = NO
-
-# Setting the INLINE_SOURCES tag to YES will include the body
-# of functions and classes directly in the documentation.
-
-INLINE_SOURCES         = NO
-
-# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
-# doxygen to hide any special comment blocks from generated source code
-# fragments. Normal C and C++ comments will always remain visible.
-
-STRIP_CODE_COMMENTS    = YES
-
-# If the REFERENCED_BY_RELATION tag is set to YES
-# then for each documented function all documented
-# functions referencing it will be listed.
-
-REFERENCED_BY_RELATION = NO
-
-# If the REFERENCES_RELATION tag is set to YES
-# then for each documented function all documented entities
-# called/used by that function will be listed.
-
-REFERENCES_RELATION    = NO
-
-# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
-# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
-# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
-# link to the source code.
-# Otherwise they will link to the documentation.
-
-REFERENCES_LINK_SOURCE = YES
-
-# If the USE_HTAGS tag is set to YES then the references to source code
-# will point to the HTML generated by the htags(1) tool instead of doxygen
-# built-in source browser. The htags tool is part of GNU's global source
-# tagging system (see http://www.gnu.org/software/global/global.html). You
-# will need version 4.8.6 or higher.
-
-USE_HTAGS              = NO
-
-# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
-# will generate a verbatim copy of the header file for each class for
-# which an include is specified. Set to NO to disable this.
-
-VERBATIM_HEADERS       = YES
-
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-
-# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
-# of all compounds will be generated. Enable this if the project
-# contains a lot of classes, structs, unions or interfaces.
-
-ALPHABETICAL_INDEX     = NO
-
-# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
-# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
-# in which this list will be split (can be a number in the range [1..20])
-
-COLS_IN_ALPHA_INDEX    = 5
-
-# In case all classes in a project start with a common prefix, all
-# classes will be put under the same header in the alphabetical index.
-# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
-# should be ignored while generating the index headers.
-
-IGNORE_PREFIX          =
-
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
-# generate HTML output.
-
-GENERATE_HTML          = YES
-
-# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `html' will be used as the default path.
-
-HTML_OUTPUT            = html
-
-# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
-# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
-# doxygen will generate files with .html extension.
-
-HTML_FILE_EXTENSION    = .html
-
-# The HTML_HEADER tag can be used to specify a personal HTML header for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard header.
-
-HTML_HEADER            =
-
-# The HTML_FOOTER tag can be used to specify a personal HTML footer for
-# each generated HTML page. If it is left blank doxygen will generate a
-# standard footer.
-
-HTML_FOOTER            =
-
-# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
-# style sheet that is used by each HTML page. It can be used to
-# fine-tune the look of the HTML output. If the tag is left blank doxygen
-# will generate a default style sheet. Note that doxygen will try to copy
-# the style sheet file to the HTML output directory, so don't put your own
-# stylesheet in the HTML output directory as well, or it will be erased!
-
-HTML_STYLESHEET        =
-
-# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML
-# page will contain the date and time when the page was generated. Setting
-# this to NO can help when comparing the output of multiple runs.
-
-HTML_TIMESTAMP         = NO
-
-# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
-# files or namespaces will be aligned in HTML using tables. If set to
-# NO a bullet list will be used.
-
-HTML_ALIGN_MEMBERS     = YES
-
-# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
-# documentation will contain sections that can be hidden and shown after the
-# page has loaded. For this to work a browser that supports
-# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
-# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
-
-HTML_DYNAMIC_SECTIONS  = NO
-
-# If the GENERATE_DOCSET tag is set to YES, additional index files
-# will be generated that can be used as input for Apple's Xcode 3
-# integrated development environment, introduced with OSX 10.5 (Leopard).
-# To create a documentation set, doxygen will generate a Makefile in the
-# HTML output directory. Running make will produce the docset in that
-# directory and running "make install" will install the docset in
-# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
-# it at startup.
-# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
-
-GENERATE_DOCSET        = NO
-
-# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
-# feed. A documentation feed provides an umbrella under which multiple
-# documentation sets from a single provider (such as a company or product suite)
-# can be grouped.
-
-DOCSET_FEEDNAME        = "Doxygen generated docs"
-
-# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
-# should uniquely identify the documentation set bundle. This should be a
-# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
-# will append .docset to the name.
-
-DOCSET_BUNDLE_ID       = org.doxygen.Project
-
-# If the GENERATE_HTMLHELP tag is set to YES, additional index files
-# will be generated that can be used as input for tools like the
-# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
-# of the generated HTML documentation.
-
-GENERATE_HTMLHELP      = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
-# be used to specify the file name of the resulting .chm file. You
-# can add a path in front of the file if the result should not be
-# written to the html output directory.
-
-CHM_FILE               =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
-# be used to specify the location (absolute path including file name) of
-# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
-# the HTML help compiler on the generated index.hhp.
-
-HHC_LOCATION           =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
-# controls if a separate .chi index file is generated (YES) or that
-# it should be included in the master .chm file (NO).
-
-GENERATE_CHI           = NO
-
-# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
-# is used to encode HtmlHelp index (hhk), content (hhc) and project file
-# content.
-
-CHM_INDEX_ENCODING     =
-
-# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
-# controls whether a binary table of contents is generated (YES) or a
-# normal table of contents (NO) in the .chm file.
-
-BINARY_TOC             = NO
-
-# The TOC_EXPAND flag can be set to YES to add extra items for group members
-# to the contents of the HTML help documentation and to the tree view.
-
-TOC_EXPAND             = NO
-
-# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
-# are set, an additional index file will be generated that can be used as input for
-# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
-# HTML documentation.
-
-GENERATE_QHP           = NO
-
-# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
-# be used to specify the file name of the resulting .qch file.
-# The path specified is relative to the HTML output folder.
-
-QCH_FILE               =
-
-# The QHP_NAMESPACE tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#namespace
-
-QHP_NAMESPACE          = org.doxygen.Project
-
-# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
-# Qt Help Project output. For more information please see
-# http://doc.trolltech.com/qthelpproject.html#virtual-folders
-
-QHP_VIRTUAL_FOLDER     = doc
-
-# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
-# For more information please see
-# http://doc.trolltech.com/qthelpproject.html#custom-filters
-
-QHP_CUST_FILTER_NAME   =
-
-# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
-# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
-
-QHP_CUST_FILTER_ATTRS  =
-
-# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
-# filter section matches.
-# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
-
-QHP_SECT_FILTER_ATTRS  =
-
-# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
-# be used to specify the location of Qt's qhelpgenerator.
-# If non-empty doxygen will try to run qhelpgenerator on the generated
-# .qhp file.
-
-QHG_LOCATION           =
-
-# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files
-#  will be generated, which together with the HTML files, form an Eclipse help
-#  plugin. To install this plugin and make it available under the help contents
-# menu in Eclipse, the contents of the directory containing the HTML and XML
-# files needs to be copied into the plugins directory of eclipse. The name of
-# the directory within the plugins directory should be the same as
-# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before the help appears.
-
-GENERATE_ECLIPSEHELP   = NO
-
-# A unique identifier for the eclipse help plugin. When installing the plugin
-# the directory name containing the HTML and XML files should also have
-# this name.
-
-ECLIPSE_DOC_ID         = org.doxygen.Project
-
-# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
-# top of each HTML page. The value NO (the default) enables the index and
-# the value YES disables it.
-
-DISABLE_INDEX          = NO
-
-# This tag can be used to set the number of enum values (range [1..20])
-# that doxygen will group on one line in the generated HTML documentation.
-
-ENUM_VALUES_PER_LINE   = 4
-
-# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
-# structure should be generated to display hierarchical information.
-# If the tag value is set to YES, a side panel will be generated
-# containing a tree-like index structure (just like the one that
-# is generated for HTML Help). For this to work a browser that supports
-# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
-# Windows users are probably better off using the HTML help feature.
-
-GENERATE_TREEVIEW      = NO
-
-# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
-# and Class Hierarchy pages using a tree view instead of an ordered list.
-
-USE_INLINE_TREES       = NO
-
-# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
-# used to set the initial width (in pixels) of the frame in which the tree
-# is shown.
-
-TREEVIEW_WIDTH         = 250
-
-# Use this tag to change the font size of Latex formulas included
-# as images in the HTML documentation. The default is 10. Note that
-# when you change the font size after a successful doxygen run you need
-# to manually remove any form_*.png images from the HTML output directory
-# to force them to be regenerated.
-
-FORMULA_FONTSIZE       = 10
-
-# When the SEARCHENGINE tag is enabled doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
-# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets (GENERATE_DOCSET) there is already a search function so this one should
-# typically be disabled. For large projects the javascript based search engine
-# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.
-
-SEARCHENGINE           = YES
-
-# When the SERVER_BASED_SEARCH tag is enabled the search engine will be implemented using a PHP enabled web server instead of at the web client using Javascript. Doxygen will generate the search PHP script and index
-# file to put on the web server. The advantage of the server based approach is that it scales better to large projects and allows full text search. The disadvances is that it is more difficult to setup
-# and does not have live searching capabilities.
-
-SERVER_BASED_SEARCH    = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
-# generate Latex output.
-
-GENERATE_LATEX         = NO
-
-# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `latex' will be used as the default path.
-
-LATEX_OUTPUT           = latex
-
-# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
-# invoked. If left blank `latex' will be used as the default command name.
-# Note that when enabling USE_PDFLATEX this option is only used for
-# generating bitmaps for formulas in the HTML output, but not in the
-# Makefile that is written to the output directory.
-
-LATEX_CMD_NAME         = latex
-
-# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
-# generate index for LaTeX. If left blank `makeindex' will be used as the
-# default command name.
-
-MAKEINDEX_CMD_NAME     = makeindex
-
-# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
-# LaTeX documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_LATEX          = NO
-
-# The PAPER_TYPE tag can be used to set the paper type that is used
-# by the printer. Possible values are: a4, a4wide, letter, legal and
-# executive. If left blank a4wide will be used.
-
-PAPER_TYPE             = a4wide
-
-# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
-# packages that should be included in the LaTeX output.
-
-EXTRA_PACKAGES         =
-
-# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
-# the generated latex document. The header should contain everything until
-# the first chapter. If it is left blank doxygen will generate a
-# standard header. Notice: only use this tag if you know what you are doing!
-
-LATEX_HEADER           =
-
-# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
-# is prepared for conversion to pdf (using ps2pdf). The pdf file will
-# contain links (just like the HTML output) instead of page references
-# This makes the output suitable for online browsing using a pdf viewer.
-
-PDF_HYPERLINKS         = YES
-
-# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
-# plain latex in the generated Makefile. Set this option to YES to get a
-# higher quality PDF documentation.
-
-USE_PDFLATEX           = YES
-
-# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
-# command to the generated LaTeX files. This will instruct LaTeX to keep
-# running if errors occur, instead of asking the user for help.
-# This option is also used when generating formulas in HTML.
-
-LATEX_BATCHMODE        = NO
-
-# If LATEX_HIDE_INDICES is set to YES then doxygen will not
-# include the index chapters (such as File Index, Compound Index, etc.)
-# in the output.
-
-LATEX_HIDE_INDICES     = NO
-
-# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
-
-LATEX_SOURCE_CODE      = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
-# The RTF output is optimized for Word 97 and may not look very pretty with
-# other RTF readers or editors.
-
-GENERATE_RTF           = NO
-
-# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `rtf' will be used as the default path.
-
-RTF_OUTPUT             = rtf
-
-# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
-# RTF documents. This may be useful for small projects and may help to
-# save some trees in general.
-
-COMPACT_RTF            = NO
-
-# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
-# will contain hyperlink fields. The RTF file will
-# contain links (just like the HTML output) instead of page references.
-# This makes the output suitable for online browsing using WORD or other
-# programs which support those fields.
-# Note: wordpad (write) and others do not support links.
-
-RTF_HYPERLINKS         = NO
-
-# Load stylesheet definitions from file. Syntax is similar to doxygen's
-# config file, i.e. a series of assignments. You only have to provide
-# replacements, missing definitions are set to their default value.
-
-RTF_STYLESHEET_FILE    =
-
-# Set optional variables used in the generation of an rtf document.
-# Syntax is similar to doxygen's config file.
-
-RTF_EXTENSIONS_FILE    =
-
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
-# generate man pages
-
-GENERATE_MAN           = NO
-
-# The MAN_OUTPUT tag is used to specify where the man pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `man' will be used as the default path.
-
-MAN_OUTPUT             = man
-
-# The MAN_EXTENSION tag determines the extension that is added to
-# the generated man pages (default is the subroutine's section .3)
-
-MAN_EXTENSION          = .3
-
-# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
-# then it will generate one additional man file for each entity
-# documented in the real man page(s). These additional files
-# only source the real man page, but without them the man command
-# would be unable to find the correct page. The default is NO.
-
-MAN_LINKS              = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_XML tag is set to YES Doxygen will
-# generate an XML file that captures the structure of
-# the code including all documentation.
-
-GENERATE_XML           = NO
-
-# The XML_OUTPUT tag is used to specify where the XML pages will be put.
-# If a relative path is entered the value of OUTPUT_DIRECTORY will be
-# put in front of it. If left blank `xml' will be used as the default path.
-
-XML_OUTPUT             = xml
-
-# The XML_SCHEMA tag can be used to specify an XML schema,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_SCHEMA             =
-
-# The XML_DTD tag can be used to specify an XML DTD,
-# which can be used by a validating XML parser to check the
-# syntax of the XML files.
-
-XML_DTD                =
-
-# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
-# dump the program listings (including syntax highlighting
-# and cross-referencing information) to the XML output. Note that
-# enabling this will significantly increase the size of the XML output.
-
-XML_PROGRAMLISTING     = YES
-
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
-# generate an AutoGen Definitions (see autogen.sf.net) file
-# that captures the structure of the code including all
-# documentation. Note that this feature is still experimental
-# and incomplete at the moment.
-
-GENERATE_AUTOGEN_DEF   = NO
-
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-
-# If the GENERATE_PERLMOD tag is set to YES Doxygen will
-# generate a Perl module file that captures the structure of
-# the code including all documentation. Note that this
-# feature is still experimental and incomplete at the
-# moment.
-
-GENERATE_PERLMOD       = NO
-
-# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
-# the necessary Makefile rules, Perl scripts and LaTeX code to be able
-# to generate PDF and DVI output from the Perl module output.
-
-PERLMOD_LATEX          = NO
-
-# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
-# nicely formatted so it can be parsed by a human reader.
-# This is useful
-# if you want to understand what is going on.
-# On the other hand, if this
-# tag is set to NO the size of the Perl module output will be much smaller
-# and Perl will parse it just the same.
-
-PERLMOD_PRETTY         = YES
-
-# The names of the make variables in the generated doxyrules.make file
-# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
-# This is useful so different doxyrules.make files included by the same
-# Makefile don't overwrite each other's variables.
-
-PERLMOD_MAKEVAR_PREFIX =
-
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-
-# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
-# evaluate all C-preprocessor directives found in the sources and include
-# files.
-
-ENABLE_PREPROCESSING   = YES
-
-# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
-# names in the source code. If set to NO (the default) only conditional
-# compilation will be performed. Macro expansion can be done in a controlled
-# way by setting EXPAND_ONLY_PREDEF to YES.
-
-MACRO_EXPANSION        = NO
-
-# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
-# then the macro expansion is limited to the macros specified with the
-# PREDEFINED and EXPAND_AS_DEFINED tags.
-
-EXPAND_ONLY_PREDEF     = NO
-
-# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
-# in the INCLUDE_PATH (see below) will be search if a #include is found.
-
-SEARCH_INCLUDES        = YES
-
-# The INCLUDE_PATH tag can be used to specify one or more directories that
-# contain include files that are not input files but should be processed by
-# the preprocessor.
-
-INCLUDE_PATH           = . include include/mysql sql
-
-# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
-# patterns (like *.h and *.hpp) to filter out the header-files in the
-# directories. If left blank, the patterns specified with FILE_PATTERNS will
-# be used.
-
-INCLUDE_FILE_PATTERNS  =
-
-# The PREDEFINED tag can be used to specify one or more macro names that
-# are defined before the preprocessor is started (similar to the -D option of
-# gcc). The argument of the tag is a list of macros of the form: name
-# or name=definition (no spaces). If the definition and the = are
-# omitted =1 is assumed. To prevent a macro definition from being
-# undefined via #undef or recursively expanded use the := operator
-# instead of the = operator.
-
-PREDEFINED             = WITH_PERFSCHEMA_STORAGE_ENGINE HAVE_PSI_INTERFACE HAVE_PSI_1 HAVE_PSI_2 USE_PSI_1
-
-# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
-# this tag can be used to specify a list of macro names that should be expanded.
-# The macro definition that is found in the sources will be used.
-# Use the PREDEFINED tag if you want to use a different macro definition.
-
-EXPAND_AS_DEFINED      =
-
-# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
-# doxygen's preprocessor will remove all function-like macros that are alone
-# on a line, have an all uppercase name, and do not end with a semicolon. Such
-# function macros are typically used for boiler-plate code, and will confuse
-# the parser if not removed.
-
-SKIP_FUNCTION_MACROS   = YES
-
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-
-# The TAGFILES option can be used to specify one or more tagfiles.
-# Optionally an initial location of the external documentation
-# can be added for each tagfile. The format of a tag file without
-# this location is as follows:
-#
-# TAGFILES = file1 file2 ...
-# Adding location for the tag files is done as follows:
-#
-# TAGFILES = file1=loc1 "file2 = loc2" ...
-# where "loc1" and "loc2" can be relative or absolute paths or
-# URLs. If a location is present for each tag, the installdox tool
-# does not have to be run to correct the links.
-# Note that each tag file must have a unique name
-# (where the name does NOT include the path)
-# If a tag file is not located in the directory in which doxygen
-# is run, you must also specify the path to the tagfile here.
-
-TAGFILES               =
-
-# When a file name is specified after GENERATE_TAGFILE, doxygen will create
-# a tag file that is based on the input files it reads.
-
-GENERATE_TAGFILE       =
-
-# If the ALLEXTERNALS tag is set to YES all external classes will be listed
-# in the class index. If set to NO only the inherited external classes
-# will be listed.
-
-ALLEXTERNALS           = NO
-
-# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
-# in the modules index. If set to NO, only the current project's groups will
-# be listed.
-
-EXTERNAL_GROUPS        = YES
-
-# The PERL_PATH should be the absolute path and name of the perl script
-# interpreter (i.e. the result of `which perl').
-
-PERL_PATH              = /usr/bin/perl
-
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-
-# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
-# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
-# or super classes. Setting the tag to NO turns the diagrams off. Note that
-# this option is superseded by the HAVE_DOT option below. This is only a
-# fallback. It is recommended to install and use dot, since it yields more
-# powerful graphs.
-
-CLASS_DIAGRAMS         = YES
-
-# You can define message sequence charts within doxygen comments using the \msc
-# command. Doxygen will then run the mscgen tool (see
-# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
-# documentation. The MSCGEN_PATH tag allows you to specify the directory where
-# the mscgen tool resides. If left empty the tool is assumed to be found in the
-# default search path.
-
-MSCGEN_PATH            =
-
-# If set to YES, the inheritance and collaboration graphs will hide
-# inheritance and usage relations if the target is undocumented
-# or is not a class.
-
-HIDE_UNDOC_RELATIONS   = YES
-
-# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
-# available from the path. This tool is part of Graphviz, a graph visualization
-# toolkit from AT&T and Lucent Bell Labs. The other options in this section
-# have no effect if this option is set to NO (the default)
-
-HAVE_DOT               = NO
-
-# By default doxygen will write a font called FreeSans.ttf to the output
-# directory and reference it in all dot files that doxygen generates. This
-# font does not include all possible unicode characters however, so when you need
-# these (or just want a differently looking font) you can specify the font name
-# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
-# which can be done by putting it in a standard location or by setting the
-# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
-# containing the font.
-
-DOT_FONTNAME           = FreeSans
-
-# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
-# The default size is 10pt.
-
-DOT_FONTSIZE           = 10
-
-# By default doxygen will tell dot to use the output directory to look for the
-# FreeSans.ttf font (which doxygen will put there itself). If you specify a
-# different font using DOT_FONTNAME you can set the path where dot
-# can find it using this tag.
-
-DOT_FONTPATH           =
-
-# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect inheritance relations. Setting this tag to YES will force the
-# the CLASS_DIAGRAMS tag to NO.
-
-CLASS_GRAPH            = YES
-
-# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for each documented class showing the direct and
-# indirect implementation dependencies (inheritance, containment, and
-# class references variables) of the class with other documented classes.
-
-COLLABORATION_GRAPH    = YES
-
-# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
-# will generate a graph for groups, showing the direct groups dependencies
-
-GROUP_GRAPHS           = YES
-
-# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
-# collaboration diagrams in a style similar to the OMG's Unified Modeling
-# Language.
-
-UML_LOOK               = NO
-
-# If set to YES, the inheritance and collaboration graphs will show the
-# relations between templates and their instances.
-
-TEMPLATE_RELATIONS     = NO
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
-# tags are set to YES then doxygen will generate a graph for each documented
-# file showing the direct and indirect include dependencies of the file with
-# other documented files.
-
-INCLUDE_GRAPH          = YES
-
-# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
-# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
-# documented header file showing the documented files that directly or
-# indirectly include this file.
-
-INCLUDED_BY_GRAPH      = YES
-
-# If the CALL_GRAPH and HAVE_DOT options are set to YES then
-# doxygen will generate a call dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable call graphs
-# for selected functions only using the \callgraph command.
-
-CALL_GRAPH             = NO
-
-# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
-# doxygen will generate a caller dependency graph for every global function
-# or class method. Note that enabling this option will significantly increase
-# the time of a run. So in most cases it will be better to enable caller
-# graphs for selected functions only using the \callergraph command.
-
-CALLER_GRAPH           = NO
-
-# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
-# will graphical hierarchy of all classes instead of a textual one.
-
-GRAPHICAL_HIERARCHY    = YES
-
-# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
-# then doxygen will show the dependencies a directory has on other directories
-# in a graphical way. The dependency relations are determined by the #include
-# relations between the files in the directories.
-
-DIRECTORY_GRAPH        = YES
-
-# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
-# generated by dot. Possible values are png, jpg, or gif
-# If left blank png will be used.
-
-DOT_IMAGE_FORMAT       = png
-
-# The tag DOT_PATH can be used to specify the path where the dot tool can be
-# found. If left blank, it is assumed the dot tool can be found in the path.
-
-DOT_PATH               =
-
-# The DOTFILE_DIRS tag can be used to specify one or more directories that
-# contain dot files that are included in the documentation (see the
-# \dotfile command).
-
-DOTFILE_DIRS           =
-
-# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
-# nodes that will be shown in the graph. If the number of nodes in a graph
-# becomes larger than this value, doxygen will truncate the graph, which is
-# visualized by representing a node as a red box. Note that doxygen if the
-# number of direct children of the root node in a graph is already larger than
-# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
-# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
-
-DOT_GRAPH_MAX_NODES    = 50
-
-# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
-# graphs generated by dot. A depth value of 3 means that only nodes reachable
-# from the root by following a path via at most 3 edges will be shown. Nodes
-# that lay further from the root node will be omitted. Note that setting this
-# option to 1 or 2 may greatly reduce the computation time needed for large
-# code bases. Also note that the size of a graph can be further restricted by
-# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
-
-MAX_DOT_GRAPH_DEPTH    = 0
-
-# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
-# background. This is disabled by default, because dot on Windows does not
-# seem to support this out of the box. Warning: Depending on the platform used,
-# enabling this option may lead to badly anti-aliased labels on the edges of
-# a graph (i.e. they become hard to read).
-
-DOT_TRANSPARENT        = NO
-
-# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
-# files in one run (i.e. multiple -o and -T options on the command line). This
-# makes dot run faster, but since only newer versions of dot (>1.8.10)
-# support this, this feature is disabled by default.
-
-DOT_MULTI_TARGETS      = NO
-
-# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
-# generate a legend page explaining the meaning of the various boxes and
-# arrows in the dot generated graphs.
-
-GENERATE_LEGEND        = YES
-
-# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
-# remove the intermediate dot files that are used to generate
-# the various graphs.
-
-DOT_CLEANUP            = YES

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2010-11-16 12:14:06 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2010-11-29 14:44:06 +0000
@@ -451,6 +451,8 @@ The following options may be given as th
  Maximum number of instrumented threads.
  --performance-schema-setup-actors-size=# 
  Maximum number of rows in SETUP_ACTORS.
+ --performance-schema-setup-objects-size=# 
+ Maximum number of rows in SETUP_OBJECTS.
  --pid-file=name     Pid file used by safe_mysqld
  --plugin-dir=name   Directory for plugins
  --plugin-load=name  Optional semicolon-separated list of plugins to load,
@@ -889,6 +891,7 @@ performance-schema-max-table-instances 1
 performance-schema-max-thread-classes 50
 performance-schema-max-thread-instances 1000
 performance-schema-setup-actors-size 100
+performance-schema-setup-objects-size 100
 plugin-load (No default value)
 port 3306
 port-open-timeout 0

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2010-11-16 12:14:06 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2010-11-29 14:44:06 +0000
@@ -451,6 +451,8 @@ The following options may be given as th
  Maximum number of instrumented threads.
  --performance-schema-setup-actors-size=# 
  Maximum number of rows in SETUP_ACTORS.
+ --performance-schema-setup-objects-size=# 
+ Maximum number of rows in SETUP_OBJECTS.
  --pid-file=name     Pid file used by safe_mysqld
  --plugin-dir=name   Directory for plugins
  --plugin-load=name  Optional semicolon-separated list of plugins to load,
@@ -893,6 +895,7 @@ performance-schema-max-table-instances 1
 performance-schema-max-thread-classes 50
 performance-schema-max-thread-instances 1000
 performance-schema-setup-actors-size 100
+performance-schema-setup-objects-size 100
 plugin-load (No default value)
 port 3306
 port-open-timeout 0

=== modified file 'mysql-test/suite/perfschema/include/schema.inc'
--- a/mysql-test/suite/perfschema/include/schema.inc	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/include/schema.inc	2010-11-15 07:40:07 +0000
@@ -34,11 +34,13 @@ show create table file_instances;
 show create table file_summary_by_event_name;
 show create table file_summary_by_instance;
 show create table mutex_instances;
+show create table objects_summary_global_by_type;
 show create table performance_timers;
 show create table rwlock_instances;
 show create table setup_actors;
 show create table setup_consumers;
 show create table setup_instruments;
+show create table setup_objects;
 show create table setup_timers;
 show create table threads;
 

=== modified file 'mysql-test/suite/perfschema/include/start_server_common.inc'
--- a/mysql-test/suite/perfschema/include/start_server_common.inc	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/include/start_server_common.inc	2010-11-15 07:40:07 +0000
@@ -37,11 +37,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 --enable_result_log

=== added file 'mysql-test/suite/perfschema/r/ddl_os_global_by_type.result'
--- a/mysql-test/suite/perfschema/r/ddl_os_global_by_type.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/ddl_os_global_by_type.result	2010-11-15 15:04:34 +0000
@@ -0,0 +1,10 @@
+alter table performance_schema.objects_summary_global_by_type
+add column foo integer;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+truncate table performance_schema.objects_summary_global_by_type;
+ALTER TABLE performance_schema.objects_summary_global_by_type
+ADD INDEX test_index(OBJECT_NAME);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+CREATE UNIQUE INDEX test_index
+ON performance_schema.objects_summary_global_by_type(OBJECT_NAME);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'

=== added file 'mysql-test/suite/perfschema/r/ddl_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/ddl_setup_objects.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/ddl_setup_objects.result	2010-11-16 04:42:59 +0000
@@ -0,0 +1,16 @@
+alter table performance_schema.setup_objects add column foo integer;
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+drop table if exists test.setup_objects;
+create table test.setup_objects as
+select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+select count(*) from performance_schema.setup_objects;
+count(*)
+0
+insert into performance_schema.setup_objects
+select * from test.setup_objects;
+drop table test.setup_objects;
+ALTER TABLE performance_schema.setup_objects ADD INDEX test_index(OBJECT_NAME);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_objects(OBJECT_NAME);
+ERROR 42000: Access denied for user 'root'@'localhost' to database 'performance_schema'

=== added file 'mysql-test/suite/perfschema/r/dml_os_global_by_type.result'
--- a/mysql-test/suite/perfschema/r/dml_os_global_by_type.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_os_global_by_type.result	2010-11-15 15:04:34 +0000
@@ -0,0 +1,45 @@
+select * from performance_schema.objects_summary_global_by_type
+where object_schema = 'performance_schema' limit 1;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+#	#	#	#	#	#	#	#
+select * from performance_schema.objects_summary_global_by_type
+where object_schema='FOO';
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+select * from performance_schema.objects_summary_global_by_type
+order by count_star limit 1;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+#	#	#	#	#	#	#	#
+select * from performance_schema.objects_summary_global_by_type
+order by count_star desc limit 1;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+#	#	#	#	#	#	#	#
+select * from performance_schema.objects_summary_global_by_type
+where object_type = 'TABLE' order by object_schema, object_name limit 1;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+#	#	#	#	#	#	#	#
+select * from performance_schema.objects_summary_global_by_type
+where object_type = 'TABLE' order by object_schema desc, object_name desc limit 1;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+#	#	#	#	#	#	#	#
+insert into performance_schema.objects_summary_global_by_type
+set object_type='TABLE', schema_name='FOO', object_name='BAR',
+count_star=1, sum_timer_wait=2, min_timer_wait=3,
+avg_timer_wait=4, max_timer_wait=5;
+ERROR 42000: INSERT command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+update performance_schema.objects_summary_global_by_type
+set count_star=12;
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+update performance_schema.objects_summary_global_by_type
+set count_star=12 where object_name like "FOO";
+ERROR 42000: UPDATE command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+delete from performance_schema.objects_summary_global_by_type
+where count_star=1;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+delete from performance_schema.objects_summary_global_by_type;
+ERROR 42000: DELETE command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+LOCK TABLES performance_schema.objects_summary_global_by_type READ;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+UNLOCK TABLES;
+LOCK TABLES performance_schema.objects_summary_global_by_type WRITE;
+ERROR 42000: SELECT, LOCK TABLES command denied to user 'root'@'localhost' for table 'objects_summary_global_by_type'
+UNLOCK TABLES;

=== modified file 'mysql-test/suite/perfschema/r/dml_setup_consumers.result'
--- a/mysql-test/suite/perfschema/r/dml_setup_consumers.result	2010-11-03 15:42:33 +0000
+++ b/mysql-test/suite/perfschema/r/dml_setup_consumers.result	2010-11-15 07:40:07 +0000
@@ -3,11 +3,8 @@ NAME	ENABLED
 events_waits_current	YES
 events_waits_history	YES
 events_waits_history_long	YES
-events_waits_summary_by_thread_by_event_name	YES
-events_waits_summary_by_event_name	YES
-events_waits_summary_by_instance	YES
-file_summary_by_event_name	YES
-file_summary_by_instance	YES
+global_instrumentation	YES
+thread_instrumentation	YES
 select * from performance_schema.setup_consumers
 where name='events_waits_current';
 NAME	ENABLED
@@ -18,11 +15,8 @@ NAME	ENABLED
 events_waits_current	YES
 events_waits_history	YES
 events_waits_history_long	YES
-events_waits_summary_by_thread_by_event_name	YES
-events_waits_summary_by_event_name	YES
-events_waits_summary_by_instance	YES
-file_summary_by_event_name	YES
-file_summary_by_instance	YES
+global_instrumentation	YES
+thread_instrumentation	YES
 select * from performance_schema.setup_consumers
 where enabled='NO';
 NAME	ENABLED

=== added file 'mysql-test/suite/perfschema/r/dml_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/dml_setup_objects.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/dml_setup_objects.result	2010-11-15 15:04:34 +0000
@@ -0,0 +1,67 @@
+drop table if exists test.setup_objects;
+create table test.setup_objects as
+select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+select * from performance_schema.setup_objects;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+select * from performance_schema.setup_objects
+order by object_type, object_schema, object_name;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+select * from performance_schema.setup_objects
+where object_type = 'TABLE'
+  order by object_type, object_schema, object_name;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+select * from performance_schema.setup_objects
+order by object_type, object_schema, object_name;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+insert into performance_schema.setup_objects
+set object_type='ILLEGAL', object_schema='FOO', object_name='BAR',
+timed='YES';
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails ()
+insert into performance_schema.setup_objects
+set object_type='TABLE', object_schema='FOO', object_name='BAR',
+timed='YES';
+insert into performance_schema.setup_objects
+set object_type='TABLE', object_schema='FOO', object_name='BAR',
+timed='NO';
+ERROR 23000: Can't write; duplicate key in table 'setup_objects'
+delete from performance_schema.setup_objects
+where object_type='TABLE' and object_schema='FOO';
+select * from performance_schema.setup_objects
+order by object_type, object_schema, object_name;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+insert into performance_schema.setup_objects
+set object_type='TABLE', object_schema='FOO', object_name='BAR',
+timed='YES';
+select * from performance_schema.setup_objects
+order by object_type, object_schema, object_name;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+TABLE	FOO	BAR	YES
+update performance_schema.setup_objects
+set object_type='ILLEGAL';
+ERROR HY000: Invalid performance_schema usage.
+update performance_schema.setup_objects
+set object_schema='ILLEGAL';
+ERROR HY000: Invalid performance_schema usage.
+update performance_schema.setup_objects
+set object_name='ILLEGAL';
+ERROR HY000: Invalid performance_schema usage.
+update performance_schema.setup_objects
+set timed='NO';
+select * from performance_schema.setup_objects
+order by object_type, object_schema, object_name;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+TABLE	FOO	BAR	NO
+update performance_schema.setup_objects
+set timed='YES';
+delete from performance_schema.setup_objects
+where object_type = 'TABLE';
+delete from performance_schema.setup_objects;
+LOCK TABLES performance_schema.setup_objects READ;
+UNLOCK TABLES;
+LOCK TABLES performance_schema.setup_objects WRITE;
+UNLOCK TABLES;
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects
+select * from test.setup_objects;
+drop table test.setup_objects;

=== modified file 'mysql-test/suite/perfschema/r/information_schema.result'
--- a/mysql-test/suite/perfschema/r/information_schema.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/information_schema.result	2010-11-15 07:40:07 +0000
@@ -13,11 +13,13 @@ performance_schema	file_instances	def
 performance_schema	file_summary_by_event_name	def
 performance_schema	file_summary_by_instance	def
 performance_schema	mutex_instances	def
+performance_schema	objects_summary_global_by_type	def
 performance_schema	performance_timers	def
 performance_schema	rwlock_instances	def
 performance_schema	setup_actors	def
 performance_schema	setup_consumers	def
 performance_schema	setup_instruments	def
+performance_schema	setup_objects	def
 performance_schema	setup_timers	def
 performance_schema	threads	def
 select lower(TABLE_NAME), TABLE_TYPE, ENGINE
@@ -35,11 +37,13 @@ file_instances	BASE TABLE	PERFORMANCE_SC
 file_summary_by_event_name	BASE TABLE	PERFORMANCE_SCHEMA
 file_summary_by_instance	BASE TABLE	PERFORMANCE_SCHEMA
 mutex_instances	BASE TABLE	PERFORMANCE_SCHEMA
+objects_summary_global_by_type	BASE TABLE	PERFORMANCE_SCHEMA
 performance_timers	BASE TABLE	PERFORMANCE_SCHEMA
 rwlock_instances	BASE TABLE	PERFORMANCE_SCHEMA
 setup_actors	BASE TABLE	PERFORMANCE_SCHEMA
 setup_consumers	BASE TABLE	PERFORMANCE_SCHEMA
 setup_instruments	BASE TABLE	PERFORMANCE_SCHEMA
+setup_objects	BASE TABLE	PERFORMANCE_SCHEMA
 setup_timers	BASE TABLE	PERFORMANCE_SCHEMA
 threads	BASE TABLE	PERFORMANCE_SCHEMA
 select lower(TABLE_NAME), VERSION, ROW_FORMAT
@@ -57,11 +61,13 @@ file_instances	10	Dynamic
 file_summary_by_event_name	10	Dynamic
 file_summary_by_instance	10	Dynamic
 mutex_instances	10	Dynamic
+objects_summary_global_by_type	10	Dynamic
 performance_timers	10	Fixed
 rwlock_instances	10	Dynamic
 setup_actors	10	Fixed
 setup_consumers	10	Dynamic
 setup_instruments	10	Dynamic
+setup_objects	10	Dynamic
 setup_timers	10	Dynamic
 threads	10	Dynamic
 select lower(TABLE_NAME), TABLE_ROWS, AVG_ROW_LENGTH
@@ -79,11 +85,13 @@ file_instances	1000	0
 file_summary_by_event_name	1000	0
 file_summary_by_instance	1000	0
 mutex_instances	1000	0
+objects_summary_global_by_type	1000	0
 performance_timers	5	0
 rwlock_instances	1000	0
 setup_actors	1	0
-setup_consumers	8	0
+setup_consumers	5	0
 setup_instruments	1000	0
+setup_objects	3	0
 setup_timers	1	0
 threads	1000	0
 select lower(TABLE_NAME), DATA_LENGTH, MAX_DATA_LENGTH
@@ -101,11 +109,13 @@ file_instances	0	0
 file_summary_by_event_name	0	0
 file_summary_by_instance	0	0
 mutex_instances	0	0
+objects_summary_global_by_type	0	0
 performance_timers	0	0
 rwlock_instances	0	0
 setup_actors	0	0
 setup_consumers	0	0
 setup_instruments	0	0
+setup_objects	0	0
 setup_timers	0	0
 threads	0	0
 select lower(TABLE_NAME), INDEX_LENGTH, DATA_FREE, AUTO_INCREMENT
@@ -123,11 +133,13 @@ file_instances	0	0	NULL
 file_summary_by_event_name	0	0	NULL
 file_summary_by_instance	0	0	NULL
 mutex_instances	0	0	NULL
+objects_summary_global_by_type	0	0	NULL
 performance_timers	0	0	NULL
 rwlock_instances	0	0	NULL
 setup_actors	0	0	NULL
 setup_consumers	0	0	NULL
 setup_instruments	0	0	NULL
+setup_objects	0	0	NULL
 setup_timers	0	0	NULL
 threads	0	0	NULL
 select lower(TABLE_NAME), CREATE_TIME, UPDATE_TIME, CHECK_TIME
@@ -145,11 +157,13 @@ file_instances	NULL	NULL	NULL
 file_summary_by_event_name	NULL	NULL	NULL
 file_summary_by_instance	NULL	NULL	NULL
 mutex_instances	NULL	NULL	NULL
+objects_summary_global_by_type	NULL	NULL	NULL
 performance_timers	NULL	NULL	NULL
 rwlock_instances	NULL	NULL	NULL
 setup_actors	NULL	NULL	NULL
 setup_consumers	NULL	NULL	NULL
 setup_instruments	NULL	NULL	NULL
+setup_objects	NULL	NULL	NULL
 setup_timers	NULL	NULL	NULL
 threads	NULL	NULL	NULL
 select lower(TABLE_NAME), TABLE_COLLATION, CHECKSUM
@@ -167,11 +181,13 @@ file_instances	utf8_general_ci	NULL
 file_summary_by_event_name	utf8_general_ci	NULL
 file_summary_by_instance	utf8_general_ci	NULL
 mutex_instances	utf8_general_ci	NULL
+objects_summary_global_by_type	utf8_general_ci	NULL
 performance_timers	utf8_general_ci	NULL
 rwlock_instances	utf8_general_ci	NULL
 setup_actors	utf8_general_ci	NULL
 setup_consumers	utf8_general_ci	NULL
 setup_instruments	utf8_general_ci	NULL
+setup_objects	utf8_general_ci	NULL
 setup_timers	utf8_general_ci	NULL
 threads	utf8_general_ci	NULL
 select lower(TABLE_NAME), TABLE_COMMENT
@@ -189,10 +205,12 @@ file_instances
 file_summary_by_event_name	
 file_summary_by_instance	
 mutex_instances	
+objects_summary_global_by_type	
 performance_timers	
 rwlock_instances	
 setup_actors	
 setup_consumers	
 setup_instruments	
+setup_objects	
 setup_timers	
 threads	

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-11-15 16:43:41 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc0.result	2010-11-24 08:34:13 +0000
@@ -19,14 +19,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -50,14 +52,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -79,14 +83,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -108,14 +114,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -137,14 +145,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-11-16 20:19:48 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc1.result	2010-11-24 08:34:13 +0000
@@ -19,14 +19,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -50,14 +52,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -79,14 +83,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -108,14 +114,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -137,14 +145,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result'
--- a/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-11-19 11:24:33 +0000
+++ b/mysql-test/suite/perfschema/r/pfs_upgrade_lc2.result	2010-11-24 08:34:13 +0000
@@ -19,14 +19,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_table";
 Tables_in_performance_schema (user_table)
@@ -50,14 +52,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 show tables like "user_view";
 Tables_in_performance_schema (user_view)
@@ -79,14 +83,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -108,14 +114,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.proc where db='performance_schema';
 name
@@ -137,14 +145,16 @@ ERROR 1050 (42S01) at line 183: Table 'f
 ERROR 1050 (42S01) at line 194: Table 'file_summary_by_event_name' already exists
 ERROR 1050 (42S01) at line 206: Table 'file_summary_by_instance' already exists
 ERROR 1050 (42S01) at line 215: Table 'mutex_instances' already exists
-ERROR 1050 (42S01) at line 225: Table 'performance_timers' already exists
-ERROR 1050 (42S01) at line 235: Table 'rwlock_instances' already exists
-ERROR 1050 (42S01) at line 244: Table 'setup_actors' already exists
-ERROR 1050 (42S01) at line 252: Table 'setup_consumers' already exists
-ERROR 1050 (42S01) at line 261: Table 'setup_instruments' already exists
-ERROR 1050 (42S01) at line 269: Table 'setup_timers' already exists
-ERROR 1050 (42S01) at line 289: Table 'threads' already exists
-ERROR 1644 (HY000) at line 707: Unexpected content found in the performance_schema database.
+ERROR 1050 (42S01) at line 229: Table 'objects_summary_global_by_type' already exists
+ERROR 1050 (42S01) at line 239: Table 'performance_timers' already exists
+ERROR 1050 (42S01) at line 249: Table 'rwlock_instances' already exists
+ERROR 1050 (42S01) at line 258: Table 'setup_actors' already exists
+ERROR 1050 (42S01) at line 266: Table 'setup_consumers' already exists
+ERROR 1050 (42S01) at line 275: Table 'setup_instruments' already exists
+ERROR 1050 (42S01) at line 285: Table 'setup_objects' already exists
+ERROR 1050 (42S01) at line 293: Table 'setup_timers' already exists
+ERROR 1050 (42S01) at line 313: Table 'threads' already exists
+ERROR 1644 (HY000) at line 731: Unexpected content found in the performance_schema database.
 FATAL ERROR: Upgrade failed
 select name from mysql.event where db='performance_schema';
 name

=== modified file 'mysql-test/suite/perfschema/r/privilege_table_io.result'
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result	2010-11-15 07:40:07 +0000
@@ -32,6 +32,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show status like "performance_schema%";
 Variable_name	Value
 Performance_schema_cond_classes_lost	0

=== removed file 'mysql-test/suite/perfschema/r/schema.result'
--- a/mysql-test/suite/perfschema/r/schema.result	2010-11-09 15:33:57 +0000
+++ b/mysql-test/suite/perfschema/r/schema.result	1970-01-01 00:00:00 +0000
@@ -1,200 +0,0 @@
-show databases;
-Database
-information_schema
-mtr
-mysql
-performance_schema
-test
-use performance_schema;
-show tables;
-Tables_in_performance_schema
-cond_instances
-events_waits_current
-events_waits_history
-events_waits_history_long
-events_waits_summary_by_instance
-events_waits_summary_by_thread_by_event_name
-events_waits_summary_global_by_event_name
-file_instances
-file_summary_by_event_name
-file_summary_by_instance
-mutex_instances
-performance_timers
-rwlock_instances
-setup_consumers
-setup_instruments
-setup_timers
-threads
-show create table cond_instances;
-Table	Create Table
-cond_instances	CREATE TABLE `cond_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_current;
-Table	Create Table
-events_waits_current	CREATE TABLE `events_waits_current` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history;
-Table	Create Table
-events_waits_history	CREATE TABLE `events_waits_history` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_history_long;
-Table	Create Table
-events_waits_history_long	CREATE TABLE `events_waits_history_long` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_ID` bigint(20) unsigned NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `SOURCE` varchar(64) DEFAULT NULL,
-  `TIMER_START` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_END` bigint(20) unsigned DEFAULT NULL,
-  `TIMER_WAIT` bigint(20) unsigned DEFAULT NULL,
-  `SPINS` int(10) unsigned DEFAULT NULL,
-  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
-  `OBJECT_NAME` varchar(512) DEFAULT NULL,
-  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `NESTING_EVENT_ID` bigint(20) unsigned DEFAULT NULL,
-  `OPERATION` varchar(16) NOT NULL,
-  `NUMBER_OF_BYTES` bigint(20) unsigned DEFAULT NULL,
-  `FLAGS` int(10) unsigned DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_instance;
-Table	Create Table
-events_waits_summary_by_instance	CREATE TABLE `events_waits_summary_by_instance` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_by_thread_by_event_name;
-Table	Create Table
-events_waits_summary_by_thread_by_event_name	CREATE TABLE `events_waits_summary_by_thread_by_event_name` (
-  `THREAD_ID` int(11) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table events_waits_summary_global_by_event_name;
-Table	Create Table
-events_waits_summary_global_by_event_name	CREATE TABLE `events_waits_summary_global_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_STAR` bigint(20) unsigned NOT NULL,
-  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
-  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_instances;
-Table	Create Table
-file_instances	CREATE TABLE `file_instances` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `OPEN_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_event_name;
-Table	Create Table
-file_summary_by_event_name	CREATE TABLE `file_summary_by_event_name` (
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table file_summary_by_instance;
-Table	Create Table
-file_summary_by_instance	CREATE TABLE `file_summary_by_instance` (
-  `FILE_NAME` varchar(512) NOT NULL,
-  `EVENT_NAME` varchar(128) NOT NULL,
-  `COUNT_READ` bigint(20) unsigned NOT NULL,
-  `COUNT_WRITE` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_READ` bigint(20) unsigned NOT NULL,
-  `SUM_NUMBER_OF_BYTES_WRITE` bigint(20) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table mutex_instances;
-Table	Create Table
-mutex_instances	CREATE TABLE `mutex_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table performance_timers;
-Table	Create Table
-performance_timers	CREATE TABLE `performance_timers` (
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL,
-  `TIMER_FREQUENCY` bigint(20) DEFAULT NULL,
-  `TIMER_RESOLUTION` bigint(20) DEFAULT NULL,
-  `TIMER_OVERHEAD` bigint(20) DEFAULT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table rwlock_instances;
-Table	Create Table
-rwlock_instances	CREATE TABLE `rwlock_instances` (
-  `NAME` varchar(128) NOT NULL,
-  `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
-  `WRITE_LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL,
-  `READ_LOCKED_BY_COUNT` int(10) unsigned NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_consumers;
-Table	Create Table
-setup_consumers	CREATE TABLE `setup_consumers` (
-  `NAME` varchar(64) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_instruments;
-Table	Create Table
-setup_instruments	CREATE TABLE `setup_instruments` (
-  `NAME` varchar(128) NOT NULL,
-  `ENABLED` enum('YES','NO') NOT NULL,
-  `TIMED` enum('YES','NO') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table setup_timers;
-Table	Create Table
-setup_timers	CREATE TABLE `setup_timers` (
-  `NAME` varchar(64) NOT NULL,
-  `TIMER_NAME` enum('CYCLE','NANOSECOND','MICROSECOND','MILLISECOND','TICK') NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
-show create table threads;
-Table	Create Table
-threads	CREATE TABLE `threads` (
-  `THREAD_ID` int(11) NOT NULL,
-  `PROCESSLIST_ID` int(11) DEFAULT NULL,
-  `NAME` varchar(128) NOT NULL
-) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8

=== modified file 'mysql-test/suite/perfschema/r/schema_lc0.result'
--- a/mysql-test/suite/perfschema/r/schema_lc0.result	2010-11-09 14:34:29 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc0.result	2010-11-15 07:40:07 +0000
@@ -18,11 +18,13 @@ file_instances
 file_summary_by_event_name
 file_summary_by_instance
 mutex_instances
+objects_summary_global_by_type
 performance_timers
 rwlock_instances
 setup_actors
 setup_consumers
 setup_instruments
+setup_objects
 setup_timers
 threads
 show create table cond_instances;
@@ -156,6 +158,18 @@ mutex_instances	CREATE TABLE `mutex_inst
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table objects_summary_global_by_type;
+Table	Create Table
+objects_summary_global_by_type	CREATE TABLE `objects_summary_global_by_type` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table performance_timers;
 Table	Create Table
 performance_timers	CREATE TABLE `performance_timers` (
@@ -192,6 +206,14 @@ setup_instruments	CREATE TABLE `setup_in
   `ENABLED` enum('YES','NO') NOT NULL,
   `TIMED` enum('YES','NO') NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table setup_objects;
+Table	Create Table
+setup_objects	CREATE TABLE `setup_objects` (
+  `OBJECT_TYPE` enum('TABLE') NOT NULL DEFAULT 'TABLE',
+  `OBJECT_SCHEMA` varchar(64) DEFAULT '%',
+  `OBJECT_NAME` varchar(64) NOT NULL DEFAULT '%',
+  `TIMED` enum('YES','NO') NOT NULL DEFAULT 'YES'
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table setup_timers;
 Table	Create Table
 setup_timers	CREATE TABLE `setup_timers` (

=== modified file 'mysql-test/suite/perfschema/r/schema_lc1.result'
--- a/mysql-test/suite/perfschema/r/schema_lc1.result	2010-11-09 14:34:29 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc1.result	2010-11-15 07:40:07 +0000
@@ -18,11 +18,13 @@ file_instances
 file_summary_by_event_name
 file_summary_by_instance
 mutex_instances
+objects_summary_global_by_type
 performance_timers
 rwlock_instances
 setup_actors
 setup_consumers
 setup_instruments
+setup_objects
 setup_timers
 threads
 show create table cond_instances;
@@ -156,6 +158,18 @@ mutex_instances	CREATE TABLE `mutex_inst
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table objects_summary_global_by_type;
+Table	Create Table
+objects_summary_global_by_type	CREATE TABLE `objects_summary_global_by_type` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table performance_timers;
 Table	Create Table
 performance_timers	CREATE TABLE `performance_timers` (
@@ -192,6 +206,14 @@ setup_instruments	CREATE TABLE `setup_in
   `ENABLED` enum('YES','NO') NOT NULL,
   `TIMED` enum('YES','NO') NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table setup_objects;
+Table	Create Table
+setup_objects	CREATE TABLE `setup_objects` (
+  `OBJECT_TYPE` enum('TABLE') NOT NULL DEFAULT 'TABLE',
+  `OBJECT_SCHEMA` varchar(64) DEFAULT '%',
+  `OBJECT_NAME` varchar(64) NOT NULL DEFAULT '%',
+  `TIMED` enum('YES','NO') NOT NULL DEFAULT 'YES'
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table setup_timers;
 Table	Create Table
 setup_timers	CREATE TABLE `setup_timers` (

=== modified file 'mysql-test/suite/perfschema/r/schema_lc2.result'
--- a/mysql-test/suite/perfschema/r/schema_lc2.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/schema_lc2.result	2010-11-15 07:40:07 +0000
@@ -18,11 +18,13 @@ file_instances
 file_summary_by_event_name
 file_summary_by_instance
 mutex_instances
+objects_summary_global_by_type
 performance_timers
 rwlock_instances
 setup_actors
 setup_consumers
 setup_instruments
+setup_objects
 setup_timers
 threads
 show create table cond_instances;
@@ -156,6 +158,18 @@ mutex_instances	CREATE TABLE `mutex_inst
   `OBJECT_INSTANCE_BEGIN` bigint(20) NOT NULL,
   `LOCKED_BY_THREAD_ID` int(11) DEFAULT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table objects_summary_global_by_type;
+Table	Create Table
+objects_summary_global_by_type	CREATE TABLE `objects_summary_global_by_type` (
+  `OBJECT_TYPE` varchar(64) DEFAULT NULL,
+  `OBJECT_SCHEMA` varchar(64) DEFAULT NULL,
+  `OBJECT_NAME` varchar(64) DEFAULT NULL,
+  `COUNT_STAR` bigint(20) unsigned NOT NULL,
+  `SUM_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MIN_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `AVG_TIMER_WAIT` bigint(20) unsigned NOT NULL,
+  `MAX_TIMER_WAIT` bigint(20) unsigned NOT NULL
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table performance_timers;
 Table	Create Table
 performance_timers	CREATE TABLE `performance_timers` (
@@ -192,6 +206,14 @@ setup_instruments	CREATE TABLE `setup_in
   `ENABLED` enum('YES','NO') NOT NULL,
   `TIMED` enum('YES','NO') NOT NULL
 ) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
+show create table setup_objects;
+Table	Create Table
+setup_objects	CREATE TABLE `setup_objects` (
+  `OBJECT_TYPE` enum('TABLE') NOT NULL DEFAULT 'TABLE',
+  `OBJECT_SCHEMA` varchar(64) DEFAULT '%',
+  `OBJECT_NAME` varchar(64) NOT NULL DEFAULT '%',
+  `TIMED` enum('YES','NO') NOT NULL DEFAULT 'YES'
+) ENGINE=PERFORMANCE_SCHEMA DEFAULT CHARSET=utf8
 show create table setup_timers;
 Table	Create Table
 setup_timers	CREATE TABLE `setup_timers` (

=== added file 'mysql-test/suite/perfschema/r/setup_objects.result'
--- a/mysql-test/suite/perfschema/r/setup_objects.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/setup_objects.result	2010-11-15 15:04:34 +0000
@@ -0,0 +1,102 @@
+drop table if exists test.setup_objects;
+create table test.setup_objects as select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects
+values ('TABLE', 'db1', 't1', 'YES');
+insert into performance_schema.setup_objects
+values ('TABLE', 'db1', 't2', 'NO');
+insert into performance_schema.setup_objects
+values ('TABLE', 'db1', '%', 'YES');
+insert into performance_schema.setup_objects
+values ('TABLE', 'db2', 't1', 'YES');
+insert into performance_schema.setup_objects
+values ('TABLE', 'db2', 't2', 'NO');
+select * from performance_schema.setup_objects
+order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+OBJECT_TYPE	OBJECT_SCHEMA	OBJECT_NAME	TIMED
+TABLE	db1	%	YES
+TABLE	db1	t1	YES
+TABLE	db1	t2	NO
+TABLE	db2	t1	YES
+TABLE	db2	t2	NO
+drop database if exists db1;
+drop database if exists db2;
+drop database if exists db3;
+create database db1;
+create database db2;
+create database db3;
+create table db1.t1(a int);
+create table db1.t2(a int);
+create table db1.t3(a int);
+create table db1.t4(a int);
+create table db1.t5(a int);
+create table db2.t1(a int);
+create table db2.t2(a int);
+create table db2.t3(a int);
+create table db2.t4(a int);
+create table db2.t5(a int);
+create table db3.t1(a int);
+select * from db1.t1;
+a
+select * from db1.t2;
+a
+select * from db1.t3;
+a
+select * from db1.t4;
+a
+select * from db1.t5;
+a
+select * from db2.t1;
+a
+select * from db2.t2;
+a
+select * from db2.t3;
+a
+select * from db2.t4;
+a
+select * from db2.t5;
+a
+select * from db3.t1;
+a
+create table db3.t2(a int);
+select * from db3.t2;
+a
+select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA 
+from performance_schema.events_waits_history_long
+where OBJECT_SCHEMA like "db%"
+  group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
+OBJECT_TYPE	OBJECT_NAME	OBJECT_SCHEMA
+TABLE	t1	db1
+TABLE	t1	db2
+TABLE	t2	db1
+TABLE	t2	db2
+TABLE	t3	db1
+TABLE	t4	db1
+TABLE	t5	db1
+select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA 
+from performance_schema.events_waits_history_long
+where OBJECT_SCHEMA like "db%" and TIMER_END is not NULL
+group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
+OBJECT_TYPE	OBJECT_NAME	OBJECT_SCHEMA
+TABLE	t1	db1
+TABLE	t1	db2
+TABLE	t3	db1
+TABLE	t4	db1
+TABLE	t5	db1
+update performance_schema.setup_objects
+set timed='YES' where OBJECT_SCHEMA = '%';
+create table db3.t3(a int);
+select * from db3.t3;
+a
+truncate table performance_schema.setup_objects;
+select count(*) from performance_schema.setup_objects;
+count(*)
+0
+drop database db1;
+drop database db2;
+drop database db3;
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects select * from test.setup_objects;
+drop table test.setup_objects;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_cond_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_cond_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_file_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_file_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_mutex_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_mutex_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_rwlock_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_rwlock_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_actors.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2010-11-09 14:34:29 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	0
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_setup_actors_size";

=== added file 'mysql-test/suite/perfschema/r/start_server_no_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result	2010-11-15 15:04:34 +0000
@@ -0,0 +1,67 @@
+show databases;
+Database
+information_schema
+mtr
+mysql
+performance_schema
+test
+select count(*) from performance_schema.performance_timers;
+count(*)
+5
+select count(*) from performance_schema.setup_consumers;
+count(*)
+5
+select count(*) > 1 from performance_schema.setup_instruments;
+count(*) > 1
+1
+select count(*) from performance_schema.setup_timers;
+count(*)
+1
+select * from performance_schema.cond_instances;
+select * from performance_schema.events_waits_current;
+select * from performance_schema.events_waits_history;
+select * from performance_schema.events_waits_history_long;
+select * from performance_schema.events_waits_summary_by_instance;
+select * from performance_schema.events_waits_summary_by_thread_by_event_name;
+select * from performance_schema.events_waits_summary_global_by_event_name;
+select * from performance_schema.file_instances;
+select * from performance_schema.file_summary_by_event_name;
+select * from performance_schema.file_summary_by_instance;
+select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
+select * from performance_schema.performance_timers;
+select * from performance_schema.rwlock_instances;
+select * from performance_schema.setup_actors;
+select * from performance_schema.setup_consumers;
+select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
+select * from performance_schema.setup_timers;
+select * from performance_schema.threads;
+show variables like "performance_schema%";
+Variable_name	Value
+performance_schema	ON
+performance_schema_events_waits_history_long_size	10000
+performance_schema_events_waits_history_size	10
+performance_schema_max_cond_classes	80
+performance_schema_max_cond_instances	1000
+performance_schema_max_file_classes	50
+performance_schema_max_file_handles	32768
+performance_schema_max_file_instances	10000
+performance_schema_max_mutex_classes	200
+performance_schema_max_mutex_instances	10000
+performance_schema_max_rwlock_classes	30
+performance_schema_max_rwlock_instances	10000
+performance_schema_max_table_handles	1000
+performance_schema_max_table_instances	500
+performance_schema_max_thread_classes	50
+performance_schema_max_thread_instances	1000
+performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	0
+show engine PERFORMANCE_SCHEMA status;
+show status like "performance_schema%";
+show variables like "performance_schema_setup_objects_size";
+Variable_name	Value
+performance_schema_setup_objects_size	0
+select count(*) from performance_schema.setup_objects;
+count(*)
+0

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_hdl.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_table_instances";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	0
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_table_instances";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	0
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_thread_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	0
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema_max_thread_classes";

=== modified file 'mysql-test/suite/perfschema/r/start_server_nothing.result'
--- a/mysql-test/suite/perfschema/r/start_server_nothing.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_nothing.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 0
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	0
 performance_schema_max_thread_classes	0
 performance_schema_max_thread_instances	0
 performance_schema_setup_actors_size	0
+performance_schema_setup_objects_size	0
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show variables like "performance_schema%";
@@ -75,6 +78,7 @@ performance_schema_max_table_instances	0
 performance_schema_max_thread_classes	0
 performance_schema_max_thread_instances	0
 performance_schema_setup_actors_size	0
+performance_schema_setup_objects_size	0
 select * from performance_schema.setup_instruments;
 NAME	ENABLED	TIMED
 wait/io/table/sql/handler	YES	YES
@@ -90,11 +94,8 @@ NAME	ENABLED
 events_waits_current	YES
 events_waits_history	YES
 events_waits_history_long	YES
-events_waits_summary_by_thread_by_event_name	YES
-events_waits_summary_by_event_name	YES
-events_waits_summary_by_instance	YES
-file_summary_by_event_name	YES
-file_summary_by_instance	YES
+global_instrumentation	YES
+thread_instrumentation	YES
 select * from performance_schema.setup_timers;
 NAME	TIMER_NAME
 wait	CYCLE
@@ -112,6 +113,7 @@ select * from performance_schema.events_
 THREAD_ID	EVENT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
 select * from performance_schema.events_waits_summary_global_by_event_name;
 EVENT_NAME	COUNT_STAR	SUM_TIMER_WAIT	MIN_TIMER_WAIT	AVG_TIMER_WAIT	MAX_TIMER_WAIT
+wait/io/table/sql/handler	0	0	0	0	0
 select * from performance_schema.file_instances;
 FILE_NAME	EVENT_NAME	OPEN_COUNT
 select * from performance_schema.file_summary_by_event_name;

=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 0
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show status like "performance_schema%";

=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result	2010-11-09 08:16:50 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result	2010-11-15 07:40:07 +0000
@@ -10,7 +10,7 @@ count(*)
 5
 select count(*) from performance_schema.setup_consumers;
 count(*)
-8
+5
 select count(*) > 1 from performance_schema.setup_instruments;
 count(*) > 1
 1
@@ -28,11 +28,13 @@ select * from performance_schema.file_in
 select * from performance_schema.file_summary_by_event_name;
 select * from performance_schema.file_summary_by_instance;
 select * from performance_schema.mutex_instances;
+select * from performance_schema.objects_summary_global_by_type;
 select * from performance_schema.performance_timers;
 select * from performance_schema.rwlock_instances;
 select * from performance_schema.setup_actors;
 select * from performance_schema.setup_consumers;
 select * from performance_schema.setup_instruments;
+select * from performance_schema.setup_objects;
 select * from performance_schema.setup_timers;
 select * from performance_schema.threads;
 show variables like "performance_schema%";
@@ -54,6 +56,7 @@ performance_schema_max_table_instances	5
 performance_schema_max_thread_classes	50
 performance_schema_max_thread_instances	1000
 performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
 show engine PERFORMANCE_SCHEMA status;
 show status like "performance_schema%";
 show status like "performance_schema%";

=== added file 'mysql-test/suite/perfschema/t/ddl_os_global_by_type.test'
--- a/mysql-test/suite/perfschema/t/ddl_os_global_by_type.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/ddl_os_global_by_type.test	2010-11-15 15:04:34 +0000
@@ -0,0 +1,34 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.objects_summary_global_by_type
+  add column foo integer;
+
+truncate table performance_schema.objects_summary_global_by_type;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.objects_summary_global_by_type
+  ADD INDEX test_index(OBJECT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index
+  ON performance_schema.objects_summary_global_by_type(OBJECT_NAME);
+

=== added file 'mysql-test/suite/perfschema/t/ddl_setup_objects.test'
--- a/mysql-test/suite/perfschema/t/ddl_setup_objects.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/ddl_setup_objects.test	2010-11-16 04:42:59 +0000
@@ -0,0 +1,44 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+-- error ER_DBACCESS_DENIED_ERROR
+alter table performance_schema.setup_objects add column foo integer;
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+
+create table test.setup_objects as
+  select * from performance_schema.setup_objects;
+
+truncate table performance_schema.setup_objects;
+
+select count(*) from performance_schema.setup_objects;
+
+insert into performance_schema.setup_objects
+  select * from test.setup_objects;
+drop table test.setup_objects;
+
+-- error ER_DBACCESS_DENIED_ERROR
+ALTER TABLE performance_schema.setup_objects ADD INDEX test_index(OBJECT_NAME);
+
+-- error ER_DBACCESS_DENIED_ERROR
+CREATE UNIQUE INDEX test_index ON performance_schema.setup_objects(OBJECT_NAME);
+

=== added file 'mysql-test/suite/perfschema/t/dml_os_global_by_type.test'
--- a/mysql-test/suite/perfschema/t/dml_os_global_by_type.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_os_global_by_type.test	2010-11-15 15:04:34 +0000
@@ -0,0 +1,72 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+  where object_schema = 'performance_schema' limit 1;
+
+select * from performance_schema.objects_summary_global_by_type
+  where object_schema='FOO';
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+  order by count_star limit 1;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+  order by count_star desc limit 1;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+  where object_type = 'TABLE' order by object_schema, object_name limit 1;
+
+--replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 #
+select * from performance_schema.objects_summary_global_by_type
+  where object_type = 'TABLE' order by object_schema desc, object_name desc limit 1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+insert into performance_schema.objects_summary_global_by_type
+  set object_type='TABLE', schema_name='FOO', object_name='BAR',
+  count_star=1, sum_timer_wait=2, min_timer_wait=3,
+  avg_timer_wait=4, max_timer_wait=5;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.objects_summary_global_by_type
+  set count_star=12;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+update performance_schema.objects_summary_global_by_type
+  set count_star=12 where object_name like "FOO";
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.objects_summary_global_by_type
+  where count_star=1;
+
+--error ER_TABLEACCESS_DENIED_ERROR
+delete from performance_schema.objects_summary_global_by_type;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.objects_summary_global_by_type READ;
+UNLOCK TABLES;
+
+-- error ER_TABLEACCESS_DENIED_ERROR
+LOCK TABLES performance_schema.objects_summary_global_by_type WRITE;
+UNLOCK TABLES;
+

=== added file 'mysql-test/suite/perfschema/t/dml_setup_objects.test'
--- a/mysql-test/suite/perfschema/t/dml_setup_objects.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/dml_setup_objects.test	2010-11-15 15:04:34 +0000
@@ -0,0 +1,108 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+
+# Save the setup
+create table test.setup_objects as
+  select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+
+# Test
+
+select * from performance_schema.setup_objects;
+
+select * from performance_schema.setup_objects
+  order by object_type, object_schema, object_name;
+
+select * from performance_schema.setup_objects
+  where object_type = 'TABLE'
+  order by object_type, object_schema, object_name;
+
+select * from performance_schema.setup_objects
+  order by object_type, object_schema, object_name;
+
+--error ER_NO_REFERENCED_ROW_2
+insert into performance_schema.setup_objects
+  set object_type='ILLEGAL', object_schema='FOO', object_name='BAR',
+  timed='YES';
+
+insert into performance_schema.setup_objects
+  set object_type='TABLE', object_schema='FOO', object_name='BAR',
+  timed='YES';
+
+--error ER_DUP_KEY
+insert into performance_schema.setup_objects
+  set object_type='TABLE', object_schema='FOO', object_name='BAR',
+  timed='NO';
+
+delete from performance_schema.setup_objects
+  where object_type='TABLE' and object_schema='FOO';
+
+select * from performance_schema.setup_objects
+  order by object_type, object_schema, object_name;
+
+insert into performance_schema.setup_objects
+  set object_type='TABLE', object_schema='FOO', object_name='BAR',
+  timed='YES';
+
+select * from performance_schema.setup_objects
+  order by object_type, object_schema, object_name;
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+  set object_type='ILLEGAL';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+  set object_schema='ILLEGAL';
+
+--error ER_WRONG_PERFSCHEMA_USAGE
+update performance_schema.setup_objects
+  set object_name='ILLEGAL';
+
+update performance_schema.setup_objects
+  set timed='NO';
+
+select * from performance_schema.setup_objects
+  order by object_type, object_schema, object_name;
+
+update performance_schema.setup_objects
+  set timed='YES';
+
+delete from performance_schema.setup_objects
+  where object_type = 'TABLE';
+
+delete from performance_schema.setup_objects;
+
+LOCK TABLES performance_schema.setup_objects READ;
+UNLOCK TABLES;
+
+LOCK TABLES performance_schema.setup_objects WRITE;
+UNLOCK TABLES;
+
+# Restore the setup
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects
+  select * from test.setup_objects;
+drop table test.setup_objects;
+

=== added file 'mysql-test/suite/perfschema/t/setup_objects.test'
--- a/mysql-test/suite/perfschema/t/setup_objects.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/setup_objects.test	2010-11-15 15:04:34 +0000
@@ -0,0 +1,118 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--disable_warnings
+drop table if exists test.setup_objects;
+--enable_warnings
+
+# Save the setup
+create table test.setup_objects as select * from performance_schema.setup_objects;
+truncate table performance_schema.setup_objects;
+
+insert into performance_schema.setup_objects
+  values ('TABLE', 'db1', 't1', 'YES');
+
+insert into performance_schema.setup_objects
+  values ('TABLE', 'db1', 't2', 'NO');
+
+insert into performance_schema.setup_objects
+  values ('TABLE', 'db1', '%', 'YES');
+
+insert into performance_schema.setup_objects
+  values ('TABLE', 'db2', 't1', 'YES');
+
+insert into performance_schema.setup_objects
+  values ('TABLE', 'db2', 't2', 'NO');
+
+select * from performance_schema.setup_objects
+  order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+--disable_warnings
+drop database if exists db1;
+drop database if exists db2;
+drop database if exists db3;
+--enable_warnings
+
+create database db1;
+create database db2;
+create database db3;
+
+create table db1.t1(a int);
+create table db1.t2(a int);
+create table db1.t3(a int);
+create table db1.t4(a int);
+create table db1.t5(a int);
+
+create table db2.t1(a int);
+create table db2.t2(a int);
+create table db2.t3(a int);
+create table db2.t4(a int);
+create table db2.t5(a int);
+
+create table db3.t1(a int);
+
+select * from db1.t1;
+select * from db1.t2;
+select * from db1.t3;
+select * from db1.t4;
+select * from db1.t5;
+
+select * from db2.t1;
+select * from db2.t2;
+select * from db2.t3;
+select * from db2.t4;
+select * from db2.t5;
+
+select * from db3.t1;
+
+create table db3.t2(a int);
+select * from db3.t2;
+
+# Verify what is instrumented
+select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA 
+  from performance_schema.events_waits_history_long
+  where OBJECT_SCHEMA like "db%"
+  group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+  order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
+
+# Verify what is instrumented and timed
+select distinct OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA 
+  from performance_schema.events_waits_history_long
+  where OBJECT_SCHEMA like "db%" and TIMER_END is not NULL
+  group by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA
+  order by OBJECT_TYPE, OBJECT_NAME, OBJECT_SCHEMA;
+
+update performance_schema.setup_objects
+  set timed='YES' where OBJECT_SCHEMA = '%';
+
+create table db3.t3(a int);
+select * from db3.t3;
+
+truncate table performance_schema.setup_objects;
+
+select count(*) from performance_schema.setup_objects;
+
+drop database db1;
+drop database db2;
+drop database db3;
+
+# Restore the setup
+truncate table performance_schema.setup_objects;
+insert into performance_schema.setup_objects select * from test.setup_objects;
+drop table test.setup_objects;
+

=== added file 'mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt'
--- a/mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_setup_objects-master.opt	2010-09-24 18:21:22 +0000
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance_schema_setup_objects_size=0

=== added file 'mysql-test/suite/perfschema/t/start_server_no_setup_objects.test'
--- a/mysql-test/suite/perfschema/t/start_server_no_setup_objects.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/start_server_no_setup_objects.test	2010-11-15 15:04:34 +0000
@@ -0,0 +1,28 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
+
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+--source ../include/start_server_common.inc
+
+# Expect no setup_objects
+show variables like "performance_schema_setup_objects_size";
+
+# Expect no setup_objects
+select count(*) from performance_schema.setup_objects;
+

=== modified file 'mysql-test/suite/perfschema_stress/r/modify.result'
--- a/mysql-test/suite/perfschema_stress/r/modify.result	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema_stress/r/modify.result	2010-11-26 10:36:52 +0000
@@ -1,17 +1,17 @@
-UPDATE performance_schema.SETUP_INSTRUMENTS SET TIMED = 'NO';
-UPDATE performance_schema.SETUP_INSTRUMENTS SET ENABLED = 'NO';
-UPDATE performance_schema.SETUP_TIMERS 
+UPDATE performance_schema.setup_instruments SET TIMED = 'NO';
+UPDATE performance_schema.setup_instruments SET ENABLED = 'NO';
+UPDATE performance_schema.setup_timers
 SET TIMER_NAME = 'NANOSECOND' WHERE NAME = 'Wait';
-UPDATE performance_schema.SETUP_TIMERS 
+UPDATE performance_schema.setup_timers
 SET TIMER_NAME = 'CYCLE' WHERE NAME = 'Wait';
-UPDATE performance_schema.SETUP_INSTRUMENTS SET TIMED = 'YES';
-UPDATE performance_schema.SETUP_INSTRUMENTS SET ENABLED = 'YES' 
-WHERE NAME IN ('wait/io/file/sql/FRM', 
-'thread/sql/Connection', 
-'wait/synch/cond/sql/COND_mdl', 
-'wait/synch/rwlock/sql/LOCK_sys_init_connect', 
+UPDATE performance_schema.setup_instruments SET TIMED = 'YES';
+UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'
+WHERE NAME IN ('wait/io/file/sql/FRM',
+'thread/sql/Connection',
+'wait/synch/cond/sql/COND_mdl',
+'wait/synch/rwlock/sql/LOCK_sys_init_connect',
 'wait/synch/mutex/sql/LOCK_mdl');
-UPDATE performance_schema.SETUP_CONSUMERS SET ENABLED = 'NO'
+UPDATE performance_schema.setup_consumers SET ENABLED = 'NO'
 WHERE NAME = 'events_waits_history';
-UPDATE performance_schema.SETUP_CONSUMERS SET ENABLED = 'YES'
+UPDATE performance_schema.setup_consumers SET ENABLED = 'YES'
 WHERE NAME = 'events_waits_history';

=== modified file 'mysql-test/suite/perfschema_stress/r/read.result'
--- a/mysql-test/suite/perfschema_stress/r/read.result	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema_stress/r/read.result	2010-11-26 10:36:52 +0000
@@ -1,21 +1,21 @@
-SELECT * FROM performance_schema.SETUP_INSTRUMENTS
+SELECT * FROM performance_schema.setup_instruments
 WHERE ENABLED='NO' AND TIMED='NO';
 NAME	ENABLED	TIMED
-SELECT * FROM performance_schema.EVENTS_WAITS_CURRENT
+SELECT * FROM performance_schema.events_waits_current
 WHERE (TIMER_END - TIMER_START != TIMER_WAIT);
 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
+SELECT * FROM performance_schema.events_waits_history
 WHERE SPINS != NULL;
 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.PROCESSLIST p,
-performance_schema.EVENTS_WAITS_CURRENT e
-WHERE p.THREAD_ID = e.THREAD_ID 
+SELECT * FROM performance_schema.threads p,
+performance_schema.events_waits_current e
+WHERE p.THREAD_ID = e.THREAD_ID
 AND TIMER_START = 0
 ORDER BY e.EVENT_ID;
-THREAD_ID	ID	NAME	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_CURRENT
-WHERE THREAD_ID IN (SELECT THREAD_ID 
-FROM performance_schema.PROCESSLIST
+THREAD_ID	NAME	TYPE	PROCESSLIST_ID	PROCESSLIST_USER	PROCESSLIST_HOST	PROCESSLIST_DB	PROCESSLIST_COMMAND	PROCESSLIST_TIME	PROCESSLIST_STATE	PROCESSLIST_INFO	PARENT_THREAD_ID	ROLE	INSTRUMENTED	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_current
+WHERE THREAD_ID IN (SELECT THREAD_ID
+FROM performance_schema.threads
 ORDER BY THREAD_ID)
 AND TIMER_END = 0
 AND TIMER_WAIT != NULL
@@ -25,5 +25,5 @@ SELECT SUM(COUNT_READ) AS sum_count_read
 SUM(COUNT_WRITE) AS sum_count_write,
 SUM(SUM_NUMBER_OF_BYTES_READ) AS sum_num_bytes_read,
 SUM(SUM_NUMBER_OF_BYTES_WRITE) AS sum_num_bytes_write
-FROM performance_schema.FILE_SUMMARY_BY_INSTANCE 
+FROM performance_schema.file_summary_by_instance
 WHERE FILE_NAME LIKE CONCAT('%', @@tmpdir, '%') ORDER BY NULL;

=== modified file 'mysql-test/suite/perfschema_stress/t/modify.test'
--- a/mysql-test/suite/perfschema_stress/t/modify.test	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema_stress/t/modify.test	2010-11-26 10:36:52 +0000
@@ -23,22 +23,22 @@ if (`SELECT ($have_table = 0)`) {
     --source suite/perfschema_stress/t/setup.test
 }
 
-UPDATE performance_schema.SETUP_INSTRUMENTS SET TIMED = 'NO';
+UPDATE performance_schema.setup_instruments SET TIMED = 'NO';
 
-UPDATE performance_schema.SETUP_INSTRUMENTS SET ENABLED = 'NO';
+UPDATE performance_schema.setup_instruments SET ENABLED = 'NO';
 
-UPDATE performance_schema.SETUP_TIMERS
+UPDATE performance_schema.setup_timers
 SET TIMER_NAME = 'NANOSECOND' WHERE NAME = 'Wait';
 
 # Let it run some time with the new timer name and instruments
 --sleep 1
 
-UPDATE performance_schema.SETUP_TIMERS
+UPDATE performance_schema.setup_timers
 SET TIMER_NAME = 'CYCLE' WHERE NAME = 'Wait';
 
-UPDATE performance_schema.SETUP_INSTRUMENTS SET TIMED = 'YES';
+UPDATE performance_schema.setup_instruments SET TIMED = 'YES';
 
-UPDATE performance_schema.SETUP_INSTRUMENTS SET ENABLED = 'YES'
+UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'
 WHERE NAME IN ('wait/io/file/sql/FRM',
                'thread/sql/Connection',
                'wait/synch/cond/sql/COND_mdl',
@@ -48,8 +48,8 @@ WHERE NAME IN ('wait/io/file/sql/FRM',
 # Two short lived changes to see that switching does not lead
 # to havoc.
 
-UPDATE performance_schema.SETUP_CONSUMERS SET ENABLED = 'NO'
+UPDATE performance_schema.setup_consumers SET ENABLED = 'NO'
 WHERE NAME = 'events_waits_history';
 
-UPDATE performance_schema.SETUP_CONSUMERS SET ENABLED = 'YES'
+UPDATE performance_schema.setup_consumers SET ENABLED = 'YES'
 WHERE NAME = 'events_waits_history';

=== modified file 'mysql-test/suite/perfschema_stress/t/read.test'
--- a/mysql-test/suite/perfschema_stress/t/read.test	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema_stress/t/read.test	2010-11-26 10:36:52 +0000
@@ -15,24 +15,24 @@
 
 --source include/not_embedded.inc
 
-SELECT * FROM performance_schema.SETUP_INSTRUMENTS
+SELECT * FROM performance_schema.setup_instruments
 WHERE ENABLED='NO' AND TIMED='NO';
 
-SELECT * FROM performance_schema.EVENTS_WAITS_CURRENT
+SELECT * FROM performance_schema.events_waits_current
 WHERE (TIMER_END - TIMER_START != TIMER_WAIT);
 
-SELECT * FROM performance_schema.EVENTS_WAITS_HISTORY
+SELECT * FROM performance_schema.events_waits_history
 WHERE SPINS != NULL;
 
-SELECT * FROM performance_schema.PROCESSLIST p,
-              performance_schema.EVENTS_WAITS_CURRENT e
+SELECT * FROM performance_schema.threads p,
+              performance_schema.events_waits_current e
 WHERE p.THREAD_ID = e.THREAD_ID
   AND TIMER_START = 0
 ORDER BY e.EVENT_ID;
 
-SELECT * FROM performance_schema.EVENTS_WAITS_CURRENT
+SELECT * FROM performance_schema.events_waits_current
 WHERE THREAD_ID IN (SELECT THREAD_ID
-                    FROM performance_schema.PROCESSLIST
+                    FROM performance_schema.threads
                     ORDER BY THREAD_ID)
   AND TIMER_END = 0
   AND TIMER_WAIT != NULL
@@ -43,7 +43,7 @@ SELECT SUM(COUNT_READ) AS sum_count_read
        SUM(COUNT_WRITE) AS sum_count_write,
        SUM(SUM_NUMBER_OF_BYTES_READ) AS sum_num_bytes_read,
        SUM(SUM_NUMBER_OF_BYTES_WRITE) AS sum_num_bytes_write
-FROM performance_schema.FILE_SUMMARY_BY_INSTANCE
+FROM performance_schema.file_summary_by_instance
 WHERE FILE_NAME LIKE CONCAT('%', @@tmpdir, '%') ORDER BY NULL;
 --enable_result_log
 

=== modified file 'mysql-test/suite/perfschema_stress/t/setup.test'
--- a/mysql-test/suite/perfschema_stress/t/setup.test	2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema_stress/t/setup.test	2010-11-26 10:36:52 +0000
@@ -48,17 +48,17 @@ while (`SELECT MAX(id) < $num_stress_row
 
 # Turn on some instruments
 
-UPDATE performance_schema.SETUP_INSTRUMENTS SET TIMED = 'YES';
+UPDATE performance_schema.setup_instruments SET TIMED = 'YES';
 
-UPDATE performance_schema.SETUP_INSTRUMENTS SET ENABLED = 'NO';
-UPDATE performance_schema.SETUP_INSTRUMENTS SET ENABLED = 'YES'
+UPDATE performance_schema.setup_instruments SET ENABLED = 'NO';
+UPDATE performance_schema.setup_instruments SET ENABLED = 'YES'
 WHERE NAME IN ('wait/io/file/sql/FRM',
                'thread/sql/Connection',
                'wait/synch/cond/sql/COND_mdl',
                'wait/synch/rwlock/sql/LOCK_sys_init_connect',
                'wait/synch/mutex/sql/LOCK_mdl');
 
-UPDATE performance_schema.SETUP_CONSUMERS SET ENABLED = 'YES';
+UPDATE performance_schema.setup_consumers SET ENABLED = 'YES';
 
 --enable_result_log
 --enable_query_log

=== added file 'mysql-test/suite/sys_vars/r/pfs_setup_objects_size_basic.result'
--- a/mysql-test/suite/sys_vars/r/pfs_setup_objects_size_basic.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/r/pfs_setup_objects_size_basic.result	2010-09-24 18:21:22 +0000
@@ -0,0 +1,23 @@
+select @@global.performance_schema_setup_objects_size;
+@@global.performance_schema_setup_objects_size
+123
+select @@session.performance_schema_setup_objects_size;
+ERROR HY000: Variable 'performance_schema_setup_objects_size' is a GLOBAL variable
+show global variables like 'performance_schema_setup_objects_size';
+Variable_name	Value
+performance_schema_setup_objects_size	123
+show session variables like 'performance_schema_setup_objects_size';
+Variable_name	Value
+performance_schema_setup_objects_size	123
+select * from information_schema.global_variables
+where variable_name='performance_schema_setup_objects_size';
+VARIABLE_NAME	VARIABLE_VALUE
+PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE	123
+select * from information_schema.session_variables
+where variable_name='performance_schema_setup_objects_size';
+VARIABLE_NAME	VARIABLE_VALUE
+PERFORMANCE_SCHEMA_SETUP_OBJECTS_SIZE	123
+set global performance_schema_setup_objects_size=1;
+ERROR HY000: Variable 'performance_schema_setup_objects_size' is a read only variable
+set session performance_schema_setup_objects_size=1;
+ERROR HY000: Variable 'performance_schema_setup_objects_size' is a read only variable

=== added file 'mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic-master.opt'
--- a/mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic-master.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic-master.opt	2010-09-24 18:21:22 +0000
@@ -0,0 +1,2 @@
+--loose-enable-performance-schema
+--loose-performance-schema-setup-objects-size=123

=== added file 'mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic.test'
--- a/mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/sys_vars/t/pfs_setup_objects_size_basic.test	2010-09-24 18:21:22 +0000
@@ -0,0 +1,47 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.   
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# Only global
+#
+
+select @@global.performance_schema_setup_objects_size;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+select @@session.performance_schema_setup_objects_size;
+
+show global variables like 'performance_schema_setup_objects_size';
+
+show session variables like 'performance_schema_setup_objects_size';
+
+select * from information_schema.global_variables
+  where variable_name='performance_schema_setup_objects_size';
+
+select * from information_schema.session_variables
+  where variable_name='performance_schema_setup_objects_size';
+
+#
+# Read-only
+#
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set global performance_schema_setup_objects_size=1;
+
+--error ER_INCORRECT_GLOBAL_LOCAL_VAR
+set session performance_schema_setup_objects_size=1;
+

=== modified file 'scripts/mysql_system_tables.sql'
--- a/scripts/mysql_system_tables.sql	2010-11-15 16:43:41 +0000
+++ b/scripts/mysql_system_tables.sql	2010-11-24 08:34:13 +0000
@@ -389,6 +389,26 @@ EXECUTE stmt;
 DROP PREPARE stmt;
 
 --
+-- TABLE OBJECTS_SUMMARY_GLOBAL_BY_TYPE
+--
+
+SET @cmd="CREATE TABLE performance_schema.objects_summary_global_by_type("
+  "OBJECT_TYPE VARCHAR(64),"
+  "OBJECT_SCHEMA VARCHAR(64),"
+  "OBJECT_NAME VARCHAR(64),"
+  "COUNT_STAR BIGINT unsigned not null,"
+  "SUM_TIMER_WAIT BIGINT unsigned not null,"
+  "MIN_TIMER_WAIT BIGINT unsigned not null,"
+  "AVG_TIMER_WAIT BIGINT unsigned not null,"
+  "MAX_TIMER_WAIT BIGINT unsigned not null"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
 -- TABLE PERFORMANCE_TIMERS
 --
 
@@ -460,6 +480,22 @@ SET @cmd="CREATE TABLE performance_schem
   ")ENGINE=PERFORMANCE_SCHEMA;";
 
 SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
+PREPARE stmt FROM @str;
+EXECUTE stmt;
+DROP PREPARE stmt;
+
+--
+-- TABLE SETUP_OBJECTS
+--
+
+SET @cmd="CREATE TABLE performance_schema.setup_objects("
+  "OBJECT_TYPE ENUM ('TABLE') not null default 'TABLE',"
+  "OBJECT_SCHEMA VARCHAR(64) default '%',"
+  "OBJECT_NAME VARCHAR(64) not null default '%',"
+  "TIMED ENUM ('YES', 'NO') not null default 'YES'"
+  ")ENGINE=PERFORMANCE_SCHEMA;";
+
+SET @str = IF(@have_pfs = 1, @cmd, 'SET @dummy = 0');
 PREPARE stmt FROM @str;
 EXECUTE stmt;
 DROP PREPARE stmt;

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2010-11-23 23:10:22 +0000
+++ b/sql/sys_vars.cc	2010-11-29 14:44:06 +0000
@@ -206,6 +206,14 @@ static Sys_var_ulong Sys_pfs_setup_actor
        DEFAULT(PFS_MAX_SETUP_ACTOR),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
+static Sys_var_ulong Sys_pfs_setup_objects_size(
+       "performance_schema_setup_objects_size",
+       "Maximum number of rows in SETUP_OBJECTS.",
+       READ_ONLY GLOBAL_VAR(pfs_param.m_setup_object_sizing),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
+       DEFAULT(PFS_MAX_SETUP_OBJECT),
+       BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
+
 #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
 static Sys_var_ulong Sys_auto_increment_increment(

=== modified file 'storage/perfschema/CMakeLists.txt'
--- a/storage/perfschema/CMakeLists.txt	2010-09-01 22:59:33 +0000
+++ b/storage/perfschema/CMakeLists.txt	2010-09-23 16:08:54 +0000
@@ -34,20 +34,24 @@ SET(PERFSCHEMA_SOURCES ha_perfschema.h
   pfs_atomic.h
   pfs_server.h
   pfs_setup_actor.h
+  pfs_setup_object.h
   pfs_stat.h
   pfs_engine_table.h
   pfs_timer.h
   table_all_instr.h
   table_events_waits.h
   table_events_waits_summary.h
+  table_ews_by_thread_by_event_name.h
   table_ews_global_by_event_name.h
   table_file_instances.h
   table_file_summary.h
   table_helper.h
+  table_os_global_by_type.h
   table_performance_timers.h
   table_setup_actors.h
   table_setup_consumers.h
   table_setup_instruments.h
+  table_setup_objects.h
   table_setup_timers.h
   table_sync_instances.h
   table_threads.h
@@ -61,18 +65,23 @@ SET(PERFSCHEMA_SOURCES ha_perfschema.h
   pfs_instr_class.cc
   pfs_server.cc
   pfs_setup_actor.cc
+  pfs_setup_object.cc
   pfs_engine_table.cc
   pfs_timer.cc
   table_all_instr.cc
   table_events_waits.cc
   table_events_waits_summary.cc
+  table_ews_by_thread_by_event_name.cc
   table_ews_global_by_event_name.cc
   table_file_instances.cc
   table_file_summary.cc
+  table_helper.cc
+  table_os_global_by_type.cc
   table_performance_timers.cc
   table_setup_actors.cc
   table_setup_consumers.cc
   table_setup_instruments.cc
+  table_setup_objects.cc
   table_setup_timers.cc
   table_sync_instances.cc
   table_threads.cc

=== modified file 'storage/perfschema/Makefile.am'
--- a/storage/perfschema/Makefile.am	2010-09-01 22:59:33 +0000
+++ b/storage/perfschema/Makefile.am	2010-09-23 16:08:54 +0000
@@ -45,7 +45,9 @@ noinst_HEADERS = ha_perfschema.h pfs_eng
 		table_ews_global_by_event_name.h table_all_instr.h \
 		table_file_instances.h table_file_summary.h \
 		pfs_lock.h pfs_atomic.h \
-		pfs_setup_actor.h pfs_defaults.h
+		pfs_setup_actor.h pfs_defaults.h \
+		pfs_setup_objects.h table_setup_objects.h table_helper.cc \
+		table_ews_by_thread_by_event_name.h table_os_global_by_type.h
 
 PSE_SOURCES = ha_perfschema.cc pfs_engine_table.cc pfs.cc pfs_server.cc \
 		pfs_global.cc pfs_instr_class.cc pfs_instr.cc \
@@ -59,7 +61,9 @@ PSE_SOURCES = ha_perfschema.cc pfs_engin
 		table_ews_global_by_event_name.cc table_all_instr.cc \
 		table_file_instances.cc table_file_summary.cc \
 		pfs_atomic.cc pfs_check.cc \
-		pfs_setup_actor.cc pfs_defaults.cc
+		pfs_setup_actor.cc pfs_defaults.cc \
+		pfs_setup_object.cc table_setup_objects.cc \
+		table_ews_by_thread_by_event_name.cc table_os_global_by_type.cc
 
 EXTRA_LIBRARIES = libperfschema.a
 noinst_LIBRARIES = @plugin_perfschema_static_target@

=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc	2010-09-01 22:59:33 +0000
+++ b/storage/perfschema/pfs.cc	2010-10-25 14:43:00 +0000
@@ -29,6 +29,7 @@
 #include "pfs_timer.h"
 #include "pfs_events_waits.h"
 #include "pfs_setup_actor.h"
+#include "pfs_setup_object.h"
 
 /**
   @page PAGE_PERFORMANCE_SCHEMA The Performance Schema main page
@@ -300,8 +301,7 @@
 */
 
 /**
-  @page PAGE_INSTRUMENTATION_INTERFACE
-  Performance schema: instrumentation interface page.
+  @page PAGE_INSTRUMENTATION_INTERFACE Performance schema: instrumentation interface page.
   MySQL performance schema instrumentation interface.
 
   @section INTRO Introduction
@@ -487,7 +487,7 @@ static inline int mysql_mutex_lock(...)
   Applying this function to our point P gives another point P':
 
   F_i (P):
-  P(x1, x2, ..., x{i-1}, x_i, x{i+1}, ..., x_N
+  P(x1, x2, ..., x{i-1}, x_i, x{i+1}, ..., x_N)
   --> P' (x1, x2, ..., x{i-1}, f_i(x_i), x{i+1}, ..., x_N)
 
   That function defines in fact an aggregate !
@@ -583,27 +583,17 @@ static inline int mysql_mutex_lock(...)
 
   What has all this to do with the code ?
 
-  Function composition such as F_2_to_3 o F_1_to_2 o F1 is implemented
-  as PFS_single_stat_chain, where each link in the chain represents
-  an individual F_{i}_to_{i+1} aggregation step.
+  Functions (or aggregates) such as F_3 are not implemented as is.
+  Instead, they are decomposed into F_2_to_3 o F_1_to_2 o F1,
+  and each intermediate aggregate is stored into an internal buffer.
+  This allows to support every F1, F2, F3 aggregates from shared
+  internal buffers, where computation already performed to compute F2
+  is reused when computing F3.
 
-  A single call to aggregate_single_stat_chain() updates all the tables
-  described in the statistics chain.
+  @section OBJECT_GRAPH Object graph
 
-  @section STAT_CHAIN Statistics chains
-
-  Statistics chains are only used for on the fly aggregates,
-  and are therefore all based initially on the '_CURRENT' base table that
-  contains the data recorded.
-  The following table aggregates are implemented with a statistics chain:
-
-  EVENTS_WAITS_CURRENT --> EVENTS_WAITS_SUMMARY_BY_INSTANCE
-  --> EVENTS_WAITS_SUMMARY_BY_EVENT_NAME
-
-  This relationship is between classes.
-
-  In terms of object instances, or records, this chain is implemented
-  as a flyweight.
+  In terms of object instances, or records, pointers between
+  different buffers define an object instance graph.
 
   For example, assuming the following scenario:
   - A mutex class "M" is instrumented, the instrument name
@@ -654,10 +644,244 @@ static inline int mysql_mutex_lock(...)
   This is necessary because the data the aggregate is based on is volatile,
   and can not be kept indefinitely.
 
+  With on the fly aggregates:
+  - the writer thread does all the computation
+  - the reader thread accesses the result directly
+
+  This model is to be avoided if possible, due to the overhead
+  caused when instrumenting code.
+
   @section HIGHER_LEVEL Higher level aggregates
 
-  Note: no higher level aggregate is implemented yet,
-  this section is a place holder.
+  'Higher level' aggregates are implemented on demand only.
+  The code executing a SELECT from the aggregate table is
+  collecting data from multiple internal buffers to produce the result.
+
+  With higher level aggregates:
+  - the reader thread does all the computation
+  - the writer thread has no overhead.
+
+  @section MIXED Mixed level aggregates
+
+  The 'Mixed' model is a compromise between 'On the fly' and 'Higher level'
+  aggregates, for internal buffers that are not permanent.
+
+  While an object is present in a buffer, the higher level model is used.
+  When an object is about to be destroyed, statistics are saved into
+  a 'parent' buffer with a longer life cycle, to follow the on the fly model.
+
+  With mixed aggregates:
+  - the reader thread does a lot of complex computation,
+  - the writer thread has minimal overhead, on destroy events.
+
+  @section IMPL_WAIT Implementation for waits aggregates
+
+  For waits, the tables that contains aggregated wait data are:
+  - EVENTS_WAITS_SUMMARY_BY_INSTANCE
+  - EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME
+  - EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME
+  - FILE_SUMMARY_BY_EVENT_NAME
+  - FILE_SUMMARY_BY_INSTANCE
+  - OBJECTS_SUMMARY_GLOBAL_BY_TYPE
+
+  The instrumented code that generates waits events consist of:
+  - mutexes (mysql_mutex_t)
+  - rwlocks (mysql_rwlock_t)
+  - conditions (mysql_cond_t)
+  - file io (MYSQL_FILE)
+  - table io
+
+  The flow of data between aggregates tables varies for each instrumentation.
+
+  @subsection IMPL_WAIT_MUTEX Mutex waits
+
+@verbatim
+  mutex_locker(T, M)
+   |
+   | [1]
+   |
+   |-> pfs_mutex(M)                           =====>> [B], [C]
+   |    |
+   |    | [2]
+   |    |
+   |    |-> pfs_mutex_class(M.class)          =====>> [C]
+   |
+   |-> pfs_thread(T).event_name(M)            =====>> [A], [D], [E], [F]
+        |
+        | [3]
+        |
+        |-> pfs_user_host(U, H).event_name(M) =====>> [D], [E], [F]
+        |    |
+        |    | [4]
+        |    |
+        |----+-> pfs_user(U).event_name(M)    =====>> [E]
+        |    |
+        |----+-> pfs_host(H).event_name(M)    =====>> [F]
+@endverbatim
+
+  How to read this diagram:
+  - events that occur during the instrumented code execution are noted with numbers,
+  as in [1]. Code executed by these events has an impact on overhead.
+  - events that occur when a reader extracts data from a performance schema table
+  are noted with letters, as in [A]. The name of the table involved,
+  and the method that builds a row are documented. Code executed by these events
+  has no impact on the instrumentation overhead. Note that the table
+  implementation may pull data from different buffers.
+  - placeholders for aggregates tables that are not implemented yet are
+  documented, to illustrate the overall architecture principles.
+
+  Implemented as:
+  - [1] @c get_thread_mutex_locker_v1(), @c start_mutex_wait_v1(), @c end_mutex_wait_v1()
+  - [2] @c destroy_mutex_v1()
+  - [A] EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME,
+        @c table_ews_by_thread_by_event_name::make_row()
+  - [B] EVENTS_WAITS_SUMMARY_BY_INSTANCE,
+        @c table_events_waits_summary_by_instance::make_mutex_row()
+  - [C] EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME,
+        @c table_ews_global_by_event_name::make_mutex_row()
+
+  Not implemented:
+  - [3] thread disconnect
+  - [4] user host disconnect
+  - [D] EVENTS_WAITS_SUMMARY_BY_USER_HOST_BY_EVENT_NAME,
+        table_ews_by_user_host_by_event_name::make_row()
+  - [E] EVENTS_WAITS_SUMMARY_BY_USER_BY_EVENT_NAME,
+        table_ews_by_user_by_event_name::make_row()
+  - [F] EVENTS_WAITS_SUMMARY_BY_HOST_BY_EVENT_NAME,
+        table_ews_by_host_by_event_name::make_row()
+
+  Table EVENTS_WAITS_SUMMARY_BY_INSTANCE is a 'on the fly' aggregate,
+  because the data is collected on the fly by (1) and stored into a buffer,
+  pfs_mutex. The table implementation [B] simply reads the results directly
+  from this buffer.
+
+  Table EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME is a 'mixed' aggregate,
+  because some data is collected on the fly (1),
+  some data is preserved with (2) at a later time in the life cycle,
+  and two different buffers pfs_mutex and pfs_mutex_class are used to store the
+  statistics collected. The table implementation [C] is more complex, since
+  it reads from two buffers pfs_mutex and pfs_mutex_class.
+
+  @subsection IMPL_WAIT_RWLOCK Rwlock waits
+
+@verbatim
+  rwlock_locker(T, R)
+   |
+   | [1]
+   |
+   |-> pfs_rwlock(R)                          =====>> [B], [C]
+   |    |
+   |    | [2]
+   |    |
+   |    |-> pfs_rwlock_class(R.class)         =====>> [C]
+   |
+   |-> pfs_thread(T).event_name(R)            =====>> [A]
+        |
+       ...
+@endverbatim
+
+  Implemented as:
+  - [1] @c get_thread_rwlock_locker_v1(), @c start_rwlock_rdwait_v1(),
+        @c end_rwlock_rdwait_v1(), ...
+  - [2] @c destroy_rwlock_v1()
+  - [A] EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME,
+        @c table_ews_by_thread_by_event_name::make_row()
+  - [B] EVENTS_WAITS_SUMMARY_BY_INSTANCE,
+        @c table_events_waits_summary_by_instance::make_rwlock_row()
+  - [C] EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME,
+        @c table_ews_global_by_event_name::make_rwlock_row()
+
+  @subsection IMPL_WAIT_COND Cond waits
+
+@verbatim
+  cond_locker(T, C)
+   |
+   | [1]
+   |
+   |-> pfs_cond(C)                            =====>> [B], [C]
+   |    |
+   |    | [2]
+   |    |
+   |    |-> pfs_cond_class(C.class)           =====>> [C]
+   |
+   |-> pfs_thread(T).event_name(C)            =====>> [A]
+        |
+       ...
+@endverbatim
+
+  Implemented as:
+  - [1] @c get_thread_cond_locker_v1(), @c start_cond_wait_v1(), @c end_cond_wait_v1()
+  - [2] @c destroy_cond_v1()
+  - [A] EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME,
+        @c table_ews_by_thread_by_event_name::make_row()
+  - [B] EVENTS_WAITS_SUMMARY_BY_INSTANCE,
+        @c table_events_waits_summary_by_instance::make_cond_row()
+  - [C] EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME,
+        @c table_ews_global_by_event_name::make_cond_row()
+
+  @subsection IMPL_WAIT_FILE File waits
+
+@verbatim
+  file_locker(T, F)
+   |
+   | [1]
+   |
+   |-> pfs_file(F)                            =====>> [B], [C], [D], [E]
+   |    |
+   |    | [2]
+   |    |
+   |    |-> pfs_file_class(F.class)           =====>> [C], [D]
+   |
+   |-> pfs_thread(T).event_name(F)            =====>> [A]
+        |
+       ...
+@endverbatim
+
+  Implemented as:
+  - [1] @c get_thread_file_name_locker_v1(), @c start_file_wait_v1(),
+        @c end_file_wait_v1(), ...
+  - [2] @c close_file_v1()
+  - [A] EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME,
+        @c table_ews_by_thread_by_event_name::make_row()
+  - [B] EVENTS_WAITS_SUMMARY_BY_INSTANCE,
+        @c table_events_waits_summary_by_instance::make_file_row()
+  - [C] EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME,
+        @c table_ews_global_by_event_name::make_file_row()
+  - [D] FILE_SUMMARY_BY_EVENT_NAME,
+        @c table_file_summary_by_event_name::make_row()
+  - [E] FILE_SUMMARY_BY_INSTANCE,
+        @c table_file_summary_by_instance::make_row()
+
+  @subsection IMPL_WAIT_TABLE Table waits
+
+@verbatim
+  table_locker(T, Tb)
+   |
+   | [1]
+   |
+   |-> pfs_table(Tb)                          =====>> [B], [C], [D]
+   |    |
+   |    | [2]
+   |    |
+   |    |-> pfs_table_share(Tb.share)         =====>> [C], [D]
+   |
+   |-> pfs_thread(T).event_name(Tb)           =====>> [A]
+        |
+       ...
+@endverbatim
+
+  Implemented as:
+  - [1] @c get_thread_table_locker_v1(), @c start_table_wait_v1(), @c end_table_wait_v1()
+  - [2] @c close_table_v1()
+  - [A] EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME,
+        @c table_ews_by_thread_by_event_name::make_row()
+  - [B] EVENTS_WAITS_SUMMARY_BY_INSTANCE,
+        @c table_events_waits_summary_by_instance::make_table_row()
+  - [C] EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME,
+        @c table_ews_global_by_event_name::make_table_io_row()
+  - [D] OBJECTS_SUMMARY_GLOBAL_BY_TYPE,
+        @c table_os_global_by_type::make_row()
+
 */
 
 /**
@@ -673,6 +897,10 @@ static inline int mysql_mutex_lock(...)
   @ingroup Performance_schema_implementation
 */
 
+#define STATE_FLAG_TIMED (1<<0)
+#define STATE_FLAG_THREAD (1<<1)
+#define STATE_FLAG_WAIT (1<<2)
+
 pthread_key(PFS_thread*, THR_PFS);
 bool THR_PFS_initialized= false;
 
@@ -735,6 +963,27 @@ static enum_operation_type table_operati
   OPERATION_TYPE_TABLE_DELETE_ROW
 };
 
+static void aggregate_table(PFS_table *pfs)
+{
+  DBUG_ASSERT(pfs);
+  PFS_table_share *table_share= pfs->m_share;
+  DBUG_ASSERT(table_share);
+
+  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME */
+  PFS_thread *thread= pfs->m_opening_thread;
+  DBUG_ASSERT(thread != NULL);
+  PFS_single_stat *event_name_array;
+  uint index;
+  event_name_array= thread->m_instr_class_wait_stats;
+
+  index= global_table_io_class.m_event_name_index;
+  pfs->m_table_stat.sum_io(& event_name_array[index]);
+
+  /* Aggregate to TABLE_IO_SUMMARY, TABLE_LOCK_SUMMARY */
+  table_share->m_table_stat.aggregate(&pfs->m_table_stat);
+  pfs->m_table_stat.reset();
+}
+
 /**
   Build the prefix name of a class of instruments in a category.
   For example, this function builds the string 'wait/sync/mutex/sql/' from
@@ -872,11 +1121,6 @@ static void register_file_v1(const char
 #define INIT_BODY_V1(T, KEY, ID)                                            \
   PFS_##T##_class *klass;                                                   \
   PFS_##T *pfs;                                                             \
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS); \
-  if (unlikely(pfs_thread == NULL))                                         \
-    return NULL;                                                            \
-  if (! pfs_thread->m_enabled)                                              \
-    return NULL;                                                            \
   klass= find_##T##_class(KEY);                                             \
   if (unlikely(klass == NULL))                                              \
     return NULL;                                                            \
@@ -885,36 +1129,60 @@ static void register_file_v1(const char
   pfs= create_##T(klass, ID);                                               \
   return reinterpret_cast<PSI_##T *> (pfs)
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::init_mutex.
+*/
 static PSI_mutex*
 init_mutex_v1(PSI_mutex_key key, const void *identity)
 {
   INIT_BODY_V1(mutex, key, identity);
 }
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::destroy_mutex.
+*/
 static void destroy_mutex_v1(PSI_mutex* mutex)
 {
   PFS_mutex *pfs= reinterpret_cast<PFS_mutex*> (mutex);
   destroy_mutex(pfs);
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::init_rwlock.
+*/
 static PSI_rwlock*
 init_rwlock_v1(PSI_rwlock_key key, const void *identity)
 {
   INIT_BODY_V1(rwlock, key, identity);
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::destroy_rwlock.
+*/
 static void destroy_rwlock_v1(PSI_rwlock* rwlock)
 {
   PFS_rwlock *pfs= reinterpret_cast<PFS_rwlock*> (rwlock);
   destroy_rwlock(pfs);
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::init_cond.
+*/
 static PSI_cond*
 init_cond_v1(PSI_cond_key key, const void *identity)
 {
   INIT_BODY_V1(cond, key, identity);
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::destroy_cond.
+*/
 static void destroy_cond_v1(PSI_cond* cond)
 {
   PFS_cond *pfs= reinterpret_cast<PFS_cond*> (cond);
@@ -928,11 +1196,13 @@ static void destroy_cond_v1(PSI_cond* co
 static PSI_table_share*
 get_table_share_v1(my_bool temporary, TABLE_SHARE *share)
 {
+  /* Do not instrument this table is all table instruments are disabled. */
+  if (! global_table_io_class.m_enabled)
+    return NULL;
+  /* An instrumented thread is required, for LF_PINS. */
   PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   if (unlikely(pfs_thread == NULL))
     return NULL;
-  if (! global_table_class.m_enabled)
-    return NULL;
   PFS_table_share* pfs_share;
   pfs_share= find_or_create_table_share(pfs_thread, temporary, share);
   return reinterpret_cast<PSI_table_share*> (pfs_share);
@@ -945,12 +1215,9 @@ get_table_share_v1(my_bool temporary, TA
 static void release_table_share_v1(PSI_table_share* share)
 {
   DBUG_ASSERT(share != NULL);
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
-    return;
   PFS_table_share* pfs;
   pfs= reinterpret_cast<PFS_table_share*> (share);
-  purge_table_share(pfs_thread, pfs);
+  release_table_share(pfs);
 }
 
 /**
@@ -976,14 +1243,12 @@ drop_table_share_v1(const char *schema_n
 static PSI_table*
 open_table_v1(PSI_table_share *share, const void *identity)
 {
+  PFS_table_share *pfs_table_share= reinterpret_cast<PFS_table_share*> (share);
+  DBUG_ASSERT(pfs_table_share);
   PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   if (unlikely(thread == NULL))
     return NULL;
-  PFS_table_share *pfs_table_share=
-    reinterpret_cast<PFS_table_share*> (share);
-  PFS_table *pfs_table;
-  DBUG_ASSERT(pfs_table_share);
-  pfs_table= create_table(pfs_table_share, thread, identity);
+  PFS_table *pfs_table= create_table(pfs_table_share, thread, identity);
   return reinterpret_cast<PSI_table *> (pfs_table);
 }
 
@@ -995,32 +1260,49 @@ static void close_table_v1(PSI_table *ta
 {
   PFS_table *pfs= reinterpret_cast<PFS_table*> (table);
   DBUG_ASSERT(pfs);
+  aggregate_table(pfs);
   destroy_table(pfs);
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::create_file.
+*/
 static void create_file_v1(PSI_file_key key, const char *name, File file)
 {
+  if (! flag_global_instrumentation)
+    return;
   int index= (int) file;
   if (unlikely(index < 0))
     return;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
-    return;
-  if (! pfs_thread->m_enabled)
-    return;
   PFS_file_class *klass= find_file_class(key);
   if (unlikely(klass == NULL))
     return;
   if (! klass->m_enabled)
     return;
-  if (likely(index < file_handle_max))
+
+  /* A thread is needed for LF_PINS */
+  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+  if (unlikely(pfs_thread == NULL))
+    return;
+
+  if (flag_thread_instrumentation && ! pfs_thread->m_enabled)
+    return;
+
+  /*
+    We want this check after pfs_thread->m_enabled,
+    to avoid reporting false loss.
+  */
+  if (unlikely(index >= file_handle_max))
   {
-    uint len= strlen(name);
-    PFS_file *pfs= find_or_create_file(pfs_thread, klass, name, len);
-    file_handle_array[index]= pfs;
-  }
-  else
     file_handle_lost++;
+    return;
+  }
+
+  uint len= strlen(name);
+  PFS_file *pfs_file= find_or_create_file(pfs_thread, klass, name, len);
+
+  file_handle_array[index]= pfs_file;
 }
 
 struct PFS_spawn_thread_arg
@@ -1080,6 +1362,10 @@ void* pfs_spawn_thread(void *arg)
   return NULL;
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::spawn_thread.
+*/
 static int spawn_thread_v1(PSI_thread_key key,
                            pthread_t *thread, const pthread_attr_t *attr,
                            void *(*start_routine)(void*), void *arg)
@@ -1104,6 +1390,10 @@ static int spawn_thread_v1(PSI_thread_ke
   return result;
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::new_thread.
+*/
 static PSI_thread*
 new_thread_v1(PSI_thread_key key, const void *identity, ulong thread_id)
 {
@@ -1118,6 +1408,10 @@ new_thread_v1(PSI_thread_key key, const
   return reinterpret_cast<PSI_thread*> (pfs);
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::set_thread_id.
+*/
 static void set_thread_id_v1(PSI_thread *thread, unsigned long id)
 {
   DBUG_ASSERT(thread);
@@ -1125,6 +1419,10 @@ static void set_thread_id_v1(PSI_thread
   pfs->m_thread_id= id;
 }
 
+/**
+  Implementation of the thread instrumentation interface.
+  @sa PSI_v1::get_thread_id.
+*/
 static PSI_thread*
 get_thread_v1(void)
 {
@@ -1147,25 +1445,30 @@ static void set_thread_user_v1(const cha
   if (unlikely(pfs == NULL))
     return;
 
+  aggregate_thread(pfs);
+
   pfs->m_lock.allocated_to_dirty();
+
   if (user_len > 0)
     memcpy(pfs->m_username, user, user_len);
   pfs->m_username_length= user_len;
 
-  bool enabled= false;
-
-  if ((pfs->m_username_length > 0) && (pfs->m_hostname_length > 0))
+  bool enabled= true;
+  if (flag_thread_instrumentation)
   {
-    /*
-      TODO: performance improvement.
-      Once performance_schema.USERS is exposed,
-      we can use PFS_user::m_enabled instead of looking up
-      SETUP_ACTORS every time.
-    */
-    lookup_setup_actor(pfs,
-                       pfs->m_username, pfs->m_username_length,
-                       pfs->m_hostname, pfs->m_hostname_length,
-                       &enabled);
+    if ((pfs->m_username_length > 0) && (pfs->m_hostname_length > 0))
+    {
+      /*
+        TODO: performance improvement.
+        Once performance_schema.USERS is exposed,
+        we can use PFS_user::m_enabled instead of looking up
+        SETUP_ACTORS every time.
+      */
+      lookup_setup_actor(pfs,
+                         pfs->m_username, pfs->m_username_length,
+                         pfs->m_hostname, pfs->m_hostname_length,
+                         &enabled);
+    }
   }
 
   pfs->m_enabled= enabled;
@@ -1202,19 +1505,22 @@ static void set_thread_user_host_v1(cons
     memcpy(pfs->m_username, user, user_len);
   pfs->m_username_length= user_len;
 
-  bool enabled= false;
-  if ((pfs->m_username_length > 0) && (pfs->m_hostname_length > 0))
+  bool enabled= true;
+  if (flag_thread_instrumentation)
   {
-    /*
-      TODO: performance improvement.
-      Once performance_schema.USERS is exposed,
-      we can use PFS_user::m_enabled instead of looking up
-      SETUP_ACTORS every time.
-    */
-    lookup_setup_actor(pfs,
-                       pfs->m_username, pfs->m_username_length,
-                       pfs->m_hostname, pfs->m_hostname_length,
-                       &enabled);
+    if ((pfs->m_username_length > 0) && (pfs->m_hostname_length > 0))
+    {
+      /*
+        TODO: performance improvement.
+        Once performance_schema.USERS is exposed,
+        we can use PFS_user::m_enabled instead of looking up
+        SETUP_ACTORS every time.
+      */
+      lookup_setup_actor(pfs,
+                         pfs->m_username, pfs->m_username_length,
+                         pfs->m_hostname, pfs->m_hostname_length,
+                         &enabled);
+    }
   }
   pfs->m_enabled= enabled;
 
@@ -1325,6 +1631,7 @@ static void delete_current_thread_v1(voi
   PFS_thread *thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   if (thread != NULL)
   {
+    aggregate_thread(thread);
     my_pthread_setspecific_ptr(THR_PFS, NULL);
     destroy_thread(thread);
   }
@@ -1333,10 +1640,18 @@ static void delete_current_thread_v1(voi
 static void delete_thread_v1(PSI_thread *thread)
 {
   PFS_thread *pfs= reinterpret_cast<PFS_thread*> (thread);
+
   if (pfs != NULL)
+  {
+    aggregate_thread(pfs);
     destroy_thread(pfs);
+  }
 }
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::get_thread_mutex_locker.
+*/
 static PSI_mutex_locker*
 get_thread_mutex_locker_v1(PSI_mutex_locker_state *state,
                            PSI_mutex *mutex, PSI_mutex_operation op)
@@ -1344,52 +1659,86 @@ get_thread_mutex_locker_v1(PSI_mutex_loc
   PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex*> (mutex);
   DBUG_ASSERT((int) op >= 0);
   DBUG_ASSERT((uint) op < array_elements(mutex_operation_map));
+  DBUG_ASSERT(state != NULL);
   DBUG_ASSERT(pfs_mutex != NULL);
   DBUG_ASSERT(pfs_mutex->m_class != NULL);
-  if (! flag_events_waits_current)
-    return NULL;
-  if (! pfs_mutex->m_class->m_enabled)
-    return NULL;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
+
+  if (! flag_global_instrumentation)
     return NULL;
-  if (! pfs_thread->m_enabled)
+  PFS_mutex_class *klass= pfs_mutex->m_class;
+  if (! klass->m_enabled)
     return NULL;
-  if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
+
+  register uint flags;
+
+  if (flag_thread_instrumentation)
   {
-    locker_lost++;
-    return NULL;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
+
+    if (klass->m_timed)
+      flags|= STATE_FLAG_TIMED;
+
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+      {
+        locker_lost++;
+        return NULL;
+      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
+
+#ifdef HAVE_NESTED_EVENTS
+      wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_mutex->m_identity;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= mutex_operation_map[(int) op];
+      wait->m_wait_class= WAIT_CLASS_MUTEX;
+
+      pfs_thread->m_events_waits_count++;
+    }
   }
-  PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-    [pfs_thread->m_wait_locker_count];
-  if (likely(pfs_thread->m_wait_locker_count == 0))
-    pfs_locker->m_waits_current.m_nesting_event_id= 0;
   else
   {
-    PFS_wait_locker *parent_locker= pfs_locker-1;
-    pfs_locker->m_waits_current.m_nesting_event_id=
-      parent_locker->m_waits_current.m_event_id;
-  }
-
-  pfs_locker->m_target.m_mutex= pfs_mutex;
-  pfs_locker->m_waits_current.m_thread= pfs_thread;
-  pfs_locker->m_waits_current.m_class= pfs_mutex->m_class;
-  if (pfs_mutex->m_class->m_timed)
-  {
-    pfs_locker->m_timer_name= wait_timer;
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
+    if (klass->m_timed)
+    {
+      flags= STATE_FLAG_TIMED;
+      state->m_thread= NULL;
+    }
+    else
+    {
+      /*
+        Complete shortcut.
+      */
+      PFS_mutex *pfs_mutex= reinterpret_cast<PFS_mutex *> (mutex);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+      pfs_mutex->m_wait_stat.aggregate_counted();
+      return NULL;
+    }
   }
-  else
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-  pfs_locker->m_waits_current.m_object_instance_addr= pfs_mutex->m_identity;
-  pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-  pfs_locker->m_waits_current.m_operation= mutex_operation_map[(int) op];
-  pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_MUTEX;
 
-  pfs_thread->m_wait_locker_count++;
-  return reinterpret_cast<PSI_mutex_locker*> (pfs_locker);
+  state->m_flags= flags;
+  state->m_mutex= mutex;
+  return reinterpret_cast<PSI_mutex_locker*> (state);
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::get_thread_rwlock_locker.
+*/
 static PSI_rwlock_locker*
 get_thread_rwlock_locker_v1(PSI_rwlock_locker_state *state,
                             PSI_rwlock *rwlock, PSI_rwlock_operation op)
@@ -1397,56 +1746,89 @@ get_thread_rwlock_locker_v1(PSI_rwlock_l
   PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock*> (rwlock);
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(rwlock_operation_map));
+  DBUG_ASSERT(state != NULL);
   DBUG_ASSERT(pfs_rwlock != NULL);
   DBUG_ASSERT(pfs_rwlock->m_class != NULL);
-  if (! flag_events_waits_current)
-    return NULL;
-  if (! pfs_rwlock->m_class->m_enabled)
-    return NULL;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
+
+  if (! flag_global_instrumentation)
     return NULL;
-  if (! pfs_thread->m_enabled)
+  PFS_rwlock_class *klass= pfs_rwlock->m_class;
+  if (! klass->m_enabled)
     return NULL;
-  if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
+
+  register uint flags;
+
+  if (flag_thread_instrumentation)
   {
-    locker_lost++;
-    return NULL;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
+
+    if (klass->m_timed)
+      flags|= STATE_FLAG_TIMED;
+
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+      {
+        locker_lost++;
+        return NULL;
+      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
+
+#ifdef HAVE_NESTED_EVENTS
+      wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_rwlock->m_identity;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= rwlock_operation_map[static_cast<int> (op)];
+      wait->m_wait_class= WAIT_CLASS_RWLOCK;
+
+      pfs_thread->m_events_waits_count++;
+    }
   }
-  PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-    [pfs_thread->m_wait_locker_count];
-  if (likely(pfs_thread->m_wait_locker_count == 0))
-    pfs_locker->m_waits_current.m_nesting_event_id= 0;
   else
   {
-    PFS_wait_locker *parent_locker= pfs_locker-1;
-    pfs_locker->m_waits_current.m_nesting_event_id=
-      parent_locker->m_waits_current.m_event_id;
-  }
-
-  pfs_locker->m_target.m_rwlock= pfs_rwlock;
-  pfs_locker->m_waits_current.m_thread= pfs_thread;
-  pfs_locker->m_waits_current.m_class= pfs_rwlock->m_class;
-  if (pfs_rwlock->m_class->m_timed)
-  {
-    pfs_locker->m_timer_name= wait_timer;
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
+    if (klass->m_timed)
+    {
+      flags= STATE_FLAG_TIMED;
+      state->m_thread= NULL;
+    }
+    else
+    {
+      /*
+        Complete shortcut.
+      */
+      PFS_rwlock *pfs_rwlock= reinterpret_cast<PFS_rwlock *> (rwlock);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+      pfs_rwlock->m_wait_stat.aggregate_counted();
+      return NULL;
+    }
   }
-  else
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-  pfs_locker->m_waits_current.m_object_instance_addr= pfs_rwlock->m_identity;
-  pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-  pfs_locker->m_waits_current.m_operation=
-    rwlock_operation_map[static_cast<int> (op)];
-  pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_RWLOCK;
 
-  pfs_thread->m_wait_locker_count++;
-  return reinterpret_cast<PSI_rwlock_locker*> (pfs_locker);
+  state->m_flags= flags;
+  state->m_rwlock= rwlock;
+  return reinterpret_cast<PSI_rwlock_locker*> (state);
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::get_thread_cond_locker.
+*/
 static PSI_cond_locker*
 get_thread_cond_locker_v1(PSI_cond_locker_state *state,
-                          PSI_cond *cond, PSI_mutex * /* unused: mutex */,
+                          PSI_cond *cond, PSI_mutex *mutex,
                           PSI_cond_operation op)
 {
   /*
@@ -1463,51 +1845,83 @@ get_thread_cond_locker_v1(PSI_cond_locke
   PFS_cond *pfs_cond= reinterpret_cast<PFS_cond*> (cond);
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(cond_operation_map));
+  DBUG_ASSERT(state != NULL);
   DBUG_ASSERT(pfs_cond != NULL);
   DBUG_ASSERT(pfs_cond->m_class != NULL);
-  if (! flag_events_waits_current)
-    return NULL;
-  if (! pfs_cond->m_class->m_enabled)
-    return NULL;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
-    return NULL;
-  if (! pfs_thread->m_enabled)
+
+  if (! flag_global_instrumentation)
     return NULL;
-  if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
-  {
-    locker_lost++;
+  PFS_cond_class *klass= pfs_cond->m_class;
+  if (! klass->m_enabled)
     return NULL;
-  }
-  PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-    [pfs_thread->m_wait_locker_count];
-  if (likely(pfs_thread->m_wait_locker_count == 0))
-    pfs_locker->m_waits_current.m_nesting_event_id= 0;
+
+  register uint flags;
+
+  if (klass->m_timed)
+    state->m_flags= STATE_FLAG_TIMED;
   else
-  {
-    PFS_wait_locker *parent_locker= pfs_locker-1;
-    pfs_locker->m_waits_current.m_nesting_event_id=
-      parent_locker->m_waits_current.m_event_id;
-  }
+    state->m_flags= 0;
 
-  pfs_locker->m_target.m_cond= pfs_cond;
-  pfs_locker->m_waits_current.m_thread= pfs_thread;
-  pfs_locker->m_waits_current.m_class= pfs_cond->m_class;
-  if (pfs_cond->m_class->m_timed)
+  if (flag_thread_instrumentation)
   {
-    pfs_locker->m_timer_name= wait_timer;
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
+
+    if (klass->m_timed)
+      flags|= STATE_FLAG_TIMED;
+
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+      {
+        locker_lost++;
+        return NULL;
+      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
+
+#ifdef HAVE_NESTED_EVENTS
+      wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_cond->m_identity;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= cond_operation_map[static_cast<int> (op)];
+      wait->m_wait_class= WAIT_CLASS_COND;
+
+      pfs_thread->m_events_waits_count++;
+    }
   }
   else
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-  pfs_locker->m_waits_current.m_object_instance_addr= pfs_cond->m_identity;
-  pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-  pfs_locker->m_waits_current.m_operation=
-    cond_operation_map[static_cast<int> (op)];
-  pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_COND;
+  {
+    if (klass->m_timed)
+      flags= STATE_FLAG_TIMED;
+    else
+    {
+      /*
+        Complete shortcut.
+      */
+      PFS_cond *pfs_cond= reinterpret_cast<PFS_cond *> (cond);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+      pfs_cond->m_wait_stat.aggregate_counted();
+      return NULL;
+    }
+  }
 
-  pfs_thread->m_wait_locker_count++;
-  return reinterpret_cast<PSI_cond_locker*> (pfs_locker);
+  state->m_flags= flags;
+  state->m_cond= cond;
+  state->m_mutex= mutex;
+  return reinterpret_cast<PSI_cond_locker*> (state);
 }
 
 /**
@@ -1516,67 +1930,134 @@ get_thread_cond_locker_v1(PSI_cond_locke
 */
 static PSI_table_locker*
 get_thread_table_locker_v1(PSI_table_locker_state *state,
-                           PSI_table *table, PSI_table_operation op, ulong flags)
+                           PSI_table *table, PSI_table_operation op, ulong op_flags)
 {
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(table_operation_map));
+  DBUG_ASSERT(state != NULL);
   PFS_table *pfs_table= reinterpret_cast<PFS_table*> (table);
   DBUG_ASSERT(pfs_table != NULL);
   DBUG_ASSERT(pfs_table->m_share != NULL);
 
-  if (! flag_events_waits_current)
-    return NULL;
-  if (! global_table_class.m_enabled)
+  if (! flag_global_instrumentation)
     return NULL;
-  /*
-    Table locks will be recorded with WL#5371.
-  */
-  if ((op == PSI_TABLE_EXTERNAL_LOCK) || (op == PSI_TABLE_LOCK))
-    return NULL;
-  if (! pfs_table->m_share->m_enabled)
-    return NULL;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
-    return NULL;
-  if (! pfs_thread->m_enabled)
-    return NULL;
-  if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
-  {
-    locker_lost++;
-    return NULL;
-  }
-  PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-    [pfs_thread->m_wait_locker_count];
-  if (likely(pfs_thread->m_wait_locker_count == 0))
-    pfs_locker->m_waits_current.m_nesting_event_id= 0;
-  else
+  PFS_table_share *share= pfs_table->m_share;
+  if (unlikely(setup_objects_version != share->m_setup_objects_version))
   {
-    PFS_wait_locker *parent_locker= pfs_locker-1;
-    pfs_locker->m_waits_current.m_nesting_event_id=
-      parent_locker->m_waits_current.m_event_id;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    /* Refresh the enabled and timed flags from SETUP_OBJECTS */
+    share->m_setup_objects_version= setup_objects_version;
+    lookup_setup_object(pfs_thread,
+                        OBJECT_TYPE_TABLE, /* even for temporary tables */
+                        share->m_schema_name,
+                        share->m_schema_name_length,
+                        share->m_table_name,
+                        share->m_table_name_length,
+                        & share->m_enabled,
+                        & share->m_timed);
+  }
+  if (! share->m_enabled)
+    return NULL;
+
+  PFS_instr_class *klass;
+
+  switch (op)
+  {
+    case PSI_TABLE_LOCK:
+    case PSI_TABLE_EXTERNAL_LOCK:
+      return NULL;
+    case PSI_TABLE_FETCH_ROW:
+    case PSI_TABLE_WRITE_ROW:
+    case PSI_TABLE_UPDATE_ROW:
+    case PSI_TABLE_DELETE_ROW:
+      if (! global_table_io_class.m_enabled)
+        return NULL;
+      klass= &global_table_io_class;
+      break;
+    default:
+      klass= NULL;
+      DBUG_ASSERT(false);
   }
 
-  pfs_locker->m_target.m_table= pfs_table;
-  pfs_locker->m_waits_current.m_thread= pfs_thread;
-  pfs_locker->m_waits_current.m_class= &global_table_class;
-  if (pfs_table->m_share->m_timed)
+
+  register uint flags;
+
+  if (flag_thread_instrumentation)
   {
-    pfs_locker->m_timer_name= wait_timer;
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
+
+    if (share->m_timed)
+      flags|= STATE_FLAG_TIMED;
+
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+      {
+        locker_lost++;
+        return NULL;
+      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_table->m_identity;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= table_operation_map[static_cast<int> (op)];
+      wait->m_flags= op_flags;
+      wait->m_object_type= share->get_object_type();
+      wait->m_schema_name= share->m_schema_name;
+      wait->m_schema_name_length= share->m_schema_name_length;
+      wait->m_object_name= share->m_table_name;
+      wait->m_object_name_length= share->m_table_name_length;
+      wait->m_wait_class= WAIT_CLASS_TABLE;
+
+      pfs_thread->m_events_waits_count++;
+    }
   }
   else
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-  pfs_locker->m_waits_current.m_object_instance_addr= pfs_table->m_identity;
-  pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-  pfs_locker->m_waits_current.m_operation=
-    table_operation_map[static_cast<int> (op)];
-  pfs_locker->m_waits_current.m_flags= flags;
-  pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_TABLE;
+  {
+    if (share->m_timed)
+    {
+      flags= STATE_FLAG_TIMED;
+    }
+    else
+    {
+#ifdef LATER
+      /*
+        Complete shortcut.
+      */
+      PFS_table *pfs_table= reinterpret_cast<PFS_table *> (table);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+      pfs_table->m_wait_stat.aggregate_counted();
+      return NULL;
+#endif
+      flags= 0;
+    }
+  }
 
-  pfs_thread->m_wait_locker_count++;
-  return reinterpret_cast<PSI_table_locker*> (pfs_locker);
+  state->m_flags= flags;
+  state->m_table= table;
+  state->m_class= klass;
+  state->m_operation= op;
+  return reinterpret_cast<PSI_table_locker*> (state);
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::get_thread_file_name_locker.
+*/
 static PSI_file_locker*
 get_thread_file_name_locker_v1(PSI_file_locker_state *state,
                                PSI_file_key key,
@@ -1585,199 +2066,259 @@ get_thread_file_name_locker_v1(PSI_file_
 {
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
+  DBUG_ASSERT(state != NULL);
 
-  if (! flag_events_waits_current)
+  if (! flag_global_instrumentation)
     return NULL;
   PFS_file_class *klass= find_file_class(key);
   if (unlikely(klass == NULL))
     return NULL;
   if (! klass->m_enabled)
     return NULL;
+
+  /* Needed for the LF_HASH */
   PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
   if (unlikely(pfs_thread == NULL))
     return NULL;
-  if (! pfs_thread->m_enabled)
-    return NULL;
-  if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
-  {
-    locker_lost++;
+
+  if (flag_thread_instrumentation && ! pfs_thread->m_enabled)
     return NULL;
-  }
+
+  register uint flags;
+
+  state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+  flags= STATE_FLAG_THREAD;
+
+  if (klass->m_timed)
+    flags|= STATE_FLAG_TIMED;
+
   uint len= strlen(name);
   PFS_file *pfs_file= find_or_create_file(pfs_thread, klass, name, len);
   if (unlikely(pfs_file == NULL))
     return NULL;
 
-  PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-    [pfs_thread->m_wait_locker_count];
-  if (likely(pfs_thread->m_wait_locker_count == 0))
-    pfs_locker->m_waits_current.m_nesting_event_id= 0;
-  else
+  if (flag_events_waits_current)
   {
-    PFS_wait_locker *parent_locker= pfs_locker-1;
-    pfs_locker->m_waits_current.m_nesting_event_id=
-      parent_locker->m_waits_current.m_event_id;
-  }
+    if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+    {
+      locker_lost++;
+      return NULL;
+    }
+    PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+    state->m_wait= wait;
+    flags|= STATE_FLAG_WAIT;
 
-  pfs_locker->m_target.m_file= pfs_file;
-  pfs_locker->m_waits_current.m_thread= pfs_thread;
-  pfs_locker->m_waits_current.m_class= pfs_file->m_class;
-  if (pfs_file->m_class->m_timed)
-  {
-    pfs_locker->m_timer_name= wait_timer;
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
-  }
-  else
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-  pfs_locker->m_waits_current.m_object_instance_addr= pfs_file;
-  pfs_locker->m_waits_current.m_object_name= pfs_file->m_filename;
-  pfs_locker->m_waits_current.m_object_name_length=
-    pfs_file->m_filename_length;
-  pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-  pfs_locker->m_waits_current.m_operation=
-    file_operation_map[static_cast<int> (op)];
-  pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_FILE;
+#ifdef HAVE_NESTED_EVENTS
+    wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
 
-  pfs_thread->m_wait_locker_count++;
-  return reinterpret_cast<PSI_file_locker*> (pfs_locker);
+    wait->m_thread= pfs_thread;
+    wait->m_class= klass;
+    wait->m_timer_start= 0;
+    wait->m_timer_end= 0;
+    wait->m_object_instance_addr= pfs_file;
+    wait->m_object_name= pfs_file->m_filename;
+    wait->m_object_name_length= pfs_file->m_filename_length;
+    wait->m_event_id= pfs_thread->m_event_id++;
+    wait->m_operation= file_operation_map[static_cast<int> (op)];
+    wait->m_wait_class= WAIT_CLASS_FILE;
+
+    pfs_thread->m_events_waits_count++;
+  }
+
+  state->m_flags= flags;
+  state->m_file= reinterpret_cast<PSI_file*> (pfs_file);
+  state->m_operation= op;
+  return reinterpret_cast<PSI_file_locker*> (state);
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::get_thread_file_stream_locker.
+*/
 static PSI_file_locker*
 get_thread_file_stream_locker_v1(PSI_file_locker_state *state,
                                  PSI_file *file, PSI_file_operation op)
 {
   PFS_file *pfs_file= reinterpret_cast<PFS_file*> (file);
-
-  DBUG_ASSERT(static_cast<int> (op) >= 0);
-  DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
   DBUG_ASSERT(pfs_file != NULL);
   DBUG_ASSERT(pfs_file->m_class != NULL);
+  DBUG_ASSERT(static_cast<int> (op) >= 0);
+  DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
+  DBUG_ASSERT(state != NULL);
 
-  if (! flag_events_waits_current)
-    return NULL;
-  if (! pfs_file->m_class->m_enabled)
+  if (! flag_global_instrumentation)
     return NULL;
-  PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-  if (unlikely(pfs_thread == NULL))
-    return NULL;
-  if (! pfs_thread->m_enabled)
+
+  PFS_file_class *klass= pfs_file->m_class;
+  if (! klass->m_enabled)
     return NULL;
-  if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
+
+  register uint flags;
+
+  if (flag_thread_instrumentation)
   {
-    locker_lost++;
-    return NULL;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
+
+    if (klass->m_timed)
+      flags|= STATE_FLAG_TIMED;
+
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
+      {
+        locker_lost++;
+        return NULL;
+      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
+
+#ifdef HAVE_NESTED_EVENTS
+      wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_file;
+      wait->m_object_name= pfs_file->m_filename;
+      wait->m_object_name_length= pfs_file->m_filename_length;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= file_operation_map[static_cast<int> (op)];
+      wait->m_wait_class= WAIT_CLASS_FILE;
+
+      pfs_thread->m_events_waits_count++;
+    }
   }
-  PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-    [pfs_thread->m_wait_locker_count];
-  if (likely(pfs_thread->m_wait_locker_count == 0))
-    pfs_locker->m_waits_current.m_nesting_event_id= 0;
   else
   {
-    PFS_wait_locker *parent_locker= pfs_locker-1;
-    pfs_locker->m_waits_current.m_nesting_event_id=
-      parent_locker->m_waits_current.m_event_id;
-  }
-
-  pfs_locker->m_target.m_file= pfs_file;
-  pfs_locker->m_waits_current.m_thread= pfs_thread;
-  pfs_locker->m_waits_current.m_class= pfs_file->m_class;
-  if (pfs_file->m_class->m_timed)
-  {
-    pfs_locker->m_timer_name= wait_timer;
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
+    state->m_thread= NULL;
+    if (klass->m_timed)
+    {
+      flags= STATE_FLAG_TIMED;
+    }
+    else
+    {
+      /* TODO: consider a shortcut. */
+      flags= 0;
+    }
   }
-  else
-    pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-  pfs_locker->m_waits_current.m_object_instance_addr= pfs_file;
-  pfs_locker->m_waits_current.m_object_name= pfs_file->m_filename;
-  pfs_locker->m_waits_current.m_object_name_length=
-    pfs_file->m_filename_length;
-  pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-  pfs_locker->m_waits_current.m_operation=
-    file_operation_map[static_cast<int> (op)];
-  pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_FILE;
 
-  pfs_thread->m_wait_locker_count++;
-  return reinterpret_cast<PSI_file_locker*> (pfs_locker);
+  state->m_flags= flags;
+  state->m_file= reinterpret_cast<PSI_file*> (pfs_file);
+  state->m_operation= op;
+  return reinterpret_cast<PSI_file_locker*> (state);
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::get_thread_file_descriptor_locker.
+*/
 static PSI_file_locker*
 get_thread_file_descriptor_locker_v1(PSI_file_locker_state *state,
                                      File file, PSI_file_operation op)
 {
   int index= static_cast<int> (file);
-
   DBUG_ASSERT(static_cast<int> (op) >= 0);
   DBUG_ASSERT(static_cast<uint> (op) < array_elements(file_operation_map));
+  DBUG_ASSERT(state != NULL);
+
+  if (! flag_global_instrumentation)
+    return NULL;
+
+  if (unlikely((index < 0) || (index >= file_handle_max)))
+    return NULL;
+
+  PFS_file *pfs_file= file_handle_array[index];
+  if (unlikely(pfs_file == NULL))
+    return NULL;
 
-  if (! flag_events_waits_current)
+  /*
+    We are about to close a file by descriptor number,
+    and the calling code still holds the descriptor.
+    Cleanup the file descriptor <--> file instrument association.
+    Remove the instrumentation *before* the close to avoid race
+    conditions with another thread opening a file
+    (that could be given the same descriptor).
+  */
+  if (op == PSI_FILE_CLOSE)
+    file_handle_array[index]= NULL;
+
+  DBUG_ASSERT(pfs_file->m_class != NULL);
+  PFS_instr_class *klass= pfs_file->m_class;
+  if (! klass->m_enabled)
     return NULL;
-  if (likely((index >= 0) && (index < file_handle_max)))
+
+  register uint flags;
+
+  if (flag_thread_instrumentation)
   {
-    PFS_file *pfs_file= file_handle_array[index];
-    if (likely(pfs_file != NULL))
-    {
-      PFS_thread *pfs_thread;
+    PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+    if (unlikely(pfs_thread == NULL))
+      return NULL;
+    if (! pfs_thread->m_enabled)
+      return NULL;
+    state->m_thread= reinterpret_cast<PSI_thread *> (pfs_thread);
+    flags= STATE_FLAG_THREAD;
 
-      /*
-        We are about to close a file by descriptor number,
-        and the calling code still holds the descriptor.
-        Cleanup the file descriptor <--> file instrument association.
-        Remove the instrumentation *before* the close to avoid race
-        conditions with another thread opening a file
-        (that could be given the same descriptor).
-      */
-      if (op == PSI_FILE_CLOSE)
-        file_handle_array[index]= NULL;
+    if (klass->m_timed)
+      flags|= STATE_FLAG_TIMED;
 
-      DBUG_ASSERT(pfs_file->m_class != NULL);
-      if (! pfs_file->m_class->m_enabled)
-        return NULL;
-      pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
-      if (unlikely(pfs_thread == NULL))
-        return NULL;
-      if (! pfs_thread->m_enabled)
-        return NULL;
-      if (unlikely(pfs_thread->m_wait_locker_count >= LOCKER_STACK_SIZE))
+    if (flag_events_waits_current)
+    {
+      if (unlikely(pfs_thread->m_events_waits_count >= WAIT_STACK_SIZE))
       {
         locker_lost++;
         return NULL;
       }
-      PFS_wait_locker *pfs_locker= &pfs_thread->m_wait_locker_stack
-        [pfs_thread->m_wait_locker_count];
-      if (likely(pfs_thread->m_wait_locker_count == 0))
-        pfs_locker->m_waits_current.m_nesting_event_id= 0;
-      else
-      {
-        PFS_wait_locker *parent_locker= pfs_locker-1;
-        pfs_locker->m_waits_current.m_nesting_event_id=
-          parent_locker->m_waits_current.m_event_id;
-      }
+      PFS_events_waits *wait= &pfs_thread->m_events_waits_stack[pfs_thread->m_events_waits_count];
+      state->m_wait= wait;
+      flags|= STATE_FLAG_WAIT;
 
-      pfs_locker->m_target.m_file= pfs_file;
-      pfs_locker->m_waits_current.m_thread= pfs_thread;
-      pfs_locker->m_waits_current.m_class= pfs_file->m_class;
-      if (pfs_file->m_class->m_timed)
-      {
-        pfs_locker->m_timer_name= wait_timer;
-        pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_STARTING;
-      }
-      else
-        pfs_locker->m_waits_current.m_timer_state= TIMER_STATE_UNTIMED;
-      pfs_locker->m_waits_current.m_object_instance_addr= pfs_file;
-      pfs_locker->m_waits_current.m_object_name= pfs_file->m_filename;
-      pfs_locker->m_waits_current.m_object_name_length=
-        pfs_file->m_filename_length;
-      pfs_locker->m_waits_current.m_event_id= pfs_thread->m_event_id++;
-      pfs_locker->m_waits_current.m_operation=
-        file_operation_map[static_cast<int> (op)];
-      pfs_locker->m_waits_current.m_wait_class= WAIT_CLASS_FILE;
+#ifdef HAVE_NESTED_EVENTS
+      wait->m_nesting_event_id= (wait - 1)->m_event_id;
+#endif
+
+      wait->m_thread= pfs_thread;
+      wait->m_class= klass;
+      wait->m_timer_start= 0;
+      wait->m_timer_end= 0;
+      wait->m_object_instance_addr= pfs_file;
+      wait->m_object_name= pfs_file->m_filename;
+      wait->m_object_name_length= pfs_file->m_filename_length;
+      wait->m_event_id= pfs_thread->m_event_id++;
+      wait->m_operation= file_operation_map[static_cast<int> (op)];
+      wait->m_wait_class= WAIT_CLASS_FILE;
 
-      pfs_thread->m_wait_locker_count++;
-      return reinterpret_cast<PSI_file_locker*> (pfs_locker);
+      pfs_thread->m_events_waits_count++;
     }
   }
-  return NULL;
+  else
+  {
+    state->m_thread= NULL;
+    if (klass->m_timed)
+    {
+      flags= STATE_FLAG_TIMED;
+    }
+    else
+    {
+      /* TODO: consider a shortcut. */
+      flags= 0;
+    }
+  }
+
+  state->m_flags= flags;
+  state->m_file= reinterpret_cast<PSI_file*> (pfs_file);
+  state->m_operation= op;
+  return reinterpret_cast<PSI_file_locker*> (state);
 }
 
 static void unlock_mutex_v1(PSI_mutex *mutex)
@@ -1813,7 +2354,7 @@ static void unlock_mutex_v1(PSI_mutex *m
   if (pfs_mutex->m_class->m_timed)
   {
     ulonglong locked_time;
-    locked_time= get_timer_value(wait_timer) - pfs_mutex->m_last_locked;
+    locked_time= get_timer_pico_value(wait_timer) - pfs_mutex->m_last_locked;
     aggregate_single_stat_chain(&pfs_mutex->m_lock_stat, locked_time);
   }
 #endif
@@ -1880,7 +2421,7 @@ static void unlock_rwlock_v1(PSI_rwlock
   {
     if (pfs_rwlock->m_class->m_timed)
     {
-      locked_time= get_timer_value(wait_timer) - pfs_rwlock->m_last_written;
+      locked_time= get_timer_pico_value(wait_timer) - pfs_rwlock->m_last_written;
       aggregate_single_stat_chain(&pfs_rwlock->m_write_lock_stat, locked_time);
     }
   }
@@ -1888,7 +2429,7 @@ static void unlock_rwlock_v1(PSI_rwlock
   {
     if (pfs_rwlock->m_class->m_timed)
     {
-      locked_time= get_timer_value(wait_timer) - pfs_rwlock->m_last_read;
+      locked_time= get_timer_pico_value(wait_timer) - pfs_rwlock->m_last_read;
       aggregate_single_stat_chain(&pfs_rwlock->m_read_lock_stat, locked_time);
     }
   }
@@ -1911,93 +2452,157 @@ static void broadcast_cond_v1(PSI_cond*
   pfs_cond->m_cond_stat.m_broadcast_count++;
 }
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::start_mutex_wait.
+*/
 static void start_mutex_wait_v1(PSI_mutex_locker* locker,
                                 const char *src_file, uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  PSI_mutex_locker_state *state= reinterpret_cast<PSI_mutex_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  register uint flags= state->m_flags;
+  ulonglong timer_start= 0;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
+
+  if (flags & STATE_FLAG_WAIT)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
 }
 
+/**
+  Implementation of the mutex instrumentation interface.
+  @sa PSI_v1::end_mutex_wait.
+*/
 static void end_mutex_wait_v1(PSI_mutex_locker* locker, int rc)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
-  {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
-  }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
+  PSI_mutex_locker_state *state= reinterpret_cast<PSI_mutex_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_mutex *mutex= reinterpret_cast<PFS_mutex *> (state->m_mutex);
+  DBUG_ASSERT(mutex != NULL);
+  PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+
+  register uint flags= state->m_flags;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (timed) */
+    mutex->m_wait_stat.aggregate_timed(wait_time);
+  }
+  else
+  {
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+    mutex->m_wait_stat.aggregate_counted();
+  }
 
-  if (rc == 0)
+  if (likely(rc == 0))
   {
-    /* Thread safe: we are protected by the instrumented mutex */
-    PFS_mutex *mutex= pfs_locker->m_target.m_mutex;
-    PFS_single_stat_chain *stat= find_per_thread_mutex_class_wait_stat(wait->m_thread, mutex->m_class);
-    mutex->m_owner= wait->m_thread;
-    mutex->m_last_locked= wait->m_timer_end;
-
-    /* If timed then aggregate stats, else increment the value counts only */
-    if (wait->m_timer_state == TIMER_STATE_TIMED)
-    {
-      ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-      aggregate_single_stat_chain(&mutex->m_wait_stat, wait_time);
-      aggregate_single_stat_chain(stat, wait_time);
+    mutex->m_owner= thread;
+    mutex->m_last_locked= timer_end;
+  }
+
+  if (flags & STATE_FLAG_THREAD)
+  {
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= mutex->m_class->m_event_name_index;
+
+    if (flags & STATE_FLAG_TIMED)
+    {
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+      event_name_array[index].aggregate_timed(wait_time);
     }
     else
     {
-      increment_single_stat_chain(&mutex->m_wait_stat);
-      increment_single_stat_chain(stat);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+      event_name_array[index].aggregate_counted();
+    }
+
+    if (flags & STATE_FLAG_WAIT)
+    {
+      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+      DBUG_ASSERT(wait != NULL);
+
+      wait->m_timer_end= timer_end;
+      if (flag_events_waits_history)
+        insert_events_waits_history(thread, wait);
+      if (flag_events_waits_history_long)
+        insert_events_waits_history_long(wait);
+      thread->m_events_waits_count--;
     }
   }
-  wait->m_thread->m_wait_locker_count--;
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::start_rwlock_rdwait.
+*/
 static void start_rwlock_rdwait_v1(PSI_rwlock_locker* locker,
                                    const char *src_file, uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  ulonglong timer_start= 0;
+  PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  if (state->m_flags & STATE_FLAG_TIMED)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
+
+  if (state->m_flags & STATE_FLAG_WAIT)
+  {
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::end_rwlock_rdwait.
+*/
 static void end_rwlock_rdwait_v1(PSI_rwlock_locker* locker, int rc)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
-  {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
-  }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
+  PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_rwlock *rwlock= reinterpret_cast<PFS_rwlock *> (state->m_rwlock);
+
+  if (state->m_flags & STATE_FLAG_TIMED)
+  {
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (timed) */
+    rwlock->m_wait_stat.aggregate_timed(wait_time);
+  }
+  else
+  {
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+    rwlock->m_wait_stat.aggregate_counted();
+  }
 
   if (rc == 0)
   {
@@ -2008,225 +2613,360 @@ static void end_rwlock_rdwait_v1(PSI_rwl
       The statistics generated are not safe, which is why they are
       just statistics, not facts.
     */
-    PFS_rwlock *rwlock= pfs_locker->m_target.m_rwlock;
-    PFS_single_stat_chain *stat= find_per_thread_rwlock_class_wait_stat(wait->m_thread, rwlock->m_class);
-
     if (rwlock->m_readers == 0)
-      rwlock->m_last_read= wait->m_timer_end;
+      rwlock->m_last_read= timer_end;
     rwlock->m_writer= NULL;
     rwlock->m_readers++;
+  }
+
+  if (state->m_flags & STATE_FLAG_THREAD)
+  {
+    PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+    DBUG_ASSERT(thread != NULL);
+
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= rwlock->m_class->m_event_name_index;
 
-    /* If timed then aggregate stats, else increment the value counts only */
-    if (wait->m_timer_state == TIMER_STATE_TIMED)
+    if (state->m_flags & STATE_FLAG_TIMED)
     {
-      ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-      aggregate_single_stat_chain(&rwlock->m_wait_stat, wait_time);
-      aggregate_single_stat_chain(stat, wait_time);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+      event_name_array[index].aggregate_timed(wait_time);
     }
     else
     {
-      increment_single_stat_chain(&rwlock->m_wait_stat);
-      increment_single_stat_chain(stat);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+      event_name_array[index].aggregate_counted();
+    }
+
+    if (state->m_flags & STATE_FLAG_WAIT)
+    {
+      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+      DBUG_ASSERT(wait != NULL);
+
+      wait->m_timer_end= timer_end;
+      if (flag_events_waits_history)
+        insert_events_waits_history(thread, wait);
+      if (flag_events_waits_history_long)
+        insert_events_waits_history_long(wait);
+      thread->m_events_waits_count--;
     }
   }
-  wait->m_thread->m_wait_locker_count--;
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::start_rwlock_wrwait.
+*/
 static void start_rwlock_wrwait_v1(PSI_rwlock_locker* locker,
                                    const char *src_file, uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  ulonglong timer_start= 0;
+  PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  if (state->m_flags & STATE_FLAG_TIMED)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
+
+  if (state->m_flags & STATE_FLAG_WAIT)
+  {
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
 }
 
+/**
+  Implementation of the rwlock instrumentation interface.
+  @sa PSI_v1::end_rwlock_wrwait.
+*/
 static void end_rwlock_wrwait_v1(PSI_rwlock_locker* locker, int rc)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
-  {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
-  }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
+  PSI_rwlock_locker_state *state= reinterpret_cast<PSI_rwlock_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_rwlock *rwlock= reinterpret_cast<PFS_rwlock *> (state->m_rwlock);
+  PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+
+  if (state->m_flags & STATE_FLAG_TIMED)
+  {
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (timed) */
+    rwlock->m_wait_stat.aggregate_timed(wait_time);
+  }
+  else
+  {
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+    rwlock->m_wait_stat.aggregate_counted();
+  }
 
-  if (rc == 0)
+  if (likely(rc == 0))
   {
     /* Thread safe : we are protected by the instrumented rwlock */
-    PFS_rwlock *rwlock= pfs_locker->m_target.m_rwlock;
-    PFS_single_stat_chain *stat= find_per_thread_rwlock_class_wait_stat(wait->m_thread, rwlock->m_class);
-    rwlock->m_writer= wait->m_thread;
-    rwlock->m_last_written= wait->m_timer_end;
+    rwlock->m_writer= thread;
+    rwlock->m_last_written= timer_end;
     /* Reset the readers stats, they could be off */
     rwlock->m_readers= 0;
     rwlock->m_last_read= 0;
+  }
 
-    /* If timed then aggregate stats, else increment the value counts only */
-    if (wait->m_timer_state == TIMER_STATE_TIMED)
+  if (state->m_flags & STATE_FLAG_THREAD)
+  {
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= rwlock->m_class->m_event_name_index;
+
+    if (state->m_flags & STATE_FLAG_TIMED)
     {
-      ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-      aggregate_single_stat_chain(&rwlock->m_wait_stat, wait_time);
-      aggregate_single_stat_chain(stat, wait_time);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+      event_name_array[index].aggregate_timed(wait_time);
     }
     else
     {
-      increment_single_stat_chain(&rwlock->m_wait_stat);
-      increment_single_stat_chain(stat);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+      event_name_array[index].aggregate_counted();
+    }
+
+    if (state->m_flags & STATE_FLAG_WAIT)
+    {
+      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+      DBUG_ASSERT(wait != NULL);
+
+      wait->m_timer_end= timer_end;
+      if (flag_events_waits_history)
+        insert_events_waits_history(thread, wait);
+      if (flag_events_waits_history_long)
+        insert_events_waits_history_long(wait);
+      thread->m_events_waits_count--;
     }
   }
-  wait->m_thread->m_wait_locker_count--;
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::start_cond_wait.
+*/
 static void start_cond_wait_v1(PSI_cond_locker* locker,
                                const char *src_file, uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  ulonglong timer_start= 0;
+  PSI_cond_locker_state *state= reinterpret_cast<PSI_cond_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  if (state->m_flags & STATE_FLAG_TIMED)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
+
+  if (state->m_flags & STATE_FLAG_WAIT)
+  {
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
 }
 
+/**
+  Implementation of the cond instrumentation interface.
+  @sa PSI_v1::end_cond_wait.
+*/
 static void end_cond_wait_v1(PSI_cond_locker* locker, int rc)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
-  {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
-  }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
+  PSI_cond_locker_state *state= reinterpret_cast<PSI_cond_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_cond *cond= reinterpret_cast<PFS_cond *> (state->m_cond);
+  /* PFS_mutex *mutex= reinterpret_cast<PFS_mutex *> (state->m_mutex); */
+
+  if (state->m_flags & STATE_FLAG_TIMED)
+  {
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (timed) */
+    cond->m_wait_stat.aggregate_timed(wait_time);
+  }
+  else
+  {
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+    cond->m_wait_stat.aggregate_counted();
+  }
 
-  if (rc == 0)
+  if (state->m_flags & STATE_FLAG_THREAD)
   {
-    /*
-      Not thread safe, race conditions will occur.
-      A first race condition is:
-      - thread 1 waits on cond A
-      - thread 2 waits on cond A
-      threads 1 and 2 compete when updating the same cond A
-      statistics, possibly missing a min / max / sum / count.
-      A second race condition is:
-      - thread 1 waits on cond A
-      - thread 2 destroys cond A
-      - thread 2 or 3 creates cond B in the same condition slot
-      thread 1 will then aggregate statistics about defunct A
-      in condition B.
-      This is accepted, the data will be slightly inaccurate.
-    */
-    PFS_cond *cond= pfs_locker->m_target.m_cond;
-    PFS_single_stat_chain *stat= find_per_thread_cond_class_wait_stat(wait->m_thread, cond->m_class);
+    PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+    DBUG_ASSERT(thread != NULL);
+
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= cond->m_class->m_event_name_index;
 
-    /* If timed then aggregate stats, else increment the value counts only */
-    if (wait->m_timer_state == TIMER_STATE_TIMED)
+    if (state->m_flags & STATE_FLAG_TIMED)
     {
-      ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-      aggregate_single_stat_chain(&cond->m_wait_stat, wait_time);
-      aggregate_single_stat_chain(stat, wait_time);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+      event_name_array[index].aggregate_timed(wait_time);
     }
     else
     {
-      increment_single_stat_chain(&cond->m_wait_stat);
-      increment_single_stat_chain(stat);
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+      event_name_array[index].aggregate_counted();
+    }
+
+    if (state->m_flags & STATE_FLAG_WAIT)
+    {
+      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+      DBUG_ASSERT(wait != NULL);
+
+      wait->m_timer_end= timer_end;
+      if (flag_events_waits_history)
+        insert_events_waits_history(thread, wait);
+      if (flag_events_waits_history_long)
+        insert_events_waits_history_long(wait);
+      thread->m_events_waits_count--;
     }
   }
-  wait->m_thread->m_wait_locker_count--;
 }
 
+/**
+  Implementation of the table instrumentation interface.
+  @sa PSI_v1::start_table_wait.
+*/
 static void start_table_wait_v1(PSI_table_locker* locker, uint index,
                                 const char *src_file, uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  ulonglong timer_start= 0;
+  PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+
+  register uint flags= state->m_flags;
 
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  if (flags & STATE_FLAG_TIMED)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
-  PFS_table_share *share= pfs_locker->m_target.m_table->m_share;
-  wait->m_object_type= share->get_object_type();
-  wait->m_schema_name= share->m_schema_name;
-  wait->m_schema_name_length= share->m_schema_name_length;
-  wait->m_object_name= share->m_table_name;
-  wait->m_object_name_length= share->m_table_name_length;
-  /* FIXME: revise this */
-  if (share->get_object_type() == OBJECT_TYPE_TEMPORARY_TABLE)
-    wait->m_index= MAX_KEY;
-  else
-    wait->m_index= index;
+
+  if (flags & STATE_FLAG_WAIT)
+  {
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
+  }
+
+  state->m_index= index;
 }
 
+/**
+  Implementation of the table instrumentation interface.
+  @sa PSI_v1::end_table_wait.
+*/
 static void end_table_wait_v1(PSI_table_locker* locker)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
-  {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
+  PSI_table_locker_state *state= reinterpret_cast<PSI_table_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_table *table= reinterpret_cast<PFS_table *> (state->m_table);
+  DBUG_ASSERT(table != NULL);
+  PFS_instr_class *klass= reinterpret_cast<PFS_instr_class *> (state->m_class);
+  DBUG_ASSERT(klass != NULL);
+
+  PFS_single_stat *stat;
+
+  switch (state->m_operation)
+  {
+  case PSI_TABLE_FETCH_ROW:
+    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
+                (state->m_index == MAX_KEY));
+    stat= & table->m_table_stat.m_index_stat[state->m_index].m_fetch;
+    break;
+  case PSI_TABLE_WRITE_ROW:
+    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
+                (state->m_index == MAX_KEY));
+    stat= & table->m_table_stat.m_index_stat[state->m_index].m_insert;
+    break;
+  case PSI_TABLE_UPDATE_ROW:
+    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
+                (state->m_index == MAX_KEY));
+    stat= & table->m_table_stat.m_index_stat[state->m_index].m_update;
+    break;
+  case PSI_TABLE_DELETE_ROW:
+    DBUG_ASSERT((state->m_index < table->m_share->m_key_count) ||
+                (state->m_index == MAX_KEY));
+    stat= & table->m_table_stat.m_index_stat[state->m_index].m_delete;
+    break;
+  case PSI_TABLE_LOCK:
+  case PSI_TABLE_EXTERNAL_LOCK:
+  default:
+    DBUG_ASSERT(false);
+    stat= NULL;
+    break;
   }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
 
-  PFS_table *table= pfs_locker->m_target.m_table;
+  register uint flags= state->m_flags;
 
-  /* If timed then aggregate stats, else increment the value counts only */
-  if (wait->m_timer_state == TIMER_STATE_TIMED)
+  if (flags & STATE_FLAG_TIMED)
   {
-    ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-    aggregate_single_stat_chain(&table->m_wait_stat, wait_time);
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    stat->aggregate_timed(wait_time);
   }
   else
   {
-    increment_single_stat_chain(&table->m_wait_stat);
+    stat->aggregate_counted();
   }
 
-  /*
-    There is currently no per table and per thread aggregation.
-    The number of tables in the application is arbitrary, and may be high.
-    The number of slots per thread to hold aggregates is fixed,
-    and is constrained by memory.
-    Implementing a per thread and per table aggregate has not been
-    decided yet.
-    If it's implemented, it's likely that the user will have to specify,
-    per table name, if the aggregate per thread is to be computed or not.
-    This will mean a SETUP_ table.
-  */
-  wait->m_thread->m_wait_locker_count--;
+  if (flags & STATE_FLAG_THREAD)
+  {
+    PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+    DBUG_ASSERT(thread != NULL);
+
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= klass->m_event_name_index;
+
+    if (flags & STATE_FLAG_TIMED)
+    {
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+      event_name_array[index].aggregate_timed(wait_time);
+    }
+    else
+    {
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+      event_name_array[index].aggregate_counted();
+    }
+
+    if (flags & STATE_FLAG_WAIT)
+    {
+      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+      DBUG_ASSERT(wait != NULL);
+
+      wait->m_timer_end= timer_end;
+      if (flag_events_waits_history)
+        insert_events_waits_history(thread, wait);
+      if (flag_events_waits_history_long)
+        insert_events_waits_history_long(wait);
+      thread->m_events_waits_count--;
+    }
+  }
 }
 
 static void start_file_wait_v1(PSI_file_locker *locker,
@@ -2237,34 +2977,45 @@ static void start_file_wait_v1(PSI_file_
 static void end_file_wait_v1(PSI_file_locker *locker,
                              size_t count);
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::start_file_open_wait.
+*/
 static PSI_file* start_file_open_wait_v1(PSI_file_locker *locker,
                                          const char *src_file,
                                          uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
   start_file_wait_v1(locker, 0, src_file, src_line);
 
-  PFS_file *pfs_file= pfs_locker->m_target.m_file;
-  return reinterpret_cast<PSI_file*> (pfs_file);
+  return state->m_file;
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::end_file_open_wait.
+*/
 static void end_file_open_wait_v1(PSI_file_locker *locker)
 {
   end_file_wait_v1(locker, 0);
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::end_file_open_wait_and_bind_to_descriptor.
+*/
 static void end_file_open_wait_and_bind_to_descriptor_v1
   (PSI_file_locker *locker, File file)
 {
   int index= (int) file;
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
   end_file_wait_v1(locker, 0);
 
-  PFS_file *pfs_file= pfs_locker->m_target.m_file;
+  PFS_file *pfs_file= reinterpret_cast<PFS_file*> (state->m_file);
   DBUG_ASSERT(pfs_file != NULL);
 
   if (likely(index >= 0))
@@ -2275,93 +3026,136 @@ static void end_file_open_wait_and_bind_
       file_handle_lost++;
   }
   else
+  {
     release_file(pfs_file);
+  }
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::start_file_wait.
+*/
 static void start_file_wait_v1(PSI_file_locker *locker,
                                size_t count,
                                const char *src_file,
                                uint src_line)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
+  ulonglong timer_start= 0;
+  PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
 
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-  if (wait->m_timer_state == TIMER_STATE_STARTING)
+  register uint flags= state->m_flags;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_start= get_timer_raw_value_and_function(wait_timer, & state->m_timer);
+    state->m_timer_start= timer_start;
+  }
+
+  if (flags & STATE_FLAG_WAIT)
   {
-    wait->m_timer_start= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_STARTED;
+    PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+    DBUG_ASSERT(wait != NULL);
+
+    wait->m_timer_start= timer_start;
+    wait->m_source_file= src_file;
+    wait->m_source_line= src_line;
+    wait->m_number_of_bytes= count;
   }
-  wait->m_source_file= src_file;
-  wait->m_source_line= src_line;
-  wait->m_number_of_bytes= count;
 }
 
+/**
+  Implementation of the file instrumentation interface.
+  @sa PSI_v1::end_file_wait.
+*/
 static void end_file_wait_v1(PSI_file_locker *locker,
                              size_t count)
 {
-  PFS_wait_locker *pfs_locker= reinterpret_cast<PFS_wait_locker*> (locker);
-  DBUG_ASSERT(pfs_locker != NULL);
-  PFS_events_waits *wait= &pfs_locker->m_waits_current;
-
-  wait->m_number_of_bytes= count;
-  if (wait->m_timer_state == TIMER_STATE_STARTED)
-  {
-    wait->m_timer_end= get_timer_value(pfs_locker->m_timer_name);
-    wait->m_timer_state= TIMER_STATE_TIMED;
-  }
-  if (flag_events_waits_history)
-    insert_events_waits_history(wait->m_thread, wait);
-  if (flag_events_waits_history_long)
-    insert_events_waits_history_long(wait);
-
-  PFS_file *file= pfs_locker->m_target.m_file;
-  PFS_single_stat_chain *stat= find_per_thread_file_class_wait_stat(wait->m_thread, file->m_class);
-
-  /* If timed then aggregate stats, else increment the value counts only */
-  if (wait->m_timer_state == TIMER_STATE_TIMED)
-  {
-    ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
-    aggregate_single_stat_chain(&file->m_wait_stat, wait_time);
-    aggregate_single_stat_chain(stat, wait_time);
+  PSI_file_locker_state *state= reinterpret_cast<PSI_file_locker_state*> (locker);
+  DBUG_ASSERT(state != NULL);
+  ulonglong timer_end= 0;
+  ulonglong wait_time= 0;
+
+  PFS_file *file= reinterpret_cast<PFS_file *> (state->m_file);
+  DBUG_ASSERT(file != NULL);
+  PFS_thread *thread= reinterpret_cast<PFS_thread *> (state->m_thread);
+
+  register uint flags= state->m_flags;
+
+  if (flags & STATE_FLAG_TIMED)
+  {
+    timer_end= state->m_timer();
+    wait_time= timer_end - state->m_timer_start;
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (timed) */
+    file->m_wait_stat.aggregate_timed(wait_time);
   }
   else
   {
-    increment_single_stat_chain(&file->m_wait_stat);
-    increment_single_stat_chain(stat);
+    /* Aggregate to EVENTS_WAITS_SUMMARY_BY_INSTANCE (counted) */
+    file->m_wait_stat.aggregate_counted();
   }
 
-  PFS_file_class *klass= file->m_class;
+  if (flags & STATE_FLAG_THREAD)
+  {
+    DBUG_ASSERT(thread != NULL);
 
-  switch(wait->m_operation)
+    PFS_single_stat *event_name_array;
+    event_name_array= thread->m_instr_class_wait_stats;
+    uint index= file->m_class->m_event_name_index;
+
+    if (flags & STATE_FLAG_TIMED)
+    {
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (timed) */
+      event_name_array[index].aggregate_timed(wait_time);
+    }
+    else
+    {
+      /* Aggregate to EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (counted) */
+      event_name_array[index].aggregate_counted();
+    }
+
+    if (state->m_flags & STATE_FLAG_WAIT)
+    {
+      PFS_events_waits *wait= reinterpret_cast<PFS_events_waits*> (state->m_wait);
+      DBUG_ASSERT(wait != NULL);
+
+      wait->m_timer_end= timer_end;
+      wait->m_number_of_bytes= count;
+      if (flag_events_waits_history)
+        insert_events_waits_history(thread, wait);
+      if (flag_events_waits_history_long)
+        insert_events_waits_history_long(wait);
+      thread->m_events_waits_count--;
+    }
+  }
+
+  /* FIXME: Have file aggregates for every operation */
+  switch(state->m_operation)
   {
-  case OPERATION_TYPE_FILEREAD:
-    file->m_file_stat.m_count_read++;
-    file->m_file_stat.m_read_bytes+= count;
-    klass->m_file_stat.m_count_read++;
-    klass->m_file_stat.m_read_bytes+= count;
+  case PSI_FILE_READ:
+    file->m_file_stat.m_io_stat.aggregate_read(count);
     break;
-  case OPERATION_TYPE_FILEWRITE:
-    file->m_file_stat.m_count_write++;
-    file->m_file_stat.m_write_bytes+= count;
-    klass->m_file_stat.m_count_write++;
-    klass->m_file_stat.m_write_bytes+= count;
+  case PSI_FILE_WRITE:
+    file->m_file_stat.m_io_stat.aggregate_write(count);
     break;
-  case OPERATION_TYPE_FILECLOSE:
-  case OPERATION_TYPE_FILESTREAMCLOSE:
-  case OPERATION_TYPE_FILESTAT:
-    release_file(pfs_locker->m_target.m_file);
+  case PSI_FILE_CLOSE:
+  case PSI_FILE_STREAM_CLOSE:
+  case PSI_FILE_STAT:
+    release_file(file);
     break;
-  case OPERATION_TYPE_FILEDELETE:
-    destroy_file(wait->m_thread, pfs_locker->m_target.m_file);
+  case PSI_FILE_DELETE:
+    DBUG_ASSERT(thread != NULL);
+    destroy_file(thread, file);
     break;
   default:
     break;
   }
-
-  wait->m_thread->m_wait_locker_count--;
 }
 
+/**
+  Implementation of the instrumentation interface.
+  @sa PSI_v1.
+*/
 PSI_v1 PFS_v1=
 {
   register_mutex_v1,

=== modified file 'storage/perfschema/pfs_defaults.cc'
--- a/storage/perfschema/pfs_defaults.cc	2010-07-02 16:15:37 +0000
+++ b/storage/perfschema/pfs_defaults.cc	2010-09-23 16:08:54 +0000
@@ -22,6 +22,7 @@
 #include "pfs_defaults.h"
 #include "pfs_instr.h"
 #include "pfs_setup_actor.h"
+#include "pfs_setup_object.h"
 
 static PSI_thread_key key;
 static PSI_thread_info info= { &key, "setup", PSI_FLAG_GLOBAL };
@@ -44,6 +45,23 @@ void install_default_setup(PSI_bootstrap
   /* Enable all users on all hosts by default */
   insert_setup_actor(&percent, &percent, &percent);
 
+#if 0
+  /* Disable system tables by default */
+  String mysql_db("mysql", 5, &my_charset_utf8_bin);
+  insert_setup_object(OBJECT_TYPE_TABLE, &mysql_db, &percent, false, false);
+#endif
+  /* Disable performance/information schema tables. */
+  String PS_db("performance_schema", 18, &my_charset_utf8_bin);
+  String IS_db("information_schema", 18, &my_charset_utf8_bin);
+  insert_setup_object(OBJECT_TYPE_TABLE, &PS_db, &percent, false, false);
+  insert_setup_object(OBJECT_TYPE_TABLE, &IS_db, &percent, false, false);
+  /* Enable every other tables */
+  insert_setup_object(OBJECT_TYPE_TABLE, &percent, &percent, true, true);
+#if 0
+  /* Disable every temporary tables */
+  insert_setup_object(OBJECT_TYPE_TEMPORARY_TABLE, &percent, &percent, false, false);
+#endif
+
   psi->delete_current_thread();
 }
 

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2010-09-28 15:17:29 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2010-10-04 18:27:08 +0000
@@ -24,11 +24,13 @@
 #include "table_setup_actors.h"
 #include "table_setup_consumers.h"
 #include "table_setup_instruments.h"
+#include "table_setup_objects.h"
 #include "table_setup_timers.h"
 #include "table_performance_timers.h"
-#include "table_threads.h"
 #include "table_events_waits_summary.h"
+#include "table_ews_by_thread_by_event_name.h"
 #include "table_ews_global_by_event_name.h"
+#include "table_os_global_by_type.h"
 #include "table_sync_instances.h"
 #include "table_file_instances.h"
 #include "table_file_summary.h"
@@ -38,6 +40,7 @@
 #include "pfs_column_values.h"
 #include "pfs_instr.h"
 #include "pfs_setup_actor.h"
+#include "pfs_setup_object.h"
 #include "pfs_global.h"
 
 #include "sql_base.h"                           // close_thread_tables
@@ -55,17 +58,19 @@ static PFS_engine_table_share *all_share
   &table_events_waits_history_long::m_share,
   &table_events_waits_history::m_share,
   &table_events_waits_summary_by_instance::m_share,
-  &table_events_waits_summary_by_thread_by_event_name::m_share,
+  &table_ews_by_thread_by_event_name::m_share,
   &table_ews_global_by_event_name::m_share,
   &table_file_instances::m_share,
   &table_file_summary_by_event_name::m_share,
   &table_file_summary_by_instance::m_share,
   &table_mutex_instances::m_share,
+  &table_os_global_by_type::m_share,
   &table_performance_timers::m_share,
   &table_rwlock_instances::m_share,
   &table_setup_actors::m_share,
   &table_setup_consumers::m_share,
   &table_setup_instruments::m_share,
+  &table_setup_objects::m_share,
   &table_setup_timers::m_share,
   &table_threads::m_share,
   NULL
@@ -82,7 +87,7 @@ void PFS_engine_table_share::check_all_t
   DBUG_EXECUTE_IF("tampered_perfschema_table1",
                   {
                     /* Hack SETUP_INSTRUMENT, incompatible change. */
-                    all_shares[15]->m_field_def->count++;
+                    all_shares[16]->m_field_def->count++;
                   });
 
   for (current= &all_shares[0]; (*current) != NULL; current++)
@@ -648,11 +653,11 @@ bool pfs_show_status(handlerton *hton, T
     switch (i){
     case 0:
       name= "EVENTS_WAITS_CURRENT.ROW_SIZE";
-      size= sizeof(PFS_wait_locker);
+      size= sizeof(PFS_events_waits);
       break;
     case 1:
       name= "EVENTS_WAITS_CURRENT.ROW_COUNT";
-      size= LOCKER_STACK_SIZE * thread_max;
+      size= WAIT_STACK_SIZE * thread_max;
       break;
     case 2:
       name= "EVENTS_WAITS_HISTORY.ROW_SIZE";
@@ -826,15 +831,15 @@ bool pfs_show_status(handlerton *hton, T
       break;
     case 41:
       name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_SIZE";
-      size= sizeof(PFS_single_stat_chain);
+      size= sizeof(PFS_single_stat);
       break;
     case 42:
       name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_COUNT";
-      size= thread_max * instr_class_per_thread;
+      size= thread_max * max_instrument_class;
       break;
     case 43:
       name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.MEMORY";
-      size= thread_max * instr_class_per_thread * sizeof(PFS_single_stat_chain);
+      size= thread_max * max_instrument_class * sizeof(PFS_single_stat);
       total_memory+= size;
       break;
     case 44:
@@ -876,11 +881,37 @@ bool pfs_show_status(handlerton *hton, T
       size= setup_actor_max * sizeof(PFS_setup_actor);
       total_memory+= size;
       break;
+    case 53:
+      name= "SETUP_OBJECTS.ROW_SIZE";
+      size= sizeof(PFS_setup_object);
+      break;
+    case 54:
+      name= "SETUP_OBJECTS.ROW_COUNT";
+      size= setup_object_max;
+      break;
+    case 55:
+      name= "SETUP_OBJECTS.MEMORY";
+      size= setup_object_max * sizeof(PFS_setup_object);
+      total_memory+= size;
+      break;
+   case 56:
+      name= "EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.ROW_SIZE";
+      size= sizeof(PFS_single_stat);
+      break;
+    case 57:
+      name= "EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.ROW_COUNT";
+      size= max_instrument_class;
+      break;
+    case 58:
+      name= "EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.MEMORY";
+      size= max_instrument_class * sizeof(PFS_single_stat);
+      total_memory+= size;
+      break;
     /*
       This case must be last,
       for aggregation in total_memory.
     */
-    case 53:
+    case 59:
       name= "PERFORMANCE_SCHEMA.MEMORY";
       size= total_memory;
       /* This will fail if something is not advertised here */

=== modified file 'storage/perfschema/pfs_events_waits.cc'
--- a/storage/perfschema/pfs_events_waits.cc	2010-08-12 10:21:22 +0000
+++ b/storage/perfschema/pfs_events_waits.cc	2010-09-23 16:08:54 +0000
@@ -33,18 +33,10 @@ bool flag_events_waits_current= true;
 bool flag_events_waits_history= true;
 /** Consumer flag for table EVENTS_WAITS_HISTORY_LONG. */
 bool flag_events_waits_history_long= true;
-/** Consumer flag for table EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */
-bool flag_events_waits_summary_by_thread_by_event_name= true;
-/** Consumer flag for table EVENTS_WAITS_SUMMARY_BY_EVENT_NAME. */
-bool flag_events_waits_summary_by_event_name= true;
-/** Consumer flag for table EVENTS_WAITS_SUMMARY_BY_INSTANCE. */
-bool flag_events_waits_summary_by_instance= true;
-bool flag_events_locks_summary_by_event_name= true;
-bool flag_events_locks_summary_by_instance= true;
-/** Consumer flag for table FILE_SUMMARY_BY_EVENT_NAME. */
-bool flag_file_summary_by_event_name= true;
-/** Consumer flag for table FILE_SUMMARY_BY_INSTANCE. */
-bool flag_file_summary_by_instance= true;
+/** Consumer flag for the global instrumentation. */
+bool flag_global_instrumentation= true;
+/** Consumer flag for the per thread instrumentation. */
+bool flag_thread_instrumentation= true;
 
 /** True if EVENTS_WAITS_HISTORY_LONG circular buffer is full. */
 bool events_waits_history_long_full= false;
@@ -138,11 +130,11 @@ void reset_events_waits_current(void)
 
   for ( ; pfs_thread < pfs_thread_last; pfs_thread++)
   {
-    PFS_wait_locker *locker= pfs_thread->m_wait_locker_stack;
-    PFS_wait_locker *locker_last= locker + LOCKER_STACK_SIZE;
+    PFS_events_waits *pfs_wait= pfs_thread->m_events_waits_stack;
+    PFS_events_waits *pfs_wait_last= pfs_wait + WAIT_STACK_SIZE;
 
-    for ( ; locker < locker_last; locker++)
-      locker->m_waits_current.m_wait_class= NO_WAIT_CLASS;
+    for ( ; pfs_wait < pfs_wait_last; pfs_wait++)
+      pfs_wait->m_wait_class= NO_WAIT_CLASS;
   }
 }
 

=== modified file 'storage/perfschema/pfs_events_waits.h'
--- a/storage/perfschema/pfs_events_waits.h	2010-08-12 10:21:22 +0000
+++ b/storage/perfschema/pfs_events_waits.h	2010-09-23 16:08:54 +0000
@@ -43,31 +43,6 @@ enum events_waits_class
   WAIT_CLASS_FILE
 };
 
-/** State of a timer. */
-enum timer_state
-{
-  /**
-    Not timed.
-    In this state, TIMER_START, TIMER_END and TIMER_WAIT are NULL.
-  */
-  TIMER_STATE_UNTIMED,
-  /**
-    About to start.
-    In this state, TIMER_START, TIMER_END and TIMER_WAIT are NULL.
-  */
-  TIMER_STATE_STARTING,
-  /**
-    Started, but not yet ended.
-    In this state, TIMER_START has a value, TIMER_END and TIMER_WAIT are NULL.
-  */
-  TIMER_STATE_STARTED,
-  /**
-    Ended.
-    In this state, TIMER_START, TIMER_END and TIMER_WAIT have a value.
-  */
-  TIMER_STATE_TIMED
-};
-
 /** Target object a wait event is waiting on. */
 union events_waits_target
 {
@@ -102,8 +77,6 @@ struct PFS_events_waits
   PFS_thread *m_thread;
   /** Instrument metadata. */
   PFS_instr_class *m_class;
-  /** Timer state. */
-  enum timer_state m_timer_state;
   /** Event id. */
   ulonglong m_event_id;
   /** Nesting event id. */
@@ -150,21 +123,6 @@ struct PFS_events_waits
   ulong m_flags;
 };
 
-/**
-  A wait locker.
-  A locker is a transient helper structure used by the instrumentation
-  during the recording of a wait.
-*/
-struct PFS_wait_locker
-{
-  /** The timer used to measure the wait. */
-  enum_timer_name m_timer_name;
-  /** The object waited on. */
-  events_waits_target m_target;
-  /** The wait data recorded. */
-  PFS_events_waits m_waits_current;
-};
-
 void insert_events_waits_history(PFS_thread *thread, PFS_events_waits *wait);
 
 void insert_events_waits_history_long(PFS_events_waits *wait);
@@ -172,14 +130,9 @@ void insert_events_waits_history_long(PF
 extern bool flag_events_waits_current;
 extern bool flag_events_waits_history;
 extern bool flag_events_waits_history_long;
-extern bool flag_events_waits_summary_by_thread_by_event_name;
-extern bool flag_events_waits_summary_by_event_name;
-extern bool flag_events_waits_summary_by_instance;
-extern bool flag_events_locks_summary_by_thread_by_name;
-extern bool flag_events_locks_summary_by_event_name;
-extern bool flag_events_locks_summary_by_instance;
-extern bool flag_file_summary_by_event_name;
-extern bool flag_file_summary_by_instance;
+extern bool flag_global_instrumentation;
+extern bool flag_thread_instrumentation;
+
 extern bool events_waits_history_long_full;
 extern volatile uint32 events_waits_history_long_index;
 extern PFS_events_waits *events_waits_history_long_array;

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2010-07-30 09:02:32 +0000
+++ b/storage/perfschema/pfs_instr.cc	2010-09-24 18:21:22 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010 Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -26,6 +26,7 @@
 #include "pfs_stat.h"
 #include "pfs_instr.h"
 #include "pfs_global.h"
+#include "pfs_instr_class.h"
 
 /**
   @addtogroup Performance_schema_buffers
@@ -65,8 +66,6 @@ ulong table_max;
 ulong table_lost;
 /** Number of EVENTS_WAITS_HISTORY records per thread. */
 ulong events_waits_history_per_thread;
-/** Number of instruments class per thread. */
-ulong instr_class_per_thread;
 /** Number of locker lost. @sa LOCKER_STACK_SIZE. */
 ulong locker_lost= 0;
 
@@ -120,13 +119,12 @@ PFS_file **file_handle_array= NULL;
 */
 PFS_table *table_array= NULL;
 
+PFS_single_stat *global_instr_class_waits_array= NULL;
+
 static volatile uint32 thread_internal_id_counter= 0;
 
-static uint per_thread_rwlock_class_start;
-static uint per_thread_cond_class_start;
-static uint per_thread_file_class_start;
 static uint thread_instr_class_waits_sizing;
-static PFS_single_stat_chain *thread_instr_class_waits_array= NULL;
+static PFS_single_stat *thread_instr_class_waits_array= NULL;
 
 static PFS_events_waits *thread_history_array= NULL;
 
@@ -149,6 +147,9 @@ int init_instruments(const PFS_global_pa
   uint thread_history_sizing;
   uint index;
 
+  /* Make sure init_event_name_sizing is called */
+  DBUG_ASSERT(max_instrument_class != 0);
+
   mutex_max= param->m_mutex_sizing;
   mutex_lost= 0;
   rwlock_max= param->m_rwlock_sizing;
@@ -168,16 +169,8 @@ int init_instruments(const PFS_global_pa
   thread_history_sizing= param->m_thread_sizing
     * events_waits_history_per_thread;
 
-  per_thread_rwlock_class_start= param->m_mutex_class_sizing;
-  per_thread_cond_class_start= per_thread_rwlock_class_start
-    + param->m_rwlock_class_sizing;
-  per_thread_file_class_start= per_thread_cond_class_start
-    + param->m_cond_class_sizing;
-  instr_class_per_thread= per_thread_file_class_start
-    + param->m_file_class_sizing;
-
   thread_instr_class_waits_sizing= param->m_thread_sizing
-    * instr_class_per_thread;
+    * max_instrument_class;
 
   mutex_array= NULL;
   rwlock_array= NULL;
@@ -252,21 +245,12 @@ int init_instruments(const PFS_global_pa
   {
     thread_instr_class_waits_array=
       PFS_MALLOC_ARRAY(thread_instr_class_waits_sizing,
-                       PFS_single_stat_chain, MYF(MY_ZEROFILL));
+                       PFS_single_stat, MYF(MY_ZEROFILL));
     if (unlikely(thread_instr_class_waits_array == NULL))
       return 1;
-  }
 
-  for (index= 0; index < thread_instr_class_waits_sizing; index++)
-  {
-    /*
-      Currently, this chain is of length 1,
-      but it's still implemented as a stat chain,
-      since more aggregations are planned to be implemented in m_parent.
-    */
-    thread_instr_class_waits_array[index].m_control_flag=
-      &flag_events_waits_summary_by_thread_by_event_name;
-    thread_instr_class_waits_array[index].m_parent= NULL;
+    for (index= 0; index < thread_instr_class_waits_sizing; index++)
+      thread_instr_class_waits_array[index].reset();
   }
 
   for (index= 0; index < thread_max; index++)
@@ -274,111 +258,35 @@ int init_instruments(const PFS_global_pa
     thread_array[index].m_waits_history=
       &thread_history_array[index * events_waits_history_per_thread];
     thread_array[index].m_instr_class_wait_stats=
-      &thread_instr_class_waits_array[index * instr_class_per_thread];
+      &thread_instr_class_waits_array[index * max_instrument_class];
   }
 
-  return 0;
-}
-
-/**
-  Find the per-thread wait statistics for a mutex class.
-  @param thread                       input thread
-  @param klass                        mutex class
-  @return the per thread per mutex class wait stat
-*/
-PFS_single_stat_chain *
-find_per_thread_mutex_class_wait_stat(PFS_thread *thread,
-                                      PFS_mutex_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  uint index;
-
-  DBUG_ASSERT(thread != NULL);
-  DBUG_ASSERT(klass != NULL);
-  index= klass->m_index;
-  DBUG_ASSERT(index < mutex_class_max);
-
-  stat= &(thread->m_instr_class_wait_stats[index]);
-  return stat;
-}
-
-/**
-  Find the per-thread wait statistics for a rwlock class.
-  @param thread                       input thread
-  @param klass                        rwlock class
-  @return the per thread per rwlock class wait stat
-*/
-PFS_single_stat_chain *
-find_per_thread_rwlock_class_wait_stat(PFS_thread *thread,
-                                       PFS_rwlock_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  uint index;
-
-  DBUG_ASSERT(thread != NULL);
-  DBUG_ASSERT(klass != NULL);
-  index= klass->m_index;
-  DBUG_ASSERT(index < rwlock_class_max);
-
-  stat= &(thread->m_instr_class_wait_stats
-          [per_thread_rwlock_class_start + index]);
-  return stat;
-}
-
-/**
-  Find the per-thread wait statistics for a condition class.
-  @param thread                       input thread
-  @param klass                        condition class
-  @return the per thread per condition class wait stat
-*/
-PFS_single_stat_chain *
-find_per_thread_cond_class_wait_stat(PFS_thread *thread,
-                                     PFS_cond_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  uint index;
-
-  DBUG_ASSERT(thread != NULL);
-  DBUG_ASSERT(klass != NULL);
-  index= klass->m_index;
-  DBUG_ASSERT(index < cond_class_max);
-
-  stat= &(thread->m_instr_class_wait_stats
-          [per_thread_cond_class_start + index]);
-  return stat;
-}
+  if (max_instrument_class > 0)
+  {
+    global_instr_class_waits_array=
+      PFS_MALLOC_ARRAY(max_instrument_class,
+                       PFS_single_stat, MYF(MY_ZEROFILL));
+    if (unlikely(global_instr_class_waits_array == NULL))
+      return 1;
 
-/**
-  Find the per-thread wait statistics for a file class.
-  @param thread                       input thread
-  @param klass                        file class
-  @return the per thread per file class wait stat
-*/
-PFS_single_stat_chain *
-find_per_thread_file_class_wait_stat(PFS_thread *thread,
-                                     PFS_file_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  uint index;
+    for (index= 0; index < max_instrument_class; index++)
+      global_instr_class_waits_array[index].reset();
+  }
 
-  DBUG_ASSERT(thread != NULL);
-  DBUG_ASSERT(klass != NULL);
-  index= klass->m_index;
-  DBUG_ASSERT(index < file_class_max);
-
-  stat= &(thread->m_instr_class_wait_stats
-          [per_thread_file_class_start + index]);
-  return stat;
+  return 0;
 }
 
 /** Reset the wait statistics per thread. */
 void reset_per_thread_wait_stat(void)
 {
-  PFS_single_stat_chain *stat= thread_instr_class_waits_array;
-  PFS_single_stat_chain *stat_last= stat + thread_instr_class_waits_sizing;
+  PFS_thread *thread= thread_array;
+  PFS_thread *thread_last= thread_array + thread_max;
 
-  for ( ; stat < stat_last; stat++)
-    reset_single_stat_link(stat);
+  for ( ; thread < thread_last; thread++)
+  {
+    if (thread->m_lock.is_populated())
+      aggregate_thread(thread);
+  }
 }
 
 /** Cleanup all the instruments buffers. */
@@ -409,6 +317,8 @@ void cleanup_instruments(void)
   thread_history_array= NULL;
   pfs_free(thread_instr_class_waits_array);
   thread_instr_class_waits_array= NULL;
+  pfs_free(global_instr_class_waits_array);
+  global_instr_class_waits_array= NULL;
 }
 
 extern "C"
@@ -548,17 +458,13 @@ PFS_mutex* create_mutex(PFS_mutex_class
         {
           pfs->m_identity= identity;
           pfs->m_class= klass;
-          pfs->m_wait_stat.m_control_flag=
-            &flag_events_waits_summary_by_instance;
-          pfs->m_wait_stat.m_parent= &klass->m_wait_stat;
-          reset_single_stat_link(&pfs->m_wait_stat);
-          pfs->m_lock_stat.m_control_flag=
-            &flag_events_locks_summary_by_instance;
-          pfs->m_lock_stat.m_parent= &klass->m_lock_stat;
-          reset_single_stat_link(&pfs->m_lock_stat);
+          pfs->m_wait_stat.reset();
+          pfs->m_lock_stat.reset();
           pfs->m_owner= NULL;
           pfs->m_last_locked= 0;
           pfs->m_lock.dirty_to_allocated();
+          if (klass->is_singleton())
+            klass->m_singleton= pfs;
           return pfs;
         }
       }
@@ -576,6 +482,13 @@ PFS_mutex* create_mutex(PFS_mutex_class
 void destroy_mutex(PFS_mutex *pfs)
 {
   DBUG_ASSERT(pfs != NULL);
+  PFS_mutex_class *klass= pfs->m_class;
+  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_EVENT_NAME */
+  uint index= klass->m_event_name_index;
+  global_instr_class_waits_array[index].aggregate(& pfs->m_wait_stat);
+  pfs->m_wait_stat.reset();
+  if (klass->is_singleton())
+    klass->m_singleton= NULL;
   pfs->m_lock.allocated_to_free();
 }
 
@@ -604,23 +517,16 @@ PFS_rwlock* create_rwlock(PFS_rwlock_cla
         {
           pfs->m_identity= identity;
           pfs->m_class= klass;
-          pfs->m_wait_stat.m_control_flag=
-            &flag_events_waits_summary_by_instance;
-          pfs->m_wait_stat.m_parent= &klass->m_wait_stat;
-          reset_single_stat_link(&pfs->m_wait_stat);
+          pfs->m_wait_stat.reset();
           pfs->m_lock.dirty_to_allocated();
-          pfs->m_read_lock_stat.m_control_flag=
-            &flag_events_locks_summary_by_instance;
-          pfs->m_read_lock_stat.m_parent= &klass->m_read_lock_stat;
-          reset_single_stat_link(&pfs->m_read_lock_stat);
-          pfs->m_write_lock_stat.m_control_flag=
-            &flag_events_locks_summary_by_instance;
-          pfs->m_write_lock_stat.m_parent= &klass->m_write_lock_stat;
-          reset_single_stat_link(&pfs->m_write_lock_stat);
+          pfs->m_read_lock_stat.reset();
+          pfs->m_write_lock_stat.reset();
           pfs->m_writer= NULL;
           pfs->m_readers= 0;
           pfs->m_last_written= 0;
           pfs->m_last_read= 0;
+          if (klass->is_singleton())
+            klass->m_singleton= pfs;
           return pfs;
         }
       }
@@ -638,6 +544,13 @@ PFS_rwlock* create_rwlock(PFS_rwlock_cla
 void destroy_rwlock(PFS_rwlock *pfs)
 {
   DBUG_ASSERT(pfs != NULL);
+  PFS_rwlock_class *klass= pfs->m_class;
+  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_EVENT_NAME */
+  uint index= klass->m_event_name_index;
+  global_instr_class_waits_array[index].aggregate(& pfs->m_wait_stat);
+  pfs->m_wait_stat.reset();
+  if (klass->is_singleton())
+    klass->m_singleton= NULL;
   pfs->m_lock.allocated_to_free();
 }
 
@@ -668,11 +581,10 @@ PFS_cond* create_cond(PFS_cond_class *kl
           pfs->m_class= klass;
           pfs->m_cond_stat.m_signal_count= 0;
           pfs->m_cond_stat.m_broadcast_count= 0;
-          pfs->m_wait_stat.m_control_flag=
-            &flag_events_waits_summary_by_instance;
-          pfs->m_wait_stat.m_parent= &klass->m_wait_stat;
-          reset_single_stat_link(&pfs->m_wait_stat);
+          pfs->m_wait_stat.reset();
           pfs->m_lock.dirty_to_allocated();
+          if (klass->is_singleton())
+            klass->m_singleton= pfs;
           return pfs;
         }
       }
@@ -690,6 +602,13 @@ PFS_cond* create_cond(PFS_cond_class *kl
 void destroy_cond(PFS_cond *pfs)
 {
   DBUG_ASSERT(pfs != NULL);
+  PFS_cond_class *klass= pfs->m_class;
+  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_EVENT_NAME */
+  uint index= klass->m_event_name_index;
+  global_instr_class_waits_array[index].aggregate(& pfs->m_wait_stat);
+  pfs->m_wait_stat.reset();
+  if (klass->is_singleton())
+    klass->m_singleton= NULL;
   pfs->m_lock.allocated_to_free();
 }
 
@@ -733,17 +652,18 @@ PFS_thread* create_thread(PFS_thread_cla
           pfs->m_event_id= 1;
           pfs->m_enabled= true;
           pfs->m_class= klass;
-          pfs->m_wait_locker_count= 0;
+          pfs->m_events_waits_count= 0;
           pfs->m_waits_history_full= false;
           pfs->m_waits_history_index= 0;
 
-          PFS_single_stat_chain *stat= pfs->m_instr_class_wait_stats;
-          PFS_single_stat_chain *stat_last= stat + instr_class_per_thread;
+          PFS_single_stat *stat= pfs->m_instr_class_wait_stats;
+          PFS_single_stat *stat_last= stat + max_instrument_class;
           for ( ; stat < stat_last; stat++)
-            reset_single_stat_link(stat);
+            stat->reset();
           pfs->m_filename_hash_pins= NULL;
           pfs->m_table_share_hash_pins= NULL;
           pfs->m_setup_actor_hash_pins= NULL;
+          pfs->m_setup_object_hash_pins= NULL;
 
           pfs->m_username_length= 0;
           pfs->m_hostname_length= 0;
@@ -764,6 +684,30 @@ PFS_thread* create_thread(PFS_thread_cla
   return NULL;
 }
 
+PFS_mutex *sanitize_mutex(PFS_mutex *unsafe)
+{
+  if ((&mutex_array[0] <= unsafe) &&
+      (unsafe < &mutex_array[mutex_max]))
+    return unsafe;
+  return NULL;
+}
+
+PFS_rwlock *sanitize_rwlock(PFS_rwlock *unsafe)
+{
+  if ((&rwlock_array[0] <= unsafe) &&
+      (unsafe < &rwlock_array[rwlock_max]))
+    return unsafe;
+  return NULL;
+}
+
+PFS_cond *sanitize_cond(PFS_cond *unsafe)
+{
+  if ((&cond_array[0] <= unsafe) &&
+      (unsafe < &cond_array[cond_max]))
+    return unsafe;
+  return NULL;
+}
+
 /**
   Sanitize a PFS_thread pointer.
   Validate that the PFS_thread is part of thread_array.
@@ -781,6 +725,14 @@ PFS_thread *sanitize_thread(PFS_thread *
   return NULL;
 }
 
+PFS_file *sanitize_file(PFS_file *unsafe)
+{
+  if ((&file_array[0] <= unsafe) &&
+      (unsafe < &file_array[file_max]))
+    return unsafe;
+  return NULL;
+}
+
 /**
   Destroy instrumentation for a thread instance.
   @param pfs                          the thread to destroy
@@ -798,6 +750,16 @@ void destroy_thread(PFS_thread *pfs)
     lf_hash_put_pins(pfs->m_table_share_hash_pins);
     pfs->m_table_share_hash_pins= NULL;
   }
+  if (pfs->m_setup_actor_hash_pins)
+  {
+    lf_hash_put_pins(pfs->m_setup_actor_hash_pins);
+    pfs->m_setup_actor_hash_pins= NULL;
+  }
+  if (pfs->m_setup_object_hash_pins)
+  {
+    lf_hash_put_pins(pfs->m_setup_object_hash_pins);
+    pfs->m_setup_object_hash_pins= NULL;
+  }
   pfs->m_lock.allocated_to_free();
 }
 
@@ -947,11 +909,9 @@ search:
           strncpy(pfs->m_filename, normalized_filename, normalized_length);
           pfs->m_filename[normalized_length]= '\0';
           pfs->m_filename_length= normalized_length;
+          pfs->m_wait_stat.reset();
           pfs->m_file_stat.m_open_count= 1;
-          pfs->m_wait_stat.m_control_flag=
-            &flag_events_waits_summary_by_instance;
-          pfs->m_wait_stat.m_parent= &klass->m_wait_stat;
-          reset_single_stat_link(&pfs->m_wait_stat);
+          pfs->m_file_stat.m_io_stat.reset();
 
           int res;
           res= lf_hash_insert(&filename_hash, thread->m_filename_hash_pins,
@@ -959,6 +919,8 @@ search:
           if (likely(res == 0))
           {
             pfs->m_lock.dirty_to_allocated();
+            if (klass->is_singleton())
+              klass->m_singleton= pfs;
             return pfs;
           }
 
@@ -1008,8 +970,21 @@ void destroy_file(PFS_thread *thread, PF
   DBUG_ASSERT(thread != NULL);
   DBUG_ASSERT(thread->m_filename_hash_pins != NULL);
   DBUG_ASSERT(pfs != NULL);
+  PFS_file_class *klass= pfs->m_class;
+
+  /* Aggregate to EVENTS_WAITS_SUMMARY_BY_EVENT_NAME */
+  uint index= klass->m_event_name_index;
+  global_instr_class_waits_array[index].aggregate(& pfs->m_wait_stat);
+  pfs->m_wait_stat.reset();
+
+  /* Aggregate to FILE_SUMMARY_BY_EVENT_NAME */
+  klass->m_file_stat.m_io_stat.aggregate(& pfs->m_file_stat.m_io_stat);
+  pfs->m_file_stat.m_io_stat.reset();
+
   lf_hash_delete(&filename_hash, thread->m_filename_hash_pins,
                  pfs->m_filename, pfs->m_filename_length);
+  if (klass->is_singleton())
+    klass->m_singleton= NULL;
   pfs->m_lock.allocated_to_free();
 }
 
@@ -1041,10 +1016,7 @@ PFS_table* create_table(PFS_table_share
           pfs->m_identity= identity;
           pfs->m_share= share;
           share->m_refcount++;
-          pfs->m_wait_stat.m_control_flag=
-            &flag_events_waits_summary_by_instance;
-          pfs->m_wait_stat.m_parent= &share->m_wait_stat;
-          reset_single_stat_link(&pfs->m_wait_stat);
+          pfs->m_table_stat.reset();
           pfs->m_opening_thread= opening_thread;
           pfs->m_lock.dirty_to_allocated();
           return pfs;
@@ -1064,6 +1036,7 @@ PFS_table* create_table(PFS_table_share
 void destroy_table(PFS_table *pfs)
 {
   DBUG_ASSERT(pfs != NULL);
+  pfs->m_share->m_refcount--;
   pfs->m_lock.allocated_to_free();
 }
 
@@ -1073,7 +1046,7 @@ static void reset_mutex_waits_by_instanc
   PFS_mutex *pfs_last= mutex_array + mutex_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
+    pfs->m_wait_stat.reset();
 }
 
 static void reset_rwlock_waits_by_instance(void)
@@ -1082,7 +1055,7 @@ static void reset_rwlock_waits_by_instan
   PFS_rwlock *pfs_last= rwlock_array + rwlock_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
+    pfs->m_wait_stat.reset();
 }
 
 static void reset_cond_waits_by_instance(void)
@@ -1091,7 +1064,7 @@ static void reset_cond_waits_by_instance
   PFS_cond *pfs_last= cond_array + cond_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
+    pfs->m_wait_stat.reset();
 }
 
 static void reset_file_waits_by_instance(void)
@@ -1100,7 +1073,7 @@ static void reset_file_waits_by_instance
   PFS_file *pfs_last= file_array + file_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
+    pfs->m_wait_stat.reset();
 }
 
 /** Reset the wait statistics per object instance. */
@@ -1119,7 +1092,78 @@ void reset_file_instance_io(void)
   PFS_file *pfs_last= file_array + file_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    reset_file_stat(&pfs->m_file_stat);
+    pfs->m_file_stat.m_io_stat.reset();
+}
+
+void reset_global_wait_stat()
+{
+  PFS_single_stat *stat= global_instr_class_waits_array;
+  PFS_single_stat *stat_last= global_instr_class_waits_array + max_instrument_class;
+
+  for ( ; stat < stat_last; stat++)
+    stat->reset();
+}
+
+void aggregate_all_event_names(PFS_single_stat *from_array,
+                               PFS_single_stat *to_array)
+{
+  PFS_single_stat *from;
+  PFS_single_stat *from_last;
+  PFS_single_stat *to;
+  PFS_single_stat *to_last;
+
+  from= from_array;
+  from_last= from_array + max_instrument_class;
+  to= to_array;
+  to_last= to_array + max_instrument_class;
+
+  for ( ; from < from_last ; from++, to++)
+  {
+    if (from->m_count > 0)
+    {
+      to->aggregate(from);
+      from->reset();
+    }
+  }
+}
+
+void aggregate_all_event_names(PFS_single_stat *from_array,
+                               PFS_single_stat *to_array_1,
+                               PFS_single_stat *to_array_2)
+{
+  PFS_single_stat *from;
+  PFS_single_stat *from_last;
+  PFS_single_stat *to_1;
+  PFS_single_stat *to_1_last;
+  PFS_single_stat *to_2;
+  PFS_single_stat *to_2_last;
+
+  from= from_array;
+  from_last= from_array + max_instrument_class;
+  to_1= to_array_1;
+  to_1_last= to_array_1 + max_instrument_class;
+  to_2= to_array_2;
+  to_2_last= to_array_2 + max_instrument_class;
+
+  for ( ; from < from_last ; from++, to_1++, to_2++)
+  {
+    if (from->m_count > 0)
+    {
+      to_1->aggregate(from);
+      to_2->aggregate(from);
+      from->reset();
+    }
+  }
+}
+
+void aggregate_thread(PFS_thread *thread)
+{
+  /* FIXME */
+
+  PFS_single_stat *stat= thread->m_instr_class_wait_stats;
+  PFS_single_stat *stat_last= stat + max_instrument_class;
+  for ( ; stat < stat_last; stat++)
+    stat->reset();
 }
 
 /** @} */

=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h	2010-07-30 09:02:32 +0000
+++ b/storage/perfschema/pfs_instr.h	2010-09-24 18:21:22 +0000
@@ -21,7 +21,15 @@
   Performance schema instruments (declarations).
 */
 
+struct PFS_mutex_class;
+struct PFS_rwlock_class;
+struct PFS_cond_class;
+struct PFS_file_class;
+struct PFS_table_share;
+struct PFS_thread_class;
+
 #include "pfs_lock.h"
+#include "pfs_stat.h"
 #include "pfs_instr_class.h"
 #include "pfs_events_waits.h"
 #include "pfs_server.h"
@@ -38,8 +46,8 @@ struct PFS_instr
 {
   /** Internal lock. */
   pfs_lock m_lock;
-  /** Instrument wait statistics chain. */
-  PFS_single_stat_chain m_wait_stat;
+  /** Instrument wait statistics. */
+  PFS_single_stat m_wait_stat;
 };
 
 /** Instrumented mutex implementation. @see PSI_mutex. */
@@ -50,10 +58,10 @@ struct PFS_mutex : public PFS_instr
   /** Mutex class. */
   PFS_mutex_class *m_class;
   /**
-    Mutex lock usage statistics chain.
+    Mutex lock usage statistics.
     This statistic is not exposed in user visible tables yet.
   */
-  PFS_single_stat_chain m_lock_stat;
+  PFS_single_stat m_lock_stat;
   /** Current owner. */
   PFS_thread *m_owner;
   /**
@@ -71,15 +79,15 @@ struct PFS_rwlock : public PFS_instr
   /** RWLock class. */
   PFS_rwlock_class *m_class;
   /**
-    RWLock read lock usage statistics chain.
+    RWLock read lock usage statistics.
     This statistic is not exposed in user visible tables yet.
   */
-  PFS_single_stat_chain m_read_lock_stat;
+  PFS_single_stat m_read_lock_stat;
   /**
-    RWLock write lock usage statistics chain.
+    RWLock write lock usage statistics.
     This statistic is not exposed in user visible tables yet.
   */
-  PFS_single_stat_chain m_write_lock_stat;
+  PFS_single_stat m_write_lock_stat;
   /** Current writer thread. */
   PFS_thread *m_writer;
   /** Current count of readers. */
@@ -121,21 +129,25 @@ struct PFS_file : public PFS_instr
 };
 
 /** Instrumented table implementation. @see PSI_table. */
-struct PFS_table : public PFS_instr
+struct PFS_table
 {
+  /** Internal lock. */
+  pfs_lock m_lock;
   /** Owner. */
   PFS_thread *m_opening_thread;
   /** Table share. */
   PFS_table_share *m_share;
   /** Table identity, typically a handler. */
   const void *m_identity;
+  /** Table statistics. */
+  PFS_table_stat m_table_stat;
 };
 
 /**
-  @def LOCKER_STACK_SIZE
+  @def WAIT_STACK_SIZE
   Maximum number of nested waits.
 */
-#define LOCKER_STACK_SIZE 3
+#define WAIT_STACK_SIZE 3
 
 /**
   @def PFS_MAX_ALLOC_RETRY
@@ -192,6 +204,8 @@ struct PFS_thread
   LF_PINS *m_table_share_hash_pins;
   /** Pins for setup_actor_hash. */
   LF_PINS *m_setup_actor_hash_pins;
+  /** Pins for setup_object_hash. */
+  LF_PINS *m_setup_object_hash_pins;
   /** Event ID counter */
   ulonglong m_event_id;
   /** Thread instrumentation flag. */
@@ -204,10 +218,10 @@ struct PFS_thread
   ulong m_thread_id;
   /** Thread class. */
   PFS_thread_class *m_class;
-  /** Size of @c m_wait_locker_stack. */
-  uint m_wait_locker_count;
+  /** Size of @c m_events_waits_stack. */
+  uint m_events_waits_count;
   /**
-    Stack of wait lockers.
+    Stack of events waits.
     This member holds the data for the table
     PERFORMANCE_SCHEMA.EVENTS_WAITS_CURRENT.
     For most locks, only 1 wait locker is used at a given time.
@@ -215,7 +229,7 @@ struct PFS_thread
     - 1 for a 'logical' wait (for example on the GLOBAL READ LOCK state)
     - 1 for a 'physical' wait (for example on COND_refresh)
   */
-  PFS_wait_locker m_wait_locker_stack[LOCKER_STACK_SIZE];
+  PFS_events_waits m_events_waits_stack[WAIT_STACK_SIZE];
   /** True if the circular buffer @c m_waits_history is full. */
   bool m_waits_history_full;
   /** Current index in the circular buffer @c m_waits_history. */
@@ -231,7 +245,7 @@ struct PFS_thread
     This member holds the data for the table
     PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
   */
-  PFS_single_stat_chain *m_instr_class_wait_stats;
+  PFS_single_stat *m_instr_class_wait_stats;
 
   /** User name. */
   char m_username[USERNAME_LENGTH];
@@ -259,23 +273,13 @@ struct PFS_thread
   uint m_processlist_info_length;
 };
 
-PFS_thread *sanitize_thread(PFS_thread *unsafe);
+extern PFS_single_stat *global_instr_class_waits_array;
 
-PFS_single_stat_chain*
-find_per_thread_mutex_class_wait_stat(PFS_thread *thread,
-                                      PFS_mutex_class *klass);
-
-PFS_single_stat_chain*
-find_per_thread_rwlock_class_wait_stat(PFS_thread *thread,
-                                       PFS_rwlock_class *klass);
-
-PFS_single_stat_chain*
-find_per_thread_cond_class_wait_stat(PFS_thread *thread,
-                                     PFS_cond_class *klass);
-
-PFS_single_stat_chain*
-find_per_thread_file_class_wait_stat(PFS_thread *thread,
-                                     PFS_file_class *klass);
+PFS_mutex *sanitize_mutex(PFS_mutex *unsafe);
+PFS_rwlock *sanitize_rwlock(PFS_rwlock *unsafe);
+PFS_cond *sanitize_cond(PFS_cond *unsafe);
+PFS_thread *sanitize_thread(PFS_thread *unsafe);
+PFS_file *sanitize_file(PFS_file *unsafe);
 
 int init_instruments(const PFS_global_param *param);
 void cleanup_instruments();
@@ -319,7 +323,6 @@ extern ulong file_handle_lost;
 extern ulong table_max;
 extern ulong table_lost;
 extern ulong events_waits_history_per_thread;
-extern ulong instr_class_per_thread;
 extern ulong locker_lost;
 
 /* Exposing the data directly, for iterators. */
@@ -336,6 +339,16 @@ void reset_events_waits_by_instance();
 void reset_per_thread_wait_stat();
 void reset_file_instance_io();
 
+void reset_global_wait_stat(void);
+
+void aggregate_all_event_names(PFS_single_stat *from_array,
+                               PFS_single_stat *to_array);
+void aggregate_all_event_names(PFS_single_stat *from_array,
+                               PFS_single_stat *to_array_1,
+                               PFS_single_stat *to_array_2);
+
+void aggregate_thread(PFS_thread *thread);
+
 /** @} */
 #endif
 

=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/pfs_instr_class.cc	2010-09-24 21:04:59 +0000
@@ -26,6 +26,7 @@
 #include "pfs_instr.h"
 #include "pfs_global.h"
 #include "pfs_events_waits.h"
+#include "pfs_setup_object.h"
 #include "pfs_atomic.h"
 #include "mysql/psi/mysql_thread.h"
 #include "lf.h"
@@ -106,15 +107,7 @@ static PFS_thread_class *thread_class_ar
 */
 PFS_table_share *table_share_array= NULL;
 
-PFS_instr_class global_table_class=
-{
-  "wait/io/table/sql/handler", /* name */
-  25, /* name length */
-  0, /* flags */
-  true, /* enabled */
-  true, /* timed */
-  { &flag_events_waits_current, NULL, 0, 0, 0, 0} /* wait stat chain */
-};
+PFS_instr_class global_table_io_class;
 
 /**
   Hash index for instrumented table shares.
@@ -139,6 +132,31 @@ static volatile uint32 file_class_alloca
 
 static PFS_file_class *file_class_array= NULL;
 
+uint mutex_class_start= 0;
+uint rwlock_class_start= 0;
+uint cond_class_start= 0;
+uint file_class_start= 0;
+uint table_class_start= 0;
+uint max_instrument_class= 0;
+
+void init_event_name_sizing(const PFS_global_param *param)
+{
+  mutex_class_start= 0;
+  rwlock_class_start= mutex_class_start + param->m_mutex_class_sizing;
+  cond_class_start= rwlock_class_start + param->m_rwlock_class_sizing;
+  file_class_start= cond_class_start + param->m_cond_class_sizing;
+  table_class_start= file_class_start + param->m_file_class_sizing;
+  max_instrument_class= table_class_start + 1; /* global table io */
+
+  memcpy(global_table_io_class.m_name, "wait/io/table/sql/handler", 25);
+  global_table_io_class.m_name_length= 25;
+  global_table_io_class.m_flags= 0;
+  global_table_io_class.m_enabled= true;
+  global_table_io_class.m_timed= true;
+  global_table_io_class.m_event_name_index= table_class_start;
+}
+
+
 /**
   Initialize the instrument synch class buffers.
   @param mutex_class_sizing           max number of mutex class
@@ -325,7 +343,7 @@ LF_PINS* get_table_share_hash_pins(PFS_t
 
 /**
   Set a table share hash key.
-  @param [out] key The key to polulate.
+  @param [out] key The key to populate.
   @param temporary True for TEMPORARY TABLE.
   @param schema_name The table schema name.
   @param schema_name_length The table schema name length.
@@ -339,19 +357,29 @@ static void set_table_share_key(PFS_tabl
 {
   DBUG_ASSERT(schema_name_length <= NAME_LEN);
   DBUG_ASSERT(table_name_length <= NAME_LEN);
+  char *saved_schema_name;
+  char *saved_table_name;
 
   char *ptr= &key->m_hash_key[0];
   ptr[0]= (temporary ? OBJECT_TYPE_TEMPORARY_TABLE : OBJECT_TYPE_TABLE);
   ptr++;
+  saved_schema_name= ptr;
   memcpy(ptr, schema_name, schema_name_length);
   ptr+= schema_name_length;
   ptr[0]= 0;
   ptr++;
+  saved_table_name= ptr;
   memcpy(ptr, table_name, table_name_length);
   ptr+= table_name_length;
   ptr[0]= 0;
   ptr++;
   key->m_key_length= ptr - &key->m_hash_key[0];
+
+  if (lower_case_table_names)
+  {
+    my_casedn_str(files_charset_info, saved_schema_name);
+    my_casedn_str(files_charset_info, saved_table_name);
+  }
 }
 
 /**
@@ -464,15 +492,10 @@ PFS_sync_key register_mutex_class(const
     */
     entry= &mutex_class_array[index];
     init_instr_class(entry, name, name_length, flags);
-    entry->m_wait_stat.m_control_flag=
-      &flag_events_waits_summary_by_event_name;
-    entry->m_wait_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_wait_stat);
-    entry->m_lock_stat.m_control_flag=
-      &flag_events_locks_summary_by_event_name;
-    entry->m_lock_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_lock_stat);
+    entry->m_lock_stat.reset();
     entry->m_index= index;
+    entry->m_event_name_index= mutex_class_start + index;
+    entry->m_singleton= NULL;
     /*
       Now that this entry is populated, advertise it
 
@@ -530,19 +553,11 @@ PFS_sync_key register_rwlock_class(const
   {
     entry= &rwlock_class_array[index];
     init_instr_class(entry, name, name_length, flags);
-    entry->m_wait_stat.m_control_flag=
-      &flag_events_waits_summary_by_event_name;
-    entry->m_wait_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_wait_stat);
-    entry->m_read_lock_stat.m_control_flag=
-      &flag_events_locks_summary_by_event_name;
-    entry->m_read_lock_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_read_lock_stat);
-    entry->m_write_lock_stat.m_control_flag=
-      &flag_events_locks_summary_by_event_name;
-    entry->m_write_lock_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_write_lock_stat);
+    entry->m_read_lock_stat.reset();
+    entry->m_write_lock_stat.reset();
     entry->m_index= index;
+    entry->m_event_name_index= rwlock_class_start + index;
+    entry->m_singleton= NULL;
     PFS_atomic::add_u32(&rwlock_class_allocated_count, 1);
     return (index + 1);
   }
@@ -574,11 +589,9 @@ PFS_sync_key register_cond_class(const c
   {
     entry= &cond_class_array[index];
     init_instr_class(entry, name, name_length, flags);
-    entry->m_wait_stat.m_control_flag=
-      &flag_events_waits_summary_by_event_name;
-    entry->m_wait_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_wait_stat);
     entry->m_index= index;
+    entry->m_event_name_index= cond_class_start + index;
+    entry->m_singleton= NULL;
     PFS_atomic::add_u32(&cond_class_allocated_count, 1);
     return (index + 1);
   }
@@ -721,11 +734,9 @@ PFS_file_key register_file_class(const c
   {
     entry= &file_class_array[index];
     init_instr_class(entry, name, name_length, flags);
-    entry->m_wait_stat.m_control_flag=
-      &flag_events_waits_summary_by_event_name;
-    entry->m_wait_stat.m_parent= NULL;
-    reset_single_stat_link(&entry->m_wait_stat);
     entry->m_index= index;
+    entry->m_event_name_index= file_class_start + index;
+    entry->m_singleton= NULL;
     PFS_atomic::add_u32(&file_class_allocated_count, 1);
     return (index + 1);
   }
@@ -749,6 +760,63 @@ PFS_file_class *sanitize_file_class(PFS_
   SANITIZE_ARRAY_BODY(file_class_array, file_class_max, unsafe);
 }
 
+PFS_instr_class *find_table_class(uint index)
+{
+  if (index == 1)
+    return & global_table_io_class;
+  return NULL;
+}
+
+PFS_instr_class *sanitize_table_class(PFS_instr_class *unsafe)
+{
+  if (likely(& global_table_io_class == unsafe))
+    return unsafe;
+  return NULL;
+}
+
+static void set_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
+{
+  int len;
+  KEY *key_info= share->key_info;
+  PFS_table_key *pfs_key= pfs->m_keys;
+  PFS_table_key *pfs_key_last= pfs->m_keys + share->keys;
+  pfs->m_key_count= share->keys;
+
+  for ( ; pfs_key < pfs_key_last; pfs_key++, key_info++)
+  {
+    len= strlen(key_info->name);
+    memcpy(pfs_key->m_name, key_info->name, len);
+    pfs_key->m_name_length= len;
+  }
+
+  pfs_key_last= pfs->m_keys + MAX_KEY;
+  for ( ; pfs_key < pfs_key_last; pfs_key++)
+    pfs_key->m_name_length= 0;
+}
+
+static int compare_keys(PFS_table_share *pfs, const TABLE_SHARE *share)
+{
+  uint len;
+  KEY *key_info= share->key_info;
+  PFS_table_key *pfs_key= pfs->m_keys;
+  PFS_table_key *pfs_key_last= pfs->m_keys + share->keys;
+
+  if (pfs->m_key_count != share->keys)
+    return 1;
+
+  for ( ; pfs_key < pfs_key_last; pfs_key++, key_info++)
+  {
+    len= strlen(key_info->name);
+    if (len != pfs_key->m_name_length)
+      return 1;
+
+    if (memcmp(pfs_key->m_name, key_info->name, len) != 0)
+      return 1;
+  }
+
+  return 0;
+}
+
 /**
   Find or create a table share instrumentation.
   @param thread                       the executing instrumented thread
@@ -761,7 +829,6 @@ PFS_table_share* find_or_create_table_sh
                                             const TABLE_SHARE *share)
 {
   /* See comments in register_mutex_class */
-  int pass;
   PFS_table_share_key key;
 
   LF_PINS *pins= get_table_share_hash_pins(thread);
@@ -782,6 +849,7 @@ PFS_table_share* find_or_create_table_sh
 
   PFS_table_share **entry;
   uint retry_count= 0;
+  uint version= 0;
   const uint retry_max= 3;
   bool enabled= true;
   bool timed= true;
@@ -795,15 +863,24 @@ search:
     PFS_table_share *pfs;
     pfs= *entry;
     pfs->m_refcount++ ;
+    if (compare_keys(pfs, share) != 0)
+    {
+      set_keys(pfs, share);
+      /* FIXME: aggregate to table_share sink ? */
+      pfs->m_table_stat.reset();
+    }
     lf_hash_search_unpin(pins);
     return pfs;
   }
 
   if (retry_count == 0)
   {
-    /* No per object lokup yet */
-    enabled= global_table_class.m_enabled;
-    timed= global_table_class.m_timed;
+    version= setup_objects_version;
+    lookup_setup_object(thread,
+                        OBJECT_TYPE_TABLE,
+                        schema_name, schema_name_length,
+                        table_name, table_name_length,
+                        &enabled, &timed);
 
     /*
       Even when enabled is false, a record is added in the dictionary:
@@ -813,35 +890,32 @@ search:
     */
   }
 
-  /* table_name is not constant, just using it for noise on create */
-  uint i= randomized_index(table_name, table_share_max);
+  PFS_scan scan;
+  uint random= randomized_index(table_name, table_share_max);
 
-  /*
-    Pass 1: [random, table_share_max - 1]
-    Pass 2: [0, table_share_max - 1]
-  */
-  for (pass= 1; pass <= 2; i=0, pass++)
+  for (scan.init(random, table_share_max);
+       scan.has_pass();
+       scan.next_pass())
   {
-    PFS_table_share *pfs= table_share_array + i;
-    PFS_table_share *pfs_last= table_share_array + table_share_max;
+    PFS_table_share *pfs= table_share_array + scan.first();
+    PFS_table_share *pfs_last= table_share_array + scan.last();
     for ( ; pfs < pfs_last; pfs++)
     {
       if (pfs->m_lock.is_free())
       {
         if (pfs->m_lock.free_to_dirty())
         {
+          pfs->m_setup_objects_version= version;
           pfs->m_key= key;
           pfs->m_schema_name= &pfs->m_key.m_hash_key[1];
           pfs->m_schema_name_length= schema_name_length;
           pfs->m_table_name= &pfs->m_key.m_hash_key[schema_name_length + 2];
           pfs->m_table_name_length= table_name_length;
-          pfs->m_wait_stat.m_control_flag=
-            &flag_events_waits_summary_by_instance;
-          pfs->m_wait_stat.m_parent= NULL;
-          reset_single_stat_link(&pfs->m_wait_stat);
           pfs->m_enabled= enabled;
           pfs->m_timed= timed;
           pfs->m_refcount= 1;
+          pfs->m_table_stat.reset();
+          set_keys(pfs, share);
 
           int res;
           res= lf_hash_insert(&table_share_hash, pins, &pfs);
@@ -877,6 +951,12 @@ search:
   return NULL;
 }
 
+void release_table_share(PFS_table_share *pfs)
+{
+  DBUG_ASSERT(pfs->m_refcount > 0);
+  pfs->m_refcount--;
+}
+
 /**
   Purge an instrumented table share from the performance schema buffers.
   The table share is removed from the hash index, and freed.
@@ -939,51 +1019,6 @@ PFS_table_share *sanitize_table_share(PF
   SANITIZE_ARRAY_BODY(table_share_array, table_share_max, unsafe);
 }
 
-static void reset_mutex_class_waits(void)
-{
-  PFS_mutex_class *pfs= mutex_class_array;
-  PFS_mutex_class *pfs_last= mutex_class_array + mutex_class_max;
-
-  for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
-}
-
-static void reset_rwlock_class_waits(void)
-{
-  PFS_rwlock_class *pfs= rwlock_class_array;
-  PFS_rwlock_class *pfs_last= rwlock_class_array + rwlock_class_max;
-
-  for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
-}
-
-static void reset_cond_class_waits(void)
-{
-  PFS_cond_class *pfs= cond_class_array;
-  PFS_cond_class *pfs_last= cond_class_array + cond_class_max;
-
-  for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
-}
-
-static void reset_file_class_waits(void)
-{
-  PFS_file_class *pfs= file_class_array;
-  PFS_file_class *pfs_last= file_class_array + file_class_max;
-
-  for ( ; pfs < pfs_last; pfs++)
-    reset_single_stat_link(&pfs->m_wait_stat);
-}
-
-/** Reset the wait statistics for every instrument class. */
-void reset_instrument_class_waits(void)
-{
-  reset_mutex_class_waits();
-  reset_rwlock_class_waits();
-  reset_cond_class_waits();
-  reset_file_class_waits();
-}
-
 /** Reset the io statistics per file class. */
 void reset_file_class_io(void)
 {
@@ -991,7 +1026,7 @@ void reset_file_class_io(void)
   PFS_file_class *pfs_last= file_class_array + file_class_max;
 
   for ( ; pfs < pfs_last; pfs++)
-    reset_file_stat(&pfs->m_file_stat);
+    pfs->m_file_stat.m_io_stat.reset();
 }
 
 /** @} */

=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/pfs_instr_class.h	2010-09-24 18:21:22 +0000
@@ -44,6 +44,8 @@
 #include "pfs_stat.h"
 #include "pfs_column_types.h"
 
+struct PFS_global_param;
+
 /**
   @addtogroup Performance_schema_buffers
   @{
@@ -60,6 +62,13 @@ typedef unsigned int PFS_file_key;
 
 struct PFS_thread;
 
+extern uint mutex_class_start;
+extern uint rwlock_class_start;
+extern uint cond_class_start;
+extern uint file_class_start;
+extern uint table_class_start;
+extern uint max_instrument_class;
+
 /** Information for all instrumentation. */
 struct PFS_instr_class
 {
@@ -73,39 +82,58 @@ struct PFS_instr_class
   bool m_enabled;
   /** True if this instrument is timed. */
   bool m_timed;
-  /** Wait statistics chain. */
-  PFS_single_stat_chain m_wait_stat;
+  /**
+    Instrument name index.
+    Self index in:
+    - EVENTS_WAITS_SUMMARY_*_BY_EVENT_NAME
+  */
+  uint m_event_name_index;
+
+  bool is_singleton() const
+  {
+    return m_flags & PSI_FLAG_GLOBAL;
+  }
 };
 
+struct PFS_mutex;
+
 /** Instrumentation metadata for a MUTEX. */
 struct PFS_mutex_class : public PFS_instr_class
 {
   /**
-    Lock statistics chain.
+    Lock statistics.
     This statistic is not exposed in user visible tables yet.
   */
-  PFS_single_stat_chain m_lock_stat;
+  PFS_single_stat m_lock_stat;
   /** Self index in @c mutex_class_array. */
   uint m_index;
+  /** Singleton instance. */
+  PFS_mutex *m_singleton;
 };
 
+struct PFS_rwlock;
+
 /** Instrumentation metadata for a RWLOCK. */
 struct PFS_rwlock_class : public PFS_instr_class
 {
   /**
-    Read lock statistics chain.
+    Read lock statistics.
     This statistic is not exposed in user visible tables yet.
   */
-  PFS_single_stat_chain m_read_lock_stat;
+  PFS_single_stat m_read_lock_stat;
   /**
-    Write lock statistics chain.
+    Write lock statistics.
     This statistic is not exposed in user visible tables yet.
   */
-  PFS_single_stat_chain m_write_lock_stat;
+  PFS_single_stat m_write_lock_stat;
   /** Self index in @c rwlock_class_array. */
   uint m_index;
+  /** Singleton instance. */
+  PFS_rwlock *m_singleton;
 };
 
+struct PFS_cond;
+
 /** Instrumentation metadata for a COND. */
 struct PFS_cond_class : public PFS_instr_class
 {
@@ -116,6 +144,8 @@ struct PFS_cond_class : public PFS_instr
   PFS_cond_stat m_cond_stat;
   /** Self index in @c cond_class_array. */
   uint m_index;
+  /** Singleton instance. */
+  PFS_cond *m_singleton;
 };
 
 /** Instrumentation metadata of a thread. */
@@ -127,6 +157,8 @@ struct PFS_thread_class
   uint m_name_length;
   /** True if this thread instrument is enabled. */
   bool m_enabled;
+  /** Singleton instance. */
+  PFS_thread *m_singleton;
 };
 
 /** Key identifying a table share. */
@@ -143,6 +175,15 @@ struct PFS_table_share_key
   uint m_key_length;
 };
 
+/** Table index or 'key' */
+struct PFS_table_key
+{
+  /** Index name */
+  char m_name[NAME_LEN];
+  /** Length in bytes of @c m_name. */
+  uint m_name_length;
+};
+
 /** Instrumentation metadata for a table share. */
 struct PFS_table_share
 {
@@ -151,6 +192,8 @@ struct PFS_table_share
     return (enum_object_type) m_key.m_hash_key[0];
   }
 
+  /** Setup object refresh version. */
+  uint m_setup_objects_version;
   /** Internal lock. */
   pfs_lock m_lock;
   /** Search key. */
@@ -163,8 +206,6 @@ struct PFS_table_share
   const char *m_table_name;
   /** Length in bytes of @c m_table_name. */
   uint m_table_name_length;
-  /** Wait statistics chain. */
-  PFS_single_stat_chain m_wait_stat;
   /** True if this table instrument is enabled. */
   bool m_enabled;
   /** True if this table instrument is timed. */
@@ -172,14 +213,21 @@ struct PFS_table_share
   bool m_purge;
   /** Number of opened table handles. */
   uint m_refcount;
+  /** Table io statistics. */
+  PFS_table_stat m_table_stat;
+  /** Number of indexes. */
+  uint m_key_count;
+  /** Index names. */
+  PFS_table_key m_keys[MAX_KEY];
 };
 
 /**
-  Instrument controlling all tables.
-  This instrument is used as a default when there is no
-  entry present in SETUP_OBJECTS.
+  Instrument controlling all table io.
+  This instrument is used with table SETUP_OBJECTS.
 */
-extern PFS_instr_class global_table_class;
+extern PFS_instr_class global_table_io_class;
+
+struct PFS_file;
 
 /** Instrumentation metadata for a file. */
 struct PFS_file_class : public PFS_instr_class
@@ -188,8 +236,12 @@ struct PFS_file_class : public PFS_instr
   PFS_file_stat m_file_stat;
   /** Self index in @c file_class_array. */
   uint m_index;
+  /** Singleton instance. */
+  PFS_file *m_singleton;
 };
 
+void init_event_name_sizing(const PFS_global_param *param);
+
 int init_sync_class(uint mutex_class_sizing,
                     uint rwlock_class_sizing,
                     uint cond_class_sizing);
@@ -229,10 +281,13 @@ PFS_thread_class *find_thread_class(PSI_
 PFS_thread_class *sanitize_thread_class(PFS_thread_class *unsafe);
 PFS_file_class *find_file_class(PSI_file_key key);
 PFS_file_class *sanitize_file_class(PFS_file_class *unsafe);
+PFS_instr_class *find_table_class(uint index);
+PFS_instr_class *sanitize_table_class(PFS_instr_class *unsafe);
 
 PFS_table_share *find_or_create_table_share(PFS_thread *thread,
                                             bool temporary,
                                             const TABLE_SHARE *share);
+void release_table_share(PFS_table_share *pfs);
 void purge_table_share(PFS_thread *thread, PFS_table_share *pfs);
 void drop_table_share(PFS_thread *thread,
                       bool temporary,
@@ -255,7 +310,6 @@ extern ulong table_share_max;
 extern ulong table_share_lost;
 extern PFS_table_share *table_share_array;
 
-void reset_instrument_class_waits();
 void reset_file_class_io();
 
 /** @} */

=== modified file 'storage/perfschema/pfs_server.cc'
--- a/storage/perfschema/pfs_server.cc	2010-07-23 19:03:52 +0000
+++ b/storage/perfschema/pfs_server.cc	2010-09-23 16:08:54 +0000
@@ -29,6 +29,7 @@
 #include "pfs_events_waits.h"
 #include "pfs_timer.h"
 #include "pfs_setup_actor.h"
+#include "pfs_setup_object.h"
 #include "pfs_defaults.h"
 
 PFS_global_param pfs_param;
@@ -55,6 +56,7 @@ initialize_performance_schema(const PFS_
 
   init_timers();
   PFS_atomic::init();
+  init_event_name_sizing(param);
 
   if (pthread_key_create(&THR_PFS, destroy_pfs_thread))
     return NULL;
@@ -73,7 +75,9 @@ initialize_performance_schema(const PFS_
       init_file_hash() ||
       init_table_share_hash() ||
       init_setup_actor(param) ||
-      init_setup_actor_hash())
+      init_setup_actor_hash() ||
+      init_setup_object(param) ||
+      init_setup_object_hash())
   {
     /*
       The performance schema initialization failed.
@@ -119,6 +123,8 @@ static void cleanup_performance_schema(v
   cleanup_file_hash();
   cleanup_setup_actor();
   cleanup_setup_actor_hash();
+  cleanup_setup_object();
+  cleanup_setup_object_hash();
   PFS_atomic::cleanup();
 }
 

=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h	2010-09-01 22:59:33 +0000
+++ b/storage/perfschema/pfs_server.h	2010-09-23 16:08:54 +0000
@@ -69,6 +69,9 @@
 #ifndef PFS_MAX_SETUP_ACTOR
   #define PFS_MAX_SETUP_ACTOR 100
 #endif
+#ifndef PFS_MAX_SETUP_OBJECT
+  #define PFS_MAX_SETUP_OBJECT 100
+#endif
 
 /** Performance schema global sizing parameters. */
 struct PFS_global_param
@@ -98,6 +101,8 @@ struct PFS_global_param
   ulong m_events_waits_history_sizing;
   ulong m_events_waits_history_long_sizing;
   ulong m_setup_actor_sizing;
+  /** Maximum number of setup object records. */
+  ulong m_setup_object_sizing;
 };
 
 extern PFS_global_param pfs_param;

=== added file 'storage/perfschema/pfs_setup_object.cc'
--- a/storage/perfschema/pfs_setup_object.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_setup_object.cc	2010-09-24 21:04:59 +0000
@@ -0,0 +1,337 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/**
+  @file storage/perfschema/pfs_setup_object.cc
+  Performance schema setup object (implementation).
+*/
+
+#include "my_global.h"
+#include "my_sys.h"
+#include "my_base.h"
+#include "sql_string.h"
+#include "pfs.h"
+#include "pfs_stat.h"
+#include "pfs_instr.h"
+#include "pfs_setup_object.h"
+#include "pfs_global.h"
+
+/**
+  @addtogroup Performance_schema_buffers
+  @{
+*/
+
+uint setup_objects_version= 0;
+
+ulong setup_object_max;
+
+PFS_setup_object *setup_object_array= NULL;
+
+static LF_HASH setup_object_hash;
+static bool setup_object_hash_inited= false;
+
+/**
+  Initialize the setup object buffers.
+  @param param                        sizing parameters
+  @return 0 on success
+*/
+int init_setup_object(const PFS_global_param *param)
+{
+  setup_object_max= param->m_setup_object_sizing;
+
+  setup_object_array= NULL;
+
+  if (setup_object_max > 0)
+  {
+    setup_object_array= PFS_MALLOC_ARRAY(setup_object_max, PFS_setup_object,
+                                         MYF(MY_ZEROFILL));
+    if (unlikely(setup_object_array == NULL))
+      return 1;
+  }
+
+  return 0;
+}
+
+/** Cleanup all the setup object buffers. */
+void cleanup_setup_object(void)
+{
+  pfs_free(setup_object_array);
+  setup_object_array= NULL;
+  setup_object_max= 0;
+}
+
+static uchar *setup_object_hash_get_key(const uchar *entry, size_t *length,
+                                        my_bool)
+{
+  const PFS_setup_object * const *typed_entry;
+  const PFS_setup_object *setup_object;
+  const void *result;
+  typed_entry= reinterpret_cast<const PFS_setup_object* const *> (entry);
+  DBUG_ASSERT(typed_entry != NULL);
+  setup_object= *typed_entry;
+  DBUG_ASSERT(setup_object != NULL);
+  *length= setup_object->m_key.m_key_length;
+  result= setup_object->m_key.m_hash_key;
+  return const_cast<uchar*> (reinterpret_cast<const uchar*> (result));
+}
+
+/**
+  Initialize the setup objects hash.
+  @return 0 on success
+*/
+int init_setup_object_hash(void)
+{
+  if (! setup_object_hash_inited)
+  {
+    lf_hash_init(&setup_object_hash, sizeof(PFS_setup_object*), LF_HASH_UNIQUE,
+                 0, 0, setup_object_hash_get_key, &my_charset_bin);
+    setup_object_hash_inited= true;
+  }
+  return 0;
+}
+
+/** Cleanup the setup objects hash. */
+void cleanup_setup_object_hash(void)
+{
+  if (setup_object_hash_inited)
+  {
+    lf_hash_destroy(&setup_object_hash);
+    setup_object_hash_inited= false;
+  }
+}
+
+static LF_PINS* get_setup_object_hash_pins(PFS_thread *thread)
+{
+  if (! setup_object_hash_inited)
+    return NULL;
+  if (unlikely(thread->m_setup_object_hash_pins == NULL))
+    thread->m_setup_object_hash_pins= lf_hash_get_pins(&setup_object_hash);
+  return thread->m_setup_object_hash_pins;
+}
+
+static void set_setup_object_key(PFS_setup_object_key *key,
+                                 enum_object_type object_type,
+                                 const char *schema, uint schema_length,
+                                 const char *object, uint object_length)
+{
+  DBUG_ASSERT(schema_length <= NAME_LEN);
+  DBUG_ASSERT(object_length <= NAME_LEN);
+
+  char *ptr= &key->m_hash_key[0];
+  ptr[0]= (char) object_type;
+  ptr++;
+  memcpy(ptr, schema, schema_length);
+  ptr+= schema_length;
+  ptr[0]= 0;
+  ptr++;
+  memcpy(ptr, object, object_length);
+  ptr+= object_length;
+  ptr[0]= 0;
+  ptr++;
+  key->m_key_length= ptr - &key->m_hash_key[0];
+}
+
+int insert_setup_object(enum_object_type object_type, const String *schema,
+                        const String *object, bool enabled, bool timed)
+{
+  if (setup_object_max == 0)
+    return HA_ERR_RECORD_FILE_FULL;
+
+  PFS_thread *thread= PFS_thread::get_current_thread();
+  if (unlikely(thread == NULL))
+    return HA_ERR_OUT_OF_MEM;
+
+  LF_PINS* pins= get_setup_object_hash_pins(thread);
+  if (unlikely(pins == NULL))
+    return HA_ERR_OUT_OF_MEM;
+
+  PFS_scan scan;
+  uint random= randomized_index(object, setup_object_max);
+
+  for (scan.init(random, setup_object_max);
+       scan.has_pass();
+       scan.next_pass())
+  {
+    PFS_setup_object *pfs= setup_object_array + scan.first();
+    PFS_setup_object *pfs_last= setup_object_array + scan.last();
+
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if (pfs->m_lock.is_free())
+      {
+        if (pfs->m_lock.free_to_dirty())
+        {
+          set_setup_object_key(&pfs->m_key, object_type,
+                               schema->ptr(), schema->length(),
+                               object->ptr(), object->length());
+          pfs->m_schema_name= &pfs->m_key.m_hash_key[1];
+          pfs->m_schema_name_length= schema->length();
+          pfs->m_object_name= pfs->m_schema_name + pfs->m_schema_name_length + 1;
+          pfs->m_object_name_length= object->length();
+          pfs->m_enabled= enabled;
+          pfs->m_timed= timed;
+
+          int res;
+          res= lf_hash_insert(&setup_object_hash, pins, &pfs);
+          if (likely(res == 0))
+          {
+            pfs->m_lock.dirty_to_allocated();
+            setup_objects_version++;
+            return 0;
+          }
+
+          pfs->m_lock.dirty_to_free();
+          if (res > 0)
+            return HA_ERR_FOUND_DUPP_KEY;
+          /* OOM in lf_hash_insert */
+          return HA_ERR_OUT_OF_MEM;
+        }
+      }
+    }
+  }
+
+  return HA_ERR_RECORD_FILE_FULL;
+}
+
+int delete_setup_object(enum_object_type object_type, const String *schema,
+                        const String *object)
+{
+  PFS_thread *thread= PFS_thread::get_current_thread();
+  if (unlikely(thread == NULL))
+    return HA_ERR_OUT_OF_MEM;
+
+  LF_PINS* pins= get_setup_object_hash_pins(thread);
+  if (unlikely(pins == NULL))
+    return HA_ERR_OUT_OF_MEM;
+
+  PFS_setup_object_key key;
+  set_setup_object_key(&key, object_type,
+                       schema->ptr(), schema->length(),
+                       object->ptr(), object->length());
+
+  PFS_setup_object **entry;
+  entry= reinterpret_cast<PFS_setup_object**>
+    (lf_hash_search(&setup_object_hash, pins, key.m_hash_key, key.m_key_length));
+
+  if (entry && (entry != MY_ERRPTR))
+  {
+    PFS_setup_object *pfs= *entry;
+    lf_hash_delete(&setup_object_hash, pins, key.m_hash_key, key.m_key_length);
+    pfs->m_lock.allocated_to_free();
+  }
+
+  setup_objects_version++;
+  return 0;
+}
+
+int reset_setup_object()
+{
+  PFS_thread *thread= PFS_thread::get_current_thread();
+  if (unlikely(thread == NULL))
+    return HA_ERR_OUT_OF_MEM;
+
+  LF_PINS* pins= get_setup_object_hash_pins(thread);
+  if (unlikely(pins == NULL))
+    return HA_ERR_OUT_OF_MEM;
+
+  PFS_setup_object *pfs= setup_object_array;
+  PFS_setup_object *pfs_last= setup_object_array + setup_object_max;
+
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if (pfs->m_enabled && pfs->m_lock.is_populated())
+    {
+      lf_hash_delete(&setup_object_hash, pins,
+                     pfs->m_key.m_hash_key, pfs->m_key.m_key_length);
+      pfs->m_lock.allocated_to_free();
+    }
+  }
+
+  setup_objects_version++;
+  return 0;
+}
+
+long setup_object_count()
+{
+  return setup_object_hash.count;
+}
+
+void lookup_setup_object(PFS_thread *thread,
+                         enum_object_type object_type,
+                         const char *schema_name, int schema_name_length,
+                         const char *object_name, int object_name_length,
+                         bool *enabled, bool *timed)
+{
+  PFS_setup_object_key key;
+  PFS_setup_object **entry;
+  PFS_setup_object *pfs;
+  int i;
+
+  /*
+    The table io instrumentation uses "TABLE" and "TEMPORARY TABLE".
+    SETUP_OBJECT uses "TABLE" for both concepts.
+    There is no way to provide a different setup for:
+    - TABLE foo.bar
+    - TEMPORARY TABLE foo.bar
+  */
+  DBUG_ASSERT(object_type != OBJECT_TYPE_TEMPORARY_TABLE);
+
+  LF_PINS* pins= get_setup_object_hash_pins(thread);
+  if (unlikely(pins == NULL))
+  {
+    *enabled= false;
+    *timed= false;
+    return;
+  }
+
+  for (i= 1; i<=3; i++)
+  {
+    switch(i)
+    {
+    case 1:
+      /* Lookup OBJECT_TYPE + OBJECT_SCHEMA + OBJECT_NAME in SETUP_OBJECTS */
+      set_setup_object_key(&key,
+                           object_type,
+                           schema_name, schema_name_length,
+                           object_name, object_name_length);
+      break;
+    case 2:
+      /* Lookup OBJECT_TYPE + OBJECT_SCHEMA + "%" in SETUP_OBJECTS */
+      set_setup_object_key(&key,
+                           object_type,
+                           schema_name, schema_name_length, "%", 1);
+      break;
+    case 3:
+      /* Lookup OBJECT_TYPE + "%" + "%" in SETUP_OBJECTS */
+      set_setup_object_key(&key, object_type, "%", 1, "%", 1);
+      break;
+    }
+    entry= reinterpret_cast<PFS_setup_object**>
+      (lf_hash_search(&setup_object_hash, pins, key.m_hash_key, key.m_key_length));
+
+    if (entry && (entry != MY_ERRPTR))
+    {
+      pfs= *entry;
+      *enabled= pfs->m_enabled;
+      *timed= pfs->m_timed;
+      return;
+    }
+  }
+  *enabled= false;
+  *timed= false;
+  return;
+}
+
+/** @} */

=== added file 'storage/perfschema/pfs_setup_object.h'
--- a/storage/perfschema/pfs_setup_object.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_setup_object.h	2010-09-23 16:08:54 +0000
@@ -0,0 +1,101 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef PFS_SETUP_OBJECT_H
+#define PFS_SETUP_OBJECT_H
+
+/**
+  @file storage/perfschema/pfs_setup_object.h
+  Performance schema setup object (declarations).
+*/
+
+#include "pfs_lock.h"
+#include "lf.h"
+
+class String;
+struct PFS_global_param;
+
+/**
+  @addtogroup Performance_schema_buffers
+  @{
+*/
+
+struct PFS_setup_object_key
+{
+  /**
+    Hash search key.
+    This has to be a string for LF_HASH,
+    the format is "<enum_object_type><schema_name><0x00><object_name><0x00>"
+  */
+  char m_hash_key[1 + NAME_LEN + 1 + NAME_LEN + 1];
+  uint m_key_length;
+};
+
+struct PFS_setup_object
+{
+  enum_object_type get_object_type()
+  {
+    return (enum_object_type) m_key.m_hash_key[0];
+  }
+
+  /** Internal lock. */
+  pfs_lock m_lock;
+  /** Hash key. */
+  PFS_setup_object_key m_key;
+  /** Schema name. Points inside m_key. */
+  const char *m_schema_name;
+  /** Length of @c m_schema_name. */
+  uint m_schema_name_length;
+  /** Object name. Points inside m_key. */
+  const char *m_object_name;
+  /** Length of @c m_object_name. */
+  uint m_object_name_length;
+  /** ENABLED flag. */
+  bool m_enabled;
+  /** TIMED flag. */
+  bool m_timed;
+};
+
+extern uint setup_objects_version;
+
+int init_setup_object(const PFS_global_param *param);
+void cleanup_setup_object(void);
+int init_setup_object_hash(void);
+void cleanup_setup_object_hash(void);
+
+int insert_setup_object(enum_object_type object_type, const String *schema,
+                        const String *object, bool enabled, bool timed);
+int delete_setup_object(enum_object_type object_type, const String *schema,
+                        const String *object);
+int reset_setup_object(void);
+long setup_object_count(void);
+
+void lookup_setup_object(PFS_thread *thread,
+                         enum_object_type object_type,
+                         const char *schema_name, int schema_name_length,
+                         const char *object_name, int object_name_length,
+                         bool *enabled, bool *timed);
+
+/* For iterators and show status. */
+
+extern ulong setup_object_max;
+
+/* Exposing the data directly, for iterators. */
+
+extern PFS_setup_object *setup_object_array;
+
+/** @} */
+#endif
+

=== modified file 'storage/perfschema/pfs_stat.h'
--- a/storage/perfschema/pfs_stat.h	2010-08-26 16:44:02 +0000
+++ b/storage/perfschema/pfs_stat.h	2010-09-23 16:08:54 +0000
@@ -16,6 +16,8 @@
 #ifndef PFS_STAT_H
 #define PFS_STAT_H
 
+#include "sql_const.h"
+
 /**
   @file storage/perfschema/pfs_stat.h
   Statistics (declarations).
@@ -26,16 +28,9 @@
   @{
 */
 
-/** Usage statistics chain, for a single value and its aggregates. */
-struct PFS_single_stat_chain
+/** Single statistic. */
+struct PFS_single_stat
 {
-  /**
-    Control flag.
-    Statistics are aggregated only if the control flag is true.
-  */
-  bool *m_control_flag;
-  /** Next link in the statistics chain. */
-  struct PFS_single_stat_chain *m_parent;
   /** Count of values. */
   ulonglong m_count;
   /** Sum of values. */
@@ -44,60 +39,48 @@ struct PFS_single_stat_chain
   ulonglong m_min;
   /** Maximum value. */
   ulonglong m_max;
-};
 
-/**
-  Reset a single statistic link.
-  Only the current link is reset, parents are not affected.
-  @param stat                         the statistics link to reset
-*/
-inline void reset_single_stat_link(PFS_single_stat_chain *stat)
-{
-  stat->m_count= 0;
-  stat->m_sum= 0;
-  stat->m_min= ULONGLONG_MAX;
-  stat->m_max= 0;
-}
+  PFS_single_stat()
+  {
+    m_count= 0;
+    m_sum= 0;
+    m_min= ULONGLONG_MAX;
+    m_max= 0;
+  }
 
-/**
-  Aggregate a value to a statistic chain.
-  @param stat                         the aggregated statistic chain
-  @param value                        the value to aggregate
-*/
-inline void aggregate_single_stat_chain(PFS_single_stat_chain *stat,
-                                        ulonglong value)
-{
-  do
+  inline void reset(void)
   {
-    if (*stat->m_control_flag)
-    {
-      stat->m_count++;
-      stat->m_sum+= value;
-      if (stat->m_min > value)
-        stat->m_min= value;
-      if (stat->m_max < value)
-        stat->m_max= value;
-    }
-    stat= stat->m_parent;
+    m_count= 0;
+    m_sum= 0;
+    m_min= ULONGLONG_MAX;
+    m_max= 0;
   }
-  while (stat);
-}
 
-/**
-  Increment the value counts in a statistic chain.
-  Used for instruments that are 'ENABLED' but not 'TIMED'.
-  @param stat                         the aggregated statistic chain
-*/
-inline void increment_single_stat_chain(PFS_single_stat_chain *stat)
-{
-  do
+  inline void aggregate(const PFS_single_stat *stat)
   {
-    if (*stat->m_control_flag)
-      stat->m_count++;
-    stat= stat->m_parent;
+    m_count+= stat->m_count;
+    m_sum+= stat->m_sum;
+    if (unlikely(m_min > stat->m_min))
+      m_min= stat->m_min;
+    if (unlikely(m_max < stat->m_max))
+      m_max= stat->m_max;
   }
-  while (stat);
-}
+
+  inline void aggregate_counted()
+  {
+    m_count++;
+  }
+
+  inline void aggregate_timed(ulonglong value)
+  {
+    m_count++;
+    m_sum+= value;
+    if (unlikely(m_min > value))
+      m_min= value;
+    if (unlikely(m_max < value))
+      m_max= value;
+  }
+};
 
 /** Statistics for COND usage. */
 struct PFS_cond_stat
@@ -108,11 +91,9 @@ struct PFS_cond_stat
   ulonglong m_broadcast_count;
 };
 
-/** Statistics for FILE usage. */
-struct PFS_file_stat
+/** Statistics for FILE IO usage. */
+struct PFS_file_io_stat
 {
-  /** Number of current open handles. */
-  ulong m_open_count;
   /** Count of READ operations. */
   ulonglong m_count_read;
   /** Count of WRITE operations. */
@@ -121,20 +102,125 @@ struct PFS_file_stat
   ulonglong m_read_bytes;
   /** Number of bytes written. */
   ulonglong m_write_bytes;
+
+  /** Reset file statistic. */
+  inline void reset(void)
+  {
+    m_count_read= 0;
+    m_count_write= 0;
+    m_read_bytes= 0;
+    m_write_bytes= 0;
+  }
+
+  inline void aggregate(const PFS_file_io_stat *stat)
+  {
+    m_count_read+= stat->m_count_read;
+    m_count_write+= stat->m_count_write;
+    m_read_bytes+= stat->m_read_bytes;
+    m_write_bytes+= stat->m_write_bytes;
+  }
+
+  inline void aggregate_read(ulonglong bytes)
+  {
+    m_count_read++;
+    m_read_bytes+= bytes;
+  }
+
+  inline void aggregate_write(ulonglong bytes)
+  {
+    m_count_write++;
+    m_write_bytes+= bytes;
+  }
 };
 
-/**
-  Reset file statistic.
-  @param stat                         the statistics to reset
-*/
-inline void reset_file_stat(PFS_file_stat *stat)
+/** Statistics for FILE usage. */
+struct PFS_file_stat
+{
+  /** Number of current open handles. */
+  ulong m_open_count;
+  /** File IO statistics. */
+  PFS_file_io_stat m_io_stat;
+};
+
+/** Single table io statistic. */
+struct PFS_table_io_stat
 {
-  stat->m_open_count= 0;
-  stat->m_count_read= 0;
-  stat->m_count_write= 0;
-  stat->m_read_bytes= 0;
-  stat->m_write_bytes= 0;
-}
+  /** FETCH statistics */
+  PFS_single_stat m_fetch;
+  /** INSERT statistics */
+  PFS_single_stat m_insert;
+  /** UPDATE statistics */
+  PFS_single_stat m_update;
+  /** DELETE statistics */
+  PFS_single_stat m_delete;
+
+  inline void reset(void)
+  {
+    m_fetch.reset();
+    m_insert.reset();
+    m_update.reset();
+    m_delete.reset();
+  }
+
+  inline void aggregate(const PFS_table_io_stat *stat)
+  {
+    m_fetch.aggregate(&stat->m_fetch);
+    m_insert.aggregate(&stat->m_insert);
+    m_update.aggregate(&stat->m_update);
+    m_delete.aggregate(&stat->m_delete);
+  }
+
+  inline void sum(PFS_single_stat *result)
+  {
+    result->aggregate(& m_fetch);
+    result->aggregate(& m_insert);
+    result->aggregate(& m_update);
+    result->aggregate(& m_delete);
+  }
+};
+
+/** Statistics for TABLE usage. */
+struct PFS_table_stat
+{
+  /**
+    Statistics, per index.
+    Each index stat is in [0, MAX_KEY-1],
+    stats when using no index are in [MAX_KEY].
+  */
+  PFS_table_io_stat m_index_stat[MAX_KEY + 1];
+
+  /** Reset table statistic. */
+  inline void reset(void)
+  {
+    PFS_table_io_stat *stat= & m_index_stat[0];
+    PFS_table_io_stat *stat_last= & m_index_stat[MAX_KEY + 1];
+    for ( ; stat < stat_last ; stat++)
+      stat->reset();
+  }
+
+  inline void aggregate(const PFS_table_stat *stat)
+  {
+    PFS_table_io_stat *to_stat= & m_index_stat[0];
+    PFS_table_io_stat *to_stat_last= & m_index_stat[MAX_KEY + 1];
+    const PFS_table_io_stat *from_stat= & stat->m_index_stat[0];
+    for ( ; to_stat < to_stat_last ; from_stat++, to_stat++)
+      to_stat->aggregate(from_stat);
+  }
+
+  inline void sum_io(PFS_single_stat *result)
+  {
+    PFS_table_io_stat *stat= & m_index_stat[0];
+    PFS_table_io_stat *stat_last= & m_index_stat[MAX_KEY + 1];
+    for ( ; stat < stat_last ; stat++)
+      stat->sum(result);
+  }
+
+  inline void sum(PFS_single_stat *result)
+  {
+    sum_io(result);
+    /* sum_lock(result); */
+  }
+};
 
 /** @} */
 #endif

=== modified file 'storage/perfschema/pfs_timer.cc'
--- a/storage/perfschema/pfs_timer.cc	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/pfs_timer.cc	2010-09-23 16:08:54 +0000
@@ -37,6 +37,17 @@ static ulong microsec_to_pico; /* In the
 static ulong millisec_to_pico; /* In theory, 1 000 000 000, fits in uint32 */
 static ulonglong tick_to_pico; /* 1e10 at 100 Hz, 1.666e10 at 60 Hz */
 
+/* Indexed by enum enum_timer_name */
+static struct time_normalizer to_pico_data[FIRST_TIMER_NAME + COUNT_TIMER_NAME]=
+{
+  { 0, 0}, /* unused */
+  { 0, 0}, /* cycle */
+  { 0, 0}, /* nanosec */
+  { 0, 0}, /* microsec */
+  { 0, 0}, /* millisec */
+  { 0, 0}  /* tick */
+};
+
 static inline ulong round_to_ulong(double value)
 {
   return (ulong) (value + 0.5);
@@ -88,13 +99,55 @@ void init_timers(void)
                                      (double)pfs_timer_info.ticks.frequency);
   else
     tick_to_pico= 0;
+
+  to_pico_data[TIMER_NAME_CYCLE].m_v0= cycle_v0;
+  to_pico_data[TIMER_NAME_CYCLE].m_factor= cycle_to_pico;
+
+  to_pico_data[TIMER_NAME_NANOSEC].m_v0= nanosec_v0;
+  to_pico_data[TIMER_NAME_NANOSEC].m_factor= nanosec_to_pico;
+
+  to_pico_data[TIMER_NAME_MICROSEC].m_v0= microsec_v0;
+  to_pico_data[TIMER_NAME_MICROSEC].m_factor= microsec_to_pico;
+
+  to_pico_data[TIMER_NAME_MILLISEC].m_v0= millisec_v0;
+  to_pico_data[TIMER_NAME_MILLISEC].m_factor= millisec_to_pico;
+
+  to_pico_data[TIMER_NAME_TICK].m_v0= tick_v0;
+  to_pico_data[TIMER_NAME_TICK].m_factor= tick_to_pico;
 }
 
-ulonglong get_timer_value(enum_timer_name timer_name)
+ulonglong get_timer_raw_value_and_function(enum_timer_name timer_name, timer_fct_t *fct)
+{
+  switch (timer_name)
+  {
+  case TIMER_NAME_CYCLE:
+    *fct= my_timer_cycles;
+    return my_timer_cycles();
+  case TIMER_NAME_NANOSEC:
+    *fct= my_timer_nanoseconds;
+    return my_timer_nanoseconds();
+  case TIMER_NAME_MICROSEC:
+    *fct= my_timer_microseconds;
+    return my_timer_microseconds();
+  case TIMER_NAME_MILLISEC:
+    *fct= my_timer_milliseconds;
+    return my_timer_milliseconds();
+  case TIMER_NAME_TICK:
+    *fct= my_timer_ticks;
+    return my_timer_ticks();
+  default:
+    *fct= NULL;
+    DBUG_ASSERT(false);
+  }
+  return 0;
+}
+
+ulonglong get_timer_pico_value(enum_timer_name timer_name)
 {
   ulonglong result;
 
-  switch (timer_name) {
+  switch (timer_name)
+  {
   case TIMER_NAME_CYCLE:
     result= (my_timer_cycles() - cycle_v0) * cycle_to_pico;
     break;
@@ -117,3 +170,38 @@ ulonglong get_timer_value(enum_timer_nam
   return result;
 }
 
+time_normalizer* time_normalizer::get(enum_timer_name timer_name)
+{
+  uint index= static_cast<uint> (timer_name);
+
+  DBUG_ASSERT(index >= FIRST_TIMER_NAME);
+  DBUG_ASSERT(index <= LAST_TIMER_NAME);
+
+  return & to_pico_data[index];
+}
+
+void time_normalizer::to_pico(ulonglong start, ulonglong end,
+                              ulonglong *pico_start, ulonglong *pico_end, ulonglong *pico_wait)
+{
+  if (start == 0)
+  {
+    *pico_start= 0;
+    *pico_end= 0;
+    *pico_wait= 0;
+  }
+  else
+  {
+    *pico_start= (start - m_v0) * m_factor;
+    if (end == 0)
+    {
+      *pico_end= 0;
+      *pico_wait= 0;
+    }
+    else
+    {
+      *pico_end= (end - m_v0) * m_factor;
+      *pico_wait= (end - start) * m_factor;
+    }
+  }
+}
+

=== modified file 'storage/perfschema/pfs_timer.h'
--- a/storage/perfschema/pfs_timer.h	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/pfs_timer.h	2010-09-23 16:08:54 +0000
@@ -23,12 +23,40 @@
 #include <my_rdtsc.h>
 #include "pfs_column_types.h"
 
+struct time_normalizer
+{
+  static time_normalizer* get(enum_timer_name timer_name);
+
+  ulonglong m_v0;
+  ulonglong m_factor;
+
+  inline ulonglong wait_to_pico(ulonglong wait)
+  {
+    return wait * m_factor;
+  }
+
+  inline ulonglong time_to_pico(ulonglong t)
+  {
+    return (t == 0 ? 0 : (t - m_v0) * m_factor);
+  }
+
+  void to_pico(ulonglong start, ulonglong end,
+               ulonglong *pico_start, ulonglong *pico_end, ulonglong *pico_wait);
+};
+
 extern enum_timer_name wait_timer;
 extern MY_TIMER_INFO pfs_timer_info;
 
 void init_timers();
 
-ulonglong get_timer_value(enum_timer_name timer_name);
+extern "C"
+{
+  typedef ulonglong (*timer_fct_t)(void);
+}
+
+ulonglong get_timer_pico_value(enum_timer_name timer_name);
+ulonglong get_timer_raw_value_and_function(enum_timer_name timer_name, timer_fct_t *fct);
+
 
 #endif
 

=== modified file 'storage/perfschema/table_all_instr.cc'
--- a/storage/perfschema/table_all_instr.cc	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/table_all_instr.cc	2010-09-23 16:08:54 +0000
@@ -151,115 +151,3 @@ int table_all_instr::rnd_pos(const void
   return HA_ERR_RECORD_DELETED;
 }
 
-table_all_instr_class::table_all_instr_class
-(const PFS_engine_table_share *share)
-  : PFS_engine_table(share, &m_pos),
-    m_pos(), m_next_pos()
-{}
-
-void table_all_instr_class::reset_position(void)
-{
-  m_pos.reset();
-  m_next_pos.reset();
-}
-
-int table_all_instr_class::rnd_next(void)
-{
-  PFS_mutex_class *mutex_class;
-  PFS_rwlock_class *rwlock_class;
-  PFS_cond_class *cond_class;
-  PFS_file_class *file_class;
-
-  for (m_pos.set_at(&m_next_pos);
-       m_pos.has_more_view();
-       m_pos.next_view())
-  {
-    switch (m_pos.m_index_1) {
-    case pos_all_instr_class::VIEW_MUTEX:
-      mutex_class= find_mutex_class(m_pos.m_index_2);
-      if (mutex_class)
-      {
-        make_instr_row(mutex_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
-      break;
-    case pos_all_instr_class::VIEW_RWLOCK:
-      rwlock_class= find_rwlock_class(m_pos.m_index_2);
-      if (rwlock_class)
-      {
-        make_instr_row(rwlock_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
-      break;
-    case pos_all_instr_class::VIEW_COND:
-      cond_class= find_cond_class(m_pos.m_index_2);
-      if (cond_class)
-      {
-        make_instr_row(cond_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
-      break;
-    case pos_all_instr_class::VIEW_FILE:
-      file_class= find_file_class(m_pos.m_index_2);
-      if (file_class)
-      {
-        make_instr_row(file_class);
-        m_next_pos.set_after(&m_pos);
-        return 0;
-      }
-      break;
-    }
-  }
-
-  return HA_ERR_END_OF_FILE;
-}
-
-int table_all_instr_class::rnd_pos(const void *pos)
-{
-  PFS_mutex_class *mutex_class;
-  PFS_rwlock_class *rwlock_class;
-  PFS_cond_class *cond_class;
-  PFS_file_class *file_class;
-
-  set_position(pos);
-  switch (m_pos.m_index_1) {
-  case pos_all_instr_class::VIEW_MUTEX:
-    mutex_class= find_mutex_class(m_pos.m_index_2);
-    if (mutex_class)
-    {
-      make_instr_row(mutex_class);
-      return 0;
-    }
-    break;
-  case pos_all_instr_class::VIEW_RWLOCK:
-    rwlock_class= find_rwlock_class(m_pos.m_index_2);
-    if (rwlock_class)
-    {
-      make_instr_row(rwlock_class);
-      return 0;
-    }
-    break;
-  case pos_all_instr_class::VIEW_COND:
-    cond_class= find_cond_class(m_pos.m_index_2);
-    if (cond_class)
-    {
-      make_instr_row(cond_class);
-      return 0;
-    }
-    break;
-  case pos_all_instr_class::VIEW_FILE:
-    file_class= find_file_class(m_pos.m_index_2);
-    if (file_class)
-    {
-      make_instr_row(file_class);
-      return 0;
-    }
-    break;
-  }
-
-  return HA_ERR_RECORD_DELETED;
-}
-

=== modified file 'storage/perfschema/table_all_instr.h'
--- a/storage/perfschema/table_all_instr.h	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/table_all_instr.h	2010-09-23 16:08:54 +0000
@@ -31,66 +31,6 @@
   @{
 */
 
-/** Position of a cursor on table_all_instr_class. */
-struct pos_all_instr_class : public PFS_double_index,
-                             public PFS_instrument_view_constants
-{
-  pos_all_instr_class()
-    : PFS_double_index(FIRST_VIEW, 1)
-  {}
-
-  inline void reset(void)
-  {
-    m_index_1= FIRST_VIEW;
-    m_index_2= 1;
-  }
-
-  inline bool has_more_view(void)
-  { return (m_index_1 <= LAST_VIEW); }
-
-  inline void next_view(void)
-  {
-    m_index_1++;
-    /* Instrument keys start at 1, not 0. */
-    m_index_2= 1;
-  }
-};
-
-/**
-  Abstract table, a union of all instrumentations class metadata.
-  This table is a union of:
-  - a view on all mutex classes,
-  - a view on all rwlock classes,
-  - a view on all cond classes,
-  - a view on all file classes
-*/
-class table_all_instr_class : public PFS_engine_table
-{
-public:
-  virtual int rnd_next();
-  virtual int rnd_pos(const void *pos);
-  virtual void reset_position(void);
-
-protected:
-  table_all_instr_class(const PFS_engine_table_share *share);
-
-public:
-  ~table_all_instr_class()
-  {}
-
-protected:
-  /**
-    Build a row.
-    @param klass                      the instrument class
-  */
-  virtual void make_instr_row(PFS_instr_class *klass)= 0;
-
-  /** Current position. */
-  pos_all_instr_class m_pos;
-  /** Next position. */
-  pos_all_instr_class m_next_pos;
-};
-
 /** Position of a cursor on table_all_instr. */
 struct pos_all_instr : public PFS_double_index,
                        public PFS_instrument_view_constants

=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc	2010-11-09 08:16:50 +0000
+++ b/storage/perfschema/table_events_waits.cc	2010-11-15 07:40:07 +0000
@@ -24,6 +24,7 @@
 #include "pfs_instr_class.h"
 #include "pfs_instr.h"
 #include "pfs_events_waits.h"
+#include "pfs_timer.h"
 
 THR_LOCK table_events_waits_current::m_table_lock;
 
@@ -224,14 +225,6 @@ void table_events_waits_common::make_row
     and sanitizes all the data before returning a row.
   */
 
-  m_row.m_thread_internal_id= safe_thread->m_thread_internal_id;
-  m_row.m_event_id= wait->m_event_id;
-  m_row.m_nesting_event_id= wait->m_nesting_event_id;
-  m_row.m_timer_state= wait->m_timer_state;
-  m_row.m_timer_start= wait->m_timer_start;
-  m_row.m_timer_end= wait->m_timer_end;
-  m_row.m_object_instance_addr= (intptr) wait->m_object_instance_addr;
-
   /*
     PFS_events_waits::m_class needs to be sanitized,
     for race conditions when this code:
@@ -273,7 +266,7 @@ void table_events_waits_common::make_row
                  (m_row.m_object_name_length > sizeof(m_row.m_object_name))))
       return;
     memcpy(m_row.m_object_name, wait->m_object_name, m_row.m_object_name_length);
-    safe_class= &global_table_class;
+    safe_class= sanitize_table_class(wait->m_class);
     break;
   case WAIT_CLASS_FILE:
     m_row.m_object_type= "FILE";
@@ -290,8 +283,22 @@ void table_events_waits_common::make_row
   default:
     return;
   }
+
   if (unlikely(safe_class == NULL))
     return;
+
+  m_row.m_thread_internal_id= safe_thread->m_thread_internal_id;
+  m_row.m_event_id= wait->m_event_id;
+#ifdef HAVE_NESTED_EVENTS
+  m_row.m_nesting_event_id= wait->m_nesting_event_id;
+#endif
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  normalizer->to_pico(wait->m_timer_start, wait->m_timer_end,
+                      & m_row.m_timer_start, & m_row.m_timer_end, & m_row.m_timer_wait);
+
+  m_row.m_object_instance_addr= (intptr) wait->m_object_instance_addr;
+
   m_row.m_name= safe_class->m_name;
   m_row.m_name_length= safe_class->m_name_length;
 
@@ -429,21 +436,20 @@ int table_events_waits_common::read_row_
         set_field_varchar_utf8(f, m_row.m_source, m_row.m_source_length);
         break;
       case 4: /* TIMER_START */
-        if ((m_row.m_timer_state == TIMER_STATE_STARTED) ||
-            (m_row.m_timer_state == TIMER_STATE_TIMED))
+        if (m_row.m_timer_start != 0)
           set_field_ulonglong(f, m_row.m_timer_start);
         else
           f->set_null();
         break;
       case 5: /* TIMER_END */
-        if (m_row.m_timer_state == TIMER_STATE_TIMED)
+        if (m_row.m_timer_end != 0)
           set_field_ulonglong(f, m_row.m_timer_end);
         else
           f->set_null();
         break;
       case 6: /* TIMER_WAIT */
-        if (m_row.m_timer_state == TIMER_STATE_TIMED)
-          set_field_ulonglong(f, m_row.m_timer_end - m_row.m_timer_start);
+        if (m_row.m_timer_wait != 0)
+          set_field_ulonglong(f, m_row.m_timer_wait);
         else
           f->set_null();
         break;
@@ -481,7 +487,11 @@ int table_events_waits_common::read_row_
         set_field_ulonglong(f, m_row.m_object_instance_addr);
         break;
       case 12: /* NESTING_EVENT_ID */
+#ifdef HAVE_NESTED_EVENTS
         set_field_ulonglong(f, m_row.m_nesting_event_id);
+#else
+        f->set_null();
+#endif
         break;
       case 13: /* OPERATION */
         operation= &operation_names_map[(int) m_row.m_operation - 1];
@@ -553,9 +563,9 @@ int table_events_waits_current::rnd_next
     if (m_pos.m_index_2 >= 1)
       continue;
 #else
-    uint safe_locker_count= pfs_thread->m_wait_locker_count;
+    uint safe_events_waits_count= pfs_thread->m_events_waits_count;
 
-    if (safe_locker_count == 0)
+    if (safe_events_waits_count == 0)
     {
       /* Display the last top level wait, when completed */
       if (m_pos.m_index_2 >= 1)
@@ -564,12 +574,12 @@ int table_events_waits_current::rnd_next
     else
     {
       /* Display all pending waits, when in progress */
-      if (m_pos.m_index_2 >= safe_locker_count)
+      if (m_pos.m_index_2 >= safe_events_waits_count)
         continue;
     }
 #endif
 
-    wait= &pfs_thread->m_wait_locker_stack[m_pos.m_index_2].m_waits_current;
+    wait= &pfs_thread->m_events_waits_stack[m_pos.m_index_2];
 
     if (wait->m_wait_class == NO_WAIT_CLASS)
     {
@@ -605,9 +615,9 @@ int table_events_waits_current::rnd_pos(
   if (m_pos.m_index_2 >= 1)
     return HA_ERR_RECORD_DELETED;
 #else
-  uint safe_locker_count= pfs_thread->m_wait_locker_count;
+  uint safe_events_waits_count= pfs_thread->m_events_waits_count;
 
-  if (safe_locker_count == 0)
+  if (safe_events_waits_count == 0)
   {
     /* Display the last top level wait, when completed */
     if (m_pos.m_index_2 >= 1)
@@ -616,14 +626,14 @@ int table_events_waits_current::rnd_pos(
   else
   {
     /* Display all pending waits, when in progress */
-    if (m_pos.m_index_2 >= safe_locker_count)
+    if (m_pos.m_index_2 >= safe_events_waits_count)
       return HA_ERR_RECORD_DELETED;
   }
 #endif
 
-  DBUG_ASSERT(m_pos.m_index_2 < LOCKER_STACK_SIZE);
+  DBUG_ASSERT(m_pos.m_index_2 < WAIT_STACK_SIZE);
 
-  wait= &pfs_thread->m_wait_locker_stack[m_pos.m_index_2].m_waits_current;
+  wait= &pfs_thread->m_events_waits_stack[m_pos.m_index_2];
 
   if (wait->m_wait_class == NO_WAIT_CLASS)
     return HA_ERR_RECORD_DELETED;

=== modified file 'storage/perfschema/table_events_waits.h'
--- a/storage/perfschema/table_events_waits.h	2010-09-28 15:17:29 +0000
+++ b/storage/perfschema/table_events_waits.h	2010-10-04 18:27:08 +0000
@@ -45,14 +45,12 @@ struct row_events_waits
   const char *m_name;
   /** Length in bytes of @c m_name. */
   uint m_name_length;
-  /** Timer state. */
-  enum timer_state m_timer_state;
   /** Column TIMER_START. */
   ulonglong m_timer_start;
-  /** True if TIMER_END is null. */
-  bool m_timer_end_null;
   /** Column TIMER_END. */
   ulonglong m_timer_end;
+  /** Column TIMER_WAIT. */
+  ulonglong m_timer_wait;
   /** Column OBJECT_TYPE. */
   const char *m_object_type;
   /** Length in bytes of @c m_object_type. */

=== modified file 'storage/perfschema/table_events_waits_summary.cc'
--- a/storage/perfschema/table_events_waits_summary.cc	2010-11-09 08:16:50 +0000
+++ b/storage/perfschema/table_events_waits_summary.cc	2010-11-15 07:40:07 +0000
@@ -26,319 +26,6 @@
 #include "table_events_waits_summary.h"
 #include "pfs_global.h"
 
-THR_LOCK table_events_waits_summary_by_thread_by_event_name::m_table_lock;
-
-static const TABLE_FIELD_TYPE ews_by_thread_by_event_name_field_types[]=
-{
-  {
-    { C_STRING_WITH_LEN("THREAD_ID") },
-    { C_STRING_WITH_LEN("int(11)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("EVENT_NAME") },
-    { C_STRING_WITH_LEN("varchar(128)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("COUNT_STAR") },
-    { C_STRING_WITH_LEN("bigint(20)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
-    { C_STRING_WITH_LEN("bigint(20)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
-    { C_STRING_WITH_LEN("bigint(20)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
-    { C_STRING_WITH_LEN("bigint(20)") },
-    { NULL, 0}
-  },
-  {
-    { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
-    { C_STRING_WITH_LEN("bigint(20)") },
-    { NULL, 0}
-  }
-};
-
-TABLE_FIELD_DEF
-table_events_waits_summary_by_thread_by_event_name::m_field_def=
-{ 7, ews_by_thread_by_event_name_field_types };
-
-PFS_engine_table_share
-table_events_waits_summary_by_thread_by_event_name::m_share=
-{
-  { C_STRING_WITH_LEN("events_waits_summary_by_thread_by_event_name") },
-  &pfs_truncatable_acl,
-  &table_events_waits_summary_by_thread_by_event_name::create,
-  NULL, /* write_row */
-  &table_events_waits_summary_by_thread_by_event_name::delete_all_rows,
-  NULL, /* get_row_count */
-  1000, /* records */
-  sizeof(pos_events_waits_summary_by_thread_by_event_name),
-  &m_table_lock,
-  &m_field_def,
-  false /* checked */
-};
-
-PFS_engine_table*
-table_events_waits_summary_by_thread_by_event_name::create(void)
-{
-  return new table_events_waits_summary_by_thread_by_event_name();
-}
-
-int
-table_events_waits_summary_by_thread_by_event_name::delete_all_rows(void)
-{
-  reset_per_thread_wait_stat();
-  return 0;
-}
-
-table_events_waits_summary_by_thread_by_event_name
-::table_events_waits_summary_by_thread_by_event_name()
-  : PFS_engine_table(&m_share, &m_pos),
-    m_row_exists(false), m_pos(), m_next_pos()
-{}
-
-void table_events_waits_summary_by_thread_by_event_name::reset_position(void)
-{
-  m_pos.reset();
-  m_next_pos.reset();
-}
-
-int table_events_waits_summary_by_thread_by_event_name::rnd_next(void)
-{
-  PFS_thread *thread;
-  PFS_mutex_class *mutex_class;
-  PFS_rwlock_class *rwlock_class;
-  PFS_cond_class *cond_class;
-  PFS_file_class *file_class;
-
-  for (m_pos.set_at(&m_next_pos);
-       m_pos.has_more_thread();
-       m_pos.next_thread())
-  {
-    thread= &thread_array[m_pos.m_index_1];
-    if (thread->m_lock.is_populated())
-    {
-      for ( ; m_pos.has_more_view(); m_pos.next_view())
-      {
-        switch (m_pos.m_index_2) {
-        case pos_events_waits_summary_by_thread_by_event_name::VIEW_MUTEX:
-          mutex_class= find_mutex_class(m_pos.m_index_3);
-          if (mutex_class)
-          {
-            make_mutex_row(thread, mutex_class);
-            m_next_pos.set_after(&m_pos);
-            return 0;
-          }
-          break;
-        case pos_events_waits_summary_by_thread_by_event_name::VIEW_RWLOCK:
-          rwlock_class= find_rwlock_class(m_pos.m_index_3);
-          if (rwlock_class)
-          {
-            make_rwlock_row(thread, rwlock_class);
-            m_next_pos.set_after(&m_pos);
-            return 0;
-          }
-          break;
-        case pos_events_waits_summary_by_thread_by_event_name::VIEW_COND:
-          cond_class= find_cond_class(m_pos.m_index_3);
-          if (cond_class)
-          {
-            make_cond_row(thread, cond_class);
-            m_next_pos.set_after(&m_pos);
-            return 0;
-          }
-          break;
-        case pos_events_waits_summary_by_thread_by_event_name::VIEW_FILE:
-          file_class= find_file_class(m_pos.m_index_3);
-          if (file_class)
-          {
-            make_file_row(thread, file_class);
-            m_next_pos.set_after(&m_pos);
-            return 0;
-          }
-          break;
-        }
-      }
-    }
-  }
-
-  return HA_ERR_END_OF_FILE;
-}
-
-int
-table_events_waits_summary_by_thread_by_event_name::rnd_pos(const void *pos)
-{
-  PFS_thread *thread;
-  PFS_mutex_class *mutex_class;
-  PFS_rwlock_class *rwlock_class;
-  PFS_cond_class *cond_class;
-  PFS_file_class *file_class;
-
-  set_position(pos);
-  DBUG_ASSERT(m_pos.m_index_1 < thread_max);
-
-  thread= &thread_array[m_pos.m_index_1];
-  if (! thread->m_lock.is_populated())
-    return HA_ERR_RECORD_DELETED;
-
-  switch (m_pos.m_index_2) {
-  case pos_events_waits_summary_by_thread_by_event_name::VIEW_MUTEX:
-    mutex_class= find_mutex_class(m_pos.m_index_3);
-    if (mutex_class)
-    {
-      make_mutex_row(thread, mutex_class);
-      return 0;
-    }
-    break;
-  case pos_events_waits_summary_by_thread_by_event_name::VIEW_RWLOCK:
-    rwlock_class= find_rwlock_class(m_pos.m_index_3);
-    if (rwlock_class)
-    {
-      make_rwlock_row(thread, rwlock_class);
-      return 0;
-    }
-    break;
-  case pos_events_waits_summary_by_thread_by_event_name::VIEW_COND:
-    cond_class= find_cond_class(m_pos.m_index_3);
-    if (cond_class)
-    {
-      make_cond_row(thread, cond_class);
-      return 0;
-    }
-    break;
-  case pos_events_waits_summary_by_thread_by_event_name::VIEW_FILE:
-    file_class= find_file_class(m_pos.m_index_3);
-    if (file_class)
-    {
-      make_file_row(thread, file_class);
-      return 0;
-    }
-    break;
-  }
-  return HA_ERR_RECORD_DELETED;
-}
-
-void table_events_waits_summary_by_thread_by_event_name
-::make_instr_row(PFS_thread *thread, PFS_instr_class *klass,
-                 PFS_single_stat_chain *stat)
-{
-  pfs_lock lock;
-
-  m_row_exists= false;
-
-  /* Protect this reader against a thread termination */
-  thread->m_lock.begin_optimistic_lock(&lock);
-
-  m_row.m_thread_internal_id= thread->m_thread_internal_id;
-  m_row.m_name= klass->m_name;
-  m_row.m_name_length= klass->m_name_length;
-
-  m_row.m_count= stat->m_count;
-  m_row.m_sum= stat->m_sum;
-  m_row.m_min= stat->m_min;
-  m_row.m_max= stat->m_max;
-
-  if (m_row.m_count)
-    m_row.m_avg= m_row.m_sum / m_row.m_count;
-  else
-  {
-    m_row.m_min= 0;
-    m_row.m_avg= 0;
-  }
-
-  if (thread->m_lock.end_optimistic_lock(&lock))
-    m_row_exists= true;
-}
-
-void table_events_waits_summary_by_thread_by_event_name
-::make_mutex_row(PFS_thread *thread, PFS_mutex_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  stat= find_per_thread_mutex_class_wait_stat(thread, klass);
-  make_instr_row(thread, klass, stat);
-}
-
-void table_events_waits_summary_by_thread_by_event_name
-::make_rwlock_row(PFS_thread *thread, PFS_rwlock_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  stat= find_per_thread_rwlock_class_wait_stat(thread, klass);
-  make_instr_row(thread, klass, stat);
-}
-
-void table_events_waits_summary_by_thread_by_event_name
-::make_cond_row(PFS_thread *thread, PFS_cond_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  stat= find_per_thread_cond_class_wait_stat(thread, klass);
-  make_instr_row(thread, klass, stat);
-}
-
-void table_events_waits_summary_by_thread_by_event_name
-::make_file_row(PFS_thread *thread, PFS_file_class *klass)
-{
-  PFS_single_stat_chain *stat;
-  stat= find_per_thread_file_class_wait_stat(thread, klass);
-  make_instr_row(thread, klass, stat);
-}
-
-int table_events_waits_summary_by_thread_by_event_name
-::read_row_values(TABLE *table, unsigned char *, Field **fields,
-                  bool read_all)
-{
-  Field *f;
-
-  if (unlikely(! m_row_exists))
-    return HA_ERR_RECORD_DELETED;
-
-  /* Set the null bits */
-  DBUG_ASSERT(table->s->null_bytes == 0);
-
-  for (; (f= *fields) ; fields++)
-  {
-    if (read_all || bitmap_is_set(table->read_set, f->field_index))
-    {
-      switch(f->field_index)
-      {
-      case 0: /* THREAD_ID */
-        set_field_ulong(f, m_row.m_thread_internal_id);
-        break;
-      case 1: /* NAME */
-        set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length);
-        break;
-      case 2: /* COUNT */
-        set_field_ulonglong(f, m_row.m_count);
-        break;
-      case 3: /* SUM */
-        set_field_ulonglong(f, m_row.m_sum);
-        break;
-      case 4: /* MIN */
-        set_field_ulonglong(f, m_row.m_min);
-        break;
-      case 5: /* AVG */
-        set_field_ulonglong(f, m_row.m_avg);
-        break;
-      case 6: /* MAX */
-        set_field_ulonglong(f, m_row.m_max);
-        break;
-      default:
-        DBUG_ASSERT(false);
-      }
-    }
-  }
-
-  return 0;
-}
-
 THR_LOCK table_events_waits_summary_by_instance::m_table_lock;
 
 static const TABLE_FIELD_TYPE ews_by_instance_field_types[]=
@@ -434,18 +121,8 @@ void table_events_waits_summary_by_insta
   m_row.m_name_length= klass->m_name_length;
   m_row.m_object_instance_addr= (intptr) object_instance_begin;
 
-  m_row.m_count= pfs->m_wait_stat.m_count;
-  m_row.m_sum= pfs->m_wait_stat.m_sum;
-  m_row.m_min= pfs->m_wait_stat.m_min;
-  m_row.m_max= pfs->m_wait_stat.m_max;
-
-  if (m_row.m_count)
-    m_row.m_avg= m_row.m_sum / m_row.m_count;
-  else
-  {
-    m_row.m_min= 0;
-    m_row.m_avg= 0;
-  }
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, & pfs->m_wait_stat);
 
   if (pfs->m_lock.end_optimistic_lock(&lock))
     m_row_exists= true;
@@ -536,19 +213,19 @@ int table_events_waits_summary_by_instan
         set_field_ulonglong(f, m_row.m_object_instance_addr);
         break;
       case 2: /* COUNT */
-        set_field_ulonglong(f, m_row.m_count);
+        set_field_ulonglong(f, m_row.m_stat.m_count);
         break;
       case 3: /* SUM */
-        set_field_ulonglong(f, m_row.m_sum);
+        set_field_ulonglong(f, m_row.m_stat.m_sum);
         break;
       case 4: /* MIN */
-        set_field_ulonglong(f, m_row.m_min);
+        set_field_ulonglong(f, m_row.m_stat.m_min);
         break;
       case 5: /* AVG */
-        set_field_ulonglong(f, m_row.m_avg);
+        set_field_ulonglong(f, m_row.m_stat.m_avg);
         break;
       case 6: /* MAX */
-        set_field_ulonglong(f, m_row.m_max);
+        set_field_ulonglong(f, m_row.m_stat.m_max);
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_events_waits_summary.h'
--- a/storage/perfschema/table_events_waits_summary.h	2010-09-01 22:59:33 +0000
+++ b/storage/perfschema/table_events_waits_summary.h	2010-09-23 16:08:54 +0000
@@ -33,118 +33,6 @@
   @{
 */
 
-/**
-  A row of table
-  PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
-*/
-struct row_events_waits_summary_by_thread_by_event_name
-{
-  /** Column THREAD_ID. */
-  ulong m_thread_internal_id;
-  /** Column EVENT_NAME. */
-  const char *m_name;
-  /** Length in bytes of @c m_name. */
-  uint m_name_length;
-  /** Column COUNT_STAR. */
-  ulonglong m_count;
-  /** Column SUM_TIMER_WAIT. */
-  ulonglong m_sum;
-  /** Column MIN_TIMER_WAIT. */
-  ulonglong m_min;
-  /** Column AVG_TIMER_WAIT. */
-  ulonglong m_avg;
-  /** Column MAX_TIMER_WAIT. */
-  ulonglong m_max;
-};
-
-/**
-  Position of a cursor on
-  PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
-*/
-struct pos_events_waits_summary_by_thread_by_event_name
-: public PFS_triple_index, public PFS_instrument_view_constants
-{
-  pos_events_waits_summary_by_thread_by_event_name()
-    : PFS_triple_index(0, FIRST_VIEW, 1)
-  {}
-
-  inline void reset(void)
-  {
-    m_index_1= 0;
-    m_index_2= FIRST_VIEW;
-    m_index_3= 1;
-  }
-
-  inline bool has_more_thread(void)
-  { return (m_index_1 < thread_max); }
-
-  inline bool has_more_view(void)
-  { return (m_index_2 <= LAST_VIEW); }
-
-  inline void next_thread(void)
-  {
-    m_index_1++;
-    m_index_2= FIRST_VIEW;
-    m_index_3= 1;
-  }
-
-  inline void next_view(void)
-  {
-    m_index_2++;
-    m_index_3= 1;
-  }
-};
-
-/** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */
-class table_events_waits_summary_by_thread_by_event_name
-  : public PFS_engine_table
-{
-public:
-  /** Table share */
-  static PFS_engine_table_share m_share;
-  static PFS_engine_table* create();
-  static int delete_all_rows();
-
-  virtual int rnd_next();
-  virtual int rnd_pos(const void *pos);
-  virtual void reset_position(void);
-
-protected:
-  virtual int read_row_values(TABLE *table,
-                              unsigned char *buf,
-                              Field **fields,
-                              bool read_all);
-
-  table_events_waits_summary_by_thread_by_event_name();
-
-public:
-  ~table_events_waits_summary_by_thread_by_event_name()
-  {}
-
-protected:
-  void make_instr_row(PFS_thread *thread, PFS_instr_class *klass,
-                      PFS_single_stat_chain *stat);
-  void make_mutex_row(PFS_thread *thread, PFS_mutex_class *klass);
-  void make_rwlock_row(PFS_thread *thread, PFS_rwlock_class *klass);
-  void make_cond_row(PFS_thread *thread, PFS_cond_class *klass);
-  void make_file_row(PFS_thread *thread, PFS_file_class *klass);
-
-private:
-  /** Table share lock. */
-  static THR_LOCK m_table_lock;
-  /** Fields definition. */
-  static TABLE_FIELD_DEF m_field_def;
-
-  /** Current row. */
-  row_events_waits_summary_by_thread_by_event_name m_row;
-  /** True if the current row exists. */
-  bool m_row_exists;
-  /** Current position. */
-  pos_events_waits_summary_by_thread_by_event_name m_pos;
-  /** Next position. */
-  pos_events_waits_summary_by_thread_by_event_name m_next_pos;
-};
-
 /** A row of PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_INSTANCE. */
 struct row_events_waits_summary_by_instance
 {
@@ -154,16 +42,8 @@ struct row_events_waits_summary_by_insta
   uint m_name_length;
   /** Column OBJECT_INSTANCE_BEGIN. */
   intptr m_object_instance_addr;
-  /** Column COUNT_STAR. */
-  ulonglong m_count;
-  /** Column SUM_TIMER_WAIT. */
-  ulonglong m_sum;
-  /** Column MIN_TIMER_WAIT. */
-  ulonglong m_min;
-  /** Column AVG_TIMER_WAIT. */
-  ulonglong m_avg;
-  /** Column MAX_TIMER_WAIT. */
-  ulonglong m_max;
+  /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
+  PFS_stat_row m_stat;
 };
 
 /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_INSTANCE. */

=== added file 'storage/perfschema/table_ews_by_thread_by_event_name.cc'
--- a/storage/perfschema/table_ews_by_thread_by_event_name.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_ews_by_thread_by_event_name.cc	2010-11-15 09:58:20 +0000
@@ -0,0 +1,374 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/**
+  @file storage/perfschema/table_ews_by_thread_by_event_name.cc
+  Table EVENTS_WAITS_SUMMARY_BY_HOST_BY_EVENT_NAME (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr_class.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "table_ews_by_thread_by_event_name.h"
+#include "pfs_global.h"
+
+THR_LOCK table_ews_by_thread_by_event_name::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("THREAD_ID") },
+    { C_STRING_WITH_LEN("int(11)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("EVENT_NAME") },
+    { C_STRING_WITH_LEN("varchar(128)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_STAR") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_ews_by_thread_by_event_name::m_field_def=
+{ 7, field_types };
+
+PFS_engine_table_share
+table_ews_by_thread_by_event_name::m_share=
+{
+  { C_STRING_WITH_LEN("events_waits_summary_by_thread_by_event_name") },
+  &pfs_truncatable_acl,
+  table_ews_by_thread_by_event_name::create,
+  NULL, /* write_row */
+  table_ews_by_thread_by_event_name::delete_all_rows,
+  NULL, /* get_row_count */
+  1000, /* records */
+  sizeof(pos_ews_by_thread_by_event_name),
+  &m_table_lock,
+  &m_field_def,
+  false /* checked */
+};
+
+PFS_engine_table*
+table_ews_by_thread_by_event_name::create(void)
+{
+  return new table_ews_by_thread_by_event_name();
+}
+
+int
+table_ews_by_thread_by_event_name::delete_all_rows(void)
+{
+  reset_per_thread_wait_stat();
+  return 0;
+}
+
+table_ews_by_thread_by_event_name::table_ews_by_thread_by_event_name()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(), m_next_pos()
+{}
+
+void table_ews_by_thread_by_event_name::reset_position(void)
+{
+  m_pos.reset();
+  m_next_pos.reset();
+}
+
+int table_ews_by_thread_by_event_name::rnd_next(void)
+{
+  PFS_thread *thread;
+  PFS_mutex_class *mutex_class;
+  PFS_rwlock_class *rwlock_class;
+  PFS_cond_class *cond_class;
+  PFS_file_class *file_class;
+  PFS_instr_class *table_class;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.has_more_view();
+       m_pos.next_view())
+  {
+    switch (m_pos.m_index_1)
+    {
+    case pos_ews_by_thread_by_event_name::VIEW_MUTEX:
+      do
+      {
+        mutex_class= find_mutex_class(m_pos.m_index_2);
+        if (mutex_class)
+        {
+          for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+          {
+            thread= &thread_array[m_pos.m_index_3];
+            if (thread->m_lock.is_populated())
+            {
+              make_row(thread, mutex_class);
+              m_next_pos.set_after(&m_pos);
+              return 0;
+            }
+          }
+          m_pos.next_instrument();
+        }
+      } while (mutex_class != NULL);
+      break;
+    case pos_ews_by_thread_by_event_name::VIEW_RWLOCK:
+      do
+      {
+        rwlock_class= find_rwlock_class(m_pos.m_index_2);
+        if (rwlock_class)
+        {
+          for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+          {
+            thread= &thread_array[m_pos.m_index_3];
+            if (thread->m_lock.is_populated())
+            {
+              make_row(thread, rwlock_class);
+              m_next_pos.set_after(&m_pos);
+              return 0;
+            }
+          }
+          m_pos.next_instrument();
+        }
+      } while (rwlock_class != NULL);
+      break;
+    case pos_ews_by_thread_by_event_name::VIEW_COND:
+      do
+      {
+        cond_class= find_cond_class(m_pos.m_index_2);
+        if (cond_class)
+        {
+          for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+          {
+            thread= &thread_array[m_pos.m_index_3];
+            if (thread->m_lock.is_populated())
+            {
+              make_row(thread, cond_class);
+              m_next_pos.set_after(&m_pos);
+              return 0;
+            }
+          }
+          m_pos.next_instrument();
+        }
+      } while (cond_class != NULL);
+      break;
+    case pos_ews_by_thread_by_event_name::VIEW_FILE:
+      do
+      {
+        file_class= find_file_class(m_pos.m_index_2);
+        if (file_class)
+        {
+          for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+          {
+            thread= &thread_array[m_pos.m_index_3];
+            if (thread->m_lock.is_populated())
+            {
+              make_row(thread, file_class);
+              m_next_pos.set_after(&m_pos);
+              return 0;
+            }
+          }
+          m_pos.next_instrument();
+        }
+      } while (file_class != NULL);
+      break;
+    case pos_ews_by_thread_by_event_name::VIEW_TABLE:
+      do
+      {
+        table_class= find_table_class(m_pos.m_index_2);
+        if (table_class)
+        {
+          for ( ; m_pos.has_more_thread(); m_pos.next_thread())
+          {
+            thread= &thread_array[m_pos.m_index_3];
+            if (thread->m_lock.is_populated())
+            {
+              make_row(thread, table_class);
+              m_next_pos.set_after(&m_pos);
+              return 0;
+            }
+          }
+          m_pos.next_instrument();
+        }
+      } while (table_class != NULL);
+      break;
+    default:
+      break;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_ews_by_thread_by_event_name::rnd_pos(const void *pos)
+{
+  PFS_thread *thread;
+  PFS_mutex_class *mutex_class;
+  PFS_rwlock_class *rwlock_class;
+  PFS_cond_class *cond_class;
+  PFS_file_class *file_class;
+  PFS_instr_class *table_class;
+
+  set_position(pos);
+  DBUG_ASSERT(m_pos.m_index_3 < thread_max);
+
+  thread= &thread_array[m_pos.m_index_3];
+  if (! thread->m_lock.is_populated())
+    return HA_ERR_RECORD_DELETED;
+
+  switch (m_pos.m_index_1)
+  {
+  case pos_ews_by_thread_by_event_name::VIEW_MUTEX:
+    mutex_class= find_mutex_class(m_pos.m_index_2);
+    if (mutex_class)
+    {
+      make_row(thread, mutex_class);
+      return 0;
+    }
+    break;
+  case pos_ews_by_thread_by_event_name::VIEW_RWLOCK:
+    rwlock_class= find_rwlock_class(m_pos.m_index_2);
+    if (rwlock_class)
+    {
+      make_row(thread, rwlock_class);
+      return 0;
+    }
+    break;
+  case pos_ews_by_thread_by_event_name::VIEW_COND:
+    cond_class= find_cond_class(m_pos.m_index_2);
+    if (cond_class)
+    {
+      make_row(thread, cond_class);
+      return 0;
+    }
+    break;
+  case pos_ews_by_thread_by_event_name::VIEW_FILE:
+    file_class= find_file_class(m_pos.m_index_2);
+    if (file_class)
+    {
+      make_row(thread, file_class);
+      return 0;
+    }
+    break;
+  case pos_ews_by_thread_by_event_name::VIEW_TABLE:
+    table_class= find_table_class(m_pos.m_index_2);
+    if (table_class)
+    {
+      make_row(thread, table_class);
+      return 0;
+    }
+    break;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+void table_ews_by_thread_by_event_name
+::make_row(PFS_thread *thread, PFS_instr_class *klass)
+{
+  pfs_lock lock;
+  PFS_single_stat *event_name_array;
+  PFS_single_stat *stat;
+  uint index= klass->m_event_name_index;
+  event_name_array= thread->m_instr_class_wait_stats;
+
+  m_row_exists= false;
+
+  /* Protect this reader against a thread termination */
+  thread->m_lock.begin_optimistic_lock(&lock);
+
+  m_row.m_thread_internal_id= thread->m_thread_internal_id;
+  m_row.m_name= klass->m_name;
+  m_row.m_name_length= klass->m_name_length;
+
+  stat= & event_name_array[index];
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, stat);
+
+  if (thread->m_lock.end_optimistic_lock(&lock))
+    m_row_exists= true;
+}
+
+int table_ews_by_thread_by_event_name
+::read_row_values(TABLE *table, unsigned char *, Field **fields,
+                  bool read_all)
+{
+  Field *f;
+
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 0);
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (read_all || bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* THREAD_ID */
+        set_field_ulong(f, m_row.m_thread_internal_id);
+        break;
+      case 1: /* NAME */
+        set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length);
+        break;
+      case 2: /* COUNT */
+        set_field_ulonglong(f, m_row.m_stat.m_count);
+        break;
+      case 3: /* SUM */
+        set_field_ulonglong(f, m_row.m_stat.m_sum);
+        break;
+      case 4: /* MIN */
+        set_field_ulonglong(f, m_row.m_stat.m_min);
+        break;
+      case 5: /* AVG */
+        set_field_ulonglong(f, m_row.m_stat.m_avg);
+        break;
+      case 6: /* MAX */
+        set_field_ulonglong(f, m_row.m_stat.m_max);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_ews_by_thread_by_event_name.h'
--- a/storage/perfschema/table_ews_by_thread_by_event_name.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_ews_by_thread_by_event_name.h	2010-09-23 16:08:54 +0000
@@ -0,0 +1,142 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H
+#define TABLE_EWS_BY_THREAD_BY_EVENT_NAME_H
+
+/**
+  @file storage/perfschema/table_ews_by_thread_by_event_name.h
+  Table EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "pfs_engine_table.h"
+#include "pfs_instr_class.h"
+#include "pfs_instr.h"
+#include "table_helper.h"
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
+*/
+struct row_ews_by_thread_by_event_name
+{
+  /** Column THREAD_ID. */
+  ulong m_thread_internal_id;
+  /** Column EVENT_NAME. */
+  const char *m_name;
+  /** Length in bytes of @c m_name. */
+  uint m_name_length;
+  /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
+  PFS_stat_row m_stat;
+};
+
+/**
+  Position of a cursor on
+  PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.
+  Index 1 on instrument view
+  Index 2 on instrument class (1 based)
+  Index 3 on thread (0 based)
+*/
+struct pos_ews_by_thread_by_event_name
+: public PFS_triple_index, public PFS_instrument_view_constants
+{
+  pos_ews_by_thread_by_event_name()
+    : PFS_triple_index(FIRST_VIEW, 1, 0)
+  {}
+
+  inline void reset(void)
+  {
+    m_index_1= FIRST_VIEW;
+    m_index_2= 1;
+    m_index_3= 0;
+  }
+
+  inline bool has_more_view(void)
+  { return (m_index_1 <= LAST_VIEW); }
+
+  inline bool has_more_thread(void)
+  { return (m_index_3 < thread_max); }
+
+  inline void next_view(void)
+  {
+    m_index_1++;
+    m_index_2= 1;
+    m_index_3= 0;
+  }
+
+  inline void next_instrument(void)
+  {
+    m_index_2++;
+    m_index_3= 0;
+  }
+
+  inline void next_thread(void)
+  {
+    m_index_3++;
+  }
+};
+
+/** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME. */
+class table_ews_by_thread_by_event_name : public PFS_engine_table
+{
+public:
+  /** Table share */
+  static PFS_engine_table_share m_share;
+  static PFS_engine_table* create();
+  static int delete_all_rows();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
+
+protected:
+  virtual int read_row_values(TABLE *table,
+                              unsigned char *buf,
+                              Field **fields,
+                              bool read_all);
+
+  table_ews_by_thread_by_event_name();
+
+public:
+  ~table_ews_by_thread_by_event_name()
+  {}
+
+protected:
+  void make_row(PFS_thread *thread, PFS_instr_class *klass);
+
+private:
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_ews_by_thread_by_event_name m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  pos_ews_by_thread_by_event_name m_pos;
+  /** Next position. */
+  pos_ews_by_thread_by_event_name m_next_pos;
+};
+
+/** @} */
+#endif

=== modified file 'storage/perfschema/table_ews_global_by_event_name.cc'
--- a/storage/perfschema/table_ews_global_by_event_name.cc	2010-11-09 08:16:50 +0000
+++ b/storage/perfschema/table_ews_global_by_event_name.cc	2010-11-15 07:40:07 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -10,8 +10,8 @@
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software Foundation,
-  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 /**
   @file storage/perfschema/table_ews_global_by_event_name.cc
@@ -25,6 +25,8 @@
 #include "pfs_column_values.h"
 #include "table_ews_global_by_event_name.h"
 #include "pfs_global.h"
+#include "pfs_instr.h"
+#include "pfs_timer.h"
 
 THR_LOCK table_ews_global_by_event_name::m_table_lock;
 
@@ -71,51 +73,390 @@ table_ews_global_by_event_name::m_share=
 {
   { C_STRING_WITH_LEN("events_waits_summary_global_by_event_name") },
   &pfs_truncatable_acl,
-  &table_ews_global_by_event_name::create,
+  table_ews_global_by_event_name::create,
   NULL, /* write_row */
-  &table_ews_global_by_event_name::delete_all_rows,
+  table_ews_global_by_event_name::delete_all_rows,
   NULL, /* get_row_count */
   1000, /* records */
-  sizeof(pos_all_instr_class),
+  sizeof(pos_ews_global_by_event_name),
   &m_table_lock,
   &m_field_def,
   false /* checked */
 };
 
-PFS_engine_table* table_ews_global_by_event_name::create(void)
+PFS_engine_table*
+table_ews_global_by_event_name::create(void)
 {
   return new table_ews_global_by_event_name();
 }
 
-int table_ews_global_by_event_name::delete_all_rows(void)
+int
+table_ews_global_by_event_name::delete_all_rows(void)
 {
-  reset_instrument_class_waits();
+  reset_events_waits_by_instance();
+  /* FIXME: table io */
+  reset_global_wait_stat();
   return 0;
 }
 
-table_ews_global_by_event_name
-::table_ews_global_by_event_name()
-  : table_all_instr_class(&m_share)
+table_ews_global_by_event_name::table_ews_global_by_event_name()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(), m_next_pos()
 {}
 
+void table_ews_global_by_event_name::reset_position(void)
+{
+  m_pos.reset();
+  m_next_pos.reset();
+}
+
+int table_ews_global_by_event_name::rnd_next(void)
+{
+  PFS_mutex_class *mutex_class;
+  PFS_rwlock_class *rwlock_class;
+  PFS_cond_class *cond_class;
+  PFS_file_class *file_class;
+
+  if (global_instr_class_waits_array == NULL)
+    return HA_ERR_END_OF_FILE;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.has_more_view();
+       m_pos.next_view())
+  {
+    switch (m_pos.m_index_1)
+    {
+    case pos_ews_global_by_event_name::VIEW_MUTEX:
+      mutex_class= find_mutex_class(m_pos.m_index_2);
+      if (mutex_class)
+      {
+        make_mutex_row(mutex_class);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+      break;
+    case pos_ews_global_by_event_name::VIEW_RWLOCK:
+      rwlock_class= find_rwlock_class(m_pos.m_index_2);
+      if (rwlock_class)
+      {
+        make_rwlock_row(rwlock_class);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+      break;
+    case pos_ews_global_by_event_name::VIEW_COND:
+      cond_class= find_cond_class(m_pos.m_index_2);
+      if (cond_class)
+      {
+        make_cond_row(cond_class);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+      break;
+    case pos_ews_global_by_event_name::VIEW_FILE:
+      file_class= find_file_class(m_pos.m_index_2);
+      if (file_class)
+      {
+        make_file_row(file_class);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+      break;
+    case pos_ews_global_by_event_name::VIEW_TABLE:
+      if (m_pos.m_index_2 == 1)
+      {
+        make_table_io_row(&global_table_io_class);
+        m_next_pos.set_after(&m_pos);
+        return 0;
+      }
+      break;
+    default:
+      break;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_ews_global_by_event_name::rnd_pos(const void *pos)
+{
+  PFS_mutex_class *mutex_class;
+  PFS_rwlock_class *rwlock_class;
+  PFS_cond_class *cond_class;
+  PFS_file_class *file_class;
+
+  set_position(pos);
+
+  if (global_instr_class_waits_array == NULL)
+    return HA_ERR_END_OF_FILE;
+
+  switch (m_pos.m_index_1)
+  {
+  case pos_ews_global_by_event_name::VIEW_MUTEX:
+    mutex_class= find_mutex_class(m_pos.m_index_2);
+    if (mutex_class)
+    {
+      make_mutex_row(mutex_class);
+      return 0;
+    }
+    break;
+  case pos_ews_global_by_event_name::VIEW_RWLOCK:
+    rwlock_class= find_rwlock_class(m_pos.m_index_2);
+    if (rwlock_class)
+    {
+      make_rwlock_row(rwlock_class);
+      return 0;
+    }
+    break;
+  case pos_ews_global_by_event_name::VIEW_COND:
+    cond_class= find_cond_class(m_pos.m_index_2);
+    if (cond_class)
+    {
+      make_cond_row(cond_class);
+      return 0;
+    }
+    break;
+  case pos_ews_global_by_event_name::VIEW_FILE:
+    file_class= find_file_class(m_pos.m_index_2);
+    if (file_class)
+    {
+      make_file_row(file_class);
+      return 0;
+    }
+    break;
+  case pos_ews_global_by_event_name::VIEW_TABLE:
+    DBUG_ASSERT(m_pos.m_index_2 == 1);
+    make_table_io_row(&global_table_io_class);
+    break;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+
+void table_ews_global_by_event_name
+::make_mutex_row(PFS_mutex_class *klass)
+{
+  m_row.m_name= klass->m_name;
+  m_row.m_name_length= klass->m_name_length;
+  uint index= klass->m_event_name_index;
+  PFS_single_stat cumulated_stat= global_instr_class_waits_array[index];
+
+  if (klass->is_singleton())
+  {
+    PFS_mutex *pfs= sanitize_mutex(klass->m_singleton);
+    if (likely(pfs != NULL))
+    {
+      if (likely(pfs->m_lock.is_populated()))
+      {
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+  else
+  {
+    /* For all the mutex instances ... */
+    PFS_mutex *pfs= mutex_array;
+    PFS_mutex *pfs_last= mutex_array + mutex_max;
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+      {
+        /*
+          If the instance belongs to this class,
+          aggregate the instance statistics.
+        */
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+  m_row_exists= true;
+}
+
+void table_ews_global_by_event_name
+::make_rwlock_row(PFS_rwlock_class *klass)
+{
+  m_row.m_name= klass->m_name;
+  m_row.m_name_length= klass->m_name_length;
+  uint index= klass->m_event_name_index;
+  PFS_single_stat cumulated_stat= global_instr_class_waits_array[index];
+
+  if (klass->is_singleton())
+  {
+    PFS_rwlock *pfs= sanitize_rwlock(klass->m_singleton);
+    if (likely(pfs != NULL))
+    {
+      if (likely(pfs->m_lock.is_populated()))
+      {
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+  else
+  {
+    /* For all the rwlock instances ... */
+    PFS_rwlock *pfs= rwlock_array;
+    PFS_rwlock *pfs_last= rwlock_array + rwlock_max;
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+      {
+        /*
+          If the instance belongs to this class,
+          aggregate the instance statistics.
+        */
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+  m_row_exists= true;
+}
+
 void table_ews_global_by_event_name
-::make_instr_row(PFS_instr_class *klass)
+::make_cond_row(PFS_cond_class *klass)
 {
   m_row.m_name= klass->m_name;
   m_row.m_name_length= klass->m_name_length;
+  uint index= klass->m_event_name_index;
+  PFS_single_stat cumulated_stat= global_instr_class_waits_array[index];
 
-  m_row.m_count= klass->m_wait_stat.m_count;
-  m_row.m_sum= klass->m_wait_stat.m_sum;
-  m_row.m_min= klass->m_wait_stat.m_min;
-  m_row.m_max= klass->m_wait_stat.m_max;
+  if (klass->is_singleton())
+  {
+    PFS_cond *pfs= sanitize_cond(klass->m_singleton);
+    if (likely(pfs != NULL))
+    {
+      if (likely(pfs->m_lock.is_populated()))
+      {
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+  else
+  {
+    /* For all the cond instances ... */
+    PFS_cond *pfs= cond_array;
+    PFS_cond *pfs_last= cond_array + cond_max;
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+      {
+        /*
+          If the instance belongs to this class,
+          aggregate the instance statistics.
+        */
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+  m_row_exists= true;
+}
 
-  if (m_row.m_count)
-    m_row.m_avg= m_row.m_sum / m_row.m_count;
+void table_ews_global_by_event_name
+::make_file_row(PFS_file_class *klass)
+{
+  m_row.m_name= klass->m_name;
+  m_row.m_name_length= klass->m_name_length;
+  uint index= klass->m_event_name_index;
+  PFS_single_stat cumulated_stat= global_instr_class_waits_array[index];
+
+  if (klass->is_singleton())
+  {
+    PFS_file *pfs= sanitize_file(klass->m_singleton);
+    if (likely(pfs != NULL))
+    {
+      if (likely(pfs->m_lock.is_populated()))
+      {
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
   else
   {
-    m_row.m_min= 0;
-    m_row.m_avg= 0;
+    /* For all the file instances ... */
+    PFS_file *pfs= file_array;
+    PFS_file *pfs_last= file_array + file_max;
+    for ( ; pfs < pfs_last; pfs++)
+    {
+      if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+      {
+        /*
+          If the instance belongs to this class,
+          aggregate the instance statistics.
+        */
+        cumulated_stat.aggregate(& pfs->m_wait_stat);
+      }
+    }
+  }
+
+  /* FIXME: */
+  /* For all the file handles ... */
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+  m_row_exists= true;
+}
+
+void table_ews_global_by_event_name
+::make_table_io_row(PFS_instr_class *klass)
+{
+  m_row.m_name= klass->m_name;
+  m_row.m_name_length= klass->m_name_length;
+  uint index= klass->m_event_name_index;
+  PFS_single_stat cumulated_stat= global_instr_class_waits_array[index];
+  PFS_table_io_stat cumulated_io_stat;
+
+  /* For all the table shares ... */
+  PFS_table_share *share= table_share_array;
+  PFS_table_share *share_last= table_share_array + table_share_max;
+  for ( ; share < share_last; share++)
+  {
+    if (share->m_lock.is_populated())
+    {
+      /* Aggregate index stats */
+      for (index= 0; index <= share->m_key_count; index++)
+        cumulated_io_stat.aggregate(& share->m_table_stat.m_index_stat[index]);
+
+      /* Aggregate global stats */
+      cumulated_io_stat.aggregate(& share->m_table_stat.m_index_stat[MAX_KEY]);
+    }
   }
+
+  /* For all the table handles ... */
+  PFS_table *table= table_array;
+  PFS_table *table_last= table_array + table_max;
+  for ( ; table < table_last; table++)
+  {
+    if (table->m_lock.is_populated())
+    {
+      PFS_table_share *safe_share= sanitize_table_share(table->m_share);
+
+      if (likely(safe_share != NULL))
+      {
+        /* Aggregate index stats */
+        for (index= 0; index <= safe_share->m_key_count; index++)
+          cumulated_io_stat.aggregate(& table->m_table_stat.m_index_stat[index]);
+
+        /* Aggregate global stats */
+        cumulated_io_stat.aggregate(& table->m_table_stat.m_index_stat[MAX_KEY]);
+      }
+    }
+  }
+
+  cumulated_io_stat.sum(& cumulated_stat);
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+  m_row_exists= true;
 }
 
 int table_ews_global_by_event_name
@@ -124,14 +465,12 @@ int table_ews_global_by_event_name
 {
   Field *f;
 
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
   /* Set the null bits */
   DBUG_ASSERT(table->s->null_bytes == 0);
 
-  /*
-    The row always exist,
-    the instrument classes are static and never disappear.
-  */
-
   for (; (f= *fields) ; fields++)
   {
     if (read_all || bitmap_is_set(table->read_set, f->field_index))
@@ -142,19 +481,19 @@ int table_ews_global_by_event_name
         set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length);
         break;
       case 1: /* COUNT */
-        set_field_ulonglong(f, m_row.m_count);
+        set_field_ulonglong(f, m_row.m_stat.m_count);
         break;
       case 2: /* SUM */
-        set_field_ulonglong(f, m_row.m_sum);
+        set_field_ulonglong(f, m_row.m_stat.m_sum);
         break;
       case 3: /* MIN */
-        set_field_ulonglong(f, m_row.m_min);
+        set_field_ulonglong(f, m_row.m_stat.m_min);
         break;
       case 4: /* AVG */
-        set_field_ulonglong(f, m_row.m_avg);
+        set_field_ulonglong(f, m_row.m_stat.m_avg);
         break;
       case 5: /* MAX */
-        set_field_ulonglong(f, m_row.m_max);
+        set_field_ulonglong(f, m_row.m_stat.m_max);
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_ews_global_by_event_name.h'
--- a/storage/perfschema/table_ews_global_by_event_name.h	2010-08-12 14:08:52 +0000
+++ b/storage/perfschema/table_ews_global_by_event_name.h	2010-09-23 16:08:54 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -10,11 +10,11 @@
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software Foundation,
-  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
-#ifndef TABLE_EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME_H
-#define TABLE_EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME_H
+#ifndef TABLE_EWS_GLOBAL_BY_EVENT_NAME_H
+#define TABLE_EWS_GLOBAL_BY_EVENT_NAME_H
 
 /**
   @file storage/perfschema/table_ews_global_by_event_name.h
@@ -25,34 +25,63 @@
 #include "pfs_engine_table.h"
 #include "pfs_instr_class.h"
 #include "pfs_instr.h"
-#include "table_all_instr.h"
+#include "table_helper.h"
 
 /**
   @addtogroup Performance_schema_tables
   @{
 */
 
-/** A row of PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME. */
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.
+*/
 struct row_ews_global_by_event_name
 {
   /** Column EVENT_NAME. */
   const char *m_name;
   /** Length in bytes of @c m_name. */
   uint m_name_length;
-  /** Column COUNT_STAR. */
-  ulonglong m_count;
-  /** Column SUM_TIMER_WAIT. */
-  ulonglong m_sum;
-  /** Column MIN_TIMER_WAIT. */
-  ulonglong m_min;
-  /** Column AVG_TIMER_WAIT. */
-  ulonglong m_avg;
-  /** Column MAX_TIMER_WAIT. */
-  ulonglong m_max;
+  /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
+  PFS_stat_row m_stat;
+};
+
+/**
+  Position of a cursor on
+  PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME.
+  Index 1 on instrument view
+  Index 2 on instrument class (1 based)
+*/
+struct pos_ews_global_by_event_name
+: public PFS_double_index, public PFS_instrument_view_constants
+{
+  pos_ews_global_by_event_name()
+    : PFS_double_index(FIRST_VIEW, 1)
+  {}
+
+  inline void reset(void)
+  {
+    m_index_1= FIRST_VIEW;
+    m_index_2= 1;
+  }
+
+  inline bool has_more_view(void)
+  { return (m_index_1 <= LAST_VIEW); }
+
+  inline void next_view(void)
+  {
+    m_index_1++;
+    m_index_2= 1;
+  }
+
+  inline void next_instrument(void)
+  {
+    m_index_2++;
+  }
 };
 
 /** Table PERFORMANCE_SCHEMA.EVENTS_WAITS_SUMMARY_GLOBAL_BY_EVENT_NAME. */
-class table_ews_global_by_event_name : public table_all_instr_class
+class table_ews_global_by_event_name : public PFS_engine_table
 {
 public:
   /** Table share */
@@ -60,9 +89,11 @@ public:
   static PFS_engine_table* create();
   static int delete_all_rows();
 
-protected:
-  virtual void make_instr_row(PFS_instr_class *klass);
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
 
+protected:
   virtual int read_row_values(TABLE *table,
                               unsigned char *buf,
                               Field **fields,
@@ -74,6 +105,13 @@ public:
   ~table_ews_global_by_event_name()
   {}
 
+protected:
+  void make_mutex_row(PFS_mutex_class *klass);
+  void make_rwlock_row(PFS_rwlock_class *klass);
+  void make_cond_row(PFS_cond_class *klass);
+  void make_file_row(PFS_file_class *klass);
+  void make_table_io_row(PFS_instr_class *klass);
+
 private:
   /** Table share lock. */
   static THR_LOCK m_table_lock;
@@ -82,6 +120,12 @@ private:
 
   /** Current row. */
   row_ews_global_by_event_name m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  pos_ews_global_by_event_name m_pos;
+  /** Next position. */
+  pos_ews_global_by_event_name m_next_pos;
 };
 
 /** @} */

=== modified file 'storage/perfschema/table_file_summary.cc'
--- a/storage/perfschema/table_file_summary.cc	2010-11-09 08:16:50 +0000
+++ b/storage/perfschema/table_file_summary.cc	2010-11-15 07:40:07 +0000
@@ -84,6 +84,7 @@ PFS_engine_table* table_file_summary_by_
 
 int table_file_summary_by_event_name::delete_all_rows(void)
 {
+  reset_file_instance_io();
   reset_file_class_io();
   return 0;
 }
@@ -140,7 +141,22 @@ void table_file_summary_by_event_name::m
 {
   m_row.m_name= &klass->m_name[0];
   m_row.m_name_length= klass->m_name_length;
-  m_row.m_file_stat= klass->m_file_stat;
+  m_row.m_file_io_stat= klass->m_file_stat.m_io_stat;
+
+  /* For all file instances ... */
+  PFS_file *pfs= file_array;
+  PFS_file *pfs_last= file_array + file_max;
+  for ( ; pfs < pfs_last; pfs++)
+  {
+    if ((pfs->m_class == klass) && pfs->m_lock.is_populated())
+    {
+      /*
+        If the instance belongs to this class,
+        aggregate the instance statistics.
+      */
+      m_row.m_file_io_stat.aggregate(& pfs->m_file_stat.m_io_stat);
+    }
+  }
 }
 
 int table_file_summary_by_event_name::read_row_values(TABLE *table,
@@ -165,16 +181,16 @@ int table_file_summary_by_event_name::re
         set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length);
         break;
       case 1: /* COUNT_READ */
-        set_field_ulonglong(f, m_row.m_file_stat.m_count_read);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_count_read);
         break;
       case 2: /* COUNT_WRITE */
-        set_field_ulonglong(f, m_row.m_file_stat.m_count_write);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_count_write);
         break;
       case 3: /* READ_BYTES */
-        set_field_ulonglong(f, m_row.m_file_stat.m_read_bytes);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_read_bytes);
         break;
       case 4: /* WRITE_BYTES */
-        set_field_ulonglong(f, m_row.m_file_stat.m_write_bytes);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_write_bytes);
         break;
       default:
         DBUG_ASSERT(false);
@@ -320,7 +336,7 @@ void table_file_summary_by_instance::mak
   m_row.m_filename_length= pfs->m_filename_length;
   m_row.m_name= safe_class->m_name;
   m_row.m_name_length= safe_class->m_name_length;
-  m_row.m_file_stat= pfs->m_file_stat;
+  m_row.m_file_io_stat= pfs->m_file_stat.m_io_stat;
 
   if (pfs->m_lock.end_optimistic_lock(&lock))
     m_row_exists= true;
@@ -352,16 +368,16 @@ int table_file_summary_by_instance::read
         set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length);
         break;
       case 2: /* COUNT_READ */
-        set_field_ulonglong(f, m_row.m_file_stat.m_count_read);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_count_read);
         break;
       case 3: /* COUNT_WRITE */
-        set_field_ulonglong(f, m_row.m_file_stat.m_count_write);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_count_write);
         break;
       case 4: /* READ_BYTES */
-        set_field_ulonglong(f, m_row.m_file_stat.m_read_bytes);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_read_bytes);
         break;
       case 5: /* WRITE_BYTES */
-        set_field_ulonglong(f, m_row.m_file_stat.m_write_bytes);
+        set_field_ulonglong(f, m_row.m_file_io_stat.m_write_bytes);
         break;
       default:
         DBUG_ASSERT(false);

=== modified file 'storage/perfschema/table_file_summary.h'
--- a/storage/perfschema/table_file_summary.h	2010-07-23 19:03:52 +0000
+++ b/storage/perfschema/table_file_summary.h	2010-09-23 16:08:54 +0000
@@ -42,7 +42,7 @@ struct row_file_summary_by_event_name
     Columns COUNT_READ, COUNT_WRITE,
     SUM_NUMBER_OF_BYTES_READ, SUM_NUMBER_OF_BYTES_WRITE.
   */
-  PFS_file_stat m_file_stat;
+  PFS_file_io_stat m_file_io_stat;
 };
 
 /** Table PERFORMANCE_SCHEMA.FILE_SUMMARY_BY_EVENT_NAME. */
@@ -101,7 +101,7 @@ struct row_file_summary_by_instance
     Columns COUNT_READ, COUNT_WRITE,
     SUM_NUMBER_OF_BYTES_READ, SUM_NUMBER_OF_BYTES_WRITE.
   */
-  PFS_file_stat m_file_stat;
+  PFS_file_io_stat m_file_io_stat;
 };
 
 /** Table PERFORMANCE_SCHEMA.FILE_UMMARY_BY_INSTANCE. */

=== added file 'storage/perfschema/table_helper.cc'
--- a/storage/perfschema/table_helper.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_helper.cc	2010-09-23 16:12:54 +0000
@@ -0,0 +1,40 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/**
+  @file storage/perfschema/table_helper.cc
+  Performance schema table helpers (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_engine_table.h"
+#include "table_helper.h"
+
+void set_field_object_type(Field *f, enum_object_type object_type)
+{
+  switch (object_type)
+  {
+  case OBJECT_TYPE_TABLE:
+    PFS_engine_table::set_field_varchar_utf8(f, "TABLE", 5);
+    break;
+  case OBJECT_TYPE_TEMPORARY_TABLE:
+    PFS_engine_table::set_field_varchar_utf8(f, "TEMPORARY TABLE", 15);
+    break;
+  default:
+    DBUG_ASSERT(false);
+  }
+}
+

=== modified file 'storage/perfschema/table_helper.h'
--- a/storage/perfschema/table_helper.h	2010-07-02 17:25:26 +0000
+++ b/storage/perfschema/table_helper.h	2010-09-24 18:21:22 +0000
@@ -10,12 +10,16 @@
   GNU General Public License for more details.
 
   You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software Foundation,
-  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
 #ifndef PFS_TABLE_HELPER_H
 #define PFS_TABLE_HELPER_H
 
+#include "pfs_column_types.h"
+#include "pfs_stat.h"
+#include "pfs_timer.h"
+
 /**
   @file storage/perfschema/table_helper.h
   Performance schema table helpers (declarations).
@@ -49,6 +53,79 @@ struct PFS_object_view_constants
   static const uint VIEW_FUNCTION= 4;
 };
 
+struct PFS_stat_row
+{
+  /** Column COUNT_STAR. */
+  ulonglong m_count;
+  /** Column SUM_TIMER_WAIT. */
+  ulonglong m_sum;
+  /** Column MIN_TIMER_WAIT. */
+  ulonglong m_min;
+  /** Column AVG_TIMER_WAIT. */
+  ulonglong m_avg;
+  /** Column MAX_TIMER_WAIT. */
+  ulonglong m_max;
+
+  inline void set(time_normalizer *normalizer, const PFS_single_stat *stat)
+  {
+    m_count= stat->m_count;
+
+    if (m_count)
+    {
+      m_sum= normalizer->wait_to_pico(stat->m_sum);
+      m_min= normalizer->wait_to_pico(stat->m_min);
+      m_max= normalizer->wait_to_pico(stat->m_max);
+      m_avg= normalizer->wait_to_pico(stat->m_sum / stat->m_count);
+    }
+    else
+    {
+      m_sum= 0;
+      m_min= 0;
+      m_avg= 0;
+      m_max= 0;
+    }
+  }
+};
+
+struct PFS_table_io_stat_row
+{
+  PFS_stat_row m_all;
+  PFS_stat_row m_all_read;
+  PFS_stat_row m_all_write;
+  PFS_stat_row m_fetch;
+  PFS_stat_row m_insert;
+  PFS_stat_row m_update;
+  PFS_stat_row m_delete;
+
+  inline void set(time_normalizer *normalizer, const PFS_table_io_stat *stat)
+  {
+    PFS_single_stat all_read;
+    PFS_single_stat all_write;
+    PFS_single_stat all;
+
+    m_fetch.set(normalizer, & stat->m_fetch);
+
+    all_read.aggregate(& stat->m_fetch);
+
+    m_insert.set(normalizer, & stat->m_insert);
+    m_update.set(normalizer, & stat->m_update);
+    m_delete.set(normalizer, & stat->m_delete);
+
+    all_write.aggregate(& stat->m_insert);
+    all_write.aggregate(& stat->m_update);
+    all_write.aggregate(& stat->m_delete);
+
+    all.aggregate(& all_read);
+    all.aggregate(& all_write);
+
+    m_all_read.set(normalizer, & all_read);
+    m_all_write.set(normalizer, & all_write);
+    m_all.set(normalizer, & all);
+  }
+};
+
+void set_field_object_type(Field *f, enum_object_type object_type);
+
 /** @} */
 
 #endif

=== added file 'storage/perfschema/table_os_global_by_type.cc'
--- a/storage/perfschema/table_os_global_by_type.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_os_global_by_type.cc	2010-11-15 07:40:07 +0000
@@ -0,0 +1,269 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/**
+  @file storage/perfschema/table_os_global_by_type.cc
+  Table OBJECTS_SUMMARY_GLOBAL_BY_TYPE (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr_class.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "table_os_global_by_type.h"
+#include "pfs_global.h"
+
+THR_LOCK table_os_global_by_type::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("OBJECT_TYPE") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_SCHEMA") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("COUNT_STAR") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("SUM_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MIN_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("AVG_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("MAX_TIMER_WAIT") },
+    { C_STRING_WITH_LEN("bigint(20)") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_os_global_by_type::m_field_def=
+{ 8, field_types };
+
+PFS_engine_table_share
+table_os_global_by_type::m_share=
+{
+  { C_STRING_WITH_LEN("objects_summary_global_by_type") },
+  &pfs_truncatable_acl,
+  table_os_global_by_type::create,
+  NULL, /* write_row */
+  table_os_global_by_type::delete_all_rows,
+  NULL, /* get_row_count */
+  1000, /* records */
+  sizeof(pos_os_global_by_type),
+  &m_table_lock,
+  &m_field_def,
+  false /* checked */
+};
+
+PFS_engine_table*
+table_os_global_by_type::create(void)
+{
+  return new table_os_global_by_type();
+}
+
+int
+table_os_global_by_type::delete_all_rows(void)
+{
+  reset_per_thread_wait_stat();
+  return 0;
+}
+
+table_os_global_by_type::table_os_global_by_type()
+  : PFS_engine_table(&m_share, &m_pos),
+    m_row_exists(false), m_pos(), m_next_pos()
+{}
+
+void table_os_global_by_type::reset_position(void)
+{
+  m_pos.reset();
+  m_next_pos.reset();
+}
+
+int table_os_global_by_type::rnd_next(void)
+{
+  PFS_table_share *table_share;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.has_more_view();
+       m_pos.next_view())
+  {
+    switch (m_pos.m_index_1) {
+    case pos_os_global_by_type::VIEW_TABLE:
+      for ( ; m_pos.m_index_2 < table_share_max; m_pos.m_index_2++)
+      {
+        table_share= &table_share_array[m_pos.m_index_2];
+        if (table_share->m_lock.is_populated())
+        {
+          make_row(table_share);
+          m_next_pos.set_after(&m_pos);
+          return 0;
+        }
+      }
+      break;
+    default:
+      break;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int
+table_os_global_by_type::rnd_pos(const void *pos)
+{
+  PFS_table_share *table_share;
+
+  set_position(pos);
+
+  switch (m_pos.m_index_1) {
+  case pos_os_global_by_type::VIEW_TABLE:
+    DBUG_ASSERT(m_pos.m_index_2 < table_share_max);
+    table_share= &table_share_array[m_pos.m_index_2];
+    if (table_share->m_lock.is_populated())
+    {
+      make_row(table_share);
+      return 0;
+    }
+    break;
+  default:
+    break;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+void table_os_global_by_type::make_row(PFS_table_share *share)
+{
+  pfs_lock lock;
+  PFS_single_stat cumulated_stat;
+
+  m_row_exists= false;
+
+  share->m_lock.begin_optimistic_lock(&lock);
+
+  m_row.m_object_type= share->get_object_type();
+  memcpy(m_row.m_schema_name, share->m_schema_name, share->m_schema_name_length);
+  m_row.m_schema_name_length= share->m_schema_name_length;
+  memcpy(m_row.m_object_name, share->m_table_name, share->m_table_name_length);
+  m_row.m_object_name_length= share->m_table_name_length;
+  share->m_table_stat.sum(& cumulated_stat);
+
+  if (! share->m_lock.end_optimistic_lock(&lock))
+    return;
+
+  m_row_exists= true;
+
+  if (share->m_refcount > 0)
+  {
+    /* For all the table handles still opened ... */
+    PFS_table *table= table_array;
+    PFS_table *table_last= table_array + table_max;
+    for ( ; table < table_last ; table++)
+    {
+      if ((table->m_share == share) && (table->m_lock.is_populated()))
+      {
+        /*
+          If the opened table handle is for this table share,
+          aggregate the table handle statistics.
+        */
+        table->m_table_stat.sum(& cumulated_stat);
+      }
+    }
+  }
+
+  time_normalizer *normalizer= time_normalizer::get(wait_timer);
+  m_row.m_stat.set(normalizer, &cumulated_stat);
+}
+
+int table_os_global_by_type::read_row_values(TABLE *table,
+                                             unsigned char *buf,
+                                             Field **fields,
+                                             bool read_all)
+{
+  Field *f;
+
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (read_all || bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        set_field_object_type(f, m_row.m_object_type);
+        break;
+      case 1: /* SCHEMA_NAME */
+        set_field_varchar_utf8(f, m_row.m_schema_name,
+                               m_row.m_schema_name_length);
+        break;
+      case 2: /* OBJECT_NAME */
+        set_field_varchar_utf8(f, m_row.m_object_name,
+                               m_row.m_object_name_length);
+        break;
+      case 3: /* COUNT */
+        set_field_ulonglong(f, m_row.m_stat.m_count);
+        break;
+      case 4: /* SUM */
+        set_field_ulonglong(f, m_row.m_stat.m_sum);
+        break;
+      case 5: /* MIN */
+        set_field_ulonglong(f, m_row.m_stat.m_min);
+        break;
+      case 6: /* AVG */
+        set_field_ulonglong(f, m_row.m_stat.m_avg);
+        break;
+      case 7: /* MAX */
+        set_field_ulonglong(f, m_row.m_stat.m_max);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+

=== added file 'storage/perfschema/table_os_global_by_type.h'
--- a/storage/perfschema/table_os_global_by_type.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_os_global_by_type.h	2010-09-23 16:08:54 +0000
@@ -0,0 +1,130 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#ifndef TABLE_OBJECTS_SUMMARY_GLOBAL_BY_TYPE_H
+#define TABLE_OBJECTS_SUMMARY_GLOBAL_BY_TYPE_H
+
+/**
+  @file storage/perfschema/table_os_global_by_type.h
+  Table OBJECTS_SUMMARY_GLOBAL_BY_TYPE (declarations).
+*/
+
+#include "pfs_column_types.h"
+#include "pfs_engine_table.h"
+#include "pfs_instr_class.h"
+#include "pfs_instr.h"
+#include "table_helper.h"
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/**
+  A row of table
+  PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE.
+*/
+struct row_os_global_by_type
+{
+  /** Column OBJECT_TYPE. */
+  enum_object_type m_object_type;
+  /** Column SCHEMA_NAME. */
+  char m_schema_name[NAME_LEN];
+  /** Length in bytes of @c m_schema_name. */
+  uint m_schema_name_length;
+  /** Column OBJECT_NAME. */
+  char m_object_name[NAME_LEN];
+  /** Length in bytes of @c m_object_name. */
+  uint m_object_name_length;
+  /** Columns COUNT_STAR, SUM/MIN/AVG/MAX TIMER_WAIT. */
+  PFS_stat_row m_stat;
+};
+
+/**
+  Position of a cursor on
+  PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE.
+  Index 1 on object type
+  Index 2 on object instance (0 based)
+*/
+struct pos_os_global_by_type : public PFS_double_index,
+                               public PFS_object_view_constants
+{
+  pos_os_global_by_type()
+    : PFS_double_index(FIRST_VIEW, 0)
+  {}
+
+  inline void reset(void)
+  {
+    m_index_1= FIRST_VIEW;
+    m_index_2= 0;
+  }
+
+  inline bool has_more_view(void)
+  { return (m_index_1 <= LAST_VIEW); }
+
+  inline void next_view(void)
+  {
+    m_index_1++;
+    m_index_2= 0;
+  }
+};
+
+/** Table PERFORMANCE_SCHEMA.OBJECTS_SUMMARY_GLOBAL_BY_TYPE. */
+class table_os_global_by_type : public PFS_engine_table
+{
+public:
+  /** Table share */
+  static PFS_engine_table_share m_share;
+  static PFS_engine_table* create();
+  static int delete_all_rows();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
+
+protected:
+  virtual int read_row_values(TABLE *table,
+                              unsigned char *buf,
+                              Field **fields,
+                              bool read_all);
+
+  table_os_global_by_type();
+
+public:
+  ~table_os_global_by_type()
+  {}
+
+protected:
+  void make_row(PFS_table_share *table_share);
+
+private:
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_os_global_by_type m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  pos_os_global_by_type m_pos;
+  /** Next position. */
+  pos_os_global_by_type m_next_pos;
+};
+
+
+/** @} */
+#endif

=== modified file 'storage/perfschema/table_setup_consumers.cc'
--- a/storage/perfschema/table_setup_consumers.cc	2010-11-09 08:16:50 +0000
+++ b/storage/perfschema/table_setup_consumers.cc	2010-11-15 07:40:07 +0000
@@ -24,7 +24,7 @@
 #include "pfs_instr.h"
 #include "pfs_events_waits.h"
 
-#define COUNT_SETUP_CONSUMERS 8
+#define COUNT_SETUP_CONSUMERS 5
 static row_setup_consumers all_setup_consumers_data[COUNT_SETUP_CONSUMERS]=
 {
   {
@@ -40,24 +40,12 @@ static row_setup_consumers all_setup_con
     &flag_events_waits_history_long
   },
   {
-    { C_STRING_WITH_LEN("events_waits_summary_by_thread_by_event_name") },
-    &flag_events_waits_summary_by_thread_by_event_name
+    { C_STRING_WITH_LEN("global_instrumentation") },
+    &flag_global_instrumentation
   },
   {
-    { C_STRING_WITH_LEN("events_waits_summary_by_event_name") },
-    &flag_events_waits_summary_by_event_name
-  },
-  {
-    { C_STRING_WITH_LEN("events_waits_summary_by_instance") },
-    &flag_events_waits_summary_by_instance
-  },
-  {
-    { C_STRING_WITH_LEN("file_summary_by_event_name") },
-    &flag_file_summary_by_event_name
-  },
-  {
-    { C_STRING_WITH_LEN("file_summary_by_instance") },
-    &flag_file_summary_by_instance
+    { C_STRING_WITH_LEN("thread_instrumentation") },
+    &flag_thread_instrumentation
   }
 };
 

=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc	2010-11-09 08:16:50 +0000
+++ b/storage/perfschema/table_setup_instruments.cc	2010-11-15 07:40:07 +0000
@@ -89,6 +89,7 @@ int table_setup_instruments::rnd_next(vo
   PFS_rwlock_class *rwlock_class;
   PFS_cond_class *cond_class;
   PFS_file_class *file_class;
+  PFS_instr_class *table_class;
 
   for (m_pos.set_at(&m_next_pos);
        m_pos.has_more_view();
@@ -135,9 +136,10 @@ int table_setup_instruments::rnd_next(vo
       }
       break;
     case pos_setup_instruments::VIEW_TABLE:
-      if (m_pos.m_index_2 == 1)
+      table_class= find_table_class(m_pos.m_index_2);
+      if (table_class)
       {
-        make_row(&global_table_class);
+        make_row(table_class);
         m_next_pos.set_after(&m_pos);
         return 0;
       }
@@ -154,6 +156,7 @@ int table_setup_instruments::rnd_pos(con
   PFS_rwlock_class *rwlock_class;
   PFS_cond_class *cond_class;
   PFS_file_class *file_class;
+  PFS_instr_class *table_class;
 
   set_position(pos);
 
@@ -194,9 +197,10 @@ int table_setup_instruments::rnd_pos(con
     }
     break;
   case pos_setup_instruments::VIEW_TABLE:
-    if (m_pos.m_index_2 == 1)
+    table_class= find_table_class(m_pos.m_index_2);
+    if (table_class)
     {
-      make_row(&global_table_class);
+      make_row(table_class);
       return 0;
     }
     break;

=== added file 'storage/perfschema/table_setup_objects.cc'
--- a/storage/perfschema/table_setup_objects.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_setup_objects.cc	2010-11-15 07:40:07 +0000
@@ -0,0 +1,362 @@
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software Foundation,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+/**
+  @file storage/perfschema/table_setup_objects.cc
+  Table SETUP_OBJECTS (implementation).
+*/
+
+#include "my_global.h"
+#include "my_pthread.h"
+#include "pfs_instr.h"
+#include "pfs_column_types.h"
+#include "pfs_column_values.h"
+#include "pfs_setup_object.h"
+#include "table_setup_objects.h"
+#include "table_helper.h"
+#include "pfs_global.h"
+
+THR_LOCK table_setup_objects::m_table_lock;
+
+static const TABLE_FIELD_TYPE field_types[]=
+{
+  {
+    { C_STRING_WITH_LEN("OBJECT_TYPE") },
+    { C_STRING_WITH_LEN("enum(\'TABLE\')") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_SCHEMA") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+  {
+    { C_STRING_WITH_LEN("OBJECT_NAME") },
+    { C_STRING_WITH_LEN("varchar(64)") },
+    { NULL, 0}
+  },
+#if 0
+  {
+    { C_STRING_WITH_LEN("ENABLED") },
+    { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") },
+    { NULL, 0}
+  },
+#endif
+  {
+    { C_STRING_WITH_LEN("TIMED") },
+    { C_STRING_WITH_LEN("enum(\'YES\',\'NO\')") },
+    { NULL, 0}
+  }
+};
+
+TABLE_FIELD_DEF
+table_setup_objects::m_field_def=
+{ 4, field_types };
+
+PFS_engine_table_share
+table_setup_objects::m_share=
+{
+  { C_STRING_WITH_LEN("setup_objects") },
+  &pfs_editable_acl,
+  table_setup_objects::create,
+  table_setup_objects::write_row,
+  table_setup_objects::delete_all_rows,
+  table_setup_objects::get_row_count,
+  1000, /* records */
+  sizeof(PFS_simple_index),
+  &m_table_lock,
+  &m_field_def,
+  false /* checked */
+};
+
+PFS_engine_table* table_setup_objects::create(void)
+{
+  return new table_setup_objects();
+}
+
+int table_setup_objects::write_row(TABLE *table, unsigned char *buf,
+                                   Field **fields)
+{
+  Field *f;
+  enum_object_type object_type= OBJECT_TYPE_TABLE;
+  String object_schema_data("%", 1, &my_charset_utf8_bin);
+  String object_name_data("%", 1, &my_charset_utf8_bin);
+  String *object_schema= &object_schema_data;
+  String *object_name= &object_name_data;
+  enum_yes_no yes_no;
+  bool enabled= true;
+  bool timed= true;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (bitmap_is_set(table->write_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        object_type= (enum_object_type) get_field_enum(f);
+        break;
+      case 1: /* OBJECT_SCHEMA */
+        object_schema= get_field_varchar_utf8(f, &object_schema_data);
+        break;
+      case 2: /* OBJECT_NAME */
+        object_name= get_field_varchar_utf8(f, &object_name_data);
+        break;
+#if 0
+      case 3: /* ENABLED */
+        yes_no= (enum_yes_no) get_field_enum(f);
+        enabled= (yes_no == ENUM_YES) ? true : false;
+        break;
+#endif
+      case 3: /* TIMED */
+        yes_no= (enum_yes_no) get_field_enum(f);
+        timed= (yes_no == ENUM_YES) ? true : false;
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  /* Reject illegal enum values in OBJECT_TYPE */
+  if (object_type != OBJECT_TYPE_TABLE)
+    return HA_ERR_NO_REFERENCED_ROW;
+
+  return insert_setup_object(object_type, object_schema, object_name,
+                             enabled, timed);
+}
+
+int table_setup_objects::delete_all_rows(void)
+{
+  return reset_setup_object();
+}
+
+ha_rows table_setup_objects::get_row_count(void)
+{
+  return setup_object_count();
+}
+
+table_setup_objects::table_setup_objects()
+  : PFS_engine_table(&m_share, &m_pos),
+  m_row_exists(false), m_pos(0), m_next_pos(0)
+{}
+
+void table_setup_objects::reset_position(void)
+{
+  m_pos.m_index= 0;
+  m_next_pos.m_index= 0;
+}
+
+int table_setup_objects::rnd_next(void)
+{
+  PFS_setup_object *pfs;
+
+  for (m_pos.set_at(&m_next_pos);
+       m_pos.m_index < setup_object_max;
+       m_pos.next())
+  {
+    pfs= &setup_object_array[m_pos.m_index];
+    if (pfs->m_lock.is_populated())
+    {
+      make_row(pfs);
+      m_next_pos.set_after(&m_pos);
+      return 0;
+    }
+  }
+
+  return HA_ERR_END_OF_FILE;
+}
+
+int table_setup_objects::rnd_pos(const void *pos)
+{
+  PFS_setup_object *pfs;
+
+  set_position(pos);
+
+  DBUG_ASSERT(m_pos.m_index < setup_object_max);
+  pfs= &setup_object_array[m_pos.m_index];
+  if (pfs->m_lock.is_populated())
+  {
+    make_row(pfs);
+    return 0;
+  }
+
+  return HA_ERR_RECORD_DELETED;
+}
+
+void table_setup_objects::make_row(PFS_setup_object *pfs)
+{
+  pfs_lock lock;
+
+  m_row_exists= false;
+
+  pfs->m_lock.begin_optimistic_lock(&lock);
+
+  m_row.m_object_type= pfs->get_object_type();
+  memcpy(m_row.m_schema_name, pfs->m_schema_name, pfs->m_schema_name_length);
+  m_row.m_schema_name_length= pfs->m_schema_name_length;
+  memcpy(m_row.m_object_name, pfs->m_object_name, pfs->m_object_name_length);
+  m_row.m_object_name_length= pfs->m_object_name_length;
+#if 0
+  m_row.m_enabled_ptr= &pfs->m_enabled;
+#else
+  /*
+    The ENABLED column does not exist,
+    so disabled records are be displayed.
+  */
+  if (! pfs->m_enabled)
+    return;
+#endif
+
+  m_row.m_timed_ptr= &pfs->m_timed;
+
+  if (pfs->m_lock.end_optimistic_lock(&lock))
+    m_row_exists= true;
+}
+
+int table_setup_objects::read_row_values(TABLE *table,
+                                         unsigned char *buf,
+                                         Field **fields,
+                                         bool read_all)
+{
+  Field *f;
+
+  if (unlikely(! m_row_exists))
+    return HA_ERR_RECORD_DELETED;
+
+  /* Set the null bits */
+  DBUG_ASSERT(table->s->null_bytes == 1);
+  buf[0]= 0;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (read_all || bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        set_field_enum(f, m_row.m_object_type);
+        break;
+      case 1: /* OBJECT_SCHEMA */
+        if (m_row.m_schema_name_length)
+          set_field_varchar_utf8(f, m_row.m_schema_name,
+                                 m_row.m_schema_name_length);
+        else
+          f->set_null();
+        break;
+      case 2: /* OBJECT_NAME */
+        if (m_row.m_object_name_length)
+          set_field_varchar_utf8(f, m_row.m_object_name,
+                                 m_row.m_object_name_length);
+        else
+          f->set_null();
+        break;
+#if 0
+      case 3: /* ENABLED */
+        set_field_enum(f, (*m_row.m_enabled_ptr) ? ENUM_YES : ENUM_NO);
+        break;
+#endif
+      case 3: /* TIMED */
+        set_field_enum(f, (*m_row.m_timed_ptr) ? ENUM_YES : ENUM_NO);
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  return 0;
+}
+
+int table_setup_objects::update_row_values(TABLE *table,
+                                           const unsigned char *,
+                                           unsigned char *,
+                                           Field **fields)
+{
+  Field *f;
+  enum_yes_no value;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (bitmap_is_set(table->write_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+      case 1: /* OBJECT_SCHEMA */
+      case 2: /* OBJECT_NAME */
+        my_error(ER_WRONG_PERFSCHEMA_USAGE, MYF(0));
+        return HA_ERR_WRONG_COMMAND;
+#if 0
+      case 3: /* ENABLED */
+        value= (enum_yes_no) get_field_enum(f);
+        *m_row.m_enabled_ptr= (value == ENUM_YES) ? true : false;
+        break;
+#endif
+      case 3: /* TIMED */
+        value= (enum_yes_no) get_field_enum(f);
+        *m_row.m_timed_ptr= (value == ENUM_YES) ? true : false;
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  setup_objects_version++;
+  return 0;
+}
+
+int table_setup_objects::delete_row_values(TABLE *table,
+                                           const unsigned char *buf,
+                                           Field **fields)
+{
+  Field *f;
+  enum_object_type object_type= OBJECT_TYPE_TABLE;
+  String object_schema_data("", 0, &my_charset_utf8_bin);
+  String object_name_data("", 0, &my_charset_utf8_bin);
+  String *object_schema= NULL;
+  String *object_name= NULL;
+
+  for (; (f= *fields) ; fields++)
+  {
+    if (bitmap_is_set(table->read_set, f->field_index))
+    {
+      switch(f->field_index)
+      {
+      case 0: /* OBJECT_TYPE */
+        object_type= (enum_object_type) get_field_enum(f);
+        break;
+      case 1: /* OBJECT_SCHEMA */
+        object_schema= get_field_varchar_utf8(f, &object_schema_data);
+        break;
+      case 2: /* OBJECT_NAME */
+        object_name= get_field_varchar_utf8(f, &object_name_data);
+        break;
+      case 3: /* ENABLED */
+      case 4: /* TIMED */
+        break;
+      default:
+        DBUG_ASSERT(false);
+      }
+    }
+  }
+
+  DBUG_ASSERT(object_schema != NULL);
+  DBUG_ASSERT(object_name != NULL);
+
+  return delete_setup_object(object_type, object_schema, object_name);
+}
+

=== added file 'storage/perfschema/table_setup_objects.h'
--- a/storage/perfschema/table_setup_objects.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/table_setup_objects.h	2010-09-23 16:08:54 +0000
@@ -0,0 +1,111 @@
+/* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software Foundation,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+#ifndef TABLE_SETUP_OBJECTS_H
+#define TABLE_SETUP_OBJECTS_H
+
+/**
+  @file storage/perfschema/table_setup_objects.h
+  Table SETUP_OBJECTS (declarations).
+*/
+
+#include "pfs_engine_table.h"
+#include "table_helper.h"
+
+struct PFS_setup_object;
+
+/**
+  @addtogroup Performance_schema_tables
+  @{
+*/
+
+/** A row of PERFORMANCE_SCHEMA.SETUP_OBJECTS. */
+struct row_setup_objects
+{
+  /** Column OBJECT_TYPE. */
+  enum_object_type m_object_type;
+  /** Column SCHEMA_NAME. */
+  char m_schema_name[NAME_LEN];
+  /** Length in bytes of @c m_schema_name. */
+  uint m_schema_name_length;
+  /** Column OBJECT_NAME. */
+  char m_object_name[NAME_LEN];
+  /** Length in bytes of @c m_object_name. */
+  uint m_object_name_length;
+#if 0
+  /** Column ENABLED. */
+  bool *m_enabled_ptr;
+#endif
+  /** Column TIMED. */
+  bool *m_timed_ptr;
+};
+
+/** Table PERFORMANCE_SCHEMA.SETUP_OBJECTS. */
+class table_setup_objects : public PFS_engine_table
+{
+public:
+  /** Table share. */
+  static PFS_engine_table_share m_share;
+  /** Table builder. */
+  static PFS_engine_table* create();
+  static int write_row(TABLE *table, unsigned char *buf, Field **fields);
+  static int delete_all_rows();
+  static ha_rows get_row_count();
+
+  virtual int rnd_next();
+  virtual int rnd_pos(const void *pos);
+  virtual void reset_position(void);
+
+protected:
+  virtual int read_row_values(TABLE *table,
+                              unsigned char *buf,
+                              Field **fields,
+                              bool read_all);
+
+  virtual int update_row_values(TABLE *table,
+                                const unsigned char *old_buf,
+                                unsigned char *new_buf,
+                                Field **fields);
+
+  virtual int delete_row_values(TABLE *table,
+                                const unsigned char *buf,
+                                Field **fields);
+
+  table_setup_objects();
+
+public:
+  ~table_setup_objects()
+  {}
+
+private:
+  void make_row(PFS_setup_object *pfs);
+
+  /** Table share lock. */
+  static THR_LOCK m_table_lock;
+  /** Fields definition. */
+  static TABLE_FIELD_DEF m_field_def;
+
+  /** Current row. */
+  row_setup_objects m_row;
+  /** True is the current row exists. */
+  bool m_row_exists;
+  /** Current position. */
+  PFS_simple_index m_pos;
+  /** Next position. */
+  PFS_simple_index m_next_pos;
+};
+
+/** @} */
+#endif

=== modified file 'storage/perfschema/unittest/pfs-t.cc'
--- a/storage/perfschema/unittest/pfs-t.cc	2010-07-23 19:03:52 +0000
+++ b/storage/perfschema/unittest/pfs-t.cc	2010-10-25 13:02:25 +0000
@@ -25,6 +25,8 @@
 #include <memory.h>
 
 #include "stub_print_error.h"
+#include "stub_pfs_defaults.h"
+#include "stub_server_misc.h"
 
 /* test helpers, to simulate the setup */
 
@@ -95,6 +97,7 @@ void test_bootstrap()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
   boot= initialize_performance_schema(& param);
   ok(boot != NULL, "boot");
@@ -138,11 +141,16 @@ PSI * load_perfschema()
   param.m_events_waits_history_sizing= 10;
   param.m_events_waits_history_long_sizing= 10;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
   /* test_bootstrap() covered this, assuming it just works */
   boot= initialize_performance_schema(& param);
   psi= boot->get_interface(PSI_VERSION_1);
 
+  /* Reset every consumer to a known state */
+  flag_global_instrumentation= true;
+  flag_thread_instrumentation= true;
+
   return (PSI*) psi;
 }
 
@@ -376,7 +384,7 @@ void test_bad_registration()
   ok(dummy_thread_key == 0, "zero key");
   dummy_thread_key= 9999;
   psi->register_thread("12345678901234567890123", bad_thread_1, 1);
-  ok(dummy_thread_key == 2, "assigned key");
+  ok(dummy_thread_key == 1, "assigned key");
 
   /*
     Test that length('thread/' (7) + category + '/' (1) + name) <= 128
@@ -412,7 +420,7 @@ void test_bad_registration()
   ok(dummy_thread_key == 0, "zero key");
 
   psi->register_thread("X", bad_thread_3, 1);
-  ok(dummy_thread_key == 3, "assigned key");
+  ok(dummy_thread_key == 2, "assigned key");
 
   /*
     Test that length('wait/io/file/' (13) + category + '/' (1)) < 32
@@ -554,8 +562,8 @@ void test_init_disabled()
   file_class_A= find_file_class(file_key_A);
   ok(file_class_A != NULL, "file class A");
 
-  /* Pretend thread T-1 is running, and disabled */
-  /* ------------------------------------------- */
+  /* Pretend thread T-1 is running, and disabled, with thread_instrumentation */
+  /* ------------------------------------------------------------------------ */
 
   psi->set_thread(thread_1);
   setup_thread(thread_1, false);
@@ -564,61 +572,61 @@ void test_init_disabled()
 
   mutex_class_A->m_enabled= false;
   mutex_A1= psi->init_mutex(mutex_key_A, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 == NULL, "mutex_A1 not instrumented");
 
-  /* enabled M-A + disabled T-1: no instrumentation */
+  /* enabled M-A + disabled T-1: instrumentation (for later) */
 
   mutex_class_A->m_enabled= true;
   mutex_A1= psi->init_mutex(mutex_key_A, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 != NULL, "mutex_A1 instrumented");
 
   /* broken key + disabled T-1: no instrumentation */
 
   mutex_class_A->m_enabled= true;
   mutex_A1= psi->init_mutex(0, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 == NULL, "mutex key 0 not instrumented");
   mutex_A1= psi->init_mutex(99, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 == NULL, "broken mutex key not instrumented");
 
   /* disabled RW-A + disabled T-1: no instrumentation */
 
   rwlock_class_A->m_enabled= false;
   rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 == NULL, "rwlock_A1 not instrumented");
 
-  /* enabled RW-A + disabled T-1: no instrumentation */
+  /* enabled RW-A + disabled T-1: instrumentation (for later) */
 
   rwlock_class_A->m_enabled= true;
   rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 != NULL, "rwlock_A1 instrumented");
 
   /* broken key + disabled T-1: no instrumentation */
 
   rwlock_class_A->m_enabled= true;
   rwlock_A1= psi->init_rwlock(0, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 == NULL, "rwlock key 0 not instrumented");
   rwlock_A1= psi->init_rwlock(99, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 == NULL, "broken rwlock key not instrumented");
 
   /* disabled C-A + disabled T-1: no instrumentation */
 
   cond_class_A->m_enabled= false;
   cond_A1= psi->init_cond(cond_key_A, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 == NULL, "cond_A1 not instrumented");
 
-  /* enabled C-A + disabled T-1: no instrumentation */
+  /* enabled C-A + disabled T-1: instrumentation (for later) */
 
   cond_class_A->m_enabled= true;
   cond_A1= psi->init_cond(cond_key_A, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 != NULL, "cond_A1 instrumented");
 
   /* broken key + disabled T-1: no instrumentation */
 
   cond_class_A->m_enabled= true;
   cond_A1= psi->init_cond(0, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 == NULL, "cond key 0 not instrumented");
   cond_A1= psi->init_cond(99, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 == NULL, "broken cond key not instrumented");
 
   /* disabled F-A + disabled T-1: no instrumentation */
 
@@ -740,17 +748,17 @@ void test_init_disabled()
   file_class_A->m_enabled= true;
   psi->create_file(file_key_A, "foo-instrumented", (File) 12);
   file_A1= lookup_file_by_name("foo-instrumented");
-  ok(file_A1 != NULL, "instrumented");
+  ok(file_A1 != NULL, "file_A1 instrumented");
 
   /* broken key + enabled T-1: no instrumentation */
 
   file_class_A->m_enabled= true;
   psi->create_file(0, "foo", (File) 12);
   file_A1= lookup_file_by_name("foo");
-  ok(file_A1 == NULL, "not instrumented");
+  ok(file_A1 == NULL, "file key 0 not instrumented");
   psi->create_file(99, "foo", (File) 12);
   file_A1= lookup_file_by_name("foo");
-  ok(file_A1 == NULL, "not instrumented");
+  ok(file_A1 == NULL, "broken file key not instrumented");
 
   /* Pretend the running thread is not instrumented */
   /* ---------------------------------------------- */
@@ -761,61 +769,61 @@ void test_init_disabled()
 
   mutex_class_A->m_enabled= false;
   mutex_A1= psi->init_mutex(mutex_key_A, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 == NULL, "mutex_A1 not instrumented");
 
-  /* enabled M-A + unknown thread: no instrumentation */
+  /* enabled M-A + unknown thread: instrumentation (for later) */
 
   mutex_class_A->m_enabled= true;
   mutex_A1= psi->init_mutex(mutex_key_A, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 != NULL, "mutex_A1 instrumented");
 
   /* broken key + unknown thread: no instrumentation */
 
   mutex_class_A->m_enabled= true;
   mutex_A1= psi->init_mutex(0, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 == NULL, "mutex key 0 not instrumented");
   mutex_A1= psi->init_mutex(99, NULL);
-  ok(mutex_A1 == NULL, "not instrumented");
+  ok(mutex_A1 == NULL, "broken mutex key not instrumented");
 
   /* disabled RW-A + unknown thread: no instrumentation */
 
   rwlock_class_A->m_enabled= false;
   rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 == NULL, "rwlock_A1 not instrumented");
 
-  /* enabled RW-A + unknown thread: no instrumentation */
+  /* enabled RW-A + unknown thread: instrumentation (for later) */
 
   rwlock_class_A->m_enabled= true;
   rwlock_A1= psi->init_rwlock(rwlock_key_A, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 != NULL, "rwlock_A1 instrumented");
 
   /* broken key + unknown thread: no instrumentation */
 
   rwlock_class_A->m_enabled= true;
   rwlock_A1= psi->init_rwlock(0, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 == NULL, "rwlock key 0 not instrumented");
   rwlock_A1= psi->init_rwlock(99, NULL);
-  ok(rwlock_A1 == NULL, "not instrumented");
+  ok(rwlock_A1 == NULL, "broken rwlock key not instrumented");
 
   /* disabled C-A + unknown thread: no instrumentation */
 
   cond_class_A->m_enabled= false;
   cond_A1= psi->init_cond(cond_key_A, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 == NULL, "cond_A1 not instrumented");
 
-  /* enabled C-A + unknown thread: no instrumentation */
+  /* enabled C-A + unknown thread: instrumentation (for later) */
 
   cond_class_A->m_enabled= true;
   cond_A1= psi->init_cond(cond_key_A, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 != NULL, "cond_A1 instrumented");
 
   /* broken key + unknown thread: no instrumentation */
 
   cond_class_A->m_enabled= true;
   cond_A1= psi->init_cond(0, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 == NULL, "cond key 0 not instrumented");
   cond_A1= psi->init_cond(99, NULL);
-  ok(cond_A1 == NULL, "not instrumented");
+  ok(cond_A1 == NULL, "broken cond key not instrumented");
 
   /* disabled F-A + unknown thread: no instrumentation */
 
@@ -960,46 +968,84 @@ void test_locker_disabled()
   cond_class_A->m_enabled= true;
   file_class_A->m_enabled= true;
 
+
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
-  ok(mutex_locker == NULL, "no locker");
+  ok(mutex_locker == NULL, "no locker (T-1 disabled)");
   rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK);
-  ok(rwlock_locker == NULL, "no locker");
+  ok(rwlock_locker == NULL, "no locker (T-1 disabled)");
   cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT);
-  ok(cond_locker == NULL, "no locker");
+  ok(cond_locker == NULL, "no locker (T-1 disabled)");
   file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL);
-  ok(file_locker == NULL, "no locker");
+  ok(file_locker == NULL, "no locker (T-1 disabled)");
   file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ);
-  ok(file_locker == NULL, "no locker");
+  ok(file_locker == NULL, "no locker (T-1 disabled)");
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
-  ok(file_locker == NULL, "no locker");
+  ok(file_locker == NULL, "no locker (T-1 disabled)");
 
-  /* Pretend the consumer is disabled */
-  /* -------------------------------- */
+  /* Pretend the global consumer is disabled */
+  /* --------------------------------------- */
 
   setup_thread(thread_1, true);
-  flag_events_waits_current= false;
+  flag_global_instrumentation= false;
   mutex_class_A->m_enabled= true;
   rwlock_class_A->m_enabled= true;
   cond_class_A->m_enabled= true;
   file_class_A->m_enabled= true;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
-  ok(mutex_locker == NULL, "no locker");
+  ok(mutex_locker == NULL, "no locker (global disabled)");
   rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK);
-  ok(rwlock_locker == NULL, "no locker");
+  ok(rwlock_locker == NULL, "no locker (global disabled)");
   cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT);
-  ok(cond_locker == NULL, "no locker");
+  ok(cond_locker == NULL, "no locker (global disabled)");
   file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL);
-  ok(file_locker == NULL, "no locker");
+  ok(file_locker == NULL, "no locker (global disabled)");
   file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ);
-  ok(file_locker == NULL, "no locker");
+  ok(file_locker == NULL, "no locker (global disabled)");
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
-  ok(file_locker == NULL, "no locker");
+  ok(file_locker == NULL, "no locker (global disabled)");
+
+  /* Pretent the mode is global, counted only */
+  /* ---------------------------------------- */
+
+  setup_thread(thread_1, true);
+  flag_global_instrumentation= true;
+  flag_thread_instrumentation= false;
+  mutex_class_A->m_enabled= true;
+  mutex_class_A->m_timed= false;
+  rwlock_class_A->m_enabled= true;
+  rwlock_class_A->m_timed= false;
+  cond_class_A->m_enabled= true;
+  cond_class_A->m_timed= false;
+  file_class_A->m_enabled= true;
+  file_class_A->m_timed= false;
+
+  mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
+  ok(mutex_locker == NULL, "no locker (global counted)");
+  rwlock_locker= psi->get_thread_rwlock_locker(&rwlock_state, rwlock_A1, PSI_RWLOCK_READLOCK);
+  ok(rwlock_locker == NULL, "no locker (global counted)");
+  cond_locker= psi->get_thread_cond_locker(&cond_state, cond_A1, mutex_A1, PSI_COND_WAIT);
+  ok(cond_locker == NULL, "no locker (global counted)");
+  file_locker= psi->get_thread_file_name_locker(&file_state, file_key_A, PSI_FILE_OPEN, "xxx", NULL);
+  ok(file_locker != NULL, "locker (global counted)");
+  psi->start_file_wait(file_locker, 10, __FILE__, __LINE__);
+  psi->end_file_wait(file_locker, 10);
+  file_locker= psi->get_thread_file_stream_locker(&file_state, file_A1, PSI_FILE_READ);
+  ok(file_locker != NULL, "locker (global counted)");
+  psi->start_file_wait(file_locker, 10, __FILE__, __LINE__);
+  psi->end_file_wait(file_locker, 10);
+  file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
+  ok(file_locker != NULL, "locker (global counted)");
+  psi->start_file_wait(file_locker, 10, __FILE__, __LINE__);
+  psi->end_file_wait(file_locker, 10);
+
+  /* TODO */
 
   /* Pretend the instrument is disabled */
   /* ---------------------------------- */
 
   setup_thread(thread_1, true);
+  flag_global_instrumentation= true;
   flag_events_waits_current= true;
   mutex_class_A->m_enabled= false;
   rwlock_class_A->m_enabled= false;
@@ -1019,15 +1065,21 @@ void test_locker_disabled()
   file_locker= psi->get_thread_file_descriptor_locker(&file_state, (File) 12, PSI_FILE_READ);
   ok(file_locker == NULL, "no locker");
 
-  /* Pretend everything is enabled */
-  /* ----------------------------- */
+  /* Pretend everything is enabled and timed */
+  /* --------------------------------------- */
 
   setup_thread(thread_1, true);
+  flag_global_instrumentation= true;
+  flag_thread_instrumentation= true;
   flag_events_waits_current= true;
   mutex_class_A->m_enabled= true;
+  mutex_class_A->m_timed= true;
   rwlock_class_A->m_enabled= true;
+  rwlock_class_A->m_timed= true;
   cond_class_A->m_enabled= true;
+  cond_class_A->m_timed= true;
   file_class_A->m_enabled= true;
+  file_class_A->m_timed= true;
 
   mutex_locker= psi->get_thread_mutex_locker(&mutex_state, mutex_A1, PSI_MUTEX_LOCK);
   ok(mutex_locker != NULL, "locker");
@@ -1204,6 +1256,118 @@ void test_enabled()
 #endif
 }
 
+void test_event_name_index()
+{
+  PSI *psi;
+  PSI_bootstrap *boot;
+  PFS_global_param param;
+
+  diag("test_event_name_index");
+
+  param.m_enabled= true;
+
+  /* Per mutex info waits should be at [0..9] */
+  param.m_mutex_class_sizing= 10;
+  /* Per rwlock info waits should be at [10..29] */
+  param.m_rwlock_class_sizing= 20;
+  /* Per cond info waits should be at [30..69] */
+  param.m_cond_class_sizing= 40;
+  /* Per file info waits should be at [70..149] */
+  param.m_file_class_sizing= 80;
+  /* Per table info waits should be at [150] */
+  param.m_table_share_sizing= 160;
+
+  param.m_thread_class_sizing= 0;
+
+  param.m_mutex_sizing= 0;
+  param.m_rwlock_sizing= 0;
+  param.m_cond_sizing= 0;
+  param.m_thread_sizing= 0;
+  param.m_table_sizing= 0;
+  param.m_file_sizing= 0;
+  param.m_file_handle_sizing= 0;
+  param.m_events_waits_history_sizing= 0;
+  param.m_events_waits_history_long_sizing= 0;
+  param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
+
+  boot= initialize_performance_schema(& param);
+  ok(boot != NULL, "bootstrap");
+  psi= (PSI*) boot->get_interface(PSI_VERSION_1);
+  ok(psi != NULL, "psi");
+
+  PFS_mutex_class *mutex_class;
+  PSI_mutex_key dummy_mutex_key_1;
+  PSI_mutex_key dummy_mutex_key_2;
+  PSI_mutex_info dummy_mutexes[]=
+  {
+    { & dummy_mutex_key_1, "M-1", 0},
+    { & dummy_mutex_key_2, "M-2", 0}
+  };
+
+  psi->register_mutex("X", dummy_mutexes, 2);
+  mutex_class= find_mutex_class(dummy_mutex_key_1);
+  ok(mutex_class != NULL, "mutex class 1");
+  ok(mutex_class->m_event_name_index == 0, "index 0");
+  mutex_class= find_mutex_class(dummy_mutex_key_2);
+  ok(mutex_class != NULL, "mutex class 2");
+  ok(mutex_class->m_event_name_index == 1, "index 1");
+
+  PFS_rwlock_class *rwlock_class;
+  PSI_rwlock_key dummy_rwlock_key_1;
+  PSI_rwlock_key dummy_rwlock_key_2;
+  PSI_rwlock_info dummy_rwlocks[]=
+  {
+    { & dummy_rwlock_key_1, "RW-1", 0},
+    { & dummy_rwlock_key_2, "RW-2", 0}
+  };
+
+  psi->register_rwlock("X", dummy_rwlocks, 2);
+  rwlock_class= find_rwlock_class(dummy_rwlock_key_1);
+  ok(rwlock_class != NULL, "rwlock class 1");
+  ok(rwlock_class->m_event_name_index == 10, "index 10");
+  rwlock_class= find_rwlock_class(dummy_rwlock_key_2);
+  ok(rwlock_class != NULL, "rwlock class 2");
+  ok(rwlock_class->m_event_name_index == 11, "index 11");
+
+  PFS_cond_class *cond_class;
+  PSI_cond_key dummy_cond_key_1;
+  PSI_cond_key dummy_cond_key_2;
+  PSI_cond_info dummy_conds[]=
+  {
+    { & dummy_cond_key_1, "C-1", 0},
+    { & dummy_cond_key_2, "C-2", 0}
+  };
+
+  psi->register_cond("X", dummy_conds, 2);
+  cond_class= find_cond_class(dummy_cond_key_1);
+  ok(cond_class != NULL, "cond class 1");
+  ok(cond_class->m_event_name_index == 30, "index 30");
+  cond_class= find_cond_class(dummy_cond_key_2);
+  ok(cond_class != NULL, "cond class 2");
+  ok(cond_class->m_event_name_index == 31, "index 31");
+
+  PFS_file_class *file_class;
+  PSI_file_key dummy_file_key_1;
+  PSI_file_key dummy_file_key_2;
+  PSI_file_info dummy_files[]=
+  {
+    { & dummy_file_key_1, "F-1", 0},
+    { & dummy_file_key_2, "F-2", 0}
+  };
+
+  psi->register_file("X", dummy_files, 2);
+  file_class= find_file_class(dummy_file_key_1);
+  ok(file_class != NULL, "file class 1");
+  ok(file_class->m_event_name_index == 70, "index 70");
+  file_class= find_file_class(dummy_file_key_2);
+  ok(file_class != NULL, "file class 2");
+  ok(file_class->m_event_name_index == 71, "index 71");
+
+  ok(global_table_io_class.m_event_name_index == 150, "index 150");
+  ok(max_instrument_class= 151, "151 event names");
+}
+
 void do_all_tests()
 {
   test_bootstrap();
@@ -1211,11 +1375,12 @@ void do_all_tests()
   test_init_disabled();
   test_locker_disabled();
   test_file_instrumentation_leak();
+  test_event_name_index();
 }
 
 int main(int, char **)
 {
-  plan(153);
+  plan(179);
   MY_INIT("pfs-t");
   do_all_tests();
   return 0;

=== modified file 'storage/perfschema/unittest/pfs_instr-oom-t.cc'
--- a/storage/perfschema/unittest/pfs_instr-oom-t.cc	2010-07-23 19:03:52 +0000
+++ b/storage/perfschema/unittest/pfs_instr-oom-t.cc	2010-09-23 16:08:54 +0000
@@ -18,9 +18,11 @@
 #include <pfs_instr.h>
 #include <pfs_stat.h>
 #include <pfs_global.h>
+#include <pfs_instr_class.h>
 #include <tap.h>
 
 #include "stub_pfs_global.h"
+#include "stub_server_misc.h"
 
 void test_oom()
 {
@@ -46,7 +48,9 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (mutex)");
 
@@ -67,7 +71,9 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (rwlock)");
 
@@ -88,7 +94,9 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (cond)");
 
@@ -109,7 +117,9 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (file)");
 
@@ -130,7 +140,9 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (table)");
 
@@ -151,7 +163,9 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (thread)");
 
@@ -174,8 +188,10 @@ void test_oom()
   param.m_events_waits_history_sizing= 10;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
   stub_alloc_fails_after_count= 2;
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (thread history sizing)");
 
@@ -196,8 +212,10 @@ void test_oom()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
   stub_alloc_fails_after_count= 2;
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 1, "oom (per thread wait)");
 

=== modified file 'storage/perfschema/unittest/pfs_instr-t.cc'
--- a/storage/perfschema/unittest/pfs_instr-t.cc	2010-07-30 09:02:32 +0000
+++ b/storage/perfschema/unittest/pfs_instr-t.cc	2010-09-23 16:08:54 +0000
@@ -18,10 +18,13 @@
 #include <pfs_instr.h>
 #include <pfs_stat.h>
 #include <pfs_global.h>
+#include <pfs_instr_class.h>
 #include <tap.h>
 
 #include <memory.h>
 
+#include "stub_server_misc.h"
+
 void test_no_instruments()
 {
   int rc;
@@ -44,7 +47,9 @@ void test_no_instruments()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 0, "zero init");
 
@@ -85,7 +90,9 @@ void test_no_instances()
   param.m_events_waits_history_sizing= 0;
   param.m_events_waits_history_long_sizing= 0;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 0, "no instances init");
 
@@ -199,10 +206,17 @@ void test_with_instances()
   param.m_events_waits_history_sizing= 10;
   param.m_events_waits_history_long_sizing= 10000;
   param.m_setup_actor_sizing= 0;
+  param.m_setup_object_sizing= 0;
 
+  init_event_name_sizing(& param);
   rc= init_instruments(& param);
   ok(rc == 0, "instances init");
 
+  dummy_mutex_class.m_event_name_index= 0;
+  dummy_rwlock_class.m_event_name_index= 1;
+  dummy_cond_class.m_event_name_index= 2;
+  dummy_file_class.m_event_name_index= 3;
+
   mutex_1= create_mutex(& dummy_mutex_class, NULL);
   ok(mutex_1 != NULL, "mutex");
   ok(mutex_lost == 0, "not lost");
@@ -317,100 +331,16 @@ void test_with_instances()
   cleanup_instruments();
 }
 
-void test_per_thread_wait()
-{
-  int rc;
-  PFS_mutex_class dummy_mutex_class;
-  PFS_rwlock_class dummy_rwlock_class;
-  PFS_cond_class dummy_cond_class;
-  PFS_thread_class dummy_thread_class;
-  PFS_file_class dummy_file_class;
-  PFS_thread *thread;
-  PFS_single_stat_chain *base;
-  PFS_single_stat_chain *stat;
-  PFS_global_param param;
-
-
-  /* Per mutex info waits should be at [0..9] */
-  mutex_class_max= 10;
-  /* Per rwlock info waits should be at [10..29] */
-  rwlock_class_max= 20;
-  /* Per cond info waits should be at [30..69] */
-  cond_class_max= 40;
-  /* Per file info waits should be at [70..149] */
-  file_class_max= 80;
-  /* Per table info waits should be at [150..309] */
-  table_share_max= 160;
-
-  param.m_enabled= true;
-  param.m_mutex_class_sizing= mutex_class_max;
-  param.m_rwlock_class_sizing= rwlock_class_max;
-  param.m_cond_class_sizing= cond_class_max;
-  param.m_thread_class_sizing= 2;
-  param.m_table_share_sizing= table_share_max;
-  param.m_file_class_sizing= file_class_max;
-  param.m_mutex_sizing= 0;
-  param.m_rwlock_sizing= 0;
-  param.m_cond_sizing= 0;
-  param.m_thread_sizing= 2;
-  param.m_table_sizing= 0;
-  param.m_file_sizing= 0;
-  param.m_file_handle_sizing= 0;
-  param.m_events_waits_history_sizing= 10;
-  param.m_events_waits_history_long_sizing= 10000;
-  param.m_setup_actor_sizing= 0;
-
-  rc= init_instruments(& param);
-  ok(rc == 0, "instances init");
-
-  thread= create_thread(& dummy_thread_class, NULL, 0);
-  ok(thread != NULL, "thread");
-  ok(thread_lost == 0, "not lost");
-
-  base= & thread->m_instr_class_wait_stats[0];
-
-  dummy_mutex_class.m_index= 0;
-  stat= find_per_thread_mutex_class_wait_stat(thread, & dummy_mutex_class);
-  ok(base + 0 == stat, "fist mutex info slot at 0");
-  dummy_mutex_class.m_index= mutex_class_max - 1;
-  stat= find_per_thread_mutex_class_wait_stat(thread, & dummy_mutex_class);
-  ok(base + 9 == stat, "last mutex info slot at 9");
-
-  dummy_rwlock_class.m_index= 0;
-  stat= find_per_thread_rwlock_class_wait_stat(thread, & dummy_rwlock_class);
-  ok(base + 10 == stat, "fist rwlock info slot at 10");
-  dummy_rwlock_class.m_index= rwlock_class_max - 1;
-  stat= find_per_thread_rwlock_class_wait_stat(thread, & dummy_rwlock_class);
-  ok(base + 29 == stat, "last rwlock info slot at 29");
-
-  dummy_cond_class.m_index= 0;
-  stat= find_per_thread_cond_class_wait_stat(thread, & dummy_cond_class);
-  ok(base + 30 == stat, "fist cond info slot at 30");
-  dummy_cond_class.m_index= cond_class_max - 1;
-  stat= find_per_thread_cond_class_wait_stat(thread, & dummy_cond_class);
-  ok(base + 69 == stat, "last cond info slot at 69");
-
-  dummy_file_class.m_index= 0;
-  stat= find_per_thread_file_class_wait_stat(thread, & dummy_file_class);
-  ok(base + 70 == stat, "fist file info slot at 70");
-  dummy_file_class.m_index= file_class_max - 1;
-  stat= find_per_thread_file_class_wait_stat(thread, & dummy_file_class);
-  ok(base + 149 == stat, "last file info slot at 149");
-
-  cleanup_instruments();
-}
-
 void do_all_tests()
 {
   test_no_instruments();
   test_no_instances();
   test_with_instances();
-  test_per_thread_wait();
 }
 
 int main(int, char **)
 {
-  plan(102);
+  plan(91);
   MY_INIT("pfs_instr-t");
   do_all_tests();
   return 0;

=== modified file 'storage/perfschema/unittest/pfs_instr_class-oom-t.cc'
--- a/storage/perfschema/unittest/pfs_instr_class-oom-t.cc	2010-07-16 01:28:30 +0000
+++ b/storage/perfschema/unittest/pfs_instr_class-oom-t.cc	2010-09-23 16:08:54 +0000
@@ -20,6 +20,7 @@
 #include <tap.h>
 
 #include "stub_pfs_global.h"
+#include "stub_server_misc.h"
 
 void test_oom()
 {

=== modified file 'storage/perfschema/unittest/pfs_instr_class-t.cc'
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc	2010-07-23 17:08:41 +0000
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc	2010-09-23 16:08:54 +0000
@@ -21,6 +21,8 @@
 #include <pfs_global.h>
 #include <tap.h>
 
+#include "stub_server_misc.h"
+
 void test_no_registration()
 {
   int rc;
@@ -82,11 +84,11 @@ void test_no_registration()
   fake_thread.m_table_share_hash_pins= NULL;
 
 #ifdef LATER
-  table= find_or_create_table_share(& fake_thread, "foo_db", 6, "foo_table", 9);
+  table= find_or_create_table_share(& fake_thread, false, "foo_db", 6, "foo_table", 9);
   ok(table == NULL, "not created");
-  table= find_or_create_table_share(& fake_thread, "bar_db", 6, "bar_table", 9);
+  table= find_or_create_table_share(& fake_thread, false, "bar_db", 6, "bar_table", 9);
   ok(table == NULL, "not created");
-  table= find_or_create_table_share(& fake_thread, "foo_db", 6, "foo_table", 9);
+  table= find_or_create_table_share(& fake_thread, false, "foo_db", 6, "foo_table", 9);
   ok(table == NULL, "not created");
 #endif
 
@@ -356,7 +358,7 @@ void test_table_registration()
   fake_thread.m_table_share_hash_pins= NULL;
 
   table_share_lost= 0;
-  table_share= find_or_create_table_share(& fake_thread, "db1", 3, "t1", 2);
+  table_share= find_or_create_table_share(& fake_thread, false, "db1", 3, "t1", 2);
   ok(table_share == NULL, "not created");
   ok(table_share_lost == 1, "lost the table");
 
@@ -364,37 +366,37 @@ void test_table_registration()
   init_table_share(5);
   init_table_share_hash();
 
-  table_share= find_or_create_table_share(& fake_thread, "db1", 3, "t1", 2);
+  table_share= find_or_create_table_share(& fake_thread, false, "db1", 3, "t1", 2);
   ok(table_share != NULL, "created db1.t1");
   ok(table_share_lost == 0, "not lost");
 
-  table_share_2= find_or_create_table_share(& fake_thread, "db1", 3, "t1", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db1", 3, "t1", 2);
   ok(table_share_2 != NULL, "found db1.t1");
   ok(table_share_lost == 0, "not lost");
   ok(table_share == table_share_2, "same table");
 
-  table_share_2= find_or_create_table_share(& fake_thread, "db1", 3, "t2", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db1", 3, "t2", 2);
   ok(table_share_2 != NULL, "created db1.t2");
   ok(table_share_lost == 0, "not lost");
 
-  table_share_2= find_or_create_table_share(& fake_thread, "db2", 3, "t1", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db2", 3, "t1", 2);
   ok(table_share_2 != NULL, "created db2.t1");
   ok(table_share_lost == 0, "not lost");
 
-  table_share_2= find_or_create_table_share(& fake_thread, "db2", 3, "t2", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db2", 3, "t2", 2);
   ok(table_share_2 != NULL, "created db2.t2");
   ok(table_share_lost == 0, "not lost");
 
-  table_share_2= find_or_create_table_share(& fake_thread, "db3", 3, "t3", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db3", 3, "t3", 2);
   ok(table_share_2 != NULL, "created db3.t3");
   ok(table_share_lost == 0, "not lost");
 
-  table_share_2= find_or_create_table_share(& fake_thread, "db4", 3, "t4", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db4", 3, "t4", 2);
   ok(table_share_2 == NULL, "lost db4.t4");
   ok(table_share_lost == 1, "lost");
 
   table_share_lost= 0;
-  table_share_2= find_or_create_table_share(& fake_thread, "db1", 3, "t2", 2);
+  table_share_2= find_or_create_table_share(& fake_thread, false, "db1", 3, "t2", 2);
   ok(table_share_2 != NULL, "found db1.t2");
   ok(table_share_lost == 0, "not lost");
   ok(strncmp(table_share_2->m_schema_name, "db1", 3) == 0 , "schema db1");
@@ -407,16 +409,22 @@ void test_table_registration()
 #endif
 }
 
-void set_wait_stat(PFS_single_stat_chain *stat)
+void set_wait_stat(PFS_instr_class *klass)
 {
+  PFS_single_stat *stat;
+  stat= & global_instr_class_waits_array[klass->m_event_name_index];
+
   stat->m_count= 12;
   stat->m_min= 5;
   stat->m_max= 120;
   stat->m_sum= 999;
 }
 
-bool is_empty_stat(PFS_single_stat_chain *stat)
+bool is_empty_stat(PFS_instr_class *klass)
 {
+  PFS_single_stat *stat;
+  stat= & global_instr_class_waits_array[klass->m_event_name_index];
+
   if (stat->m_count != 0)
     return false;
   if (stat->m_min != (ulonglong) -1)
@@ -509,46 +517,48 @@ void test_instruments_reset()
   file_3= find_file_class(3);
   ok(file_3 != NULL, "file key 3");
 
-  set_wait_stat(& mutex_1->m_wait_stat);
-  set_wait_stat(& mutex_2->m_wait_stat);
-  set_wait_stat(& mutex_3->m_wait_stat);
-  set_wait_stat(& rwlock_1->m_wait_stat);
-  set_wait_stat(& rwlock_2->m_wait_stat);
-  set_wait_stat(& rwlock_3->m_wait_stat);
-  set_wait_stat(& cond_1->m_wait_stat);
-  set_wait_stat(& cond_2->m_wait_stat);
-  set_wait_stat(& cond_3->m_wait_stat);
-  set_wait_stat(& file_1->m_wait_stat);
-  set_wait_stat(& file_2->m_wait_stat);
-  set_wait_stat(& file_3->m_wait_stat);
-
-  ok(! is_empty_stat(& mutex_1->m_wait_stat), "mutex_1 stat is populated");
-  ok(! is_empty_stat(& mutex_2->m_wait_stat), "mutex_2 stat is populated");
-  ok(! is_empty_stat(& mutex_3->m_wait_stat), "mutex_3 stat is populated");
-  ok(! is_empty_stat(& rwlock_1->m_wait_stat), "rwlock_1 stat is populated");
-  ok(! is_empty_stat(& rwlock_2->m_wait_stat), "rwlock_2 stat is populated");
-  ok(! is_empty_stat(& rwlock_3->m_wait_stat), "rwlock_3 stat is populated");
-  ok(! is_empty_stat(& cond_1->m_wait_stat), "cond_1 stat is populated");
-  ok(! is_empty_stat(& cond_2->m_wait_stat), "cond_2 stat is populated");
-  ok(! is_empty_stat(& cond_3->m_wait_stat), "cond_3 stat is populated");
-  ok(! is_empty_stat(& file_1->m_wait_stat), "file_1 stat is populated");
-  ok(! is_empty_stat(& file_2->m_wait_stat), "file_2 stat is populated");
-  ok(! is_empty_stat(& file_3->m_wait_stat), "file_3 stat is populated");
-
-  reset_instrument_class_waits();
-
-  ok(is_empty_stat(& mutex_1->m_wait_stat), "mutex_1 stat is cleared");
-  ok(is_empty_stat(& mutex_2->m_wait_stat), "mutex_2 stat is cleared");
-  ok(is_empty_stat(& mutex_3->m_wait_stat), "mutex_3 stat is cleared");
-  ok(is_empty_stat(& rwlock_1->m_wait_stat), "rwlock_1 stat is cleared");
-  ok(is_empty_stat(& rwlock_2->m_wait_stat), "rwlock_2 stat is cleared");
-  ok(is_empty_stat(& rwlock_3->m_wait_stat), "rwlock_3 stat is cleared");
-  ok(is_empty_stat(& cond_1->m_wait_stat), "cond_1 stat is cleared");
-  ok(is_empty_stat(& cond_2->m_wait_stat), "cond_2 stat is cleared");
-  ok(is_empty_stat(& cond_3->m_wait_stat), "cond_3 stat is cleared");
-  ok(is_empty_stat(& file_1->m_wait_stat), "file_1 stat is cleared");
-  ok(is_empty_stat(& file_2->m_wait_stat), "file_2 stat is cleared");
-  ok(is_empty_stat(& file_3->m_wait_stat), "file_3 stat is cleared");
+#ifdef LATER
+  set_wait_stat(mutex_1);
+  set_wait_stat(mutex_2);
+  set_wait_stat(mutex_3);
+  set_wait_stat(rwlock_1);
+  set_wait_stat(rwlock_2);
+  set_wait_stat(rwlock_3);
+  set_wait_stat(cond_1);
+  set_wait_stat(cond_2);
+  set_wait_stat(cond_3);
+  set_wait_stat(file_1);
+  set_wait_stat(file_2);
+  set_wait_stat(file_3);
+
+  ok(! is_empty_stat(mutex_1), "mutex_1 stat is populated");
+  ok(! is_empty_stat(mutex_2), "mutex_2 stat is populated");
+  ok(! is_empty_stat(mutex_3), "mutex_3 stat is populated");
+  ok(! is_empty_stat(rwlock_1), "rwlock_1 stat is populated");
+  ok(! is_empty_stat(rwlock_2), "rwlock_2 stat is populated");
+  ok(! is_empty_stat(rwlock_3), "rwlock_3 stat is populated");
+  ok(! is_empty_stat(cond_1), "cond_1 stat is populated");
+  ok(! is_empty_stat(cond_2), "cond_2 stat is populated");
+  ok(! is_empty_stat(cond_3), "cond_3 stat is populated");
+  ok(! is_empty_stat(file_1), "file_1 stat is populated");
+  ok(! is_empty_stat(file_2), "file_2 stat is populated");
+  ok(! is_empty_stat(file_3), "file_3 stat is populated");
+
+  reset_global_wait_stat();
+
+  ok(is_empty_stat(mutex_1), "mutex_1 stat is cleared");
+  ok(is_empty_stat(mutex_2), "mutex_2 stat is cleared");
+  ok(is_empty_stat(mutex_3), "mutex_3 stat is cleared");
+  ok(is_empty_stat(rwlock_1), "rwlock_1 stat is cleared");
+  ok(is_empty_stat(rwlock_2), "rwlock_2 stat is cleared");
+  ok(is_empty_stat(rwlock_3), "rwlock_3 stat is cleared");
+  ok(is_empty_stat(cond_1), "cond_1 stat is cleared");
+  ok(is_empty_stat(cond_2), "cond_2 stat is cleared");
+  ok(is_empty_stat(cond_3), "cond_3 stat is cleared");
+  ok(is_empty_stat(file_1), "file_1 stat is cleared");
+  ok(is_empty_stat(file_2), "file_2 stat is cleared");
+  ok(is_empty_stat(file_3), "file_3 stat is cleared");
+#endif
 
   cleanup_sync_class();
   cleanup_file_class();
@@ -568,7 +578,7 @@ void do_all_tests()
 
 int main(int, char **)
 {
-  plan(170);
+  plan(146);
   MY_INIT("pfs_instr_info-t");
   do_all_tests();
   return 0;

=== added file 'storage/perfschema/unittest/stub_pfs_defaults.h'
--- a/storage/perfschema/unittest/stub_pfs_defaults.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/unittest/stub_pfs_defaults.h	2010-09-23 16:08:54 +0000
@@ -0,0 +1,23 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+#include <my_global.h>
+#include <pfs.h>
+#include <pfs_defaults.h>
+
+void install_default_setup(PSI_bootstrap *)
+{
+}
+

=== added file 'storage/perfschema/unittest/stub_server_misc.h'
--- a/storage/perfschema/unittest/stub_server_misc.h	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/unittest/stub_server_misc.h	2010-09-23 16:08:54 +0000
@@ -0,0 +1,22 @@
+/* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
+
+/*
+  Minimal code to be able to link a unit test.
+*/
+
+uint lower_case_table_names= 0;
+CHARSET_INFO *files_charset_info= NULL;
+


Attachment: [text/bzr-bundle] bzr/chris.powers@oracle.com-20101202184244-srjkjm163kgfrjun.bundle
Thread
bzr push into mysql-trunk-wl4896 branch (chris.powers:3207 to 3208) Christopher Powers2 Dec