Commit 6b36cc4b authored by marko's avatar marko

branches/zip: Clean up the file format stamping.

trx_sys_file_format_max_upgrade(): Rename from
trx_sys_file_format_max_update().  Improve the documentation.  Add a
const qualifier to the parameter "name".  Replace the parameter
"flags" with "format_id", because this function should deal with file
format identifiers, not with table flags.

trx_sys_file_format_max_write(), trx_sys_file_format_max_set(): Add a
const qualifier to the parameter "name".

ha_innodb.cc: Correct the spelling in some comments: "side effect".
Remove redundant prototypes for some static callback functions.

innodb_file_format_name_update(), innodb_file_format_check_update():
Correct the function signature.  Use appropriate pointer type conversions.

MYSQL_SYSVAR_STR(file_format), MYSQL_SYSVAR_STR(file_format_check):
Remove the type conversions from the callback function pointers.  When
the function signatures match, no type conversion is needed.  The type
conversions would only prevent compilation warnings for any mismatch.

Approved by Sunny in rb://25.
parent 19893425
...@@ -210,7 +210,7 @@ innobase_file_format_name_lookup( ...@@ -210,7 +210,7 @@ innobase_file_format_name_lookup(
const char* format_name); /* in: pointer to file format const char* format_name); /* in: pointer to file format
name */ name */
/**************************************************************** /****************************************************************
Validate the file format check config parameters, as a side affect it Validate the file format check config parameters, as a side effect it
sets the srv_check_file_format_at_startup variable. */ sets the srv_check_file_format_at_startup variable. */
static static
bool bool
...@@ -220,7 +220,7 @@ innobase_file_format_check_on_off( ...@@ -220,7 +220,7 @@ innobase_file_format_check_on_off(
"on" or "off" */ "on" or "off" */
const char* format_check); /* in: parameter value */ const char* format_check); /* in: parameter value */
/**************************************************************** /****************************************************************
Validate the file format check config parameters, as a side affect it Validate the file format check config parameters, as a side effect it
sets the srv_check_file_format_at_startup variable. */ sets the srv_check_file_format_at_startup variable. */
static static
bool bool
...@@ -229,71 +229,6 @@ innobase_file_format_check_validate( ...@@ -229,71 +229,6 @@ innobase_file_format_check_validate(
/* out: true if valid /* out: true if valid
config value */ config value */
const char* format_check); /* in: parameter value */ const char* format_check); /* in: parameter value */
/*****************************************************************
Check if it is a valid file format. This function is registered as
a callback with MySQL. */
static
int
innodb_file_format_name_validate(
/*=============================*/
/* out: 0 for valid file
format */
THD* thd, /* in: thread handle */
struct st_mysql_sys_var* var, /* in: pointer to system
variable */
void* save, /* out: immediate result
for update function */
struct st_mysql_value* value); /* in: incoming string */
/********************************************************************
Update the system variable innodb_file_format using the "saved"
value. This function is registered as a callback with MySQL. */
static
bool
innodb_file_format_name_update(
/*===========================*/
/* out: should never
fail since it is
already validated */
THD* thd, /* in: thread handle */
struct st_mysql_sys_var* var, /* in: pointer to
system variable */
void* var_ptr,/* out: where the
formal string goes */
void* save); /* in: immediate result
from check function */
/*****************************************************************
Check if it is a valid file format. This function is registered as
a callback with MySQL. */
static
int
innodb_file_format_check_validate(
/*==============================*/
/* out: 0 for valid file
format */
THD* thd, /* in: thread handle */
struct st_mysql_sys_var* var, /* in: pointer to system
variable */
void* save, /* out: immediate result
for update function */
struct st_mysql_value* value); /* in: incoming string */
/********************************************************************
Update the system variable innodb_file_format_check using the "saved"
value. This function is registered as a callback with MySQL. */
static
bool
innodb_file_format_check_update(
/*============================*/
/* out: should never
fail since it is
already validated */
THD* thd, /* in: thread handle */
struct st_mysql_sys_var* var, /* in: pointer to
system variable */
void* var_ptr,/* out: where the
formal string goes */
void* save); /* in: immediate result
from check function */
/******************************************************************** /********************************************************************
Return alter table flags supported in an InnoDB database. */ Return alter table flags supported in an InnoDB database. */
static static
...@@ -1988,13 +1923,13 @@ innobase_init( ...@@ -1988,13 +1923,13 @@ innobase_init(
/* Process innobase_file_format_check variable */ /* Process innobase_file_format_check variable */
ut_a(innobase_file_format_check != NULL); ut_a(innobase_file_format_check != NULL);
/* As a side affect it will set srv_check_file_format_at_startup /* As a side effect it will set srv_check_file_format_at_startup
on valid input. First we check for "on"/"off". */ on valid input. First we check for "on"/"off". */
if (!innobase_file_format_check_on_off(innobase_file_format_check)) { if (!innobase_file_format_check_on_off(innobase_file_format_check)) {
/* Did the user specify a format name that we support ? /* Did the user specify a format name that we support ?
As a side affect it will update the variable As a side effect it will update the variable
srv_check_file_format_at_startup*/ srv_check_file_format_at_startup */
if (!innobase_file_format_check_validate( if (!innobase_file_format_check_validate(
innobase_file_format_check)) { innobase_file_format_check)) {
...@@ -3032,8 +2967,9 @@ retry: ...@@ -3032,8 +2967,9 @@ retry:
/* We update the highest file format in the system table /* We update the highest file format in the system table
space, if this table has higher file format setting. */ space, if this table has higher file format setting. */
trx_sys_file_format_max_update( trx_sys_file_format_max_upgrade(
prebuilt->table->flags, &innobase_file_format_check); (const char**) &innobase_file_format_check,
dict_table_get_format(prebuilt->table));
} }
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
...@@ -6166,10 +6102,14 @@ ha_innobase::create( ...@@ -6166,10 +6102,14 @@ ha_innobase::create(
DBUG_ASSERT(innobase_table != 0); DBUG_ASSERT(innobase_table != 0);
/* We update the highest file format in the system table if (innobase_table) {
space, if this table has a higher file format setting. */ /* We update the highest file format in the system table
space, if this table has higher file format setting. */
trx_sys_file_format_max_update(flags, &innobase_file_format_check); trx_sys_file_format_max_upgrade(
(const char**) &innobase_file_format_check,
dict_table_get_format(innobase_table));
}
/* Note: We can't call update_thd() as prebuilt will not be /* Note: We can't call update_thd() as prebuilt will not be
setup at this stage and so we use thd. */ setup at this stage and so we use thd. */
...@@ -9078,7 +9018,7 @@ innobase_file_format_name_lookup( ...@@ -9078,7 +9018,7 @@ innobase_file_format_name_lookup(
/**************************************************************** /****************************************************************
Validate the file format check value, is it one of "on" or "off", Validate the file format check value, is it one of "on" or "off",
as a side affect it sets the srv_check_file_format_at_startup variable. */ as a side effect it sets the srv_check_file_format_at_startup variable. */
static static
bool bool
innobase_file_format_check_on_off( innobase_file_format_check_on_off(
...@@ -9106,7 +9046,7 @@ innobase_file_format_check_on_off( ...@@ -9106,7 +9046,7 @@ innobase_file_format_check_on_off(
} }
/**************************************************************** /****************************************************************
Validate the file format check config parameters, as a side affect it Validate the file format check config parameters, as a side effect it
sets the srv_check_file_format_at_startup variable. */ sets the srv_check_file_format_at_startup variable. */
static static
bool bool
...@@ -9117,7 +9057,7 @@ innobase_file_format_check_validate( ...@@ -9117,7 +9057,7 @@ innobase_file_format_check_validate(
{ {
uint format_id; uint format_id;
bool ret = true; bool ret = true;
format_id = innobase_file_format_name_lookup(format_check); format_id = innobase_file_format_name_lookup(format_check);
if (format_id < DICT_TF_FORMAT_MAX + 1) { if (format_id < DICT_TF_FORMAT_MAX + 1) {
...@@ -9174,32 +9114,25 @@ innodb_file_format_name_validate( ...@@ -9174,32 +9114,25 @@ innodb_file_format_name_validate(
Update the system variable innodb_file_format using the "saved" Update the system variable innodb_file_format using the "saved"
value. This function is registered as a callback with MySQL. */ value. This function is registered as a callback with MySQL. */
static static
bool void
innodb_file_format_name_update( innodb_file_format_name_update(
/*===========================*/ /*===========================*/
/* out: should never
fail since it is
already validated */
THD* thd, /* in: thread handle */ THD* thd, /* in: thread handle */
struct st_mysql_sys_var* var, /* in: pointer to struct st_mysql_sys_var* var, /* in: pointer to
system variable */ system variable */
void* var_ptr, /* out: where the void* var_ptr, /* out: where the
formal string goes */ formal string goes */
void* save) /* in: immediate result const void* save) /* in: immediate result
from check function */ from check function */
{ {
ut_a(var_ptr != NULL); ut_a(var_ptr != NULL);
ut_a(save != NULL); ut_a(save != NULL);
ut_a((*(uint*) save) <= DICT_TF_FORMAT_MAX); ut_a((*(const uint*) save) <= DICT_TF_FORMAT_MAX);
srv_file_format = *(uint*) save;
/* Given the type of var_ptr we have little choice but to cast srv_file_format = *(const uint*) save;
away the constness from the returned name. */
(*(char**) var_ptr) =
(char*) trx_sys_file_format_id_to_name(srv_file_format);
return(true); *(const char**) var_ptr
= trx_sys_file_format_id_to_name(srv_file_format);
} }
/***************************************************************** /*****************************************************************
...@@ -9268,18 +9201,15 @@ innodb_file_format_check_validate( ...@@ -9268,18 +9201,15 @@ innodb_file_format_check_validate(
Update the system variable innodb_file_format_check using the "saved" Update the system variable innodb_file_format_check using the "saved"
value. This function is registered as a callback with MySQL. */ value. This function is registered as a callback with MySQL. */
static static
bool void
innodb_file_format_check_update( innodb_file_format_check_update(
/*============================*/ /*============================*/
/* out: should never
fail since it is
already validated */
THD* thd, /* in: thread handle */ THD* thd, /* in: thread handle */
struct st_mysql_sys_var* var, /* in: pointer to struct st_mysql_sys_var* var, /* in: pointer to
system variable */ system variable */
void* var_ptr, /* out: where the void* var_ptr, /* out: where the
formal string goes */ formal string goes */
void* save) /* in: immediate result const void* save) /* in: immediate result
from check function */ from check function */
{ {
uint format_id; uint format_id;
...@@ -9287,17 +9217,15 @@ innodb_file_format_check_update( ...@@ -9287,17 +9217,15 @@ innodb_file_format_check_update(
ut_a(save != NULL); ut_a(save != NULL);
ut_a(var_ptr != NULL); ut_a(var_ptr != NULL);
format_id = *(uint*) save; format_id = *(const uint*) save;
/* Update the max format id in the system tablespace. */ /* Update the max format id in the system tablespace. */
if (trx_sys_file_format_max_set(format_id, (char**) var_ptr)) { if (trx_sys_file_format_max_set(format_id, (const char**) var_ptr)) {
ut_print_timestamp(stderr); ut_print_timestamp(stderr);
fprintf(stderr, fprintf(stderr,
" [Info] InnoDB: the file format in the system " " [Info] InnoDB: the file format in the system "
"tablespace is now set to %s.\n", *(char**) var_ptr); "tablespace is now set to %s.\n", *(char**) var_ptr);
} }
return(true);
} }
static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff) static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
...@@ -9354,14 +9282,14 @@ static MYSQL_SYSVAR_BOOL(file_per_table, srv_file_per_table, ...@@ -9354,14 +9282,14 @@ static MYSQL_SYSVAR_BOOL(file_per_table, srv_file_per_table,
static MYSQL_SYSVAR_STR(file_format, innobase_file_format_name, static MYSQL_SYSVAR_STR(file_format, innobase_file_format_name,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"File format to use for new tables in .ibd files.", "File format to use for new tables in .ibd files.",
(mysql_var_check_func) &innodb_file_format_name_validate, innodb_file_format_name_validate,
(mysql_var_update_func) &innodb_file_format_name_update, "Antelope"); innodb_file_format_name_update, "Antelope");
static MYSQL_SYSVAR_STR(file_format_check, innobase_file_format_check, static MYSQL_SYSVAR_STR(file_format_check, innobase_file_format_check,
PLUGIN_VAR_OPCMDARG, PLUGIN_VAR_OPCMDARG,
"The highest file format in the tablespace.", "The highest file format in the tablespace.",
(mysql_var_check_func) &innodb_file_format_check_validate, innodb_file_format_check_validate,
(mysql_var_update_func) &innodb_file_format_check_update, innodb_file_format_check_update,
"on"); "on");
static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit, static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit,
......
...@@ -326,7 +326,7 @@ const char* ...@@ -326,7 +326,7 @@ const char*
trx_sys_file_format_id_to_name( trx_sys_file_format_id_to_name(
/*===========================*/ /*===========================*/
/* out: pointer to the name */ /* out: pointer to the name */
const uint id); /* in: id of the file format */ const ulint id); /* in: id of the file format */
/********************************************************************* /*********************************************************************
Set the file format id unconditionally except if it's already the Set the file format id unconditionally except if it's already the
same value. */ same value. */
...@@ -336,7 +336,7 @@ trx_sys_file_format_max_set( ...@@ -336,7 +336,7 @@ trx_sys_file_format_max_set(
/*========================*/ /*========================*/
/* out: TRUE if value updated */ /* out: TRUE if value updated */
ulint format_id, /* in: file format id */ ulint format_id, /* in: file format id */
char** name); /* out: max file format name or const char** name); /* out: max file format name or
NULL if not needed. */ NULL if not needed. */
/********************************************************************* /*********************************************************************
Get the name representation of the file format from its id. */ Get the name representation of the file format from its id. */
...@@ -354,14 +354,16 @@ trx_sys_file_format_max_check( ...@@ -354,14 +354,16 @@ trx_sys_file_format_max_check(
/* out: DB_SUCCESS or error code */ /* out: DB_SUCCESS or error code */
ulint max_format_id); /* in: the max format id to check */ ulint max_format_id); /* in: the max format id to check */
/************************************************************************ /************************************************************************
Update the file format tag in the tablespace to the max value. */ Update the file format tag in the system tablespace only if the given
format id is greater than the known max id. */
UNIV_INTERN UNIV_INTERN
ibool ibool
trx_sys_file_format_max_update( trx_sys_file_format_max_upgrade(
/*===========================*/ /*============================*/
/* out: TRUE if value updated */ /* out: TRUE if format_id was
uint flags, /* in: flags of the table */ bigger than the known max id */
char** name); /* out: max format name */ const char** name, /* out: max file format name */
ulint format_id); /* in: file format identifier */
/* The automatically created system rollback segment has this id */ /* The automatically created system rollback segment has this id */
#define TRX_SYS_SYSTEM_RSEG_ID 0 #define TRX_SYS_SYSTEM_RSEG_ID 0
......
...@@ -24,7 +24,7 @@ Created 3/26/1996 Heikki Tuuri ...@@ -24,7 +24,7 @@ Created 3/26/1996 Heikki Tuuri
/* The file format tag structure with id and name. */ /* The file format tag structure with id and name. */
struct file_format_struct { struct file_format_struct {
uint id; /* id of the file format */ ulint id; /* id of the file format */
const char* name; /* text representation of the const char* name; /* text representation of the
file format */ file format */
mutex_t mutex; /* covers changes to the above mutex_t mutex; /* covers changes to the above
...@@ -95,8 +95,8 @@ static const char* file_format_name_map[] = { ...@@ -95,8 +95,8 @@ static const char* file_format_name_map[] = {
}; };
/* The number of elements in the file format name array. */ /* The number of elements in the file format name array. */
static const ulint FILE_FORMAT_NAME_N = static const ulint FILE_FORMAT_NAME_N
sizeof(file_format_name_map) / sizeof(file_format_name_map[0]); = sizeof(file_format_name_map) / sizeof(file_format_name_map[0]);
/* This is used to track the maximum file format id known to InnoDB. It's /* This is used to track the maximum file format id known to InnoDB. It's
updated via SET GLOBAL innodb_file_format_check = 'x' or when we open updated via SET GLOBAL innodb_file_format_check = 'x' or when we open
...@@ -1057,7 +1057,7 @@ trx_sys_file_format_max_write( ...@@ -1057,7 +1057,7 @@ trx_sys_file_format_max_write(
/*==========================*/ /*==========================*/
/* out: always TRUE */ /* out: always TRUE */
ulint format_id, /* in: file format id */ ulint format_id, /* in: file format id */
char** name) /* out: max file format name, can const char** name) /* out: max file format name, can
be NULL */ be NULL */
{ {
mtr_t mtr; mtr_t mtr;
...@@ -1077,7 +1077,7 @@ trx_sys_file_format_max_write( ...@@ -1077,7 +1077,7 @@ trx_sys_file_format_max_write(
tag_value_low = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW; tag_value_low = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW;
if (name) { if (name) {
*name = (char*) file_format_max.name; *name = file_format_max.name;
} }
mlog_write_dulint( mlog_write_dulint(
...@@ -1137,7 +1137,7 @@ const char* ...@@ -1137,7 +1137,7 @@ const char*
trx_sys_file_format_id_to_name( trx_sys_file_format_id_to_name(
/*===========================*/ /*===========================*/
/* out: pointer to the name */ /* out: pointer to the name */
const uint id) /* in: id of the file format */ const ulint id) /* in: id of the file format */
{ {
ut_a(id < FILE_FORMAT_NAME_N); ut_a(id < FILE_FORMAT_NAME_N);
...@@ -1207,7 +1207,7 @@ trx_sys_file_format_max_set( ...@@ -1207,7 +1207,7 @@ trx_sys_file_format_max_set(
/*========================*/ /*========================*/
/* out: TRUE if value updated */ /* out: TRUE if value updated */
ulint format_id, /* in: file format id */ ulint format_id, /* in: file format id */
char** name) /* out: max file format name or const char** name) /* out: max file format name or
NULL if not needed. */ NULL if not needed. */
{ {
ibool ret = FALSE; ibool ret = FALSE;
...@@ -1248,20 +1248,19 @@ trx_sys_file_format_tag_init(void) ...@@ -1248,20 +1248,19 @@ trx_sys_file_format_tag_init(void)
} }
/************************************************************************ /************************************************************************
Update the file format tag in the tablespace only if the given format id Update the file format tag in the system tablespace only if the given
is greater than the known max id. */ format id is greater than the known max id. */
UNIV_INTERN UNIV_INTERN
ibool ibool
trx_sys_file_format_max_update( trx_sys_file_format_max_upgrade(
/*===========================*/ /*============================*/
uint flags, /* in: flags of the table.*/ /* out: TRUE if format_id was
char** name) /* out: max file format name */ bigger than the known max id */
const char** name, /* out: max file format name */
ulint format_id) /* in: file format identifier */
{ {
ulint format_id;
ibool ret = FALSE; ibool ret = FALSE;
format_id = (flags & DICT_TF_FORMAT_MASK) >> DICT_TF_FORMAT_SHIFT;
ut_a(name); ut_a(name);
ut_a(file_format_max.name != NULL); ut_a(file_format_max.name != NULL);
ut_a(format_id <= DICT_TF_FORMAT_MAX); ut_a(format_id <= DICT_TF_FORMAT_MAX);
......
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