From 821db3801d443f5b7640921da9a6d15496649803 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 15 Apr 2013 18:47:47 +0200 Subject: [PATCH] remove numerous #ifdef HAVE_PSI_TABLE_INTERFACE simplify ha_table_share_psi() --- include/mysql/psi/mysql_table.h | 16 +++++++++++++ sql/handler.cc | 40 ++++++++++----------------------- sql/handler.h | 14 +++++------- sql/sql_base.cc | 12 ++-------- sql/sql_table.cc | 8 +++---- 5 files changed, 38 insertions(+), 52 deletions(-) diff --git a/include/mysql/psi/mysql_table.h b/include/mysql/psi/mysql_table.h index 1796943096e..5067bdaaab8 100644 --- a/include/mysql/psi/mysql_table.h +++ b/include/mysql/psi/mysql_table.h @@ -29,6 +29,22 @@ @{ */ +#ifdef HAVE_PSI_TABLE_INTERFACE +#define PSI_CALL_unbind_table PSI_CALL(unbind_table) +#define PSI_CALL_rebind_table PSI_CALL(rebind_table) +#define PSI_CALL_open_table PSI_CALL(open_table) +#define PSI_CALL_close_table PSI_CALL(close_table) +#define PSI_CALL_get_table_share PSI_CALL(get_table_share) +#define PSI_CALL_drop_table_share PSI_CALL(drop_table_share) +#else +#define PSI_CALL_unbind_table(A1) /* no-op */ +#define PSI_CALL_rebind_table(A1,A2,A3) NULL +#define PSI_CALL_close_table(A1) /* no-op */ +#define PSI_CALL_open_table(A1,A2) NULL +#define PSI_CALL_get_table_share(A1,A2) NULL +#define PSI_CALL_drop_table_share(A1,A2,A3,A4,A5) /* no-op */ +#endif + /** @def MYSQL_TABLE_WAIT_VARIABLES Instrumentation helper for table waits. diff --git a/sql/handler.cc b/sql/handler.cc index 398b6b5c8b1..88e91e51133 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -2265,14 +2265,11 @@ int ha_delete_table(THD *thd, handlerton *table_type, const char *path, } delete file; -#ifdef HAVE_PSI_TABLE_INTERFACE if (likely(error == 0)) { - my_bool temp_table= (my_bool)is_prefix(alias, tmp_file_prefix); - PSI_CALL(drop_table_share)(temp_table, db, strlen(db), - alias, strlen(alias)); + PSI_CALL_drop_table_share(is_prefix(alias, tmp_file_prefix), + db, strlen(db), alias, strlen(alias)); } -#endif DBUG_RETURN(error); } @@ -2343,31 +2340,27 @@ THD *handler::ha_thd(void) const void handler::unbind_psi() { -#ifdef HAVE_PSI_TABLE_INTERFACE /* Notify the instrumentation that this table is not owned by this thread any more. */ - PSI_CALL(unbind_table)(m_psi); -#endif + PSI_CALL_unbind_table(m_psi); } void handler::rebind_psi() { -#ifdef HAVE_PSI_TABLE_INTERFACE /* Notify the instrumentation that this table is now owned by this thread. */ - PSI_table_share *share_psi= ha_table_share_psi(table_share); - m_psi= PSI_CALL(rebind_table)(share_psi, this, m_psi); -#endif + PSI_table_share *share_psi= ha_table_share_psi(); + m_psi= PSI_CALL_rebind_table(share_psi, this, m_psi); } -PSI_table_share *handler::ha_table_share_psi(const TABLE_SHARE *share) const +PSI_table_share *handler::ha_table_share_psi() const { - return share->m_psi; + return table_share->m_psi; } /** @brief @@ -2409,10 +2402,7 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, { DBUG_ASSERT(m_psi == NULL); DBUG_ASSERT(table_share != NULL); -#ifdef HAVE_PSI_TABLE_INTERFACE - PSI_table_share *share_psi= ha_table_share_psi(table_share); - m_psi= PSI_CALL(open_table)(share_psi, this); -#endif + m_psi= PSI_CALL_open_table(ha_table_share_psi(), this); if (table->s->db_options_in_use & HA_OPTION_READ_ONLY_DATA) table->db_stat|=HA_READ_ONLY; @@ -2443,10 +2433,8 @@ int handler::ha_close(void) */ if (table->in_use) status_var_add(table->in_use->status_var.rows_tmp_read, rows_tmp_read); -#ifdef HAVE_PSI_TABLE_INTERFACE - PSI_CALL(close_table)(m_psi); + PSI_CALL_close_table(m_psi); m_psi= NULL; /* instrumentation handle, invalid after close_table() */ -#endif DBUG_RETURN(close()); } @@ -4355,9 +4343,7 @@ int ha_create_table(THD *thd, const char *path, goto err; } -#ifdef HAVE_PSI_TABLE_INTERFACE - share.m_psi= PSI_CALL(get_table_share)(temp_table, &share); -#endif + share.m_psi= PSI_CALL_get_table_share(temp_table, &share); if (open_table_from_share(thd, &share, "", 0, READ_ALL, 0, &table, true)) goto err; @@ -4373,10 +4359,8 @@ int ha_create_table(THD *thd, const char *path, if (error) { my_error(ER_CANT_CREATE_TABLE, MYF(0), db, table_name, error); -#ifdef HAVE_PSI_TABLE_INTERFACE - PSI_CALL(drop_table_share)(temp_table, share.db.str, share.db.length, - share.table_name.str, share.table_name.length); -#endif + PSI_CALL_drop_table_share(temp_table, share.db.str, share.db.length, + share.table_name.str, share.table_name.length); } err: diff --git a/sql/handler.h b/sql/handler.h index 44d86e5ec97..1b2ae21c05a 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -36,6 +36,7 @@ #include #include #include +#include #if MAX_KEY > 128 #error MAX_KEY is too large. Values up to 128 are supported. @@ -2907,34 +2908,29 @@ protected: /** Acquire the instrumented table information from a table share. - @param share a table share @return an instrumented table share, or NULL. */ - PSI_table_share *ha_table_share_psi(const TABLE_SHARE *share) const; + PSI_table_share *ha_table_share_psi() const; inline void psi_open() { DBUG_ASSERT(m_psi == NULL); DBUG_ASSERT(table_share != NULL); -#ifdef HAVE_PSI_INTERFACE if (PSI_server) { - PSI_table_share *share_psi= ha_table_share_psi(table_share); + PSI_table_share *share_psi= ha_table_share_psi(); if (share_psi) - m_psi= PSI_server->open_table(share_psi, this); + m_psi= PSI_CALL_open_table(share_psi, this); } -#endif } inline void psi_close() { -#ifdef HAVE_PSI_INTERFACE if (PSI_server && m_psi) { - PSI_server->close_table(m_psi); + PSI_CALL_close_table(m_psi); m_psi= NULL; /* instrumentation handle, invalid after close_table() */ } -#endif DBUG_ASSERT(m_psi == NULL); } diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 004fbb24294..7fe9429d664 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -640,11 +640,7 @@ TABLE_SHARE *get_table_share(THD *thd, const char *db, const char *table_name, goto err; } -#ifdef HAVE_PSI_TABLE_INTERFACE - share->m_psi= PSI_CALL(get_table_share)(false, share); -#else - share->m_psi= NULL; -#endif + share->m_psi= PSI_CALL_get_table_share(false, share); DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u", (ulong) share, share->ref_count)); @@ -6007,11 +6003,7 @@ TABLE *open_table_uncached(THD *thd, handlerton *hton, DBUG_RETURN(0); } -#ifdef HAVE_PSI_TABLE_INTERFACE - share->m_psi= PSI_CALL(get_table_share)(true, share); -#else - share->m_psi= NULL; -#endif + share->m_psi= PSI_CALL_get_table_share(true, share); if (open_table_from_share(thd, share, table_name, (uint) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE | diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 3ff20c52092..ab611ab8fc9 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4668,18 +4668,16 @@ mysql_rename_table(handlerton *base, const char *old_db, else if (error) my_error(ER_ERROR_ON_RENAME, MYF(0), from, to, error); -#ifdef HAVE_PSI_TABLE_INTERFACE /* Remove the old table share from the pfs table share array. The new table share will be created when the renamed table is first accessed. */ if (likely(error == 0)) { - my_bool temp_table= (my_bool)is_prefix(old_name, tmp_file_prefix); - PSI_CALL(drop_table_share)(temp_table, old_db, strlen(old_db), - old_name, strlen(old_name)); + PSI_CALL_drop_table_share(is_prefix(old_name, tmp_file_prefix), + old_db, strlen(old_db), + old_name, strlen(old_name)); } -#endif DBUG_RETURN(error != 0); }