returns a pointer to the memory which holds the thd-local variable or a pointer to the global variable if thd==null. If required, will sync with global variables if the requested variable has not yet been allocated in the current thread. */
| 3205 | has not yet been allocated in the current thread. |
| 3206 | */ |
| 3207 | static void *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) |
| 3208 | { |
| 3209 | DBUG_ENTER("intern_sys_var_ptr"); |
| 3210 | DBUG_ASSERT(offset >= 0); |
| 3211 | DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head); |
| 3212 | |
| 3213 | if (!thd) |
| 3214 | DBUG_RETURN(global_system_variables.dynamic_variables_ptr + offset); |
| 3215 | |
| 3216 | /* |
| 3217 | dynamic_variables_head points to the largest valid offset |
| 3218 | */ |
| 3219 | if (!thd->variables.dynamic_variables_ptr || |
| 3220 | (uint)offset > thd->variables.dynamic_variables_head) |
| 3221 | { |
| 3222 | mysql_prlock_rdlock(&LOCK_system_variables_hash); |
| 3223 | sync_dynamic_session_variables(thd, global_lock); |
| 3224 | mysql_prlock_unlock(&LOCK_system_variables_hash); |
| 3225 | } |
| 3226 | DBUG_RETURN(thd->variables.dynamic_variables_ptr + offset); |
| 3227 | } |
| 3228 | |
| 3229 | |
| 3230 | /** |
no test coverage detected