Commit 232d8337 authored by vasil's avatar vasil

branches/zip:

 
Rewrite the function innodb_plugin_init() to support parameters in
different order (in static and dynamic InnoDB) and to support more
parameters in the static InnoDB.
 
The previous implementation traversed both lists at the same time,
skipping parameters in the dynamic list that do not exist in the static
list. E.g. both lists were allowed to be static=(a, b, c),
dynamic=(a, b, c) or static=(a, b, c), dynamic=(a, b, x, c).
 
With the new implementation they are allowed to be
static=(a, b, c), dynamic=(b, a, c) or
static=(a, b, x, c), dynamic=(b, a, c) in addition.

The new implementation has complexity O(N^2) while the old one was O(N),
but this is acceptable sacrifice provided that innodb_plugin_init() is
called once per InnoDB lifetime and that N=39 currently, and N is not
going to increase much in the future, N=number of the InnoDB parameters.

Suggested by:	Sunny
Approved by:	Sunny
parent 6ef84d75
......@@ -9467,58 +9467,77 @@ innodb_plugin_init(void)
/* Copy the system variables. */
struct st_mysql_plugin* builtin;
struct st_mysql_sys_var** sta;
struct st_mysql_sys_var** dyn;
struct st_mysql_sys_var** sta; /* static parameters */
struct st_mysql_sys_var** dyn; /* dynamic parameters */
builtin = (struct st_mysql_plugin*) &builtin_innobase_plugin;
sta = builtin->system_vars;
dyn = innobase_system_variables;
for (; *sta != NULL; sta++, dyn++) {
if (*dyn == NULL) {
fprintf(stderr, "InnoDB: unknown parameter %s,0x%x\n",
(*sta)->name, (*sta)->flags);
return(false);
} else if (!innobase_match_parameter((*sta)->name,
(*dyn)->name)) {
/* Skip the destination parameter, since it doesn't
exist in the source. */
sta--;
continue;
} else if (((*sta)->flags ^ (*dyn)->flags)
& ~PLUGIN_VAR_READONLY) {
/* Ignore changes that affect the READONLY flag. */
fprintf(stderr,
"InnoDB: parameter mismatch:"
" %s,%s,0x%x,0x%x\n",
(*sta)->name, (*dyn)->name,
(*sta)->flags, (*dyn)->flags);
return(false);
} else if ((*sta)->flags & PLUGIN_VAR_THDLOCAL) {
/* Do not copy session variables. */
for (sta = builtin->system_vars; *sta != NULL; sta++) {
/* do not copy session variables */
if ((*sta)->flags & PLUGIN_VAR_THDLOCAL) {
continue;
}
switch ((*sta)->flags
& ~(PLUGIN_VAR_MASK | PLUGIN_VAR_UNSIGNED)) {
#define COPY_VAR(label, type) \
case label: \
*(type*)(*dyn)->value = *(type*)(*sta)->value; \
break;
for (dyn = innobase_system_variables; *dyn != NULL; dyn++) {
COPY_VAR(PLUGIN_VAR_BOOL, char);
COPY_VAR(PLUGIN_VAR_INT, int);
COPY_VAR(PLUGIN_VAR_LONG, long);
COPY_VAR(PLUGIN_VAR_LONGLONG, long long);
COPY_VAR(PLUGIN_VAR_STR, char*);
if (innobase_match_parameter((*sta)->name,
(*dyn)->name)) {
default:
fprintf(stderr, "InnoDB: unknown flags 0x%x for %s\n",
(*sta)->flags, (*sta)->name);
}
/* found the corresponding parameter */
/* check if the flags are the same,
ignoring differences in the READONLY flag;
e.g. we are not copying string variable to
an integer one */
if (((*sta)->flags & ~PLUGIN_VAR_READONLY)
!= ((*dyn)->flags & ~PLUGIN_VAR_READONLY)) {
fprintf(stderr,
"InnoDB: %s in static InnoDB "
"(flags=0x%x) differs from "
"%s in dynamic InnoDB "
"(flags=0x%x)\n",
(*sta)->name, (*sta)->flags,
(*dyn)->name, (*dyn)->flags);
/* we could break; here leaving this
parameter uncopied */
return(false);
}
/* Make the static InnoDB variable point to the dynamic one */
(*sta)->value = (*dyn)->value;
/* assign the value of the static parameter
to the dynamic one, according to their type */
#define COPY_VAR(label, type) \
case label: \
*(type*)(*dyn)->value = *(type*)(*sta)->value; \
break;
switch ((*sta)->flags
& ~(PLUGIN_VAR_MASK
| PLUGIN_VAR_UNSIGNED)) {
COPY_VAR(PLUGIN_VAR_BOOL, char);
COPY_VAR(PLUGIN_VAR_INT, int);
COPY_VAR(PLUGIN_VAR_LONG, long);
COPY_VAR(PLUGIN_VAR_LONGLONG, long long);
COPY_VAR(PLUGIN_VAR_STR, char*);
default:
fprintf(stderr,
"InnoDB: unknown flags "
"0x%x for %s\n",
(*sta)->flags, (*sta)->name);
}
/* Make the static InnoDB variable point to
the dynamic one */
(*sta)->value = (*dyn)->value;
break;
}
}
}
return(true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment