MCPcopy Create free account
hub / github.com/MariaDB/server / sync_dynamic_session_variables

Function sync_dynamic_session_variables

sql/sql_plugin.cc:3145–3198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3143
3144
3145void sync_dynamic_session_variables(THD* thd, bool global_lock)
3146{
3147 uint idx;
3148
3149 thd->variables.dynamic_variables_ptr= (char*)
3150 my_realloc(key_memory_THD_variables,
3151 thd->variables.dynamic_variables_ptr,
3152 global_variables_dynamic_size,
3153 MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR));
3154
3155 if (global_lock)
3156 mysql_mutex_lock(&LOCK_global_system_variables);
3157
3158 mysql_mutex_assert_owner(&LOCK_global_system_variables);
3159
3160 memcpy(thd->variables.dynamic_variables_ptr +
3161 thd->variables.dynamic_variables_size,
3162 global_system_variables.dynamic_variables_ptr +
3163 thd->variables.dynamic_variables_size,
3164 global_system_variables.dynamic_variables_size -
3165 thd->variables.dynamic_variables_size);
3166
3167 /*
3168 now we need to iterate through any newly copied 'defaults'
3169 and if it is a string type with MEMALLOC flag, we need to strdup
3170 */
3171 for (idx= 0; idx < bookmark_hash.records; idx++)
3172 {
3173 st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx);
3174
3175 if (v->version <= thd->variables.dynamic_variables_version)
3176 continue; /* already in thd->variables */
3177
3178 /* Here we do anything special that may be required of the data types */
3179
3180 if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
3181 v->key[0] & BOOKMARK_MEMALLOC)
3182 {
3183 char **pp= (char**) (thd->variables.dynamic_variables_ptr + v->offset);
3184 if (*pp)
3185 *pp= my_strdup(key_memory_THD_variables, *pp, MYF(MY_WME|MY_FAE));
3186 }
3187 }
3188
3189 if (global_lock)
3190 mysql_mutex_unlock(&LOCK_global_system_variables);
3191
3192 thd->variables.dynamic_variables_version=
3193 global_system_variables.dynamic_variables_version;
3194 thd->variables.dynamic_variables_head=
3195 global_system_variables.dynamic_variables_head;
3196 thd->variables.dynamic_variables_size=
3197 global_system_variables.dynamic_variables_size;
3198}
3199
3200
3201/*

Callers 2

intern_sys_var_ptrFunction · 0.85
fill_variablesFunction · 0.85

Calls 3

my_reallocFunction · 0.85
my_hash_elementFunction · 0.85
my_strdupFunction · 0.85

Tested by

no test coverage detected