| 2974 | ****************************************************************************/ |
| 2975 | |
| 2976 | sys_var *find_sys_var(THD *thd, const char *str, size_t length, |
| 2977 | bool throw_error, bool hash_already_locked) |
| 2978 | { |
| 2979 | sys_var *var; |
| 2980 | sys_var_pluginvar *pi; |
| 2981 | DBUG_ENTER("find_sys_var"); |
| 2982 | DBUG_PRINT("enter", ("var '%.*s'", (int)length, str)); |
| 2983 | |
| 2984 | if (!hash_already_locked) |
| 2985 | mysql_prlock_rdlock(&LOCK_system_variables_hash); |
| 2986 | if ((var= intern_find_sys_var(str, length)) && |
| 2987 | (pi= var->cast_pluginvar())) |
| 2988 | { |
| 2989 | mysql_mutex_lock(&LOCK_plugin); |
| 2990 | if (!intern_plugin_lock(thd ? thd->lex : 0, plugin_int_to_ref(pi->plugin), |
| 2991 | PLUGIN_IS_READY)) |
| 2992 | var= NULL; /* failed to lock it, it must be uninstalling */ |
| 2993 | mysql_mutex_unlock(&LOCK_plugin); |
| 2994 | } |
| 2995 | if (!hash_already_locked) |
| 2996 | mysql_prlock_unlock(&LOCK_system_variables_hash); |
| 2997 | |
| 2998 | if (unlikely(!throw_error && !var)) |
| 2999 | my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), |
| 3000 | (int) (length ? length : strlen(str)), (char*) str); |
| 3001 | DBUG_RETURN(var); |
| 3002 | } |
| 3003 | |
| 3004 | |
| 3005 | /* |
no test coverage detected