3142 Marc Alff 2010-05-05
WL#4895 PERFORMANCE SCHEMA Instrument Table IO
Port in progress
added:
include/mysql/psi/mysql_table.h
modified:
include/Makefile.am
include/mysql/psi/psi.h
mysql-test/include/mtr_check.sql
mysql-test/suite/perfschema/include/start_server_common.inc
mysql-test/suite/perfschema/r/dml_events_waits_current.result
mysql-test/suite/perfschema/r/dml_events_waits_history.result
mysql-test/suite/perfschema/r/dml_events_waits_history_long.result
mysql-test/suite/perfschema/r/func_file_io.result
mysql-test/suite/perfschema/r/func_mutex.result
mysql-test/suite/perfschema/r/myisam_file_io.result
mysql-test/suite/perfschema/r/no_threads.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_thread_class.result
mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
mysql-test/suite/perfschema/r/start_server_off.result
mysql-test/suite/perfschema/r/start_server_on.result
mysql-test/suite/perfschema/t/dml_events_waits_current.test
mysql-test/suite/perfschema/t/dml_events_waits_history.test
mysql-test/suite/perfschema/t/dml_events_waits_history_long.test
mysql-test/suite/perfschema/t/func_file_io.test
mysql-test/suite/perfschema/t/func_mutex.test
mysql-test/suite/perfschema/t/myisam_file_io.test
mysql-test/suite/perfschema/t/no_threads.test
mysys/thr_lock.c
sql/event_db_repository.cc
sql/filesort.cc
sql/ha_partition.cc
sql/handler.cc
sql/handler.h
sql/item_subselect.cc
sql/log_event.cc
sql/log_event_old.cc
sql/opt_range.cc
sql/opt_sum.cc
sql/records.cc
sql/sp.cc
sql/sql_acl.cc
sql/sql_base.cc
sql/sql_cursor.cc
sql/sql_handler.cc
sql/sql_help.cc
sql/sql_insert.cc
sql/sql_partition.cc
sql/sql_plugin.cc
sql/sql_select.cc
sql/sql_servers.cc
sql/sql_show.cc
sql/sql_table.cc
sql/sql_udf.cc
sql/sql_update.cc
sql/table.cc
sql/tztime.cc
storage/perfschema/ha_perfschema.cc
storage/perfschema/pfs.cc
storage/perfschema/pfs_column_types.h
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/table_events_waits.cc
storage/perfschema/table_events_waits.h
storage/perfschema/table_setup_instruments.cc
storage/perfschema/table_setup_instruments.h
storage/perfschema/table_setup_objects.cc
storage/perfschema/unittest/pfs_instr-t.cc
storage/perfschema/unittest/pfs_instr_class-t.cc
3141 Marc Alff 2010-04-28 [merge]
merge from mysql-next-mr
removed:
sql/mysql_priv.h.pp
strings/dtoa.c
added:
include/sha2.h
mysql-test/include/have_archive_plugin.inc
mysql-test/include/have_blackhole_plugin.inc
mysql-test/include/have_ssl_crypto_functs.inc
mysql-test/r/archive_plugin.result
mysql-test/r/blackhole_plugin.result
mysql-test/r/func_digest.result
mysql-test/r/have_ssl_is_yes_or_disabled_only.require
mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result
mysql-test/suite/rpl/r/rpl_non_direct_row_mixing_engines.result
mysql-test/suite/rpl/r/rpl_non_direct_stm_mixing_engines.result
mysql-test/suite/rpl/r/rpl_temp_temporary.result
mysql-test/suite/rpl/t/rpl_non_direct_mixed_mixing_engines.test
mysql-test/suite/rpl/t/rpl_non_direct_row_mixing_engines.test
mysql-test/suite/rpl/t/rpl_non_direct_stm_mixing_engines.test
mysql-test/suite/rpl/t/rpl_temp_temporary.test
mysql-test/t/archive_plugin-master.opt
mysql-test/t/archive_plugin.test
mysql-test/t/blackhole_plugin-master.opt
mysql-test/t/blackhole_plugin.test
mysql-test/t/func_digest.test
sql/sha2.cc
strings/dtoa.c
modified:
.bzrignore
BUILD/choose_configure.sh
Makefile.am
client/mysql.cc
client/mysqltest.cc
cmake/abi_check.cmake
cmake/install_macros.cmake
cmake/libutils.cmake
cmake/mysql_add_executable.cmake
cmake/mysql_version.cmake
cmake/os/WindowsCache.cmake
cmake/plugin.cmake
configure.cmake
dbug/dbug.c
include/Makefile.am
include/my_global.h
include/mysql/innodb_priv.h
include/mysql/plugin_audit.h
include/mysql_embed.h
include/sslopt-case.h
include/sslopt-longopts.h
include/sslopt-vars.h
include/violite.h
libmysqld/CMakeLists.txt
libmysqld/Makefile.am
libmysqld/examples/Makefile.am
libmysqld/lib_sql.cc
mysql-test/collections/default.experimental
mysql-test/extra/rpl_tests/rpl_binlog_max_cache_size.test
mysql-test/extra/rpl_tests/rpl_implicit_commit_binlog.test
mysql-test/extra/rpl_tests/rpl_innodb.test
mysql-test/extra/rpl_tests/rpl_loaddata.test
mysql-test/extra/rpl_tests/rpl_mixing_engines.test
mysql-test/include/commit.inc
mysql-test/include/ctype_utf8_table.inc
mysql-test/r/commit_1innodb.result
mysql-test/r/count_distinct.result
mysql-test/r/ctype_cp932_binlog_stm.result
mysql-test/r/func_encrypt_nossl.result
mysql-test/r/func_group.result
mysql-test/r/func_misc.result
mysql-test/r/grant.result
mysql-test/r/innodb_mysql_sync.result
mysql-test/r/insert_notembedded.result
mysql-test/r/lock_sync.result
mysql-test/r/myisam.result
mysql-test/r/mysqldump.result
mysql-test/r/show_check.result
mysql-test/r/sp-lock.result
mysql-test/r/sp.result
mysql-test/r/sp_sync.result
mysql-test/r/trigger_notembedded.result
mysql-test/suite/binlog/r/binlog_database.result
mysql-test/suite/binlog/r/binlog_innodb_row.result
mysql-test/suite/binlog/r/binlog_multi_engine.result
mysql-test/suite/binlog/r/binlog_row_binlog.result
mysql-test/suite/binlog/r/binlog_row_drop_tmp_tbl.result
mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
mysql-test/suite/binlog/r/binlog_stm_binlog.result
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
mysql-test/suite/binlog/r/binlog_switch_inside_trans.result
mysql-test/suite/binlog/t/binlog_switch_inside_trans.test
mysql-test/suite/binlog/t/binlog_tmp_table.test
mysql-test/suite/ndb/r/ndb_binlog_format.result
mysql-test/suite/perfschema/r/dml_cond_instances.result
mysql-test/suite/perfschema/r/dml_events_waits_current.result
mysql-test/suite/perfschema/r/dml_events_waits_history.result
mysql-test/suite/perfschema/r/dml_events_waits_history_long.result
mysql-test/suite/perfschema/r/dml_ews_by_event_name.result
mysql-test/suite/perfschema/r/dml_ews_by_instance.result
mysql-test/suite/perfschema/r/dml_ews_by_thread_by_event_name.result
mysql-test/suite/perfschema/r/dml_file_instances.result
mysql-test/suite/perfschema/r/dml_file_summary_by_event_name.result
mysql-test/suite/perfschema/r/dml_file_summary_by_instance.result
mysql-test/suite/perfschema/r/dml_mutex_instances.result
mysql-test/suite/perfschema/r/dml_performance_timers.result
mysql-test/suite/perfschema/r/dml_processlist.result
mysql-test/suite/perfschema/r/dml_rwlock_instances.result
mysql-test/suite/perfschema/r/misc.result
mysql-test/suite/perfschema/r/pfs_upgrade.result
mysql-test/suite/perfschema/r/privilege.result
mysql-test/suite/perfschema/r/tampered_perfschema_table1.result
mysql-test/suite/perfschema/t/misc.test
mysql-test/suite/perfschema/t/tampered_perfschema_table1.test
mysql-test/suite/rpl/r/rpl_concurrency_error.result
mysql-test/suite/rpl/r/rpl_mixed_binlog_max_cache_size.result
mysql-test/suite/rpl/r/rpl_mixed_implicit_commit_binlog.result
mysql-test/suite/rpl/r/rpl_mixed_mixing_engines.result
mysql-test/suite/rpl/r/rpl_mixed_row_innodb.result
mysql-test/suite/rpl/r/rpl_row_drop.result
mysql-test/suite/rpl/r/rpl_row_implicit_commit_binlog.result
mysql-test/suite/rpl/r/rpl_row_mixing_engines.result
mysql-test/suite/rpl/r/rpl_sp.result
mysql-test/suite/rpl/r/rpl_stm_binlog_max_cache_size.result
mysql-test/suite/rpl/r/rpl_stm_implicit_commit_binlog.result
mysql-test/suite/rpl/r/rpl_stm_innodb.result
mysql-test/suite/rpl/r/rpl_stm_mixing_engines.result
mysql-test/suite/rpl/r/rpl_stm_stop_middle_group.result
mysql-test/suite/rpl/t/rpl000013.test
mysql-test/suite/rpl/t/rpl_misc_functions.test
mysql-test/suite/rpl/t/rpl_semi_sync.test
mysql-test/suite/rpl/t/rpl_sp.test
mysql-test/suite/rpl/t/rpl_ssl.test
mysql-test/suite/rpl/t/rpl_ssl1.test
mysql-test/suite/rpl/t/rpl_temp_table.test
mysql-test/suite/rpl/t/rpl_temporary.test
mysql-test/suite/rpl_ndb/r/rpl_ndb_mixed_engines_transactions.result
mysql-test/suite/rpl_ndb/r/rpl_ndb_row_implicit_commit_binlog.result
mysql-test/suite/rpl_ndb/r/rpl_truncate_7ndb.result
mysql-test/suite/rpl_ndb/t/rpl_ndb_mixed_engines_transactions.test
mysql-test/suite/rpl_ndb/t/rpl_truncate_7ndb.test
mysql-test/suite/sys_vars/r/large_files_support_basic.result
mysql-test/t/count_distinct.test
mysql-test/t/create_select_tmp.test
mysql-test/t/ctype_cp932_binlog_stm.test
mysql-test/t/disabled.def
mysql-test/t/events_1.test
mysql-test/t/func_des_encrypt.test
mysql-test/t/func_encrypt.test
mysql-test/t/func_group.test
mysql-test/t/func_misc.test
mysql-test/t/innodb_mysql_sync.test
mysql-test/t/lock_sync.test
mysql-test/t/myisam.test
mysql-test/t/mysqlbinlog.test
mysql-test/t/openssl_1.test
mysql-test/t/show_check.test
mysql-test/t/sp-destruct.test
mysql-test/t/sp-lock.test
mysql-test/t/sp.test
mysql-test/t/sp_sync.test
mysql-test/t/ssl-big.test
mysql-test/t/ssl.test
mysql-test/t/ssl_8k_key.test
mysql-test/t/ssl_compress.test
mysql-test/t/ssl_connect.test
mysys/typelib.c
plugin/audit_null/audit_null.c
scripts/CMakeLists.txt
scripts/make_win_bin_dist
scripts/mysql_system_tables.sql
scripts/mysql_system_tables_fix.sql
sql-common/client.c
sql/CMakeLists.txt
sql/Makefile.am
sql/event_db_repository.cc
sql/event_scheduler.cc
sql/handler.cc
sql/item.cc
sql/item.h
sql/item_create.cc
sql/item_strfunc.cc
sql/item_strfunc.h
sql/item_sum.cc
sql/item_sum.h
sql/log.cc
sql/log.h
sql/log_event.cc
sql/log_event_old.cc
sql/mdl.h
sql/mysqld.cc
sql/share/errmsg-utf8.txt
sql/sp.cc
sql/sp_head.cc
sql/sql_acl.cc
sql/sql_audit.cc
sql/sql_base.cc
sql/sql_class.cc
sql/sql_class.h
sql/sql_connect.cc
sql/sql_lex.cc
sql/sql_lex.h
sql/sql_parse.cc
sql/sql_priv.h
sql/sql_select.cc
sql/sql_show.cc
sql/sql_string.cc
sql/sql_string.h
sql/sql_table.cc
sql/sql_update.cc
sql/sql_yacc.yy
sql/sys_vars.cc
sql/table.cc
storage/archive/Makefile.am
storage/archive/azlib.h
storage/blackhole/Makefile.am
storage/example/Makefile.am
storage/innobase/handler/ha_innodb.cc
storage/innobase/handler/i_s.cc
storage/innobase/trx/trx0i_s.c
storage/myisam/ha_myisam.h
storage/perfschema/CMakeLists.txt
storage/perfschema/Makefile.am
storage/perfschema/ha_perfschema.cc
storage/perfschema/ha_perfschema.h
storage/perfschema/pfs.cc
storage/perfschema/pfs.h
storage/perfschema/pfs_atomic.cc
storage/perfschema/pfs_atomic.h
storage/perfschema/pfs_check.cc
storage/perfschema/pfs_column_types.h
storage/perfschema/pfs_column_values.cc
storage/perfschema/pfs_column_values.h
storage/perfschema/pfs_engine_table.cc
storage/perfschema/pfs_engine_table.h
storage/perfschema/pfs_events_waits.cc
storage/perfschema/pfs_events_waits.h
storage/perfschema/pfs_global.cc
storage/perfschema/pfs_global.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_lock.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/plug.in
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_file_instances.cc
storage/perfschema/table_file_instances.h
storage/perfschema/table_file_summary.cc
storage/perfschema/table_file_summary.h
storage/perfschema/table_performance_timers.cc
storage/perfschema/table_performance_timers.h
storage/perfschema/table_processlist.cc
storage/perfschema/table_processlist.h
storage/perfschema/table_setup_consumers.cc
storage/perfschema/table_setup_consumers.h
storage/perfschema/table_setup_instruments.cc
storage/perfschema/table_setup_instruments.h
storage/perfschema/table_setup_objects.cc
storage/perfschema/table_setup_objects.h
storage/perfschema/table_setup_timers.cc
storage/perfschema/table_setup_timers.h
storage/perfschema/table_sync_instances.cc
storage/perfschema/table_sync_instances.h
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
support-files/mysql.spec.sh
=== modified file 'include/Makefile.am'
--- a/include/Makefile.am 2010-04-13 15:04:45 +0000
+++ b/include/Makefile.am 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2000-2006 MySQL AB, 2009 Sun Microsystems, Inc
+# Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
@@ -27,6 +27,7 @@ pkginclude_HEADERS = $(HEADERS_ABI) my_d
my_pthread.h my_no_pthread.h \
mysql/psi/psi.h mysql/psi/mysql_thread.h \
mysql/psi/mysql_file.h \
+ mysql/psi/mysql_table.h \
decimal.h errmsg.h my_global.h my_net.h \
my_getopt.h sslopt-longopts.h my_dir.h \
sslopt-vars.h sslopt-case.h sql_common.h keycache.h \
=== added file 'include/mysql/psi/mysql_table.h'
--- a/include/mysql/psi/mysql_table.h 1970-01-01 00:00:00 +0000
+++ b/include/mysql/psi/mysql_table.h 2010-05-05 08:16:47 +0000
@@ -0,0 +1,75 @@
+/* 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 MYSQL_TABLE_H
+#define MYSQL_TABLE_H
+
+/**
+ @file mysql/psi/mysql_table.h
+ Instrumentation helpers for table io.
+*/
+
+#include "mysql/psi/psi.h"
+
+/**
+ @defgroup Table_instrumentation Table Instrumentation
+ @ingroup Instrumentation_interface
+ @{
+*/
+
+#ifdef HAVE_PSI_INTERFACE
+ #define MYSQL_START_TABLE_WAIT(PSI, OP, INDEX, FLAGS) \
+ inline_mysql_start_table_wait(PSI, OP, INDEX, FLAGS, __FILE__, __LINE__)
+#else
+ #define MYSQL_START_TABLE_WAIT(PSI, OP, INDEX, FLAGS) \
+ NULL
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+ #define MYSQL_END_TABLE_WAIT(L) \
+ inline_mysql_end_table_wait(L)
+#else
+ #define MYSQL_END_TABLE_WAIT(L) \
+ do {} while (0)
+#endif
+
+#ifdef HAVE_PSI_INTERFACE
+static inline struct PSI_table_locker *
+inline_mysql_start_table_wait(struct PSI_table *psi, enum PSI_table_operation op,
+ uint index, ulong flags,
+ const char *src_file, int src_line)
+{
+ struct PSI_table_locker *locker= NULL;
+ if (likely(PSI_server && psi))
+ {
+ locker= PSI_server->get_thread_table_locker(psi, op, flags);
+ if (likely(locker != NULL))
+ PSI_server->start_table_wait(locker, index, src_file, src_line);
+ }
+ return locker;
+}
+
+static inline void
+inline_mysql_end_table_wait(struct PSI_table_locker *locker)
+{
+ if (likely(locker != NULL))
+ PSI_server->end_table_wait(locker);
+}
+#endif
+
+/** @} (end of group Table_instrumentation) */
+
+#endif
+
=== modified file 'include/mysql/psi/psi.h'
--- a/include/mysql/psi/psi.h 2010-01-26 23:42:54 +0000
+++ b/include/mysql/psi/psi.h 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2010 Sun Microsystems, Inc
+/* 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
@@ -29,6 +29,8 @@
C_MODE_START
+struct TABLE_SHARE;
+
/**
@file mysql/psi/psi.h
Performance schema instrumentation interface.
@@ -80,6 +82,12 @@ struct PSI_thread;
*/
struct PSI_file;
+/**
+ Interface for an instrumented table operation.
+ This is an opaque structure.
+*/
+struct PSI_table_locker;
+
/** Entry point for the performance schema interface. */
struct PSI_bootstrap
{
@@ -229,11 +237,16 @@ enum PSI_file_operation
PSI_FILE_SYNC= 16
};
-/**
- Interface for an instrumented table operation.
- This is an opaque structure.
-*/
-struct PSI_table_locker;
+/** Operation performed on an instrumented table. */
+enum PSI_table_operation
+{
+ PSI_TABLE_LOCK= 0,
+ PSI_TABLE_EXTERNAL_LOCK= 1,
+ PSI_TABLE_FETCH_ROW= 2,
+ PSI_TABLE_WRITE_ROW= 3,
+ PSI_TABLE_UPDATE_ROW= 4,
+ PSI_TABLE_DELETE_ROW= 5
+};
/**
Instrumented mutex key.
@@ -515,17 +528,13 @@ typedef struct PSI_cond* (*init_cond_v1_
typedef void (*destroy_cond_v1_t)(struct PSI_cond *cond);
/**
- Acquire a table info by name.
- @param schema_name name of the table schema
- @param schema_name_length length of schema_name
- @param table_name name of the table
- @param table_name_length length of table_name
- @param identity table identity pointer, typically the table share
- @return a table info, or NULL if the table is not instrumented
+ Acquire a table share instrumentation.
+ @param temporary True for temporary tables
+ @param share The SQL layer table share
+ @return a table share instrumentation, or NULL
*/
typedef struct PSI_table_share* (*get_table_share_v1_t)
- (const char *schema_name, int schema_name_length, const char *table_name,
- int table_name_length, const void *identity);
+ (my_bool temporary, struct TABLE_SHARE *share);
/**
Release a table share.
@@ -533,6 +542,10 @@ typedef struct PSI_table_share* (*get_ta
*/
typedef void (*release_table_share_v1_t)(struct PSI_table_share *share);
+typedef void (*drop_table_share_v1_t)
+ (const char *schema_name, int schema_name_length,
+ const char *table_name, int table_name_length);
+
/**
Open an instrumentation table handle.
@param share the table to open
@@ -646,10 +659,12 @@ typedef struct PSI_cond_locker* (*get_th
/**
Get a table instrumentation locker.
@param table the instrumented table to lock
+ @param op the operation to be performed
+ @param flags Per operation flags
@return a table locker, or NULL
*/
typedef struct PSI_table_locker* (*get_thread_table_locker_v1_t)
- (struct PSI_table *table);
+ (struct PSI_table *table, enum PSI_table_operation op, ulong flags);
/**
Get a file instrumentation locker, for opening or creating a file.
@@ -779,11 +794,12 @@ typedef void (*end_cond_wait_v1_t)
/**
Record a table instrumentation wait start event.
@param locker a table locker for the running thread
+ @param index the index used if any, or MAX_KEY
@param file the source file name
@param line the source line number
*/
typedef void (*start_table_wait_v1_t)
- (struct PSI_table_locker *locker, const char *src_file, uint src_line);
+ (struct PSI_table_locker *locker, uint index, const char *src_file, uint src_line);
/**
Record a table instrumentation wait end event.
@@ -875,6 +891,8 @@ struct PSI_v1
get_table_share_v1_t get_table_share;
/** @sa release_table_share_v1_t. */
release_table_share_v1_t release_table_share;
+ /** @sa drop_table_share_v1_t. */
+ drop_table_share_v1_t drop_table_share;
/** @sa open_table_v1_t. */
open_table_v1_t open_table;
/** @sa close_table_v1_t. */
=== modified file 'mysql-test/include/mtr_check.sql'
--- a/mysql-test/include/mtr_check.sql 2009-03-31 13:39:40 +0000
+++ b/mysql-test/include/mtr_check.sql 2010-05-05 08:16:47 +0000
@@ -1,7 +1,52 @@
+# 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
delimiter ||;
use mtr||
+CREATE DEFINER=root@localhost PROCEDURE check_testcase_perfschema()
+BEGIN
+ -- For tests tampering with performance_schema table structure
+ DECLARE CONTINUE HANDLER for SQLEXCEPTION
+ BEGIN
+ END;
+
+ -- Leave the instruments in the same state
+ SELECT * from performance_schema.SETUP_INSTRUMENTS
+ where enabled='NO' order by NAME;
+
+ -- Leave the consumers in the same state
+ SELECT * from performance_schema.SETUP_CONSUMERS
+ order by NAME;
+
+ -- Leave the actors setup in the same state
+ SELECT * from performance_schema.SETUP_ACTORS
+ order by USER, HOST;
+
+ -- Leave the objects setup in the same state
+ SELECT * from performance_schema.SETUP_OBJECTS
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+ -- Leave the core objects in the same state
+ SELECT * from performance_schema.OBJECTS
+ where enabled='YES' and OBJECT_SCHEMA in ('performance_schema', 'mysql')
+ order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME;
+
+END||
+
--
-- Procedure used to check if server has been properly
-- restored after testcase has been run
@@ -9,6 +54,8 @@ use mtr||
CREATE DEFINER=root@localhost PROCEDURE check_testcase()
BEGIN
+ CALL check_testcase_perfschema();
+
-- Dump all global variables except those
-- that are supposed to change
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
=== modified file 'mysql-test/suite/perfschema/include/start_server_common.inc'
--- a/mysql-test/suite/perfschema/include/start_server_common.inc 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/include/start_server_common.inc 2010-05-05 08:16:47 +0000
@@ -19,7 +19,8 @@ show databases;
select count(*) from performance_schema.PERFORMANCE_TIMERS;
select count(*) from performance_schema.SETUP_CONSUMERS;
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
+# wait/io/table/sql/handler is a native instrument
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
select count(*) from performance_schema.SETUP_TIMERS;
# Make sure we don't crash, no matter what the starting parameters are
=== modified file 'mysql-test/suite/perfschema/r/dml_events_waits_current.result'
--- a/mysql-test/suite/perfschema/r/dml_events_waits_current.result 2010-03-18 15:35:06 +0000
+++ b/mysql-test/suite/perfschema/r/dml_events_waits_current.result 2010-05-05 08:16:47 +0000
@@ -1,10 +1,7 @@
select * from performance_schema.EVENTS_WAITS_CURRENT
where event_name like 'Wait/Synch/%' limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.EVENTS_WAITS_CURRENT
where event_name='FOO';
-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
insert into performance_schema.EVENTS_WAITS_CURRENT
set thread_id='1', event_id=1,
event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
=== modified file 'mysql-test/suite/perfschema/r/dml_events_waits_history.result'
--- a/mysql-test/suite/perfschema/r/dml_events_waits_history.result 2010-03-18 15:35:06 +0000
+++ b/mysql-test/suite/perfschema/r/dml_events_waits_history.result 2010-05-05 08:16:47 +0000
@@ -1,18 +1,11 @@
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name like 'Wait/Synch/%' limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name='FOO';
-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
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
insert into performance_schema.EVENTS_WAITS_HISTORY
set thread_id='1', event_id=1,
event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
=== modified file 'mysql-test/suite/perfschema/r/dml_events_waits_history_long.result'
--- a/mysql-test/suite/perfschema/r/dml_events_waits_history_long.result 2010-03-18 15:35:06 +0000
+++ b/mysql-test/suite/perfschema/r/dml_events_waits_history_long.result 2010-05-05 08:16:47 +0000
@@ -1,18 +1,11 @@
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name like 'Wait/Synch/%' limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name='FOO';
-THREAD_ID EVENT_ID EVENT_NAME SOURCE TIMER_START TIMER_END TIMER_WAIT SPINS OBJECT_SCHEMA OBJECT_NAME OBJECT_TYPE OBJECT_INSTANCE_BEGIN NESTING_EVENT_ID OPERATION NUMBER_OF_BYTES FLAGS
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
-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
-# # # # # # # # NULL NULL NULL # NULL # NULL 0
insert into performance_schema.EVENTS_WAITS_HISTORY_LONG
set thread_id='1', event_id=1,
event_name='FOO', timer_start=1, timer_end=2, timer_wait=3;
=== modified file 'mysql-test/suite/perfschema/r/func_file_io.result'
--- a/mysql-test/suite/perfschema/r/func_file_io.result 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/func_file_io.result 2010-05-05 08:16:47 +0000
@@ -115,3 +115,4 @@ LEFT JOIN information_schema.PROCESSLIST
GROUP BY i.user, h.operation
HAVING BYTES > 0
ORDER BY i.user, h.operation;
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'YES', timed = 'YES';
=== modified file 'mysql-test/suite/perfschema/r/func_mutex.result'
--- a/mysql-test/suite/perfschema/r/func_mutex.result 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/func_mutex.result 2010-05-05 08:16:47 +0000
@@ -111,3 +111,4 @@ SELECT IF((COALESCE(@after_count, 0) - C
test_fm2_rw_timed
Success
DROP TABLE t1;
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'YES', timed = 'YES';
=== modified file 'mysql-test/suite/perfschema/r/myisam_file_io.result'
--- a/mysql-test/suite/perfschema/r/myisam_file_io.result 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/myisam_file_io.result 2010-05-05 08:16:47 +0000
@@ -14,7 +14,8 @@ left(source, locate(":", source)) as sho
operation, number_of_bytes,
substring(object_name, locate("no_index_tab", object_name)) as short_name
from performance_schema.EVENTS_WAITS_HISTORY_LONG
-where operation not like "tell"
+where event_name like 'wait/io/file/%'
+ and operation not like "tell"
order by thread_id, event_id;
event_name short_source operation number_of_bytes short_name
wait/io/file/myisam/kfile mi_create.c: create NULL no_index_tab.MYI
=== modified file 'mysql-test/suite/perfschema/r/no_threads.result'
--- a/mysql-test/suite/perfschema/r/no_threads.result 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/no_threads.result 2010-05-05 08:16:47 +0000
@@ -40,4 +40,5 @@ left(source, locate(":", source)) as sho
from performance_schema.EVENTS_WAITS_HISTORY_LONG;
event_name operation short_source
wait/synch/mutex/mysys/THR_LOCK_myisam lock mi_create.c:
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES';
drop table test.t1;
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== 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-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
0
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result 2010-05-05 08:16:47 +0000
@@ -11,8 +11,8 @@ count(*)
select count(*) from performance_schema.SETUP_CONSUMERS;
count(*)
8
-select count(*) > 0 from performance_schema.SETUP_INSTRUMENTS;
-count(*) > 0
+select count(*) > 1 from performance_schema.SETUP_INSTRUMENTS;
+count(*) > 1
1
select count(*) from performance_schema.SETUP_TIMERS;
count(*)
=== modified file 'mysql-test/suite/perfschema/t/dml_events_waits_current.test'
--- a/mysql-test/suite/perfschema/t/dml_events_waits_current.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_current.test 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# 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
@@ -18,12 +18,13 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
+--disable_result_log
select * from performance_schema.EVENTS_WAITS_CURRENT
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.EVENTS_WAITS_CURRENT
where event_name='FOO';
+--enable_result_log
--replace_result '\'events_waits_current' '\'EVENTS_WAITS_CURRENT'
--error ER_TABLEACCESS_DENIED_ERROR
=== modified file 'mysql-test/suite/perfschema/t/dml_events_waits_history.test'
--- a/mysql-test/suite/perfschema/t/dml_events_waits_history.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_history.test 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# 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
@@ -18,20 +18,19 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
+--disable_result_log
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name='FOO';
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.EVENTS_WAITS_HISTORY
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
+--enable_result_log
--replace_result '\'events_waits_history' '\'EVENTS_WAITS_HISTORY'
--error ER_TABLEACCESS_DENIED_ERROR
=== modified file 'mysql-test/suite/perfschema/t/dml_events_waits_history_long.test'
--- a/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/dml_events_waits_history_long.test 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# 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
@@ -18,20 +18,19 @@
--source include/not_embedded.inc
--source include/have_perfschema.inc
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
+--disable_result_log
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name like 'Wait/Synch/%' limit 1;
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name='FOO';
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name like 'Wait/Synch/%' order by timer_wait limit 1;
---replace_column 1 # 2 # 3 # 4 # 5 # 6 # 7 # 8 # 12 # 14 #
select * from performance_schema.EVENTS_WAITS_HISTORY_LONG
where event_name like 'Wait/Synch/%' order by timer_wait desc limit 1;
+--enable_result_log
--replace_result '\'events_waits_history_long' '\'EVENTS_WAITS_HISTORY_LONG'
--error ER_TABLEACCESS_DENIED_ERROR
=== modified file 'mysql-test/suite/perfschema/t/func_file_io.test'
--- a/mysql-test/suite/perfschema/t/func_file_io.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/func_file_io.test 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# 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
@@ -190,3 +190,5 @@ GROUP BY i.user, h.operation
HAVING BYTES > 0
ORDER BY i.user, h.operation;
--enable_result_log
+
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'YES', timed = 'YES';
=== modified file 'mysql-test/suite/perfschema/t/func_mutex.test'
--- a/mysql-test/suite/perfschema/t/func_mutex.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/func_mutex.test 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2008-2009 Sun Microsystems, Inc
+# 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
@@ -129,3 +129,6 @@ SET @after_count = (SELECT SUM(TIMER_WAI
SELECT IF((COALESCE(@after_count, 0) - COALESCE(@before_count, 0)) = 0, 'Success', 'Failure') test_fm2_rw_timed;
DROP TABLE t1;
+
+UPDATE performance_schema.SETUP_INSTRUMENTS SET enabled = 'YES', timed = 'YES';
+
=== modified file 'mysql-test/suite/perfschema/t/myisam_file_io.test'
--- a/mysql-test/suite/perfschema/t/myisam_file_io.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/myisam_file_io.test 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009 Sun Microsystems, Inc
+# 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
@@ -49,7 +49,8 @@ select event_name,
operation, number_of_bytes,
substring(object_name, locate("no_index_tab", object_name)) as short_name
from performance_schema.EVENTS_WAITS_HISTORY_LONG
- where operation not like "tell"
+ where event_name like 'wait/io/file/%'
+ and operation not like "tell"
order by thread_id, event_id;
# In case of failures, this will tell if file io are lost.
=== modified file 'mysql-test/suite/perfschema/t/no_threads.test'
--- a/mysql-test/suite/perfschema/t/no_threads.test 2010-01-12 01:47:27 +0000
+++ b/mysql-test/suite/perfschema/t/no_threads.test 2010-05-05 08:16:47 +0000
@@ -65,5 +65,7 @@ select event_name, operation,
# Cleanup
+update performance_schema.SETUP_INSTRUMENTS set enabled='YES';
+
drop table test.t1;
=== modified file 'mysys/thr_lock.c'
--- a/mysys/thr_lock.c 2010-02-15 12:11:20 +0000
+++ b/mysys/thr_lock.c 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 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
@@ -78,6 +78,7 @@ multiple read locks.
#ifdef THREAD
#include "thr_lock.h"
+#include "mysql/psi/mysql_table.h"
#include <m_string.h>
#include <errno.h>
@@ -517,12 +518,16 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_O
enum enum_thr_lock_result result= THR_LOCK_SUCCESS;
struct st_lock_list *wait_queue;
THR_LOCK_DATA *lock_owner;
+ struct PSI_table_locker *locker;
DBUG_ENTER("thr_lock");
data->next=0;
data->cond=0; /* safety */
data->type=lock_type;
data->owner= owner; /* Must be reset ! */
+
+ locker= MYSQL_START_TABLE_WAIT(data->m_psi, PSI_TABLE_LOCK, 0, lock_type);
+
mysql_mutex_lock(&lock->mutex);
DBUG_PRINT("lock",("data: 0x%lx thread: 0x%lx lock: 0x%lx type: %d",
(long) data, data->owner->info->thread_id,
@@ -776,9 +781,12 @@ thr_lock(THR_LOCK_DATA *data, THR_LOCK_O
goto end;
}
/* Can't get lock yet; Wait for it */
- DBUG_RETURN(wait_for_lock(wait_queue, data, 0, lock_wait_timeout));
+ result= wait_for_lock(wait_queue, data, 0, lock_wait_timeout);
+ MYSQL_END_TABLE_WAIT(locker);
+ DBUG_RETURN(result);
end:
mysql_mutex_unlock(&lock->mutex);
+ MYSQL_END_TABLE_WAIT(locker);
DBUG_RETURN(result);
}
=== modified file 'sql/event_db_repository.cc'
--- a/sql/event_db_repository.cc 2010-04-16 14:24:06 +0000
+++ b/sql/event_db_repository.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2004-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2004, 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
@@ -432,17 +432,17 @@ Event_db_repository::index_read_for_db_f
}
key_copy(key_buf, event_table->record[0], key_info, key_len);
- if (!(ret= event_table->file->index_read_map(event_table->record[0], key_buf,
- (key_part_map)1,
- HA_READ_PREFIX)))
+ if (!(ret= event_table->file->ha_index_read_map(event_table->record[0], key_buf,
+ (key_part_map)1,
+ HA_READ_PREFIX)))
{
DBUG_PRINT("info",("Found rows. Let's retrieve them. ret=%d", ret));
do
{
ret= copy_event_to_schema_table(thd, schema_table, event_table);
if (ret == 0)
- ret= event_table->file->index_next_same(event_table->record[0],
- key_buf, key_len);
+ ret= event_table->file->ha_index_next_same(event_table->record[0],
+ key_buf, key_len);
} while (ret == 0);
}
DBUG_PRINT("info", ("Scan finished. ret=%d", ret));
@@ -911,8 +911,8 @@ Event_db_repository::find_named_event(LE
key_copy(key, table->record[0], table->key_info, table->key_info->key_length);
- if (table->file->index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
DBUG_PRINT("info", ("Row not found"));
DBUG_RETURN(TRUE);
=== modified file 'sql/filesort.cc'
--- a/sql/filesort.cc 2010-03-31 14:05:33 +0000
+++ b/sql/filesort.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 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
@@ -589,7 +589,7 @@ static ha_rows find_all_keys(SORTPARAM *
}
else
{
- error=file->rnd_next(sort_form->record[0]);
+ error=file->ha_rnd_next(sort_form->record[0]);
if (!flag)
{
my_store_ptr(ref_pos,ref_length,record); // Position to row
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2010-04-01 19:34:09 +0000
+++ b/sql/ha_partition.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2005, 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
@@ -1308,7 +1308,7 @@ int ha_partition::prepare_new_partition(
DBUG_RETURN(0);
error_external_lock:
- (void) file->close();
+ (void) file->ha_close();
error_open:
(void) file->ha_delete_table(part_name);
error_create:
@@ -1354,7 +1354,7 @@ void ha_partition::cleanup_new_partition
while ((part_count > 0) && (*file))
{
(*file)->ha_external_lock(thd, F_UNLCK);
- (*file)->close();
+ (*file)->ha_close();
/* Leave the (*file)->ha_delete_table(part_name) to the ddl-log */
@@ -1723,7 +1723,7 @@ int ha_partition::copy_partitions(ulongl
goto error;
while (TRUE)
{
- if ((result= file->rnd_next(m_rec0)))
+ if ((result= file->ha_rnd_next(m_rec0)))
{
if (result == HA_ERR_RECORD_DELETED)
continue; //Probably MyISAM
@@ -2685,7 +2685,7 @@ int ha_partition::open(const char *name,
err_handler:
while (file-- != m_file)
- (*file)->close();
+ (*file)->ha_close();
bitmap_free(&m_bulk_insert_started);
if (!is_clone)
bitmap_free(&(m_part_info->used_partitions));
@@ -2742,7 +2742,7 @@ int ha_partition::close(void)
repeat:
do
{
- (*file)->close();
+ (*file)->ha_close();
} while (*(++file));
if (first && m_added_file && m_added_file[0])
@@ -3800,7 +3800,7 @@ int ha_partition::rnd_next(uchar *buf)
while (TRUE)
{
- result= file->rnd_next(buf);
+ result= file->ha_rnd_next(buf);
if (!result)
{
m_last_part= part_id;
@@ -3810,7 +3810,7 @@ int ha_partition::rnd_next(uchar *buf)
}
/*
- if we get here, then the current partition rnd_next returned failure
+ if we get here, then the current partition ha_rnd_next returned failure
*/
if (result == HA_ERR_RECORD_DELETED)
continue; // Probably MyISAM
@@ -4650,8 +4650,8 @@ int ha_partition::handle_unordered_next(
}
else if (is_next_same)
{
- if (!(error= file->index_next_same(buf, m_start_key.key,
- m_start_key.length)))
+ if (!(error= file->ha_index_next_same(buf, m_start_key.key,
+ m_start_key.length)))
{
m_last_part= m_part_spec.start_part;
DBUG_RETURN(0);
@@ -4659,7 +4659,7 @@ int ha_partition::handle_unordered_next(
}
else
{
- if (!(error= file->index_next(buf)))
+ if (!(error= file->ha_index_next(buf)))
{
m_last_part= m_part_spec.start_part;
DBUG_RETURN(0); // Row was in range
@@ -4714,13 +4714,13 @@ int ha_partition::handle_unordered_scan_
break;
case partition_index_read:
DBUG_PRINT("info", ("index_read on partition %d", i));
- error= file->index_read_map(buf, m_start_key.key,
- m_start_key.keypart_map,
- m_start_key.flag);
+ error= file->ha_index_read_map(buf, m_start_key.key,
+ m_start_key.keypart_map,
+ m_start_key.flag);
break;
case partition_index_first:
DBUG_PRINT("info", ("index_first on partition %d", i));
- error= file->index_first(buf);
+ error= file->ha_index_first(buf);
break;
case partition_index_first_unordered:
/*
@@ -4801,17 +4801,17 @@ int ha_partition::handle_ordered_index_s
switch (m_index_scan_type) {
case partition_index_read:
- error= file->index_read_map(rec_buf_ptr,
- m_start_key.key,
- m_start_key.keypart_map,
- m_start_key.flag);
+ error= file->ha_index_read_map(rec_buf_ptr,
+ m_start_key.key,
+ m_start_key.keypart_map,
+ m_start_key.flag);
break;
case partition_index_first:
- error= file->index_first(rec_buf_ptr);
+ error= file->ha_index_first(rec_buf_ptr);
reverse_order= FALSE;
break;
case partition_index_last:
- error= file->index_last(rec_buf_ptr);
+ error= file->ha_index_last(rec_buf_ptr);
reverse_order= TRUE;
break;
case partition_index_read_last:
@@ -4919,10 +4919,10 @@ int ha_partition::handle_ordered_next(uc
memcpy(rec_buf(part_id), table->record[0], m_rec_length);
}
else if (!is_next_same)
- error= file->index_next(rec_buf(part_id));
+ error= file->ha_index_next(rec_buf(part_id));
else
- error= file->index_next_same(rec_buf(part_id), m_start_key.key,
- m_start_key.length);
+ error= file->ha_index_next_same(rec_buf(part_id), m_start_key.key,
+ m_start_key.length);
if (error)
{
if (error == HA_ERR_END_OF_FILE)
@@ -4967,7 +4967,7 @@ int ha_partition::handle_ordered_prev(uc
handler *file= m_file[part_id];
DBUG_ENTER("ha_partition::handle_ordered_prev");
- if ((error= file->index_prev(rec_buf(part_id))))
+ if ((error= file->ha_index_prev(rec_buf(part_id))))
{
if (error == HA_ERR_END_OF_FILE)
{
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2010-04-20 08:51:50 +0000
+++ b/sql/handler.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -41,6 +41,7 @@
#include "transaction.h"
#include <errno.h>
#include "probes_mysql.h"
+#include <mysql/psi/mysql_table.h>
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
@@ -2034,6 +2035,12 @@ int ha_delete_table(THD *thd, handlerton
ha_delete_table_error_handler.buff);
}
delete file;
+
+#ifdef HAVE_PSI_INTERFACE
+ if (likely((error == 0) && (PSI_server != NULL)))
+ PSI_server->drop_table_share(db, strlen(db), alias, strlen(alias));
+#endif
+
DBUG_RETURN(error);
}
@@ -2118,6 +2125,7 @@ int handler::ha_open(TABLE *table_arg, c
}
else
{
+ psi_open();
if (table->s->db_options_in_use & HA_OPTION_READ_ONLY_DATA)
table->db_stat|=HA_READ_ONLY;
(void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL
@@ -2126,6 +2134,7 @@ int handler::ha_open(TABLE *table_arg, c
if (!ref && !(ref= (uchar*) alloc_root(&table->mem_root,
ALIGN_SIZE(ref_length)*2)))
{
+ psi_close();
close();
error=HA_ERR_OUT_OF_MEM;
}
@@ -3575,8 +3584,18 @@ int ha_create_table(THD *thd, const char
DBUG_ENTER("ha_create_table");
init_tmp_table_share(thd, &share, db, 0, table_name, path);
- if (open_table_def(thd, &share, 0) ||
- open_table_from_share(thd, &share, "", 0, (uint) READ_ALL, 0, &table,
+ if (open_table_def(thd, &share, 0))
+ goto err;
+
+#ifdef HAVE_PSI_INTERFACE
+ if (likely(PSI_server != NULL))
+ {
+ my_bool temp= (create_info->options & HA_LEX_CREATE_TMP_TABLE ? TRUE : FALSE);
+ share.m_psi= PSI_server->get_table_share(temp, &share);
+ }
+#endif
+
+ if (open_table_from_share(thd, &share, "", 0, (uint) READ_ALL, 0, &table,
TRUE))
goto err;
@@ -3646,6 +3665,15 @@ int ha_create_table_from_engine(THD* thd
{
DBUG_RETURN(3);
}
+
+#ifdef HAVE_PSI_INTERFACE
+ /*
+ Table discovery is not instrumented.
+ Once discovered, the table will be opened normally,
+ and instrumented normally.
+ */
+#endif
+
if (open_table_from_share(thd, &share, "" ,0, 0, 0, &table, FALSE))
{
free_table_share(&share);
@@ -4618,12 +4646,16 @@ int handler::ha_external_lock(THD *thd,
}
}
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_EXTERNAL_LOCK, MAX_KEY, lock_type);
/*
We cache the table flags if the locking succeeded. Otherwise, we
keep them as they were when they were fetched in ha_open().
*/
int error= external_lock(thd, lock_type);
+ MYSQL_END_TABLE_WAIT(locker);
+
if (error == 0)
cached_table_flags= table_flags();
@@ -4678,8 +4710,12 @@ int handler::ha_write_row(uchar *buf)
MYSQL_INSERT_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_WRITE_ROW, MAX_KEY, 0);
error= write_row(buf);
+
+ MYSQL_END_TABLE_WAIT(locker);
MYSQL_INSERT_ROW_DONE(error);
if (unlikely(error))
DBUG_RETURN(error);
@@ -4704,7 +4740,12 @@ int handler::ha_update_row(const uchar *
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_UPDATE_ROW, MAX_KEY, 0);
+
error= update_row(old_data, new_data);
+
+ MYSQL_END_TABLE_WAIT(locker);
MYSQL_UPDATE_ROW_DONE(error);
if (unlikely(error))
return error;
@@ -4721,7 +4762,12 @@ int handler::ha_delete_row(const uchar *
MYSQL_DELETE_ROW_START(table_share->db.str, table_share->table_name.str);
mark_trx_read_write();
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_DELETE_ROW, MAX_KEY, 0);
+
error= delete_row(buf);
+
+ MYSQL_END_TABLE_WAIT(locker);
MYSQL_DELETE_ROW_DONE(error);
if (unlikely(error))
return error;
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2010-03-31 14:05:33 +0000
+++ b/sql/handler.h 2010-05-05 08:16:47 +0000
@@ -1,7 +1,7 @@
#ifndef HANDLER_INCLUDED
#define HANDLER_INCLUDED
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -32,6 +32,7 @@
#include <my_handler.h>
#include <ft_global.h>
#include <keycache.h>
+#include <mysql/psi/mysql_table.h>
#ifndef NO_HASH
#define NO_HASH /* Not yet implemented */
@@ -1262,9 +1263,14 @@ public:
{
cached_table_flags= table_flags();
}
- /* ha_ methods: pubilc wrappers for private virtual API */
+ /* ha_ methods: public wrappers for private virtual API */
int ha_open(TABLE *table, const char *name, int mode, int test_if_locked);
+ int ha_close(void)
+ {
+ psi_close();
+ return close();
+ }
int ha_index_init(uint idx, bool sorted)
{
int result;
@@ -1296,6 +1302,15 @@ public:
inited=NONE;
DBUG_RETURN(rnd_end());
}
+ int ha_rnd_next(uchar *buf)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, MAX_KEY, 0);
+ result= rnd_next(buf);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
int ha_reset();
/* this is necessary in many places, e.g. in HANDLER command */
int ha_index_or_rnd_end()
@@ -1434,7 +1449,6 @@ public:
*/
virtual void column_bitmaps_signal();
uint get_index(void) const { return active_index; }
- virtual int close(void)=0;
/**
@retval 0 Bulk update used by handler
@@ -1478,6 +1492,74 @@ public:
DBUG_ASSERT(FALSE);
return HA_ERR_WRONG_COMMAND;
}
+ int ha_index_read_map(uchar *buf, const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_read_map(buf, key, keypart_map, find_flag);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_read_idx_map(uchar *buf, uint index, const uchar *key,
+ key_part_map keypart_map,
+ enum ha_rkey_function find_flag)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, index, 0);
+ result= index_read_idx_map(buf, index, key, keypart_map, find_flag);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_next(uchar * buf)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_next(buf);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_prev(uchar * buf)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_prev(buf);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_first(uchar * buf)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_first(buf);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_last(uchar * buf)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_last(buf);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_next_same(uchar *buf, const uchar *key, uint keylen)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_next_same(buf, key, keylen);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+protected:
/**
@brief
Positions an index cursor to the index specified in the handle. Fetches the
@@ -1509,6 +1591,7 @@ public:
virtual int index_last(uchar * buf)
{ return HA_ERR_WRONG_COMMAND; }
virtual int index_next_same(uchar *buf, const uchar *key, uint keylen);
+public:
/**
@brief
The following functions works like index_read, but it find the last
@@ -1534,7 +1617,9 @@ public:
virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key)
{ return NULL; }
virtual int ft_read(uchar *buf) { return HA_ERR_WRONG_COMMAND; }
+protected:
virtual int rnd_next(uchar *buf)=0;
+public:
virtual int rnd_pos(uchar * buf, uchar *pos)=0;
/**
One has to use this method when to find
@@ -1861,10 +1946,10 @@ protected:
DBUG_ASSERT(m_psi == NULL);
DBUG_ASSERT(table_share != NULL);
#ifdef HAVE_PSI_INTERFACE
- if (PSI_server)
+ if (likely(PSI_server != NULL))
{
PSI_table_share *share_psi= ha_table_share_psi(table_share);
- if (share_psi)
+ if (likely(share_psi != NULL))
m_psi= PSI_server->open_table(share_psi, this);
}
#endif
@@ -1873,7 +1958,7 @@ protected:
inline void psi_close()
{
#ifdef HAVE_PSI_INTERFACE
- if (PSI_server && m_psi)
+ if (likely(PSI_server && m_psi))
{
PSI_server->close_table(m_psi);
m_psi= NULL; /* instrumentation handle, invalid after close_table() */
@@ -1906,6 +1991,7 @@ private:
*/
virtual int open(const char *name, int mode, uint test_if_locked)=0;
+ virtual int close(void)=0;
virtual int index_init(uint idx, bool sorted) { active_index= idx; return 0; }
virtual int index_end() { active_index= MAX_KEY; return 0; }
/**
@@ -1982,11 +2068,32 @@ private:
{ return HA_ADMIN_NOT_IMPLEMENTED; }
virtual void start_bulk_insert(ha_rows rows) {}
virtual int end_bulk_insert() { return 0; }
+ int ha_index_read(uchar *buf, const uchar *key, uint key_len,
+ enum ha_rkey_function find_flag)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_read(buf, key, key_len, find_flag);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+ int ha_index_read_last(uchar *buf, const uchar *key, uint key_len)
+ {
+ int result;
+ struct PSI_table_locker *locker;
+ locker= MYSQL_START_TABLE_WAIT(m_psi, PSI_TABLE_FETCH_ROW, active_index, 0);
+ result= index_read_last(buf, key, key_len);
+ MYSQL_END_TABLE_WAIT(locker);
+ return result;
+ }
+protected:
virtual int index_read(uchar * buf, const uchar * key, uint key_len,
enum ha_rkey_function find_flag)
{ return HA_ERR_WRONG_COMMAND; }
virtual int index_read_last(uchar * buf, const uchar * key, uint key_len)
{ return (my_errno= HA_ERR_WRONG_COMMAND); }
+public:
/**
This method is similar to update_row, however the handler doesn't need
to execute the updates at this point in time. The handler can be certain
=== modified file 'sql/item_subselect.cc'
--- a/sql/item_subselect.cc 2010-03-31 14:05:33 +0000
+++ b/sql/item_subselect.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 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
@@ -2037,7 +2037,7 @@ int subselect_uniquesubquery_engine::sca
table->null_row= 0;
for (;;)
{
- error=table->file->rnd_next(table->record[0]);
+ error=table->file->ha_rnd_next(table->record[0]);
if (error && error != HA_ERR_END_OF_FILE)
{
error= report_error(table, error);
@@ -2211,10 +2211,10 @@ int subselect_uniquesubquery_engine::exe
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key, 0);
- error= table->file->index_read_map(table->record[0],
- tab->ref.key_buff,
- make_prev_keypart_map(tab->ref.key_parts),
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_map(table->record[0],
+ tab->ref.key_buff,
+ make_prev_keypart_map(tab->ref.key_parts),
+ HA_READ_KEY_EXACT);
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
error= report_error(table, error);
@@ -2332,10 +2332,10 @@ int subselect_indexsubquery_engine::exec
if (!table->file->inited)
table->file->ha_index_init(tab->ref.key, 1);
- error= table->file->index_read_map(table->record[0],
- tab->ref.key_buff,
- make_prev_keypart_map(tab->ref.key_parts),
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_map(table->record[0],
+ tab->ref.key_buff,
+ make_prev_keypart_map(tab->ref.key_parts),
+ HA_READ_KEY_EXACT);
if (error &&
error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
error= report_error(table, error);
@@ -2356,9 +2356,9 @@ int subselect_indexsubquery_engine::exec
((Item_in_subselect *) item)->value= 1;
break;
}
- error= table->file->index_next_same(table->record[0],
- tab->ref.key_buff,
- tab->ref.key_length);
+ error= table->file->ha_index_next_same(table->record[0],
+ tab->ref.key_buff,
+ tab->ref.key_length);
if (error && error != HA_ERR_END_OF_FILE)
{
error= report_error(table, error);
=== modified file 'sql/log_event.cc'
--- a/sql/log_event.cc 2010-04-26 09:06:35 +0000
+++ b/sql/log_event.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -8780,10 +8780,10 @@ Rows_log_event::write_row(const Relay_lo
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
0);
- error= table->file->index_read_idx_map(table->record[1], keynum,
- (const uchar*)key.get(),
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_idx_map(table->record[1], keynum,
+ (const uchar*)key.get(),
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT);
if (error)
{
DBUG_PRINT("info",("index_read_idx() returns %s", HA_ERR(error)));
@@ -9115,9 +9115,9 @@ int Rows_log_event::find_row(const Relay
table->record[0][table->s->null_bytes - 1]|=
256U - (1U << table->s->last_null_bit_pos);
- if ((error= table->file->index_read_map(table->record[0], m_key,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_map(table->record[0], m_key,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT)))
{
DBUG_PRINT("info",("no record matching the key found in the table"));
if (error == HA_ERR_RECORD_DELETED)
@@ -9179,7 +9179,7 @@ int Rows_log_event::find_row(const Relay
256U - (1U << table->s->last_null_bit_pos);
}
- while ((error= table->file->index_next(table->record[0])))
+ while ((error= table->file->ha_index_next(table->record[0])))
{
/* We just skip records that has already been deleted */
if (error == HA_ERR_RECORD_DELETED)
@@ -9198,11 +9198,11 @@ int Rows_log_event::find_row(const Relay
}
else
{
- DBUG_PRINT("info",("locating record using table scan (rnd_next)"));
+ DBUG_PRINT("info",("locating record using table scan (ha_rnd_next)"));
int restart_count= 0; // Number of times scanning has restarted from top
- /* We don't have a key: search the table using rnd_next() */
+ /* We don't have a key: search the table using ha_rnd_next() */
if ((error= table->file->ha_rnd_init(1)))
{
DBUG_PRINT("info",("error initializing table scan"
@@ -9214,8 +9214,8 @@ int Rows_log_event::find_row(const Relay
/* Continue until we find the right record or have made a full loop */
do
{
- restart_rnd_next:
- error= table->file->rnd_next(table->record[0]);
+ restart_ha_rnd_next:
+ error= table->file->ha_rnd_next(table->record[0]);
DBUG_PRINT("info", ("error: %s", HA_ERR(error)));
switch (error) {
@@ -9228,7 +9228,7 @@ int Rows_log_event::find_row(const Relay
any comparisons.
*/
case HA_ERR_RECORD_DELETED:
- goto restart_rnd_next;
+ goto restart_ha_rnd_next;
case HA_ERR_END_OF_FILE:
if (++restart_count < 2)
@@ -9237,7 +9237,7 @@ int Rows_log_event::find_row(const Relay
default:
DBUG_PRINT("info", ("Failed to get next record"
- " (rnd_next returns %d)",error));
+ " (ha_rnd_next returns %d)",error));
table->file->print_error(error, MYF(0));
table->file->ha_rnd_end();
goto err;
=== modified file 'sql/log_event_old.cc'
--- a/sql/log_event_old.cc 2010-04-20 11:58:28 +0000
+++ b/sql/log_event_old.cc 2010-05-05 08:16:47 +0000
@@ -551,10 +551,10 @@ replace_record(THD *thd, TABLE *table,
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
0);
- error= table->file->index_read_idx_map(table->record[1], keynum,
- (const uchar*)key.get(),
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_idx_map(table->record[1], keynum,
+ (const uchar*)key.get(),
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT);
if (error)
{
DBUG_PRINT("info", ("index_read_idx() returns error %d", error));
@@ -710,8 +710,8 @@ static int find_and_fetch_row(TABLE *tab
my_ptrdiff_t const pos=
table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0;
table->record[1][pos]= 0xFF;
- if ((error= table->file->index_read_map(table->record[1], key, HA_WHOLE_KEY,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_map(table->record[1], key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT)))
{
table->file->print_error(error, MYF(0));
table->file->ha_index_end();
@@ -765,7 +765,7 @@ static int find_and_fetch_row(TABLE *tab
256U - (1U << table->s->last_null_bit_pos);
}
- while ((error= table->file->index_next(table->record[1])))
+ while ((error= table->file->ha_index_next(table->record[1])))
{
/* We just skip records that has already been deleted */
if (error == HA_ERR_RECORD_DELETED)
@@ -786,15 +786,15 @@ static int find_and_fetch_row(TABLE *tab
int restart_count= 0; // Number of times scanning has restarted from top
int error;
- /* We don't have a key: search the table using rnd_next() */
+ /* We don't have a key: search the table using ha_rnd_next() */
if ((error= table->file->ha_rnd_init(1)))
return error;
/* Continue until we find the right record or have made a full loop */
do
{
- restart_rnd_next:
- error= table->file->rnd_next(table->record[1]);
+ restart_ha_rnd_next:
+ error= table->file->ha_rnd_next(table->record[1]);
DBUG_DUMP("record[0]", table->record[0], table->s->reclength);
DBUG_DUMP("record[1]", table->record[1], table->s->reclength);
@@ -808,7 +808,7 @@ static int find_and_fetch_row(TABLE *tab
any comparisons.
*/
case HA_ERR_RECORD_DELETED:
- goto restart_rnd_next;
+ goto restart_ha_rnd_next;
case HA_ERR_END_OF_FILE:
if (++restart_count < 2)
@@ -2063,10 +2063,10 @@ Old_rows_log_event::write_row(const Rela
key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum,
0);
- error= table->file->index_read_idx_map(table->record[1], keynum,
- (const uchar*)key.get(),
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_idx_map(table->record[1], keynum,
+ (const uchar*)key.get(),
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT);
if (error)
{
DBUG_PRINT("info",("index_read_idx() returns error %d", error));
@@ -2283,9 +2283,9 @@ int Old_rows_log_event::find_row(const R
table->s->null_bytes > 0 ? table->s->null_bytes - 1 : 0;
table->record[0][pos]= 0xFF;
- if ((error= table->file->index_read_map(table->record[0], m_key,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_map(table->record[0], m_key,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT)))
{
DBUG_PRINT("info",("no record matching the key found in the table"));
if (error == HA_ERR_RECORD_DELETED)
@@ -2347,7 +2347,7 @@ int Old_rows_log_event::find_row(const R
256U - (1U << table->s->last_null_bit_pos);
}
- while ((error= table->file->index_next(table->record[0])))
+ while ((error= table->file->ha_index_next(table->record[0])))
{
/* We just skip records that has already been deleted */
if (error == HA_ERR_RECORD_DELETED)
@@ -2366,11 +2366,11 @@ int Old_rows_log_event::find_row(const R
}
else
{
- DBUG_PRINT("info",("locating record using table scan (rnd_next)"));
+ DBUG_PRINT("info",("locating record using table scan (ha_rnd_next)"));
int restart_count= 0; // Number of times scanning has restarted from top
- /* We don't have a key: search the table using rnd_next() */
+ /* We don't have a key: search the table using ha_rnd_next() */
if ((error= table->file->ha_rnd_init(1)))
{
DBUG_PRINT("info",("error initializing table scan"
@@ -2382,8 +2382,8 @@ int Old_rows_log_event::find_row(const R
/* Continue until we find the right record or have made a full loop */
do
{
- restart_rnd_next:
- error= table->file->rnd_next(table->record[0]);
+ restart_ha_rnd_next:
+ error= table->file->ha_rnd_next(table->record[0]);
switch (error) {
@@ -2391,7 +2391,7 @@ int Old_rows_log_event::find_row(const R
break;
case HA_ERR_RECORD_DELETED:
- goto restart_rnd_next;
+ goto restart_ha_rnd_next;
case HA_ERR_END_OF_FILE:
if (++restart_count < 2)
@@ -2400,7 +2400,7 @@ int Old_rows_log_event::find_row(const R
default:
DBUG_PRINT("info", ("Failed to get next record"
- " (rnd_next returns %d)",error));
+ " (ha_rnd_next returns %d)",error));
table->file->print_error(error, MYF(0));
table->file->ha_rnd_end();
DBUG_RETURN(error);
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2010-03-31 14:05:33 +0000
+++ b/sql/opt_range.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -1210,7 +1210,7 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT(
DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file,
free_file));
file->ha_external_lock(current_thd, F_UNLCK);
- file->close();
+ file->ha_close();
delete file;
}
}
@@ -1389,7 +1389,7 @@ int QUICK_RANGE_SELECT::init_ror_merged_
if (init() || reset())
{
file->ha_external_lock(thd, F_UNLCK);
- file->close();
+ file->ha_close();
goto failure;
}
free_file= TRUE;
@@ -8840,8 +8840,8 @@ int QUICK_RANGE_SELECT::get_next_prefix(
{
/* Read the next record in the same range with prefix after cur_prefix. */
DBUG_ASSERT(cur_prefix != 0);
- result= file->index_read_map(record, cur_prefix, keypart_map,
- HA_READ_AFTER_KEY);
+ result= file->ha_index_read_map(record, cur_prefix, keypart_map,
+ HA_READ_AFTER_KEY);
if (result || (file->compare_key(file->end_range) <= 0))
DBUG_RETURN(result);
}
@@ -8897,8 +8897,8 @@ int QUICK_RANGE_SELECT_GEOM::get_next()
if (last_range)
{
// Already read through key
- result= file->index_next_same(record, last_range->min_key,
- last_range->min_length);
+ result= file->ha_index_next_same(record, last_range->min_key,
+ last_range->min_length);
if (result != HA_ERR_END_OF_FILE)
DBUG_RETURN(result);
}
@@ -8912,10 +8912,10 @@ int QUICK_RANGE_SELECT_GEOM::get_next()
}
last_range= *(cur_range++);
- result= file->index_read_map(record, last_range->min_key,
- last_range->min_keypart_map,
- (ha_rkey_function)(last_range->flag ^
- GEOM_FLAG));
+ result= file->ha_index_read_map(record, last_range->min_key,
+ last_range->min_keypart_map,
+ (ha_rkey_function)(last_range->flag ^
+ GEOM_FLAG));
if (result != HA_ERR_KEY_NOT_FOUND && result != HA_ERR_END_OF_FILE)
DBUG_RETURN(result);
last_range= 0; // Not found, to next range
@@ -9027,9 +9027,9 @@ int QUICK_SELECT_DESC::get_next()
{ // Already read through key
result = ((last_range->flag & EQ_RANGE &&
used_key_parts <= head->key_info[index].key_parts) ?
- file->index_next_same(record, last_range->min_key,
- last_range->min_length) :
- file->index_prev(record));
+ file->ha_index_next_same(record, last_range->min_key,
+ last_range->min_length) :
+ file->ha_index_prev(record));
if (!result)
{
if (cmp_prev(*rev_it.ref()) == 0)
@@ -9045,7 +9045,7 @@ int QUICK_SELECT_DESC::get_next()
if (last_range->flag & NO_MAX_RANGE) // Read last record
{
int local_error;
- if ((local_error=file->index_last(record)))
+ if ((local_error= file->ha_index_last(record)))
DBUG_RETURN(local_error); // Empty table
if (cmp_prev(last_range) == 0)
DBUG_RETURN(0);
@@ -9057,9 +9057,9 @@ int QUICK_SELECT_DESC::get_next()
used_key_parts <= head->key_info[index].key_parts)
{
- result = file->index_read_map(record, last_range->max_key,
- last_range->max_keypart_map,
- HA_READ_KEY_EXACT);
+ result= file->ha_index_read_map(record, last_range->max_key,
+ last_range->max_keypart_map,
+ HA_READ_KEY_EXACT);
}
else
{
@@ -9067,11 +9067,11 @@ int QUICK_SELECT_DESC::get_next()
(last_range->flag & EQ_RANGE &&
used_key_parts > head->key_info[index].key_parts) ||
range_reads_after_key(last_range));
- result=file->index_read_map(record, last_range->max_key,
- last_range->max_keypart_map,
- ((last_range->flag & NEAR_MAX) ?
- HA_READ_BEFORE_KEY :
- HA_READ_PREFIX_LAST_OR_PREV));
+ result= file->ha_index_read_map(record, last_range->max_key,
+ last_range->max_keypart_map,
+ ((last_range->flag & NEAR_MAX) ?
+ HA_READ_BEFORE_KEY :
+ HA_READ_PREFIX_LAST_OR_PREV));
}
if (result)
{
@@ -10842,7 +10842,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::reset(vo
DBUG_RETURN(result);
if (quick_prefix_select && quick_prefix_select->reset())
DBUG_RETURN(1);
- result= file->index_last(record);
+ result= file->ha_index_last(record);
if (result == HA_ERR_END_OF_FILE)
DBUG_RETURN(0);
/* Save the prefix of the last group. */
@@ -10944,9 +10944,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::get_next
first sub-group with the extended prefix.
*/
if (!have_min && !have_max && key_infix_len > 0)
- result= file->index_read_map(record, group_prefix,
- make_prev_keypart_map(real_key_parts),
- HA_READ_KEY_EXACT);
+ result= file->ha_index_read_map(record, group_prefix,
+ make_prev_keypart_map(real_key_parts),
+ HA_READ_KEY_EXACT);
result= have_min ? min_res : have_max ? max_res : result;
} while ((result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE) &&
@@ -10998,9 +10998,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min
/* Apply the constant equality conditions to the non-group select fields */
if (key_infix_len > 0)
{
- if ((result= file->index_read_map(record, group_prefix,
- make_prev_keypart_map(real_key_parts),
- HA_READ_KEY_EXACT)))
+ if ((result= file->ha_index_read_map(record, group_prefix,
+ make_prev_keypart_map(real_key_parts),
+ HA_READ_KEY_EXACT)))
DBUG_RETURN(result);
}
@@ -11015,9 +11015,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min
{
/* Find the first subsequent record without NULL in the MIN/MAX field. */
key_copy(tmp_record, record, index_info, 0);
- result= file->index_read_map(record, tmp_record,
- make_keypart_map(real_key_parts),
- HA_READ_AFTER_KEY);
+ result= file->ha_index_read_map(record, tmp_record,
+ make_keypart_map(real_key_parts),
+ HA_READ_AFTER_KEY);
/*
Check if the new record belongs to the current group by comparing its
prefix with the group's prefix. If it is from the next group, then the
@@ -11072,9 +11072,9 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max
if (min_max_ranges.elements > 0)
result= next_max_in_range();
else
- result= file->index_read_map(record, group_prefix,
- make_prev_keypart_map(real_key_parts),
- HA_READ_PREFIX_LAST);
+ result= file->ha_index_read_map(record, group_prefix,
+ make_prev_keypart_map(real_key_parts),
+ HA_READ_PREFIX_LAST);
DBUG_RETURN(result);
}
@@ -11116,16 +11116,16 @@ static int index_next_different (bool is
while (!key_cmp (key_part, group_prefix, group_prefix_len))
{
- result= file->index_next(record);
+ result= file->ha_index_next(record);
if (result)
return(result);
}
return result;
}
else
- return file->index_read_map(record, group_prefix,
- make_prev_keypart_map(group_key_parts),
- HA_READ_AFTER_KEY);
+ return file->ha_index_read_map(record, group_prefix,
+ make_prev_keypart_map(group_key_parts),
+ HA_READ_AFTER_KEY);
}
@@ -11167,7 +11167,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_pre
{
if (!seen_first_key)
{
- result= file->index_first(record);
+ result= file->ha_index_first(record);
if (result)
DBUG_RETURN(result);
seen_first_key= TRUE;
@@ -11254,7 +11254,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min
HA_READ_AFTER_KEY : HA_READ_KEY_OR_NEXT;
}
- result= file->index_read_map(record, group_prefix, keypart_map, find_flag);
+ result= file->ha_index_read_map(record, group_prefix, keypart_map, find_flag);
if (result)
{
if ((result == HA_ERR_KEY_NOT_FOUND || result == HA_ERR_END_OF_FILE) &&
@@ -11393,7 +11393,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max
HA_READ_BEFORE_KEY : HA_READ_PREFIX_LAST_OR_PREV;
}
- result= file->index_read_map(record, group_prefix, keypart_map, find_flag);
+ result= file->ha_index_read_map(record, group_prefix, keypart_map, find_flag);
if (result)
{
=== modified file 'sql/opt_sum.cc'
--- a/sql/opt_sum.cc 2010-03-31 14:05:33 +0000
+++ b/sql/opt_sum.cc 2010-05-05 08:16:47 +0000
@@ -255,7 +255,7 @@ int opt_sum_query(TABLE_LIST *tables, Li
error= table->file->ha_index_init((uint) ref.key, 1);
if (!ref.key_length)
- error= table->file->index_first(table->record[0]);
+ error= table->file->ha_index_first(table->record[0]);
else
{
/*
@@ -277,10 +277,10 @@ int opt_sum_query(TABLE_LIST *tables, Li
Closed interval: Either The MIN argument is non-nullable, or
we have a >= predicate for the MIN argument.
*/
- error= table->file->index_read_map(table->record[0],
- ref.key_buff,
- make_prev_keypart_map(ref.key_parts),
- HA_READ_KEY_OR_NEXT);
+ error= table->file->ha_index_read_map(table->record[0],
+ ref.key_buff,
+ make_prev_keypart_map(ref.key_parts),
+ HA_READ_KEY_OR_NEXT);
else
{
/*
@@ -289,10 +289,10 @@ int opt_sum_query(TABLE_LIST *tables, Li
2) there is a > predicate on it, nullability is irrelevant.
We need to scan the next bigger record first.
*/
- error= table->file->index_read_map(table->record[0],
- ref.key_buff,
- make_prev_keypart_map(ref.key_parts),
- HA_READ_AFTER_KEY);
+ error= table->file->ha_index_read_map(table->record[0],
+ ref.key_buff,
+ make_prev_keypart_map(ref.key_parts),
+ HA_READ_AFTER_KEY);
/*
If the found record is outside the group formed by the search
prefix, or there is no such record at all, check if all
@@ -315,10 +315,10 @@ int opt_sum_query(TABLE_LIST *tables, Li
key_cmp_if_same(table, ref.key_buff, ref.key, prefix_len)))
{
DBUG_ASSERT(item_field->field->real_maybe_null());
- error= table->file->index_read_map(table->record[0],
- ref.key_buff,
- make_prev_keypart_map(ref.key_parts),
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_map(table->record[0],
+ ref.key_buff,
+ make_prev_keypart_map(ref.key_parts),
+ HA_READ_KEY_EXACT);
}
}
}
@@ -402,13 +402,13 @@ int opt_sum_query(TABLE_LIST *tables, Li
error= table->file->ha_index_init((uint) ref.key, 1);
if (!ref.key_length)
- error= table->file->index_last(table->record[0]);
+ error= table->file->ha_index_last(table->record[0]);
else
- error= table->file->index_read_map(table->record[0], key_buff,
- make_prev_keypart_map(ref.key_parts),
- range_fl & NEAR_MAX ?
- HA_READ_BEFORE_KEY :
- HA_READ_PREFIX_LAST_OR_PREV);
+ error= table->file->ha_index_read_map(table->record[0], key_buff,
+ make_prev_keypart_map(ref.key_parts),
+ range_fl & NEAR_MAX ?
+ HA_READ_BEFORE_KEY :
+ HA_READ_PREFIX_LAST_OR_PREV);
if (!error && reckey_in_range(1, &ref, item_field->field,
conds, range_fl, prefix_len))
error= HA_ERR_KEY_NOT_FOUND;
=== modified file 'sql/records.cc'
--- a/sql/records.cc 2010-03-31 14:05:33 +0000
+++ b/sql/records.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright (c) 2000, 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
@@ -164,7 +164,7 @@ void init_read_record_idx(READ_RECORD *i
rr_sequential:
--------------
This is the most basic access method of a table using rnd_init,
- rnd_next and rnd_end. No indexes are used.
+ ha_rnd_next and rnd_end. No indexes are used.
*/
void init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
SQL_SELECT *select,
@@ -356,7 +356,7 @@ static int rr_quick(READ_RECORD *info)
static int rr_index_first(READ_RECORD *info)
{
- int tmp= info->file->index_first(info->record);
+ int tmp= info->file->ha_index_first(info->record);
info->read_record= rr_index;
if (tmp)
tmp= rr_handle_error(info, tmp);
@@ -382,7 +382,7 @@ static int rr_index_first(READ_RECORD *i
static int rr_index(READ_RECORD *info)
{
- int tmp= info->file->index_next(info->record);
+ int tmp= info->file->ha_index_next(info->record);
if (tmp)
tmp= rr_handle_error(info, tmp);
return tmp;
@@ -392,10 +392,10 @@ static int rr_index(READ_RECORD *info)
int rr_sequential(READ_RECORD *info)
{
int tmp;
- while ((tmp=info->file->rnd_next(info->record)))
+ while ((tmp=info->file->ha_rnd_next(info->record)))
{
/*
- rnd_next can return RECORD_DELETED for MyISAM when one thread is
+ ha_rnd_next can return RECORD_DELETED for MyISAM when one thread is
reading and another deleting without locks.
*/
if (info->thd->killed || (tmp != HA_ERR_RECORD_DELETED))
=== modified file 'sql/sp.cc'
--- a/sql/sp.cc 2010-04-16 14:24:06 +0000
+++ b/sql/sp.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002 MySQL AB
+/* Copyright (c) 2002, 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
@@ -495,8 +495,8 @@ db_find_routine_aux(THD *thd, int type,
key_copy(key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0], 0, key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
DBUG_RETURN(SP_KEY_NOT_FOUND);
DBUG_RETURN(SP_OK);
@@ -1373,9 +1373,9 @@ sp_drop_db_routines(THD *thd, char *db)
ret= SP_OK;
table->file->ha_index_init(0, 1);
- if (! table->file->index_read_map(table->record[0],
- (uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr,
- (key_part_map)1, HA_READ_KEY_EXACT))
+ if (! table->file->ha_index_read_map(table->record[0],
+ (uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr,
+ (key_part_map)1, HA_READ_KEY_EXACT))
{
int nxtres;
bool deleted= FALSE;
@@ -1390,7 +1390,7 @@ sp_drop_db_routines(THD *thd, char *db)
nxtres= 0;
break;
}
- } while (! (nxtres= table->file->index_next_same(table->record[0],
+ } while (! (nxtres= table->file->ha_index_next_same(table->record[0],
(uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr,
key_len)));
if (nxtres != HA_ERR_END_OF_FILE)
=== modified file 'sql/sql_acl.cc'
--- a/sql/sql_acl.cc 2010-04-13 17:50:59 +0000
+++ b/sql/sql_acl.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 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
@@ -1888,9 +1888,9 @@ static bool update_user_table(THD *thd,
key_copy((uchar *) user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx_map(table->record[0], 0,
- (uchar *) user_key, HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar *) user_key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH),
MYF(0)); /* purecov: deadcode */
@@ -1981,9 +1981,9 @@ static int replace_user_table(THD *thd,
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx_map(table->record[0], 0, user_key,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0], 0, user_key,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
/* what == 'N' means revoke */
if (what == 'N')
@@ -2205,9 +2205,9 @@ static int replace_db_table(TABLE *table
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx_map(table->record[0],0, user_key,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0],0, user_key,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
if (what == 'N')
{ // no row, no revoke
@@ -2439,8 +2439,8 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TA
col_privs->field[4]->store("",0, &my_charset_latin1);
col_privs->file->ha_index_init(0, 1);
- if (col_privs->file->index_read_map(col_privs->record[0], (uchar*) key,
- (key_part_map)15, HA_READ_KEY_EXACT))
+ if (col_privs->file->ha_index_read_map(col_privs->record[0], (uchar*) key,
+ (key_part_map)15, HA_READ_KEY_EXACT))
{
cols = 0; /* purecov: deadcode */
col_privs->file->ha_index_end();
@@ -2466,7 +2466,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TA
privs= cols= 0;
return;
}
- } while (!col_privs->file->index_next(col_privs->record[0]) &&
+ } while (!col_privs->file->ha_index_next(col_privs->record[0]) &&
!key_cmp_if_same(col_privs,key,0,key_prefix_len));
col_privs->file->ha_index_end();
}
@@ -2611,8 +2611,8 @@ static int replace_column_table(GRANT_TA
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_map(table->record[0], user_key, HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_map(table->record[0], user_key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
if (revoke_grant)
{
@@ -2693,9 +2693,9 @@ static int replace_column_table(GRANT_TA
key_copy(user_key, table->record[0], table->key_info,
key_prefix_length);
- if (table->file->index_read_map(table->record[0], user_key,
- (key_part_map)15,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_map(table->record[0], user_key,
+ (key_part_map)15,
+ HA_READ_KEY_EXACT))
goto end;
/* Scan through all rows with the same host,db,user and table */
@@ -2746,7 +2746,7 @@ static int replace_column_table(GRANT_TA
my_hash_delete(&g_t->hash_columns,(uchar*) grant_column);
}
}
- } while (!table->file->index_next(table->record[0]) &&
+ } while (!table->file->ha_index_next(table->record[0]) &&
!key_cmp_if_same(table, key, 0, key_prefix_length));
}
@@ -2796,9 +2796,9 @@ static int replace_table_table(THD *thd,
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (table->file->index_read_idx_map(table->record[0], 0, user_key,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0], 0, user_key,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
/*
The following should never happen as we first check the in memory
@@ -2923,10 +2923,10 @@ static int replace_routine_table(THD *th
TRUE);
store_record(table,record[1]); // store at pos 1
- if (table->file->index_read_idx_map(table->record[0], 0,
- (uchar*) table->field[0]->ptr,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar*) table->field[0]->ptr,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
/*
The following should never happen as we first check the in memory
@@ -3691,7 +3691,7 @@ static my_bool grant_load_procs_priv(TAB
p_table->file->ha_index_init(0, 1);
p_table->use_all_columns();
- if (!p_table->file->index_first(p_table->record[0]))
+ if (!p_table->file->ha_index_first(p_table->record[0]))
{
memex_ptr= &memex;
my_pthread_setspecific_ptr(THR_MALLOC, &memex_ptr);
@@ -3743,7 +3743,7 @@ static my_bool grant_load_procs_priv(TAB
goto end_unlock;
}
}
- while (!p_table->file->index_next(p_table->record[0]));
+ while (!p_table->file->ha_index_next(p_table->record[0]));
}
/* Return ok */
return_val= 0;
@@ -3793,7 +3793,7 @@ static my_bool grant_load(THD *thd, TABL
t_table->use_all_columns();
c_table->use_all_columns();
- if (!t_table->file->index_first(t_table->record[0]))
+ if (!t_table->file->ha_index_first(t_table->record[0]))
{
memex_ptr= &memex;
my_pthread_setspecific_ptr(THR_MALLOC, &memex_ptr);
@@ -3828,7 +3828,7 @@ static my_bool grant_load(THD *thd, TABL
goto end_unlock;
}
}
- while (!t_table->file->index_next(t_table->record[0]));
+ while (!t_table->file->ha_index_next(t_table->record[0]));
}
return_val=0; // Return ok
@@ -5399,9 +5399,9 @@ static int handle_grant_table(TABLE_LIST
table->key_info->key_part[1].store_length);
key_copy(user_key, table->record[0], table->key_info, key_prefix_length);
- if ((error= table->file->index_read_idx_map(table->record[0], 0,
- user_key, (key_part_map)3,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_idx_map(table->record[0], 0,
+ user_key, (key_part_map)3,
+ HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
{
@@ -5436,7 +5436,7 @@ static int handle_grant_table(TABLE_LIST
DBUG_PRINT("info",("scan table: '%s' search: '%s'@'%s'",
table->s->table_name.str, user_str, host_str));
#endif
- while ((error= table->file->rnd_next(table->record[0])) !=
+ while ((error= table->file->ha_rnd_next(table->record[0])) !=
HA_ERR_END_OF_FILE)
{
if (error)
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2010-04-21 07:35:37 +0000
+++ b/sql/sql_base.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -537,6 +537,12 @@ TABLE_SHARE *get_table_share(THD *thd, T
DBUG_RETURN(0);
}
share->ref_count++; // Mark in use
+
+#ifdef HAVE_PSI_INTERFACE
+ if (likely(PSI_server != NULL))
+ share->m_psi= PSI_server->get_table_share(false, share);
+#endif
+
DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u",
(ulong) share, share->ref_count));
DBUG_RETURN(share);
@@ -5576,8 +5582,20 @@ TABLE *open_temporary_table(THD *thd, co
init_tmp_table_share(thd, share, saved_cache_key, key_length,
strend(saved_cache_key)+1, tmp_path);
- if (open_table_def(thd, share, 0) ||
- open_table_from_share(thd, share, table_name,
+ if (open_table_def(thd, share, 0))
+ {
+ /* No need to lock share->mutex as this is not needed for tmp tables */
+ free_table_share(share);
+ my_free((char*) tmp_table,MYF(0));
+ DBUG_RETURN(0);
+ }
+
+#ifdef HAVE_PSI_INTERFACE
+ if (likely(PSI_server != NULL))
+ share->m_psi= PSI_server->get_table_share(true, share);
+#endif
+
+ if (open_table_from_share(thd, share, table_name,
(uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
HA_GET_INDEX),
READ_KEYINFO | COMPUTE_TYPES | EXTRA_RECORD,
=== modified file 'sql/sql_cursor.cc'
--- a/sql/sql_cursor.cc 2010-03-31 14:05:33 +0000
+++ b/sql/sql_cursor.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005-2006 MySQL AB
+/* Copyright (c) 2005, 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
@@ -661,7 +661,7 @@ void Materialized_cursor::fetch(ulong nu
result->begin_dataset();
for (fetch_limit+= num_rows; fetch_count < fetch_limit; fetch_count++)
{
- if ((res= table->file->rnd_next(table->record[0])))
+ if ((res= table->file->ha_rnd_next(table->record[0])))
break;
/* Send data only if the read was successful. */
result->send_data(item_list);
=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc 2010-03-31 14:05:33 +0000
+++ b/sql/sql_handler.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 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
@@ -630,8 +630,8 @@ retry:
if (table->file->inited != handler::NONE)
{
error=keyname ?
- table->file->index_next(table->record[0]) :
- table->file->rnd_next(table->record[0]);
+ table->file->ha_index_next(table->record[0]) :
+ table->file->ha_rnd_next(table->record[0]);
break;
}
/* else fall through */
@@ -640,13 +640,13 @@ retry:
{
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno, 1);
- error= table->file->index_first(table->record[0]);
+ error= table->file->ha_index_first(table->record[0]);
}
else
{
table->file->ha_index_or_rnd_end();
if (!(error= table->file->ha_rnd_init(1)))
- error= table->file->rnd_next(table->record[0]);
+ error= table->file->ha_rnd_next(table->record[0]);
}
mode=RNEXT;
break;
@@ -654,7 +654,7 @@ retry:
DBUG_ASSERT(keyname != 0);
if (table->file->inited != handler::NONE)
{
- error=table->file->index_prev(table->record[0]);
+ error= table->file->ha_index_prev(table->record[0]);
break;
}
/* else fall through */
@@ -662,13 +662,13 @@ retry:
DBUG_ASSERT(keyname != 0);
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno, 1);
- error= table->file->index_last(table->record[0]);
+ error= table->file->ha_index_last(table->record[0]);
mode=RPREV;
break;
case RNEXT_SAME:
/* Continue scan on "(keypart1,keypart2,...)=(c1, c2, ...) */
DBUG_ASSERT(keyname != 0);
- error= table->file->index_next_same(table->record[0], key, key_len);
+ error= table->file->ha_index_next_same(table->record[0], key, key_len);
break;
case RKEY:
{
@@ -708,8 +708,8 @@ retry:
table->file->ha_index_or_rnd_end();
table->file->ha_index_init(keyno, 1);
key_copy(key, table->record[0], table->key_info + keyno, key_len);
- error= table->file->index_read_map(table->record[0],
- key, keypart_map, ha_rkey_mode);
+ error= table->file->ha_index_read_map(table->record[0],
+ key, keypart_map, ha_rkey_mode);
mode=rkey_to_rnext[(int)ha_rkey_mode];
break;
}
=== modified file 'sql/sql_help.cc'
--- a/sql/sql_help.cc 2010-03-31 14:05:33 +0000
+++ b/sql/sql_help.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB
+/* Copyright (c) 2000, 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
@@ -300,13 +300,13 @@ int get_topics_for_keyword(THD *thd, TAB
rkey_id->store((longlong) key_id, TRUE);
rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW);
- int key_res= relations->file->index_read_map(relations->record[0],
- buff, (key_part_map) 1,
- HA_READ_KEY_EXACT);
+ int key_res= relations->file->ha_index_read_map(relations->record[0],
+ buff, (key_part_map) 1,
+ HA_READ_KEY_EXACT);
for ( ;
!key_res && key_id == (int16) rkey_id->val_int() ;
- key_res= relations->file->index_next(relations->record[0]))
+ key_res= relations->file->ha_index_next(relations->record[0]))
{
uchar topic_id_buff[8];
longlong topic_id= rtopic_id->val_int();
@@ -314,8 +314,8 @@ int get_topics_for_keyword(THD *thd, TAB
field->store((longlong) topic_id, TRUE);
field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW);
- if (!topics->file->index_read_map(topics->record[0], topic_id_buff,
- (key_part_map)1, HA_READ_KEY_EXACT))
+ if (!topics->file->ha_index_read_map(topics->record[0], topic_id_buff,
+ (key_part_map)1, HA_READ_KEY_EXACT))
{
memorize_variant_topic(thd,topics,count,find_fields,
names,name,description,example);
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2010-04-07 12:02:19 +0000
+++ b/sql/sql_insert.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -1509,9 +1509,9 @@ int write_record(THD *thd, TABLE *table,
}
}
key_copy((uchar*) key,table->record[0],table->key_info+key_nr,0);
- if ((error=(table->file->index_read_idx_map(table->record[1],key_nr,
- (uchar*) key, HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))))
+ if ((error=(table->file->ha_index_read_idx_map(table->record[1],key_nr,
+ (uchar*) key, HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))))
goto err;
}
if (info->handle_duplicates == DUP_UPDATE)
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2010-04-01 19:34:09 +0000
+++ b/sql/sql_partition.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2005-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2005, 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
@@ -6314,7 +6314,7 @@ static int alter_close_tables(ALTER_PART
!strcmp(table->s->db.str, share->db.str))
{
mysql_lock_remove(thd, thd->lock, table);
- table->file->close();
+ table->file->ha_close();
table->db_stat= 0; // Mark file closed
/*
Ensure that we won't end up with a crippled table instance
=== modified file 'sql/sql_plugin.cc'
--- a/sql/sql_plugin.cc 2010-04-01 19:34:09 +0000
+++ b/sql/sql_plugin.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005 MySQL AB, 2009 Sun Microsystems, Inc.
+/* Copyright (c) 2005, 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
@@ -1866,8 +1866,8 @@ bool mysql_uninstall_plugin(THD *thd, co
table->field[0]->store(name->str, name->length, system_charset_info);
key_copy(user_key, table->record[0], table->key_info,
table->key_info->key_length);
- if (! table->file->index_read_idx_map(table->record[0], 0, user_key,
- HA_WHOLE_KEY, HA_READ_KEY_EXACT))
+ if (! table->file->ha_index_read_idx_map(table->record[0], 0, user_key,
+ HA_WHOLE_KEY, HA_READ_KEY_EXACT))
{
int error;
/*
=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc 2010-04-13 12:16:36 +0000
+++ b/sql/sql_select.cc 2010-05-05 08:16:47 +0000
@@ -11061,7 +11061,7 @@ bool create_myisam_from_heap(THD *thd, T
is safe as this is a temporary MyISAM table without timestamp/autoincrement
or partitioning.
*/
- while (!table->file->rnd_next(new_table.record[1]))
+ while (!table->file->ha_rnd_next(new_table.record[1]))
{
write_err= new_table.file->ha_write_row(new_table.record[1]);
DBUG_EXECUTE_IF("raise_error", write_err= HA_ERR_FOUND_DUPP_KEY ;);
@@ -11078,7 +11078,7 @@ bool create_myisam_from_heap(THD *thd, T
/* remove heap table and change to use myisam table */
(void) table->file->ha_rnd_end();
- (void) table->file->close(); // This deletes the table !
+ (void) table->file->ha_close(); // This deletes the table !
delete table->file;
table->file=0;
plugin_unlock(0, table->s->db_plugin);
@@ -11098,7 +11098,7 @@ bool create_myisam_from_heap(THD *thd, T
DBUG_PRINT("error",("Got error: %d",write_err));
table->file->print_error(write_err, MYF(0));
(void) table->file->ha_rnd_end();
- (void) new_table.file->close();
+ (void) new_table.file->ha_close();
err1:
new_table.file->ha_delete_table(new_table.s->table_name.str);
err2:
@@ -11867,10 +11867,10 @@ int safe_index_read(JOIN_TAB *tab)
{
int error;
TABLE *table= tab->table;
- if ((error=table->file->index_read_map(table->record[0],
- tab->ref.key_buff,
- make_prev_keypart_map(tab->ref.key_parts),
- HA_READ_KEY_EXACT)))
+ if ((error=table->file->ha_index_read_map(table->record[0],
+ tab->ref.key_buff,
+ make_prev_keypart_map(tab->ref.key_parts),
+ HA_READ_KEY_EXACT)))
return report_error(table, error);
return 0;
}
@@ -12001,10 +12001,10 @@ join_read_const(JOIN_TAB *tab)
error=HA_ERR_KEY_NOT_FOUND;
else
{
- error=table->file->index_read_idx_map(table->record[0],tab->ref.key,
- (uchar*) tab->ref.key_buff,
- make_prev_keypart_map(tab->ref.key_parts),
- HA_READ_KEY_EXACT);
+ error=table->file->ha_index_read_idx_map(table->record[0],tab->ref.key,
+ (uchar*) tab->ref.key_buff,
+ make_prev_keypart_map(tab->ref.key_parts),
+ HA_READ_KEY_EXACT);
}
if (error)
{
@@ -12054,10 +12054,10 @@ join_read_key(JOIN_TAB *tab)
tab->read_record.file->unlock_row();
tab->ref.has_record= FALSE;
}
- error=table->file->index_read_map(table->record[0],
- tab->ref.key_buff,
- make_prev_keypart_map(tab->ref.key_parts),
- HA_READ_KEY_EXACT);
+ error= table->file->ha_index_read_map(table->record[0],
+ tab->ref.key_buff,
+ make_prev_keypart_map(tab->ref.key_parts),
+ HA_READ_KEY_EXACT);
if (error && error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
return report_error(table, error);
@@ -12132,10 +12132,10 @@ join_read_always_key(JOIN_TAB *tab)
if (cp_buffer_from_ref(tab->join->thd, table, &tab->ref))
return -1;
- if ((error=table->file->index_read_map(table->record[0],
- tab->ref.key_buff,
- make_prev_keypart_map(tab->ref.key_parts),
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_map(table->record[0],
+ tab->ref.key_buff,
+ make_prev_keypart_map(tab->ref.key_parts),
+ HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
return report_error(table, error);
@@ -12187,9 +12187,9 @@ join_read_next_same(READ_RECORD *info)
TABLE *table= info->table;
JOIN_TAB *tab=table->reginfo.join_tab;
- if ((error=table->file->index_next_same(table->record[0],
- tab->ref.key_buff,
- tab->ref.key_length)))
+ if ((error= table->file->ha_index_next_same(table->record[0],
+ tab->ref.key_buff,
+ tab->ref.key_length)))
{
if (error != HA_ERR_END_OF_FILE)
return report_error(table, error);
@@ -12207,7 +12207,7 @@ join_read_prev_same(READ_RECORD *info)
TABLE *table= info->table;
JOIN_TAB *tab=table->reginfo.join_tab;
- if ((error=table->file->index_prev(table->record[0])))
+ if ((error= table->file->ha_index_prev(table->record[0])))
return report_error(table, error);
if (key_cmp_if_same(table, tab->ref.key_buff, tab->ref.key,
tab->ref.key_length))
@@ -12271,7 +12271,7 @@ join_read_first(JOIN_TAB *tab)
tab->read_record.record=table->record[0];
if (!table->file->inited)
table->file->ha_index_init(tab->index, tab->sorted);
- if ((error=tab->table->file->index_first(tab->table->record[0])))
+ if ((error= tab->table->file->ha_index_first(tab->table->record[0])))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
report_error(table, error);
@@ -12285,7 +12285,7 @@ static int
join_read_next(READ_RECORD *info)
{
int error;
- if ((error=info->file->index_next(info->record)))
+ if ((error= info->file->ha_index_next(info->record)))
return report_error(info->table, error);
return 0;
}
@@ -12306,7 +12306,7 @@ join_read_last(JOIN_TAB *tab)
tab->read_record.record=table->record[0];
if (!table->file->inited)
table->file->ha_index_init(tab->index, 1);
- if ((error= tab->table->file->index_last(tab->table->record[0])))
+ if ((error= tab->table->file->ha_index_last(tab->table->record[0])))
return report_error(table, error);
return 0;
}
@@ -12316,7 +12316,7 @@ static int
join_read_prev(READ_RECORD *info)
{
int error;
- if ((error= info->file->index_prev(info->record)))
+ if ((error= info->file->ha_index_prev(info->record)))
return report_error(info->table, error);
return 0;
}
@@ -12699,10 +12699,10 @@ end_update(JOIN *join, JOIN_TAB *join_ta
if (item->maybe_null)
group->buff[-1]= (char) group->field->is_null();
}
- if (!table->file->index_read_map(table->record[1],
- join->tmp_table_param.group_buff,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (!table->file->ha_index_read_map(table->record[1],
+ join->tmp_table_param.group_buff,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{ /* Update old record */
restore_record(table,record[1]);
update_tmptable_sum_func(join->sum_funcs,table);
@@ -14144,7 +14144,7 @@ static int remove_dup_with_compare(THD *
new_record=(char*) table->record[1]+offset;
file->ha_rnd_init(1);
- error=file->rnd_next(record);
+ error=file->ha_rnd_next(record);
for (;;)
{
if (thd->killed)
@@ -14157,7 +14157,7 @@ static int remove_dup_with_compare(THD *
{
if (error == HA_ERR_RECORD_DELETED)
{
- error= file->rnd_next(record);
+ error= file->ha_rnd_next(record);
continue;
}
if (error == HA_ERR_END_OF_FILE)
@@ -14168,7 +14168,7 @@ static int remove_dup_with_compare(THD *
{
if ((error=file->ha_delete_row(record)))
goto err;
- error=file->rnd_next(record);
+ error=file->ha_rnd_next(record);
continue;
}
if (copy_blobs(first_field))
@@ -14183,7 +14183,7 @@ static int remove_dup_with_compare(THD *
bool found=0;
for (;;)
{
- if ((error=file->rnd_next(record)))
+ if ((error=file->ha_rnd_next(record)))
{
if (error == HA_ERR_RECORD_DELETED)
continue;
@@ -14282,7 +14282,7 @@ static int remove_dup_with_hash_index(TH
error=0;
goto err;
}
- if ((error=file->rnd_next(record)))
+ if ((error=file->ha_rnd_next(record)))
{
if (error == HA_ERR_RECORD_DELETED)
continue;
=== modified file 'sql/sql_servers.cc'
--- a/sql/sql_servers.cc 2010-03-31 14:05:33 +0000
+++ b/sql/sql_servers.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 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
@@ -545,10 +545,10 @@ int insert_server_record(TABLE *table, F
system_charset_info);
/* read index until record is that specified in server_name */
- if ((error= table->file->index_read_idx_map(table->record[0], 0,
- (uchar *)table->field[0]->ptr,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar *)table->field[0]->ptr,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT)))
{
/* if not found, err */
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
@@ -886,10 +886,10 @@ update_server_record(TABLE *table, FOREI
server->server_name_length,
system_charset_info);
- if ((error= table->file->index_read_idx_map(table->record[0], 0,
- (uchar *)table->field[0]->ptr,
- ~(longlong)0,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar *)table->field[0]->ptr,
+ ~(longlong)0,
+ HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
table->file->print_error(error, MYF(0));
@@ -943,10 +943,10 @@ delete_server_record(TABLE *table,
/* set the field that's the PK to the value we're looking for */
table->field[0]->store(server_name, server_name_length, system_charset_info);
- if ((error= table->file->index_read_idx_map(table->record[0], 0,
- (uchar *)table->field[0]->ptr,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT)))
+ if ((error= table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar *)table->field[0]->ptr,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT)))
{
if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE)
table->file->print_error(error, MYF(0));
=== modified file 'sql/sql_show.cc'
--- a/sql/sql_show.cc 2010-04-21 07:35:37 +0000
+++ b/sql/sql_show.cc 2010-05-05 08:16:47 +0000
@@ -4677,7 +4677,7 @@ int fill_schema_proc(THD *thd, TABLE_LIS
DBUG_RETURN(1);
}
proc_table->file->ha_index_init(0, 1);
- if ((res= proc_table->file->index_first(proc_table->record[0])))
+ if ((res= proc_table->file->ha_index_first(proc_table->record[0])))
{
res= (res == HA_ERR_END_OF_FILE) ? 0 : 1;
goto err;
@@ -4690,7 +4690,7 @@ int fill_schema_proc(THD *thd, TABLE_LIS
res= 1;
goto err;
}
- while (!proc_table->file->index_next(proc_table->record[0]))
+ while (!proc_table->file->ha_index_next(proc_table->record[0]))
{
if (schema_table_idx == SCH_PROCEDURES ?
store_schema_proc(thd, table, proc_table, wild, full_access, definer):
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2010-04-21 07:35:37 +0000
+++ b/sql/sql_table.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -7981,7 +7981,7 @@ bool mysql_checksum_table(THD *thd, TABL
goto err;
}
ha_checksum row_crc= 0;
- int error= t->file->rnd_next(t->record[0]);
+ int error= t->file->ha_rnd_next(t->record[0]);
if (unlikely(error))
{
if (error == HA_ERR_RECORD_DELETED)
=== modified file 'sql/sql_udf.cc'
--- a/sql/sql_udf.cc 2010-04-01 19:34:09 +0000
+++ b/sql/sql_udf.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2000, 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
@@ -606,10 +606,10 @@ int mysql_drop_function(THD *thd,const L
goto err;
table->use_all_columns();
table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin);
- if (!table->file->index_read_idx_map(table->record[0], 0,
- (uchar*) table->field[0]->ptr,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (!table->file->ha_index_read_idx_map(table->record[0], 0,
+ (uchar*) table->field[0]->ptr,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
int error;
if ((error = table->file->ha_delete_row(table->record[0])))
=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc 2010-04-21 07:35:37 +0000
+++ b/sql/sql_update.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -1961,7 +1961,7 @@ int multi_update::do_updates()
{
if (thd->killed && trans_safe)
goto err;
- if ((local_error=tmp_table->file->rnd_next(tmp_table->record[0])))
+ if ((local_error=tmp_table->file->ha_rnd_next(tmp_table->record[0])))
{
if (local_error == HA_ERR_END_OF_FILE)
break;
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2010-04-16 14:24:06 +0000
+++ b/sql/table.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 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
@@ -441,6 +441,12 @@ void free_table_share(TABLE_SHARE *share
key_info->flags= 0;
}
}
+
+#ifdef HAVE_PSI_INTERFACE
+ if (likely(PSI_server && share->m_psi))
+ PSI_server->release_table_share(share->m_psi);
+#endif
+
/* We must copy mem_root from share because share is allocated through it */
memcpy((char*) &mem_root, (char*) &share->mem_root, sizeof(mem_root));
free_root(&mem_root, MYF(0)); // Free's share
@@ -2016,7 +2022,7 @@ int closefrm(register TABLE *table, bool
DBUG_PRINT("enter", ("table: 0x%lx", (long) table));
if (table->db_stat)
- error=table->file->close();
+ error=table->file->ha_close();
my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR));
table->alias= 0;
if (table->field)
=== modified file 'sql/tztime.cc'
--- a/sql/tztime.cc 2010-03-31 14:05:33 +0000
+++ b/sql/tztime.cc 2010-05-05 08:16:47 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 MySQL AB, 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2004, 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
@@ -1719,7 +1719,7 @@ my_tz_init(THD *org_thd, const char *def
tz_leapcnt= 0;
- res= table->file->index_first(table->record[0]);
+ res= table->file->ha_index_first(table->record[0]);
while (!res)
{
@@ -1741,7 +1741,7 @@ my_tz_init(THD *org_thd, const char *def
tz_leapcnt, (ulong) tz_lsis[tz_leapcnt-1].ls_trans,
tz_lsis[tz_leapcnt-1].ls_corr));
- res= table->file->index_next(table->record[0]);
+ res= table->file->ha_index_next(table->record[0]);
}
(void)table->file->ha_index_end();
@@ -1913,8 +1913,8 @@ tz_load_from_open_tables(const String *t
*/
(void)table->file->ha_index_init(0, 1);
- if (table->file->index_read_map(table->record[0], table->field[0]->ptr,
- HA_WHOLE_KEY, HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_map(table->record[0], table->field[0]->ptr,
+ HA_WHOLE_KEY, HA_READ_KEY_EXACT))
{
#ifdef EXTRA_DEBUG
/*
@@ -1941,8 +1941,8 @@ tz_load_from_open_tables(const String *t
table->field[0]->store((longlong) tzid, TRUE);
(void)table->file->ha_index_init(0, 1);
- if (table->file->index_read_map(table->record[0], table->field[0]->ptr,
- HA_WHOLE_KEY, HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_map(table->record[0], table->field[0]->ptr,
+ HA_WHOLE_KEY, HA_READ_KEY_EXACT))
{
sql_print_error("Can't find description of time zone '%u'", tzid);
goto end;
@@ -1968,8 +1968,8 @@ tz_load_from_open_tables(const String *t
table->field[0]->store((longlong) tzid, TRUE);
(void)table->file->ha_index_init(0, 1);
- res= table->file->index_read_map(table->record[0], table->field[0]->ptr,
- (key_part_map)1, HA_READ_KEY_EXACT);
+ res= table->file->ha_index_read_map(table->record[0], table->field[0]->ptr,
+ (key_part_map)1, HA_READ_KEY_EXACT);
while (!res)
{
ttid= (uint)table->field[1]->val_int();
@@ -2016,8 +2016,8 @@ tz_load_from_open_tables(const String *t
tmp_tz_info.typecnt= ttid + 1;
- res= table->file->index_next_same(table->record[0],
- table->field[0]->ptr, 4);
+ res= table->file->ha_index_next_same(table->record[0],
+ table->field[0]->ptr, 4);
}
if (res != HA_ERR_END_OF_FILE)
@@ -2039,8 +2039,8 @@ tz_load_from_open_tables(const String *t
table->field[0]->store((longlong) tzid, TRUE);
(void)table->file->ha_index_init(0, 1);
- res= table->file->index_read_map(table->record[0], table->field[0]->ptr,
- (key_part_map)1, HA_READ_KEY_EXACT);
+ res= table->file->ha_index_read_map(table->record[0], table->field[0]->ptr,
+ (key_part_map)1, HA_READ_KEY_EXACT);
while (!res)
{
ttime= (my_time_t)table->field[1]->val_int();
@@ -2069,8 +2069,8 @@ tz_load_from_open_tables(const String *t
("time_zone_transition table: tz_id: %u tt_time: %lu tt_id: %u",
tzid, (ulong) ttime, ttid));
- res= table->file->index_next_same(table->record[0],
- table->field[0]->ptr, 4);
+ res= table->file->ha_index_next_same(table->record[0],
+ table->field[0]->ptr, 4);
}
/*
=== modified file 'storage/perfschema/ha_perfschema.cc'
--- a/storage/perfschema/ha_perfschema.cc 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/ha_perfschema.cc 2010-05-05 08:16:47 +0000
@@ -185,8 +185,6 @@ int ha_perfschema::open(const char *name
thr_lock_data_init(m_table_share->m_thr_lock_ptr, &m_thr_lock, NULL);
ref_length= m_table_share->m_ref_length;
- psi_open();
-
DBUG_RETURN(0);
}
@@ -197,8 +195,6 @@ int ha_perfschema::close(void)
delete m_table;
m_table= NULL;
- psi_close();
-
DBUG_RETURN(0);
}
=== modified file 'storage/perfschema/pfs.cc'
--- a/storage/perfschema/pfs.cc 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs.cc 2010-05-05 08:16:47 +0000
@@ -27,9 +27,6 @@
#include "pfs_timer.h"
#include "pfs_events_waits.h"
-/* Pending WL#4895 PERFORMANCE_SCHEMA Instrumenting Table IO */
-#undef HAVE_TABLE_WAIT
-
/**
@page PAGE_PERFORMANCE_SCHEMA The Performance Schema main page
MySQL PERFORMANCE_SCHEMA implementation.
@@ -722,6 +719,20 @@ static enum_operation_type file_operatio
};
/**
+ Conversion map from PSI_table_operation to enum_operation_type.
+ Indexed by enum PSI_table_operation.
+*/
+static enum_operation_type table_operation_map[]=
+{
+ OPERATION_TYPE_TABLE_LOCK,
+ OPERATION_TYPE_TABLE_EXTERNAL_LOCK,
+ OPERATION_TYPE_TABLE_FETCH,
+ OPERATION_TYPE_TABLE_WRITE_ROW,
+ OPERATION_TYPE_TABLE_UPDATE_ROW,
+ OPERATION_TYPE_TABLE_DELETE_ROW
+};
+
+/**
Build the prefix name of a class of instruments in a category.
For example, this function builds the string 'wait/sync/mutex/sql/' from
a prefix 'wait/sync/mutex' and a category 'sql'.
@@ -904,39 +915,52 @@ static void destroy_cond_v1(PSI_cond* co
}
static PSI_table_share*
-get_table_share_v1(const char *schema_name, int schema_name_length,
- const char *table_name, int table_name_length,
- const void *identity)
+get_table_share_v1(my_bool temporary, TABLE_SHARE *share)
{
-#ifdef HAVE_TABLE_WAIT
PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
if (unlikely(pfs_thread == NULL))
return NULL;
- PFS_table_share* share;
- share= find_or_create_table_share(pfs_thread,
- schema_name, schema_name_length,
- table_name, table_name_length);
- return reinterpret_cast<PSI_table_share*> (share);
-#else
- return NULL;
-#endif
+ 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);
}
static void release_table_share_v1(PSI_table_share* share)
{
- /*
- To be implemented by WL#4895 PERFORMANCE_SCHEMA Instrumenting Table IO.
- */
+ 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);
+}
+
+static void
+drop_table_share_v1(const char *schema_name, int schema_name_length,
+ const char *table_name, int table_name_length)
+{
+ PFS_thread *pfs_thread= my_pthread_getspecific_ptr(PFS_thread*, THR_PFS);
+ if (unlikely(pfs_thread == NULL))
+ return;
+ /* TODO: temporary tables */
+ drop_table_share(pfs_thread, false, schema_name, schema_name_length,
+ table_name, table_name_length);
}
static PSI_table*
open_table_v1(PSI_table_share *share, const void *identity)
{
+ 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, identity);
+ pfs_table= create_table(pfs_table_share, thread, identity);
return reinterpret_cast<PSI_table *> (pfs_table);
}
@@ -1112,6 +1136,14 @@ get_thread_mutex_locker_v1(PSI_mutex *mu
}
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_mutex= pfs_mutex;
@@ -1157,6 +1189,14 @@ get_thread_rwlock_locker_v1(PSI_rwlock *
}
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_rwlock= pfs_rwlock;
@@ -1215,6 +1255,14 @@ get_thread_cond_locker_v1(PSI_cond *cond
}
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_cond= pfs_cond;
@@ -1238,11 +1286,20 @@ get_thread_cond_locker_v1(PSI_cond *cond
}
static PSI_table_locker*
-get_thread_table_locker_v1(PSI_table *table)
+get_thread_table_locker_v1(PSI_table *table, PSI_table_operation op, ulong flags)
{
+ DBUG_ASSERT(static_cast<int> (op) >= 0);
+ DBUG_ASSERT(static_cast<uint> (op) < array_elements(table_operation_map));
PFS_table *pfs_table= reinterpret_cast<PFS_table*> (table);
DBUG_ASSERT(pfs_table != NULL);
DBUG_ASSERT(pfs_table->m_share != NULL);
+
+ /*
+ See the handler::external_lock() API design,
+ there is no handler::external_unlock().
+ */
+ if ((op == PSI_TABLE_EXTERNAL_LOCK) && (flags == F_UNLCK))
+ return NULL;
if (! flag_events_waits_current)
return NULL;
if (! pfs_table->m_share->m_enabled)
@@ -1259,6 +1316,14 @@ get_thread_table_locker_v1(PSI_table *ta
}
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_table= pfs_table;
@@ -1273,6 +1338,9 @@ get_thread_table_locker_v1(PSI_table *ta
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;
pfs_thread->m_wait_locker_count++;
@@ -1311,6 +1379,14 @@ get_thread_file_name_locker_v1(PSI_file_
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_file= pfs_file;
@@ -1362,6 +1438,14 @@ get_thread_file_stream_locker_v1(PSI_fil
}
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_file= pfs_file;
@@ -1430,6 +1514,14 @@ get_thread_file_descriptor_locker_v1(Fil
}
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_waits_current.m_wait_class= NO_WAIT_CLASS;
pfs_locker->m_target.m_file= pfs_file;
@@ -1633,7 +1725,7 @@ static void end_mutex_wait_v1(PSI_mutex_
aggregate_single_stat_chain(&mutex->m_wait_stat, wait_time);
stat= find_per_thread_mutex_class_wait_stat(wait->m_thread,
mutex->m_class);
- aggregate_single_stat_chain(stat, wait_time);
+ aggregate_single_stat_chain(stat, wait_time);
}
wait->m_thread->m_wait_locker_count--;
}
@@ -1785,7 +1877,7 @@ static void end_cond_wait_v1(PSI_cond_lo
Not thread safe, race conditions will occur.
A first race condition is:
- thread 1 waits on cond A
- - thread 2 waits on cond B
+ - 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:
@@ -1808,7 +1900,7 @@ static void end_cond_wait_v1(PSI_cond_lo
wait->m_thread->m_wait_locker_count--;
}
-static void start_table_wait_v1(PSI_table_locker* locker,
+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);
@@ -1822,12 +1914,17 @@ static void start_table_wait_v1(PSI_tabl
}
wait->m_source_file= src_file;
wait->m_source_line= src_line;
- wait->m_operation= OPERATION_TYPE_LOCK;
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;
}
static void end_table_wait_v1(PSI_table_locker* locker)
@@ -1846,10 +1943,6 @@ static void end_table_wait_v1(PSI_table_
if (flag_events_waits_history_long)
insert_events_waits_history_long(wait);
- PFS_table *table= pfs_locker->m_target.m_table;
- ulonglong wait_time= wait->m_timer_end - wait->m_timer_start;
- aggregate_single_stat_chain(&table->m_wait_stat, wait_time);
-
/*
There is currently no per table and per thread aggregation.
The number of tables in the application is arbitrary, and may be high.
@@ -2005,6 +2098,7 @@ PSI_v1 PFS_v1=
destroy_cond_v1,
get_table_share_v1,
release_table_share_v1,
+ drop_table_share_v1,
open_table_v1,
close_table_v1,
create_file_v1,
=== modified file 'storage/perfschema/pfs_column_types.h'
--- a/storage/perfschema/pfs_column_types.h 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs_column_types.h 2010-05-05 08:16:47 +0000
@@ -109,11 +109,27 @@ enum enum_operation_type
OPERATION_TYPE_FILECHSIZE= 22,
OPERATION_TYPE_FILEDELETE= 23,
OPERATION_TYPE_FILERENAME= 24,
- OPERATION_TYPE_FILESYNC= 25
+ OPERATION_TYPE_FILESYNC= 25,
+
+ OPERATION_TYPE_TABLE_LOCK= 26,
+ OPERATION_TYPE_TABLE_EXTERNAL_LOCK= 27,
+ OPERATION_TYPE_TABLE_FETCH= 28,
+ OPERATION_TYPE_TABLE_WRITE_ROW= 29,
+ OPERATION_TYPE_TABLE_UPDATE_ROW= 30,
+ OPERATION_TYPE_TABLE_DELETE_ROW= 31
};
#define FIRST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_LOCK))
-#define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_FILESYNC))
+#define LAST_OPERATION_TYPE (static_cast<int> (OPERATION_TYPE_TABLE_DELETE_ROW))
#define COUNT_OPERATION_TYPE (LAST_OPERATION_TYPE - FIRST_OPERATION_TYPE + 1)
+enum enum_object_type
+{
+ OBJECT_TYPE_TABLE= 1,
+ OBJECT_TYPE_TEMPORARY_TABLE= 2
+};
+#define FIRST_OBJECT_TYPE (static_cast<int> (OBJECT_TYPE_TABLE))
+#define LAST_OBJECT_TYPE (static_cast<int> (OBJECT_TYPE_TEMPORARY_TABLE))
+#define COUNT_OBJECT_TYPE (LAST_OBJECT_TYPE - FIRST_OBJECT_TYPE + 1)
+
#endif
=== modified file 'storage/perfschema/pfs_events_waits.h'
--- a/storage/perfschema/pfs_events_waits.h 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs_events_waits.h 2010-05-05 08:16:47 +0000
@@ -106,6 +106,8 @@ struct PFS_events_waits
enum timer_state m_timer_state;
/** Event id. */
ulonglong m_event_id;
+ /** Nesting event id. */
+ ulonglong m_nesting_event_id;
/**
Timer start.
This member is populated only if m_timed is true.
@@ -120,6 +122,8 @@ struct PFS_events_waits
const char *m_schema_name;
/** Length in bytes of @c m_schema_name. */
uint m_schema_name_length;
+ /** Object type */
+ enum_object_type m_object_type;
/** Object name. */
const char *m_object_name;
/** Length in bytes of @c m_object_name. */
@@ -137,6 +141,13 @@ struct PFS_events_waits
This member is populated for file READ/WRITE operations only.
*/
size_t m_number_of_bytes;
+ /**
+ Index used.
+ This member is populated for TABLE IO operations only.
+ */
+ uint m_index;
+ /** Flags */
+ ulong m_flags;
};
/**
=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc 2010-04-13 09:49:50 +0000
+++ b/storage/perfschema/pfs_instr.cc 2010-05-05 08:16:47 +0000
@@ -990,10 +990,12 @@ void destroy_file(PFS_thread *thread, PF
/**
Create instrumentation for a table instance.
@param share the table share
+ @param opening_thread the opening thread
@param identity the table address
@return a table instance, or NULL
*/
-PFS_table* create_table(PFS_table_share *share, const void *identity)
+PFS_table* create_table(PFS_table_share *share, PFS_thread *opening_thread,
+ const void *identity)
{
PFS_scan scan;
uint random= randomized_index(identity, table_max);
@@ -1012,10 +1014,12 @@ 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_opening_thread= opening_thread;
pfs->m_lock.dirty_to_allocated();
return pfs;
}
=== modified file 'storage/perfschema/pfs_instr.h'
--- a/storage/perfschema/pfs_instr.h 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs_instr.h 2010-05-05 08:16:47 +0000
@@ -124,6 +124,8 @@ struct PFS_file : public PFS_instr
/** Instrumented table implementation. @see PSI_table. */
struct PFS_table : public PFS_instr
{
+ /** Owner. */
+ PFS_thread *m_opening_thread;
/** Table share. */
PFS_table_share *m_share;
/** Table identity, typically a handler. */
@@ -266,7 +268,8 @@ PFS_file* find_or_create_file(PFS_thread
void release_file(PFS_file *pfs);
void destroy_file(PFS_thread *thread, PFS_file *pfs);
-PFS_table* create_table(PFS_table_share *share, const void *identity);
+PFS_table* create_table(PFS_table_share *share, PFS_thread *opening_thread,
+ const void *identity);
void destroy_table(PFS_table *pfs);
/* For iterators and show status. */
=== modified file 'storage/perfschema/pfs_instr_class.cc'
--- a/storage/perfschema/pfs_instr_class.cc 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs_instr_class.cc 2010-05-05 08:16:47 +0000
@@ -20,6 +20,8 @@
#include "my_global.h"
#include "my_sys.h"
+#include "structs.h"
+#include "table.h"
#include "pfs_instr_class.h"
#include "pfs_instr.h"
#include "pfs_global.h"
@@ -291,6 +293,37 @@ void cleanup_table_share_hash(void)
}
}
+LF_PINS* get_table_share_hash_pins(PFS_thread *thread)
+{
+ if (! table_share_hash_inited)
+ return NULL;
+ if (unlikely(thread->m_table_share_hash_pins == NULL))
+ thread->m_table_share_hash_pins= lf_hash_get_pins(&table_share_hash);
+ return thread->m_table_share_hash_pins;
+}
+
+static void set_table_share_key(PFS_table_share_key *key,
+ bool temporary,
+ const char *schema_name, uint schema_name_length,
+ const char *table_name, uint table_name_length)
+{
+ DBUG_ASSERT(schema_name_length <= NAME_LEN);
+ DBUG_ASSERT(table_name_length <= NAME_LEN);
+
+ char *ptr= &key->m_hash_key[0];
+ ptr[0]= (temporary ? OBJECT_TYPE_TEMPORARY_TABLE : OBJECT_TYPE_TABLE);
+ ptr++;
+ memcpy(ptr, schema_name, schema_name_length);
+ ptr+= schema_name_length;
+ ptr[0]= 0;
+ 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];
+}
+
/**
Initialize the file class buffer.
@param file_class_sizing max number of file class
@@ -687,68 +720,69 @@ PFS_file_class *sanitize_file_class(PFS_
}
/**
- Find or create a table instance by name.
+ Find or create a table share instrumentation.
@param thread the executing instrumented thread
- @param schema_name the table schema name
- @param schema_name_length the table schema name length
- @param table_name the table name
- @param table_name_length the table name length
- @return a table instance, or NULL
+ @param temporary true for TEMPORARY TABLE
+ @param share table share
+ @return a table share, or NULL
*/
PFS_table_share* find_or_create_table_share(PFS_thread *thread,
- const char *schema_name,
- uint schema_name_length,
- const char *table_name,
- uint table_name_length)
+ bool temporary,
+ const TABLE_SHARE *share)
{
/* See comments in register_mutex_class */
int pass;
PFS_table_share_key key;
- if (! table_share_hash_inited)
+ LF_PINS *pins= get_table_share_hash_pins(thread);
+ if (unlikely(pins == NULL))
{
- /* Table instrumentation can be turned off. */
table_share_lost++;
return NULL;
}
- if (unlikely(thread->m_table_share_hash_pins == NULL))
- {
- thread->m_table_share_hash_pins= lf_hash_get_pins(&table_share_hash);
- if (unlikely(thread->m_table_share_hash_pins == NULL))
- {
- table_share_lost++;
- return NULL;
- }
- }
-
- DBUG_ASSERT(schema_name_length <= NAME_LEN);
- DBUG_ASSERT(table_name_length <= NAME_LEN);
-
- char *ptr= &key.m_hash_key[0];
- memcpy(ptr, schema_name, schema_name_length);
- ptr+= schema_name_length;
- ptr[0]= 0; 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];
+ const char *schema_name= share->db.str;
+ uint schema_name_length= share->db.length;
+ const char *table_name= share->table_name.str;
+ uint table_name_length= share->table_name.length;
+
+ set_table_share_key(&key, temporary,
+ schema_name, schema_name_length,
+ table_name, table_name_length);
PFS_table_share **entry;
uint retry_count= 0;
const uint retry_max= 3;
+ bool enabled= true;
+ bool timed= true;
+
search:
entry= reinterpret_cast<PFS_table_share**>
- (lf_hash_search(&table_share_hash, thread->m_table_share_hash_pins,
- &key.m_hash_key[0], key.m_key_length));
+ (lf_hash_search(&table_share_hash, pins,
+ key.m_hash_key, key.m_key_length));
if (entry && (entry != MY_ERRPTR))
{
PFS_table_share *pfs;
pfs= *entry;
- lf_hash_search_unpin(thread->m_table_share_hash_pins);
+ pfs->m_refcount++ ;
+ 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;
+
+ /*
+ Even when enabled is false, a record is added in the dictionary:
+ - It makes enabling a table already in the table cache possible,
+ - It improves performances for the next time a TABLE_SHARE is reloaded
+ in the table cache.
+ */
+ }
+
/* table_name is not constant, just using it for noise on create */
uint i= randomized_index(table_name, table_share_max);
@@ -767,21 +801,20 @@ search:
if (pfs->m_lock.free_to_dirty())
{
pfs->m_key= key;
- pfs->m_schema_name= &pfs->m_key.m_hash_key[0];
+ 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 + 1];
+ 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= true;
- pfs->m_timed= true;
- pfs->m_aggregated= false;
+ pfs->m_enabled= enabled;
+ pfs->m_timed= timed;
+ pfs->m_refcount= 1;
int res;
- res= lf_hash_insert(&table_share_hash,
- thread->m_table_share_hash_pins, &pfs);
+ res= lf_hash_insert(&table_share_hash, pins, &pfs);
if (likely(res == 0))
{
pfs->m_lock.dirty_to_allocated();
@@ -814,6 +847,43 @@ search:
return NULL;
}
+void purge_table_share(PFS_thread *thread, PFS_table_share *pfs)
+{
+ if (pfs->m_refcount == 1)
+ {
+ LF_PINS* pins= get_table_share_hash_pins(thread);
+ if (likely(pins != NULL))
+ lf_hash_delete(&table_share_hash, pins,
+ pfs->m_key.m_hash_key, pfs->m_key.m_key_length);
+ pfs->m_lock.allocated_to_free();
+ }
+}
+
+void drop_table_share(PFS_thread *thread,
+ bool temporary,
+ const char *schema_name, uint schema_name_length,
+ const char *table_name, uint table_name_length)
+{
+ PFS_table_share_key key;
+ LF_PINS* pins= get_table_share_hash_pins(thread);
+ if (unlikely(pins == NULL))
+ return;
+ set_table_share_key(&key, temporary, schema_name, schema_name_length,
+ table_name, table_name_length);
+ PFS_table_share **entry;
+ entry= reinterpret_cast<PFS_table_share**>
+ (lf_hash_search(&table_share_hash, pins,
+ key.m_hash_key, key.m_key_length));
+ if (entry && (entry != MY_ERRPTR))
+ {
+ PFS_table_share *pfs= *entry;
+ lf_hash_search_unpin(pins);
+ lf_hash_delete(&table_share_hash, pins,
+ pfs->m_key.m_hash_key, pfs->m_key.m_key_length);
+ pfs->m_lock.allocated_to_free();
+ }
+}
+
PFS_table_share *sanitize_table_share(PFS_table_share *unsafe)
{
SANITIZE_ARRAY_BODY(table_share_array, table_share_max, unsafe);
=== modified file 'storage/perfschema/pfs_instr_class.h'
--- a/storage/perfschema/pfs_instr_class.h 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs_instr_class.h 2010-05-05 08:16:47 +0000
@@ -43,6 +43,7 @@
#include <mysql/psi/psi.h>
#include "pfs_lock.h"
#include "pfs_stat.h"
+#include "pfs_column_types.h"
/**
@addtogroup Performance_schema_buffers
@@ -135,17 +136,28 @@ struct PFS_table_share_key
/**
Hash search key.
This has to be a string for LF_HASH,
- the format is "<schema_name><0x00><object_name><0x00>"
+ the format is "<enum_object_type><schema_name><0x00><object_name><0x00>"
@see create_table_def_key
*/
- char m_hash_key[NAME_LEN + 1 + NAME_LEN + 1];
+ char m_hash_key[1 + NAME_LEN + 1 + NAME_LEN + 1];
/** Length in bytes of @c m_hash_key. */
uint m_key_length;
};
+struct PFS_table_key
+{
+ char m_name[NAME_LEN];
+ uint m_name_length;
+};
+
/** Instrumentation metadata for a table share. */
struct PFS_table_share
{
+ enum_object_type get_object_type()
+ {
+ return (enum_object_type) m_key.m_hash_key[0];
+ }
+
/** Internal lock. */
pfs_lock m_lock;
/** Search key. */
@@ -164,8 +176,9 @@ struct PFS_table_share
bool m_enabled;
/** True if this table instrument is timed. */
bool m_timed;
- /** True if this table instrument is aggregated. */
- bool m_aggregated;
+ bool m_purge;
+ /** Number of opened table handles. */
+ uint m_refcount;
};
/**
@@ -225,10 +238,13 @@ PFS_file_class *find_file_class(PSI_file
PFS_file_class *sanitize_file_class(PFS_file_class *unsafe);
PFS_table_share *find_or_create_table_share(PFS_thread *thread,
- const char *schema_name,
- uint schema_name_length,
- const char *table_name,
- uint table_name_length);
+ bool temporary,
+ const TABLE_SHARE *share);
+void purge_table_share(PFS_thread *thread, PFS_table_share *pfs);
+void drop_table_share(PFS_thread *thread,
+ bool temporary,
+ const char *schema_name, uint schema_name_length,
+ const char *table_name, uint table_name_length);
PFS_table_share *sanitize_table_share(PFS_table_share *unsafe);
=== modified file 'storage/perfschema/table_events_waits.cc'
--- a/storage/perfschema/table_events_waits.cc 2010-04-26 09:27:44 +0000
+++ b/storage/perfschema/table_events_waits.cc 2010-05-05 08:16:47 +0000
@@ -18,7 +18,8 @@
Table EVENTS_WAITS_xxx (implementation).
*/
-#include "sql_priv.h"
+#include "my_global.h"
+#include "my_pthread.h"
#include "table_events_waits.h"
#include "pfs_instr_class.h"
#include "pfs_instr.h"
@@ -230,6 +231,7 @@ void table_events_waits_common::make_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;
@@ -256,8 +258,16 @@ void table_events_waits_common::make_row
safe_class= sanitize_cond_class((PFS_cond_class*) wait->m_class);
break;
case WAIT_CLASS_TABLE:
- m_row.m_object_type= "TABLE";
- m_row.m_object_type_length= 5;
+ if (wait->m_object_type == OBJECT_TYPE_TABLE)
+ {
+ m_row.m_object_type= "TABLE";
+ m_row.m_object_type_length= 5;
+ }
+ else
+ {
+ m_row.m_object_type= "TEMPORARY TABLE";
+ m_row.m_object_type_length= 15;
+ }
memcpy(m_row.m_object_schema, wait->m_schema_name,
wait->m_schema_name_length);
m_row.m_object_schema_length= wait->m_schema_name_length;
@@ -299,7 +309,7 @@ void table_events_waits_common::make_row
m_row.m_source_length= sizeof(m_row.m_source);
m_row.m_operation= wait->m_operation;
m_row.m_number_of_bytes= wait->m_number_of_bytes;
- m_row.m_flags= 0;
+ m_row.m_flags= wait->m_flags;
if (thread_own_wait)
{
@@ -360,7 +370,15 @@ static const LEX_STRING operation_names_
{ C_STRING_WITH_LEN("chsize") },
{ C_STRING_WITH_LEN("delete") },
{ C_STRING_WITH_LEN("rename") },
- { C_STRING_WITH_LEN("sync") }
+ { C_STRING_WITH_LEN("sync") },
+
+ /* Table operations */
+ { C_STRING_WITH_LEN("lock") },
+ { C_STRING_WITH_LEN("external lock") },
+ { C_STRING_WITH_LEN("fetch") },
+ { C_STRING_WITH_LEN("insert") }, /* write row */
+ { C_STRING_WITH_LEN("update") }, /* update row */
+ { C_STRING_WITH_LEN("delete") } /* delete row */
};
@@ -462,7 +480,7 @@ int table_events_waits_common::read_row_
set_field_ulonglong(f, m_row.m_object_instance_addr);
break;
case 12: /* NESTING_EVENT_ID */
- f->set_null();
+ set_field_ulonglong(f, m_row.m_nesting_event_id);
break;
case 13: /* OPERATION */
operation= &operation_names_map[(int) m_row.m_operation - 1];
@@ -477,7 +495,11 @@ int table_events_waits_common::read_row_
f->set_null();
break;
case 15: /* FLAGS */
- set_field_ulong(f, m_row.m_flags);
+ if ((m_row.m_operation == OPERATION_TYPE_TABLE_LOCK) ||
+ (m_row.m_operation == OPERATION_TYPE_TABLE_EXTERNAL_LOCK))
+ set_field_ulong(f, m_row.m_flags);
+ else
+ f->set_null();
break;
default:
DBUG_ASSERT(false);
@@ -524,14 +546,26 @@ int table_events_waits_current::rnd_next
We do not show nested events for now,
this will be revised with TABLE io
*/
-#define ONLY_SHOW_ONE_WAIT
+// #define ONLY_SHOW_ONE_WAIT
#ifdef ONLY_SHOW_ONE_WAIT
if (m_pos.m_index_2 >= 1)
continue;
#else
- if (m_pos.m_index_2 >= pfs_thread->m_wait_locker_count)
- continue;
+ uint safe_locker_count= pfs_thread->m_wait_locker_count;
+
+ if (safe_locker_count == 0)
+ {
+ /* Display the last top level wait, when completed */
+ if (m_pos.m_index_2 >= 1)
+ continue;
+ }
+ else
+ {
+ /* Display all pending waits, when in progress */
+ if (m_pos.m_index_2 >= safe_locker_count)
+ continue;
+ }
#endif
wait= &pfs_thread->m_wait_locker_stack[m_pos.m_index_2].m_waits_current;
@@ -566,9 +600,24 @@ int table_events_waits_current::rnd_pos(
if (! pfs_thread->m_lock.is_populated())
return HA_ERR_RECORD_DELETED;
-#ifdef ONLY_SHOW_CURRENT_WAITS
- if (m_pos.m_index_2 >= pfs_thread->m_wait_locker_count)
+#ifdef ONLY_SHOW_ONE_WAIT
+ if (m_pos.m_index_2 >= 1)
return HA_ERR_RECORD_DELETED;
+#else
+ uint safe_locker_count= pfs_thread->m_wait_locker_count;
+
+ if (safe_locker_count == 0)
+ {
+ /* Display the last top level wait, when completed */
+ if (m_pos.m_index_2 >= 1)
+ return HA_ERR_RECORD_DELETED;
+ }
+ else
+ {
+ /* Display all pending waits, when in progress */
+ if (m_pos.m_index_2 >= safe_locker_count)
+ return HA_ERR_RECORD_DELETED;
+ }
#endif
DBUG_ASSERT(m_pos.m_index_2 < LOCKER_STACK_SIZE);
=== modified file 'storage/perfschema/table_events_waits.h'
--- a/storage/perfschema/table_events_waits.h 2010-04-26 09:27:44 +0000
+++ b/storage/perfschema/table_events_waits.h 2010-05-05 08:16:47 +0000
@@ -39,6 +39,8 @@ struct row_events_waits
ulong m_thread_internal_id;
/** Column EVENT_ID. */
ulonglong m_event_id;
+ /** Column NESTING_EVENT_ID. */
+ ulonglong m_nesting_event_id;
/** Column EVENT_NAME. */
const char *m_name;
/** Length in bytes of @c m_name. */
=== modified file 'storage/perfschema/table_setup_instruments.cc'
--- a/storage/perfschema/table_setup_instruments.cc 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/table_setup_instruments.cc 2010-05-05 08:16:47 +0000
@@ -18,8 +18,8 @@
Table SETUP_INSTRUMENTS (implementation).
*/
-#include "sql_priv.h"
-#include "unireg.h"
+#include "my_global.h"
+#include "my_pthread.h"
#include "pfs_instr_class.h"
#include "pfs_column_types.h"
#include "pfs_column_values.h"
@@ -133,6 +133,14 @@ int table_setup_instruments::rnd_next(vo
return 0;
}
break;
+ case pos_setup_instruments::VIEW_TABLE:
+ if (m_pos.m_index_2 == 1)
+ {
+ make_row(&global_table_class);
+ m_next_pos.set_after(&m_pos);
+ return 0;
+ }
+ break;
}
}
@@ -184,6 +192,13 @@ int table_setup_instruments::rnd_pos(con
return 0;
}
break;
+ case pos_setup_instruments::VIEW_TABLE:
+ if (m_pos.m_index_2 == 1)
+ {
+ make_row(&global_table_class);
+ return 0;
+ }
+ break;
}
return HA_ERR_RECORD_DELETED;
=== modified file 'storage/perfschema/table_setup_instruments.h'
--- a/storage/perfschema/table_setup_instruments.h 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/table_setup_instruments.h 2010-05-05 08:16:47 +0000
@@ -51,6 +51,7 @@ struct pos_setup_instruments : public PF
/** Reverved for WL#4674, PERFORMANCE_SCHEMA Setup For Actors. */
static const uint VIEW_THREAD= 4;
static const uint VIEW_FILE= 5;
+ static const uint VIEW_TABLE= 6;
pos_setup_instruments()
: PFS_double_index(VIEW_MUTEX, 1)
@@ -63,7 +64,7 @@ struct pos_setup_instruments : public PF
}
inline bool has_more_view(void)
- { return (m_index_1 <= VIEW_FILE); }
+ { return (m_index_1 <= VIEW_TABLE); }
inline void next_view(void)
{
=== modified file 'storage/perfschema/table_setup_objects.cc'
--- a/storage/perfschema/table_setup_objects.cc 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/table_setup_objects.cc 2010-05-05 08:16:47 +0000
@@ -112,59 +112,11 @@ void table_setup_objects::reset_position
int table_setup_objects::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_setup_objects::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;
- case pos_setup_objects::VIEW_EVENT:
- case pos_setup_objects::VIEW_PROCEDURE:
- case pos_setup_objects::VIEW_FUNCTION:
- default:
- break;
- }
- }
-
return HA_ERR_END_OF_FILE;
}
int table_setup_objects::rnd_pos(const void *pos)
{
- PFS_table_share *share;
-
- set_position(pos);
-
- switch (m_pos.m_index_1) {
- case pos_setup_objects::VIEW_TABLE:
- DBUG_ASSERT(m_pos.m_index_2 < table_share_max);
- share= &table_share_array[m_pos.m_index_2];
- if (share->m_lock.is_populated())
- {
- make_row(share);
- return 0;
- }
- break;
- case pos_setup_objects::VIEW_EVENT:
- case pos_setup_objects::VIEW_PROCEDURE:
- case pos_setup_objects::VIEW_FUNCTION:
- default:
- break;
- }
-
return HA_ERR_RECORD_DELETED;
}
@@ -184,7 +136,7 @@ void table_setup_objects::make_row(PFS_t
m_row.m_object_name_length= share->m_table_name_length;
m_row.m_enabled_ptr= &share->m_enabled;
m_row.m_timed_ptr= &share->m_timed;
- m_row.m_aggregated_ptr= &share->m_aggregated;
+ m_row.m_aggregated_ptr= NULL;
if (share->m_lock.end_optimistic_lock(&lock))
m_row_exists= true;
=== modified file 'storage/perfschema/unittest/pfs_instr-t.cc'
--- a/storage/perfschema/unittest/pfs_instr-t.cc 2010-04-13 11:48:46 +0000
+++ b/storage/perfschema/unittest/pfs_instr-t.cc 2010-05-05 08:16:47 +0000
@@ -143,10 +143,10 @@ void test_no_instances()
ok(file == NULL, "no file");
ok(file_lost == 5, "lost 5");
- table= create_table(& dummy_table_share, NULL);
+ table= create_table(& dummy_table_share, & fake_thread, NULL);
ok(table == NULL, "no table");
ok(table_lost == 1, "lost 1");
- table= create_table(& dummy_table_share, NULL);
+ table= create_table(& dummy_table_share, & fake_thread, NULL);
ok(table == NULL, "no table");
ok(table_lost == 2, "lost 2");
@@ -293,17 +293,17 @@ void test_with_instances()
ok(file_2 == NULL, "no file");
ok(file_lost == 2, "lost");
- table_1= create_table(& dummy_table_share, NULL);
+ table_1= create_table(& dummy_table_share, & fake_thread, NULL);
ok(table_1 != NULL, "table");
ok(table_lost == 0, "not lost");
- table_2= create_table(& dummy_table_share, NULL);
+ table_2= create_table(& dummy_table_share, & fake_thread, NULL);
ok(table_2 != NULL, "table");
ok(table_lost == 0, "not lost");
- table_2= create_table(& dummy_table_share, NULL);
+ table_2= create_table(& dummy_table_share, & fake_thread, NULL);
ok(table_2 == NULL, "no table");
ok(table_lost == 1, "lost 1");
destroy_table(table_1);
- table_2= create_table(& dummy_table_share, NULL);
+ table_2= create_table(& dummy_table_share, & fake_thread, NULL);
ok(table_2 != NULL, "table");
ok(table_lost == 1, "no new loss");
=== modified file 'storage/perfschema/unittest/pfs_instr_class-t.cc'
--- a/storage/perfschema/unittest/pfs_instr_class-t.cc 2010-04-13 11:48:46 +0000
+++ b/storage/perfschema/unittest/pfs_instr_class-t.cc 2010-05-05 08:16:47 +0000
@@ -83,12 +83,14 @@ void test_no_registration()
PFS_thread fake_thread;
fake_thread.m_table_share_hash_pins= NULL;
+#ifdef LATER
table= find_or_create_table_share(& fake_thread, "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);
ok(table == NULL, "not created");
table= find_or_create_table_share(& fake_thread, "foo_db", 6, "foo_table", 9);
ok(table == NULL, "not created");
+#endif
mutex= find_mutex_class(0);
ok(mutex == NULL, "no mutex key 0");
@@ -348,6 +350,7 @@ void test_file_registration()
void test_table_registration()
{
+#ifdef LATER
PFS_table_share *table_share;
PFS_table_share *table_share_2;
@@ -403,6 +406,7 @@ void test_table_registration()
cleanup_table_share_hash();
cleanup_table_share();
+#endif
}
void set_wait_stat(PFS_single_stat_chain *stat)
Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100505081647-ut84e6dyu4i6otq3.bundle
| Thread |
|---|
| • bzr push into mysql-next-mr-wl4895 branch (marc.alff:3141 to 3142)WL#4895 | Marc Alff | 5 May |