3370 Marc Alff 2011-05-19
Fixed the table handle thread owner for:
- partitioned tables
- temporary tables used in replications in a slave
modified:
sql/ha_partition.cc
sql/ha_partition.h
sql/handler.cc
sql/handler.h
sql/rpl_slave.cc
sql/sql_base.cc
3369 Marc Alff 2011-05-18
Integrated the table instrumentation with the table open cache.
modified:
include/mysql/psi/psi.h
include/mysql/psi/psi_abi_v1.h.pp
mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
sql/sql_base.cc
storage/perfschema/pfs.cc
=== modified file 'sql/ha_partition.cc'
--- a/sql/ha_partition.cc 2011-05-16 11:32:07 +0000
+++ b/sql/ha_partition.cc 2011-05-19 15:42:44 +0000
@@ -2963,6 +2963,33 @@ err_alloc:
DBUG_RETURN(error);
}
+void ha_partition::unbind_psi()
+{
+ uint i;
+
+ DBUG_ENTER("ha_partition::unbind_psi");
+ handler::unbind_psi();
+ for (i= 0; i < m_tot_parts; i++)
+ {
+ DBUG_ASSERT(m_file[i] != NULL);
+ m_file[i]->unbind_psi();
+ }
+ DBUG_VOID_RETURN;
+}
+
+void ha_partition::rebind_psi()
+{
+ uint i;
+
+ DBUG_ENTER("ha_partition::rebind_psi");
+ handler::rebind_psi();
+ for (i= 0; i < m_tot_parts; i++)
+ {
+ DBUG_ASSERT(m_file[i] != NULL);
+ m_file[i]->rebind_psi();
+ }
+ DBUG_VOID_RETURN;
+}
/**
Clone the open and locked partitioning handler.
=== modified file 'sql/ha_partition.h'
--- a/sql/ha_partition.h 2011-05-16 11:32:07 +0000
+++ b/sql/ha_partition.h 2011-05-19 15:42:44 +0000
@@ -299,6 +299,8 @@ public:
If the object was opened it will also be closed before being deleted.
*/
virtual int open(const char *name, int mode, uint test_if_locked);
+ virtual void unbind_psi();
+ virtual void rebind_psi();
virtual int close(void);
/*
=== modified file 'sql/handler.cc'
--- a/sql/handler.cc 2011-05-16 14:30:54 +0000
+++ b/sql/handler.cc 2011-05-19 15:42:44 +0000
@@ -2132,6 +2132,30 @@ THD *handler::ha_thd(void) const
return (table && table->in_use) ? table->in_use : current_thd;
}
+void handler::unbind_psi()
+{
+#ifdef HAVE_PSI_INTERFACE
+ /*
+ Notify the instrumentation that this table is not owned
+ by this thread any more.
+ */
+ if (likely(PSI_server != NULL))
+ PSI_server->unbind_table(m_psi);
+#endif
+}
+
+void handler::rebind_psi()
+{
+#ifdef HAVE_PSI_INTERFACE
+ /*
+ Notify the instrumentation that this table is now owned
+ by this thread.
+ */
+ if (likely(PSI_server != NULL))
+ PSI_server->rebind_table(m_psi);
+#endif
+}
+
PSI_table_share *handler::ha_table_share_psi(const TABLE_SHARE *share) const
{
return share->m_psi;
=== modified file 'sql/handler.h'
--- a/sql/handler.h 2011-05-12 17:29:19 +0000
+++ b/sql/handler.h 2011-05-19 15:42:44 +0000
@@ -1360,6 +1360,9 @@ public:
*/
PSI_table *m_psi;
+ virtual void unbind_psi();
+ virtual void rebind_psi();
+
private:
friend class DsMrr_impl;
/**
=== modified file 'sql/rpl_slave.cc'
--- a/sql/rpl_slave.cc 2011-05-16 14:30:54 +0000
+++ b/sql/rpl_slave.cc 2011-05-19 15:42:44 +0000
@@ -606,7 +606,19 @@ static void set_thd_in_use_temporary_tab
TABLE *table;
for (table= rli->save_temporary_tables ; table ; table= table->next)
+ {
table->in_use= rli->info_thd;
+ if (table->file != NULL)
+ {
+ /*
+ Since we are stealing opened temporary tables from one thread to another,
+ we need to let the performance schema know that,
+ for aggregates per thread to work properly.
+ */
+ table->file->unbind_psi();
+ table->file->rebind_psi();
+ }
+ }
}
int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock)
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2011-05-18 16:02:19 +0000
+++ b/sql/sql_base.cc 2011-05-19 15:42:44 +0000
@@ -467,14 +467,7 @@ static void table_def_use_table(THD *thd
/* The children must be detached from the table. */
DBUG_ASSERT(! table->file->extra(HA_EXTRA_IS_ATTACHED_CHILDREN));
-#ifdef HAVE_PSI_INTERFACE
- /*
- Notify the instrumentation that this table is now owned
- by this thread.
- */
- if (likely(PSI_server != NULL))
- PSI_server->rebind_table(table->file->m_psi);
-#endif
+ table->file->rebind_psi();
}
@@ -491,15 +484,7 @@ static void table_def_unuse_table(TABLE
DBUG_ASSERT(! table->s->has_old_version());
table->in_use= 0;
-
-#ifdef HAVE_PSI_INTERFACE
- /*
- Notify the instrumentation that this table is not owned
- by this thread any more.
- */
- if (likely(PSI_server != NULL))
- PSI_server->unbind_table(table->file->m_psi);
-#endif
+ table->file->unbind_psi();
/* Remove table from the list of tables used in this share. */
table->s->used_tables.remove(table);
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-wl5342 branch (marc.alff:3369 to 3370) | Marc Alff | 19 May |