Commit 821db380 authored by Sergei Golubchik's avatar Sergei Golubchik

remove numerous #ifdef HAVE_PSI_TABLE_INTERFACE

simplify ha_table_share_psi()
parent a9035be5
......@@ -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.
......
......@@ -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:
......
......@@ -36,6 +36,7 @@
#include <my_compare.h>
#include <ft_global.h>
#include <keycache.h>
#include <mysql/psi/mysql_table.h>
#if MAX_KEY > 128
#error MAX_KEY is too large. Values up to 128 are supported.
......@@ -2907,34 +2908,29 @@ class handler :public Sql_alloc
/**
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);
}
......
......@@ -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 |
......
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment