| 3281 | } |
| 3282 | |
| 3283 | void plugin_thdvar_init(THD *thd) |
| 3284 | { |
| 3285 | plugin_ref old_table_plugin= thd->variables.table_plugin; |
| 3286 | plugin_ref old_tmp_table_plugin= thd->variables.tmp_table_plugin; |
| 3287 | plugin_ref old_enforced_table_plugin= thd->variables.enforced_table_plugin; |
| 3288 | DBUG_ENTER("plugin_thdvar_init"); |
| 3289 | |
| 3290 | // This function may be called many times per THD (e.g. on COM_CHANGE_USER) |
| 3291 | thd->variables.table_plugin= NULL; |
| 3292 | thd->variables.tmp_table_plugin= NULL; |
| 3293 | thd->variables.enforced_table_plugin= NULL; |
| 3294 | cleanup_variables(&thd->variables); |
| 3295 | |
| 3296 | /* This and all other variable cleanups are here for COM_CHANGE_USER :( */ |
| 3297 | #ifndef EMBEDDED_LIBRARY |
| 3298 | thd->session_tracker.sysvars.deinit(thd); |
| 3299 | my_free(thd->variables.redirect_url); |
| 3300 | thd->variables.redirect_url= 0; |
| 3301 | #endif |
| 3302 | my_free((char*) thd->variables.default_master_connection.str); |
| 3303 | thd->variables.default_master_connection.str= 0; |
| 3304 | thd->variables.default_master_connection.length= 0; |
| 3305 | |
| 3306 | thd->variables= global_system_variables; |
| 3307 | |
| 3308 | /* we are going to allocate these lazily */ |
| 3309 | thd->variables.dynamic_variables_version= 0; |
| 3310 | thd->variables.dynamic_variables_size= 0; |
| 3311 | thd->variables.dynamic_variables_ptr= 0; |
| 3312 | |
| 3313 | mysql_mutex_lock(&LOCK_plugin); |
| 3314 | thd->variables.table_plugin= |
| 3315 | intern_plugin_lock(NULL, global_system_variables.table_plugin); |
| 3316 | if (global_system_variables.tmp_table_plugin) |
| 3317 | thd->variables.tmp_table_plugin= |
| 3318 | intern_plugin_lock(NULL, global_system_variables.tmp_table_plugin); |
| 3319 | if (global_system_variables.enforced_table_plugin) |
| 3320 | thd->variables.enforced_table_plugin= |
| 3321 | intern_plugin_lock(NULL, global_system_variables.enforced_table_plugin); |
| 3322 | intern_plugin_unlock(NULL, old_table_plugin); |
| 3323 | intern_plugin_unlock(NULL, old_tmp_table_plugin); |
| 3324 | intern_plugin_unlock(NULL, old_enforced_table_plugin); |
| 3325 | mysql_mutex_unlock(&LOCK_plugin); |
| 3326 | |
| 3327 | thd->variables.default_master_connection.str= |
| 3328 | my_strndup(key_memory_Sys_var_charptr_value, |
| 3329 | global_system_variables.default_master_connection.str, |
| 3330 | global_system_variables.default_master_connection.length, |
| 3331 | MYF(MY_WME | MY_THREAD_SPECIFIC)); |
| 3332 | #ifndef EMBEDDED_LIBRARY |
| 3333 | thd->session_tracker.sysvars.init(thd); |
| 3334 | thd->variables.redirect_url= |
| 3335 | my_strdup(key_memory_Sys_var_charptr_value, |
| 3336 | global_system_variables.redirect_url, |
| 3337 | MYF(MY_WME | MY_THREAD_SPECIFIC)); |
| 3338 | #endif |
| 3339 | |
| 3340 | DBUG_VOID_RETURN; |
no test coverage detected