mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
MDEV-10441 Document the server_audit_loc_info variable
fix PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT plugin thdvars to work. use that for server_audit_loc_info
This commit is contained in:
parent
c91fdb66db
commit
d61e5260fb
4 changed files with 80 additions and 104 deletions
|
@ -8,7 +8,6 @@ server_audit_file_rotate_now OFF
|
|||
server_audit_file_rotate_size 1000000
|
||||
server_audit_file_rotations 9
|
||||
server_audit_incl_users
|
||||
server_audit_loc_info
|
||||
server_audit_logging OFF
|
||||
server_audit_mode 0
|
||||
server_audit_output_type file
|
||||
|
@ -72,7 +71,6 @@ server_audit_file_rotate_now OFF
|
|||
server_audit_file_rotate_size 1000000
|
||||
server_audit_file_rotations 9
|
||||
server_audit_incl_users odin, root, dva, tri
|
||||
server_audit_loc_info
|
||||
server_audit_logging ON
|
||||
server_audit_mode 0
|
||||
server_audit_output_type file
|
||||
|
@ -218,7 +216,6 @@ server_audit_file_rotate_now OFF
|
|||
server_audit_file_rotate_size 1000000
|
||||
server_audit_file_rotations 9
|
||||
server_audit_incl_users odin, root, dva, tri
|
||||
server_audit_loc_info
|
||||
server_audit_logging ON
|
||||
server_audit_mode 1
|
||||
server_audit_output_type file
|
||||
|
|
|
@ -8,7 +8,6 @@ server_audit_file_rotate_now OFF
|
|||
server_audit_file_rotate_size 1000000
|
||||
server_audit_file_rotations 9
|
||||
server_audit_incl_users
|
||||
server_audit_loc_info
|
||||
server_audit_logging OFF
|
||||
server_audit_mode 0
|
||||
server_audit_output_type file
|
||||
|
@ -72,7 +71,6 @@ server_audit_file_rotate_now OFF
|
|||
server_audit_file_rotate_size 1000000
|
||||
server_audit_file_rotations 9
|
||||
server_audit_incl_users odin, root, dva, tri
|
||||
server_audit_loc_info
|
||||
server_audit_logging ON
|
||||
server_audit_mode 0
|
||||
server_audit_output_type file
|
||||
|
@ -218,7 +216,6 @@ server_audit_file_rotate_now OFF
|
|||
server_audit_file_rotate_size 1000000
|
||||
server_audit_file_rotations 9
|
||||
server_audit_incl_users odin, root, dva, tri
|
||||
server_audit_loc_info
|
||||
server_audit_logging ON
|
||||
server_audit_mode 1
|
||||
server_audit_output_type file
|
||||
|
|
|
@ -429,9 +429,8 @@ static MYSQL_SYSVAR_UINT(query_log_limit, query_log_limit,
|
|||
char locinfo_ini_value[sizeof(struct connection_info)+4];
|
||||
|
||||
static MYSQL_THDVAR_STR(loc_info,
|
||||
PLUGIN_VAR_READONLY | PLUGIN_VAR_MEMALLOC,
|
||||
"Auxiliary info.", NULL, NULL,
|
||||
locinfo_ini_value);
|
||||
PLUGIN_VAR_NOSYSVAR | PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_MEMALLOC,
|
||||
"Internal info", NULL, NULL, locinfo_ini_value);
|
||||
|
||||
static const char *syslog_facility_names[]=
|
||||
{
|
||||
|
|
|
@ -2756,6 +2756,22 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name,
|
|||
}
|
||||
|
||||
|
||||
static size_t var_storage_size(int flags)
|
||||
{
|
||||
switch (flags & PLUGIN_VAR_TYPEMASK) {
|
||||
case PLUGIN_VAR_BOOL: return sizeof(my_bool);
|
||||
case PLUGIN_VAR_INT: return sizeof(int);
|
||||
case PLUGIN_VAR_LONG: return sizeof(long);
|
||||
case PLUGIN_VAR_ENUM: return sizeof(long);
|
||||
case PLUGIN_VAR_LONGLONG: return sizeof(ulonglong);
|
||||
case PLUGIN_VAR_SET: return sizeof(ulonglong);
|
||||
case PLUGIN_VAR_STR: return sizeof(char*);
|
||||
case PLUGIN_VAR_DOUBLE: return sizeof(double);
|
||||
default: DBUG_ASSERT(0); return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
returns a bookmark for thd-local variables, creating if neccessary.
|
||||
returns null for non thd-local variables.
|
||||
|
@ -2764,39 +2780,13 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name,
|
|||
static st_bookmark *register_var(const char *plugin, const char *name,
|
||||
int flags)
|
||||
{
|
||||
uint length= strlen(plugin) + strlen(name) + 3, size= 0, offset, new_size;
|
||||
uint length= strlen(plugin) + strlen(name) + 3, size, offset, new_size;
|
||||
st_bookmark *result;
|
||||
char *varname, *p;
|
||||
|
||||
if (!(flags & PLUGIN_VAR_THDLOCAL))
|
||||
return NULL;
|
||||
|
||||
switch (flags & PLUGIN_VAR_TYPEMASK) {
|
||||
case PLUGIN_VAR_BOOL:
|
||||
size= sizeof(my_bool);
|
||||
break;
|
||||
case PLUGIN_VAR_INT:
|
||||
size= sizeof(int);
|
||||
break;
|
||||
case PLUGIN_VAR_LONG:
|
||||
case PLUGIN_VAR_ENUM:
|
||||
size= sizeof(long);
|
||||
break;
|
||||
case PLUGIN_VAR_LONGLONG:
|
||||
case PLUGIN_VAR_SET:
|
||||
size= sizeof(ulonglong);
|
||||
break;
|
||||
case PLUGIN_VAR_STR:
|
||||
size= sizeof(char*);
|
||||
break;
|
||||
case PLUGIN_VAR_DOUBLE:
|
||||
size= sizeof(double);
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
return NULL;
|
||||
};
|
||||
DBUG_ASSERT(flags & PLUGIN_VAR_THDLOCAL);
|
||||
|
||||
size= var_storage_size(flags);
|
||||
varname= ((char*) my_alloca(length));
|
||||
strxmov(varname + 1, plugin, "_", name, NullS);
|
||||
for (p= varname + 1; *p; p++)
|
||||
|
@ -3005,25 +2995,17 @@ void sync_dynamic_session_variables(THD* thd, bool global_lock)
|
|||
*/
|
||||
for (idx= 0; idx < bookmark_hash.records; idx++)
|
||||
{
|
||||
sys_var_pluginvar *pi;
|
||||
sys_var *var;
|
||||
st_bookmark *v= (st_bookmark*) my_hash_element(&bookmark_hash,idx);
|
||||
|
||||
if (v->version <= thd->variables.dynamic_variables_version)
|
||||
continue; /* already in thd->variables */
|
||||
|
||||
if (!(var= intern_find_sys_var(v->key + 1, v->name_len)) ||
|
||||
!(pi= var->cast_pluginvar()) ||
|
||||
v->key[0] != plugin_var_bookmark_key(pi->plugin_var->flags))
|
||||
continue;
|
||||
|
||||
/* Here we do anything special that may be required of the data types */
|
||||
|
||||
if ((pi->plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
|
||||
pi->plugin_var->flags & PLUGIN_VAR_MEMALLOC)
|
||||
if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
|
||||
v->key[0] & BOOKMARK_MEMALLOC)
|
||||
{
|
||||
int offset= ((thdvar_str_t *)(pi->plugin_var))->offset;
|
||||
char **pp= (char**) (thd->variables.dynamic_variables_ptr + offset);
|
||||
char **pp= (char**) (thd->variables.dynamic_variables_ptr + v->offset);
|
||||
if (*pp)
|
||||
*pp= my_strdup(*pp, MYF(MY_WME|MY_FAE));
|
||||
}
|
||||
|
@ -3284,6 +3266,48 @@ bool sys_var_pluginvar::session_update(THD *thd, set_var *var)
|
|||
return false;
|
||||
}
|
||||
|
||||
static const void *var_def_ptr(st_mysql_sys_var *pv)
|
||||
{
|
||||
switch (pv->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {
|
||||
case PLUGIN_VAR_INT:
|
||||
return &((sysvar_uint_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_LONG:
|
||||
return &((sysvar_ulong_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_LONGLONG:
|
||||
return &((sysvar_ulonglong_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_ENUM:
|
||||
return &((sysvar_enum_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_SET:
|
||||
return &((sysvar_set_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_BOOL:
|
||||
return &((sysvar_bool_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_STR:
|
||||
return &((sysvar_str_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_DOUBLE:
|
||||
return &((sysvar_double_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_uint_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_ulong_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_ulonglong_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_enum_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_set_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_bool_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_str_t*) pv)->def_val;
|
||||
case PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL:
|
||||
return &((thdvar_double_t*) pv)->def_val;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool sys_var_pluginvar::global_update(THD *thd, set_var *var)
|
||||
{
|
||||
DBUG_ASSERT(!is_readonly());
|
||||
|
@ -3293,60 +3317,7 @@ bool sys_var_pluginvar::global_update(THD *thd, set_var *var)
|
|||
const void *src= &var->save_result;
|
||||
|
||||
if (!var->value)
|
||||
{
|
||||
switch (plugin_var->flags & (PLUGIN_VAR_TYPEMASK | PLUGIN_VAR_THDLOCAL)) {
|
||||
case PLUGIN_VAR_INT:
|
||||
src= &((sysvar_uint_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_LONG:
|
||||
src= &((sysvar_ulong_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_LONGLONG:
|
||||
src= &((sysvar_ulonglong_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_ENUM:
|
||||
src= &((sysvar_enum_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_SET:
|
||||
src= &((sysvar_set_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_BOOL:
|
||||
src= &((sysvar_bool_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_STR:
|
||||
src= &((sysvar_str_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_DOUBLE:
|
||||
src= &((sysvar_double_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_INT | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_uint_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_LONG | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_ulong_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_LONGLONG | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_ulonglong_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_ENUM | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_enum_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_SET | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_set_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_BOOL | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_bool_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_STR | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_str_t*) plugin_var)->def_val;
|
||||
break;
|
||||
case PLUGIN_VAR_DOUBLE | PLUGIN_VAR_THDLOCAL:
|
||||
src= &((thdvar_double_t*) plugin_var)->def_val;
|
||||
break;
|
||||
default:
|
||||
DBUG_ASSERT(0);
|
||||
}
|
||||
}
|
||||
src= var_def_ptr(plugin_var);
|
||||
|
||||
plugin_var->update(thd, plugin_var, tgt, src);
|
||||
return false;
|
||||
|
@ -3713,7 +3684,18 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp,
|
|||
*(int*)(opt + 1)= offset= v->offset;
|
||||
|
||||
if (opt->flags & PLUGIN_VAR_NOCMDOPT)
|
||||
{
|
||||
char *val= global_system_variables.dynamic_variables_ptr + offset;
|
||||
if (((opt->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR) &&
|
||||
(opt->flags & PLUGIN_VAR_MEMALLOC))
|
||||
{
|
||||
char *def_val= *(char**)var_def_ptr(opt);
|
||||
*(char**)val= def_val ? my_strdup(def_val, MYF(0)) : NULL;
|
||||
}
|
||||
else
|
||||
memcpy(val, var_def_ptr(opt), var_storage_size(opt->flags));
|
||||
continue;
|
||||
}
|
||||
|
||||
optname= (char*) memdup_root(mem_root, v->key + 1,
|
||||
(optnamelen= v->name_len) + 1);
|
||||
|
@ -3912,9 +3894,10 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp,
|
|||
*str->value= strdup_root(mem_root, *str->value);
|
||||
}
|
||||
|
||||
var= find_bookmark(plugin_name.str, o->name, o->flags);
|
||||
if (o->flags & PLUGIN_VAR_NOSYSVAR)
|
||||
continue;
|
||||
if ((var= find_bookmark(plugin_name.str, o->name, o->flags)))
|
||||
if (var)
|
||||
v= new (mem_root) sys_var_pluginvar(&chain, var->key + 1, o, tmp);
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue