Commit f0cf48a0 authored by Sergei Golubchik's avatar Sergei Golubchik

small code cleanup - "good ifdef is no ifdef"

parent 81424b5b
...@@ -82,7 +82,7 @@ static plugin_ref ha_default_plugin(THD *thd) ...@@ -82,7 +82,7 @@ static plugin_ref ha_default_plugin(THD *thd)
{ {
if (thd->variables.table_plugin) if (thd->variables.table_plugin)
return thd->variables.table_plugin; return thd->variables.table_plugin;
return my_plugin_lock(thd, &global_system_variables.table_plugin); return my_plugin_lock(thd, global_system_variables.table_plugin);
} }
...@@ -163,13 +163,8 @@ plugin_ref ha_lock_engine(THD *thd, handlerton *hton) ...@@ -163,13 +163,8 @@ plugin_ref ha_lock_engine(THD *thd, handlerton *hton)
{ {
if (hton) if (hton)
{ {
st_plugin_int **plugin= hton2plugin + hton->slot; st_plugin_int *plugin= hton2plugin[hton->slot];
return my_plugin_lock(thd, plugin_int_to_ref(plugin));
#ifdef DBUG_OFF
return my_plugin_lock(thd, plugin);
#else
return my_plugin_lock(thd, &plugin);
#endif
} }
return NULL; return NULL;
} }
......
...@@ -3845,7 +3845,7 @@ uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, ...@@ -3845,7 +3845,7 @@ uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type,
LEX_STRING *engine_name; LEX_STRING *engine_name;
plugin_ref plugin= thd->variables.*offset; plugin_ref plugin= thd->variables.*offset;
if (type == OPT_GLOBAL) if (type == OPT_GLOBAL)
plugin= my_plugin_lock(thd, &(global_system_variables.*offset)); plugin= my_plugin_lock(thd, global_system_variables.*offset);
hton= plugin_data(plugin, handlerton*); hton= plugin_data(plugin, handlerton*);
engine_name= hton_name(hton); engine_name= hton_name(hton);
result= (uchar *) thd->strmake(engine_name->str, engine_name->length); result= (uchar *) thd->strmake(engine_name->str, engine_name->length);
...@@ -3866,7 +3866,7 @@ void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type) ...@@ -3866,7 +3866,7 @@ void sys_var_thd_storage_engine::set_default(THD *thd, enum_var_type type)
else else
{ {
value= &(thd->variables.*offset); value= &(thd->variables.*offset);
new_value= my_plugin_lock(NULL, &(global_system_variables.*offset)); new_value= my_plugin_lock(NULL, global_system_variables.*offset);
} }
DBUG_ASSERT(new_value); DBUG_ASSERT(new_value);
old_value= *value; old_value= *value;
...@@ -3883,7 +3883,7 @@ bool sys_var_thd_storage_engine::update(THD *thd, set_var *var) ...@@ -3883,7 +3883,7 @@ bool sys_var_thd_storage_engine::update(THD *thd, set_var *var)
old_value= *value; old_value= *value;
if (old_value != var->save_result.plugin) if (old_value != var->save_result.plugin)
{ {
*value= my_plugin_lock(NULL, &var->save_result.plugin); *value= my_plugin_lock(NULL, var->save_result.plugin);
plugin_unlock(NULL, old_value); plugin_unlock(NULL, old_value);
} }
return 0; return 0;
......
...@@ -19,14 +19,6 @@ ...@@ -19,14 +19,6 @@
#define REPORT_TO_LOG 1 #define REPORT_TO_LOG 1
#define REPORT_TO_USER 2 #define REPORT_TO_USER 2
#ifdef DBUG_OFF
#define plugin_ref_to_int(A) A
#define plugin_int_to_ref(A) A
#else
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
#define plugin_int_to_ref(A) &(A)
#endif
extern struct st_mysql_plugin *mysqld_builtins[]; extern struct st_mysql_plugin *mysqld_builtins[];
/** /**
...@@ -658,13 +650,13 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO) ...@@ -658,13 +650,13 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO)
} }
plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO) plugin_ref plugin_lock(THD *thd, plugin_ref ptr CALLER_INFO_PROTO)
{ {
LEX *lex= thd ? thd->lex : 0; LEX *lex= thd ? thd->lex : 0;
plugin_ref rc; plugin_ref rc;
DBUG_ENTER("plugin_lock"); DBUG_ENTER("plugin_lock");
pthread_mutex_lock(&LOCK_plugin); pthread_mutex_lock(&LOCK_plugin);
rc= my_intern_plugin_lock_ci(lex, *ptr); rc= my_intern_plugin_lock_ci(lex, ptr);
pthread_mutex_unlock(&LOCK_plugin); pthread_mutex_unlock(&LOCK_plugin);
DBUG_RETURN(rc); DBUG_RETURN(rc);
} }
......
...@@ -89,6 +89,8 @@ struct st_plugin_int ...@@ -89,6 +89,8 @@ struct st_plugin_int
*/ */
#ifdef DBUG_OFF #ifdef DBUG_OFF
typedef struct st_plugin_int *plugin_ref; typedef struct st_plugin_int *plugin_ref;
#define plugin_ref_to_int(A) A
#define plugin_int_to_ref(A) A
#define plugin_decl(pi) ((pi)->plugin) #define plugin_decl(pi) ((pi)->plugin)
#define plugin_dlib(pi) ((pi)->plugin_dl) #define plugin_dlib(pi) ((pi)->plugin_dl)
#define plugin_data(pi,cast) ((cast)((pi)->data)) #define plugin_data(pi,cast) ((cast)((pi)->data))
...@@ -97,6 +99,8 @@ typedef struct st_plugin_int *plugin_ref; ...@@ -97,6 +99,8 @@ typedef struct st_plugin_int *plugin_ref;
#define plugin_equals(p1,p2) ((p1) == (p2)) #define plugin_equals(p1,p2) ((p1) == (p2))
#else #else
typedef struct st_plugin_int **plugin_ref; typedef struct st_plugin_int **plugin_ref;
#define plugin_ref_to_int(A) (A ? A[0] : NULL)
#define plugin_int_to_ref(A) &(A)
#define plugin_decl(pi) ((pi)[0]->plugin) #define plugin_decl(pi) ((pi)[0]->plugin)
#define plugin_dlib(pi) ((pi)[0]->plugin_dl) #define plugin_dlib(pi) ((pi)[0]->plugin_dl)
#define plugin_data(pi,cast) ((cast)((pi)[0]->data)) #define plugin_data(pi,cast) ((cast)((pi)[0]->data))
...@@ -120,7 +124,7 @@ extern bool plugin_is_ready(const LEX_STRING *name, int type); ...@@ -120,7 +124,7 @@ extern bool plugin_is_ready(const LEX_STRING *name, int type);
#define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO) #define my_plugin_lock_by_name_ci(A,B,C) plugin_lock_by_name(A,B,C ORIG_CALLER_INFO)
#define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO) #define my_plugin_lock(A,B) plugin_lock(A,B CALLER_INFO)
#define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO) #define my_plugin_lock_ci(A,B) plugin_lock(A,B ORIG_CALLER_INFO)
extern plugin_ref plugin_lock(THD *thd, plugin_ref *ptr CALLER_INFO_PROTO); extern plugin_ref plugin_lock(THD *thd, plugin_ref ptr CALLER_INFO_PROTO);
extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name, extern plugin_ref plugin_lock_by_name(THD *thd, const LEX_STRING *name,
int type CALLER_INFO_PROTO); int type CALLER_INFO_PROTO);
extern void plugin_unlock(THD *thd, plugin_ref plugin); extern void plugin_unlock(THD *thd, plugin_ref plugin);
......
...@@ -11014,7 +11014,7 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table, ...@@ -11014,7 +11014,7 @@ create_internal_tmp_table_from_heap2(THD *thd, TABLE *table,
delete table->file; delete table->file;
table->file=0; table->file=0;
plugin_unlock(0, table->s->db_plugin); plugin_unlock(0, table->s->db_plugin);
share.db_plugin= my_plugin_lock(0, &share.db_plugin); share.db_plugin= my_plugin_lock(0, share.db_plugin);
new_table.s= table->s; // Keep old share new_table.s= table->s; // Keep old share
*table= new_table; *table= new_table;
*table->s= share; *table->s= share;
......
...@@ -899,7 +899,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, ...@@ -899,7 +899,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
replacing it with a globally locked version of tmp_plugin replacing it with a globally locked version of tmp_plugin
*/ */
plugin_unlock(NULL, share->db_plugin); plugin_unlock(NULL, share->db_plugin);
share->db_plugin= my_plugin_lock(NULL, &tmp_plugin); share->db_plugin= my_plugin_lock(NULL, tmp_plugin);
DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)", DBUG_PRINT("info", ("setting dbtype to '%.*s' (%d)",
str_db_type_length, next_chunk + 2, str_db_type_length, next_chunk + 2,
ha_legacy_type(share->db_type()))); ha_legacy_type(share->db_type())));
......
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