diff --git a/handler/ha_innodb.cc b/handler/ha_innodb.cc index f95bc1021d2afcb4005a7973f1610c2e9a022cd4..a05cfdee3a2c3a23cbd78d0e945f4333d34e9e8a 100644 --- a/handler/ha_innodb.cc +++ b/handler/ha_innodb.cc @@ -210,7 +210,7 @@ innobase_file_format_name_lookup( const char* format_name); /* in: pointer to file format 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. */ static bool @@ -220,7 +220,7 @@ innobase_file_format_check_on_off( "on" or "off" */ 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. */ static bool @@ -229,71 +229,6 @@ innobase_file_format_check_validate( /* out: true if valid config 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. */ static @@ -1988,13 +1923,13 @@ innobase_init( /* Process innobase_file_format_check variable */ 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". */ if (!innobase_file_format_check_on_off(innobase_file_format_check)) { /* Did the user specify a format name that we support ? - As a side affect it will update the variable - srv_check_file_format_at_startup*/ + As a side effect it will update the variable + srv_check_file_format_at_startup */ if (!innobase_file_format_check_validate( innobase_file_format_check)) { @@ -3032,8 +2967,9 @@ retry: /* 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( - prebuilt->table->flags, &innobase_file_format_check); + trx_sys_file_format_max_upgrade( + (const char**) &innobase_file_format_check, + dict_table_get_format(prebuilt->table)); } info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); @@ -6166,10 +6102,14 @@ ha_innobase::create( DBUG_ASSERT(innobase_table != 0); - /* We update the highest file format in the system table - space, if this table has a higher file format setting. */ + if (innobase_table) { + /* 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 setup at this stage and so we use thd. */ @@ -9078,7 +9018,7 @@ innobase_file_format_name_lookup( /**************************************************************** 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 bool 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. */ static bool @@ -9117,7 +9057,7 @@ innobase_file_format_check_validate( { uint format_id; bool ret = true; - + format_id = innobase_file_format_name_lookup(format_check); if (format_id < DICT_TF_FORMAT_MAX + 1) { @@ -9174,32 +9114,25 @@ innodb_file_format_name_validate( Update the system variable innodb_file_format using the "saved" value. This function is registered as a callback with MySQL. */ static -bool +void 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 + const void* save) /* in: immediate result from check function */ { ut_a(var_ptr != NULL); ut_a(save != NULL); - ut_a((*(uint*) save) <= DICT_TF_FORMAT_MAX); - - srv_file_format = *(uint*) save; + ut_a((*(const uint*) save) <= DICT_TF_FORMAT_MAX); - /* Given the type of var_ptr we have little choice but to cast - away the constness from the returned name. */ - (*(char**) var_ptr) = - (char*) trx_sys_file_format_id_to_name(srv_file_format); + srv_file_format = *(const uint*) save; - 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( Update the system variable innodb_file_format_check using the "saved" value. This function is registered as a callback with MySQL. */ static -bool +void 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 + const void* save) /* in: immediate result from check function */ { uint format_id; @@ -9287,17 +9217,15 @@ innodb_file_format_check_update( ut_a(save != NULL); ut_a(var_ptr != NULL); - format_id = *(uint*) save; + format_id = *(const uint*) save; /* 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); fprintf(stderr, " [Info] InnoDB: the file format in the system " "tablespace is now set to %s.\n", *(char**) var_ptr); } - - return(true); } 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, static MYSQL_SYSVAR_STR(file_format, innobase_file_format_name, PLUGIN_VAR_RQCMDARG, "File format to use for new tables in .ibd files.", - (mysql_var_check_func) &innodb_file_format_name_validate, - (mysql_var_update_func) &innodb_file_format_name_update, "Antelope"); + innodb_file_format_name_validate, + innodb_file_format_name_update, "Antelope"); static MYSQL_SYSVAR_STR(file_format_check, innobase_file_format_check, PLUGIN_VAR_OPCMDARG, "The highest file format in the tablespace.", - (mysql_var_check_func) &innodb_file_format_check_validate, - (mysql_var_update_func) &innodb_file_format_check_update, + innodb_file_format_check_validate, + innodb_file_format_check_update, "on"); static MYSQL_SYSVAR_ULONG(flush_log_at_trx_commit, srv_flush_log_at_trx_commit, diff --git a/include/trx0sys.h b/include/trx0sys.h index f6074b0614cd6688ce7105b1f493687d4d875f76..8271a5fb38ae8544c0806fe29255d2f767802f9a 100644 --- a/include/trx0sys.h +++ b/include/trx0sys.h @@ -326,7 +326,7 @@ const char* trx_sys_file_format_id_to_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 same value. */ @@ -336,7 +336,7 @@ trx_sys_file_format_max_set( /*========================*/ /* out: TRUE if value updated */ 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. */ /********************************************************************* Get the name representation of the file format from its id. */ @@ -354,14 +354,16 @@ trx_sys_file_format_max_check( /* out: DB_SUCCESS or error code */ 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 ibool -trx_sys_file_format_max_update( -/*===========================*/ - /* out: TRUE if value updated */ - uint flags, /* in: flags of the table */ - char** name); /* out: max format name */ +trx_sys_file_format_max_upgrade( +/*============================*/ + /* out: TRUE if format_id was + bigger than the known max id */ + const char** name, /* out: max file format name */ + ulint format_id); /* in: file format identifier */ /* The automatically created system rollback segment has this id */ #define TRX_SYS_SYSTEM_RSEG_ID 0 diff --git a/trx/trx0sys.c b/trx/trx0sys.c index 37bedb3e6630ed0d53748b5819cdd2d34f599997..68bcc41a2a33a38fb980ea96e6b812349067e569 100644 --- a/trx/trx0sys.c +++ b/trx/trx0sys.c @@ -24,7 +24,7 @@ Created 3/26/1996 Heikki Tuuri /* The file format tag structure with id and name. */ 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 file format */ mutex_t mutex; /* covers changes to the above @@ -95,8 +95,8 @@ static const char* file_format_name_map[] = { }; /* The number of elements in the file format name array. */ -static const ulint FILE_FORMAT_NAME_N = - sizeof(file_format_name_map) / sizeof(file_format_name_map[0]); +static const ulint FILE_FORMAT_NAME_N + = 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 updated via SET GLOBAL innodb_file_format_check = 'x' or when we open @@ -1057,7 +1057,7 @@ trx_sys_file_format_max_write( /*==========================*/ /* out: always TRUE */ 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 */ { mtr_t mtr; @@ -1077,7 +1077,7 @@ trx_sys_file_format_max_write( tag_value_low = format_id + TRX_SYS_FILE_FORMAT_TAG_MAGIC_N_LOW; if (name) { - *name = (char*) file_format_max.name; + *name = file_format_max.name; } mlog_write_dulint( @@ -1137,7 +1137,7 @@ const char* trx_sys_file_format_id_to_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); @@ -1207,7 +1207,7 @@ trx_sys_file_format_max_set( /*========================*/ /* out: TRUE if value updated */ 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. */ { ibool ret = FALSE; @@ -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 -is greater than the known max id. */ +Update the file format tag in the system tablespace only if the given +format id is greater than the known max id. */ UNIV_INTERN ibool -trx_sys_file_format_max_update( -/*===========================*/ - uint flags, /* in: flags of the table.*/ - char** name) /* out: max file format name */ +trx_sys_file_format_max_upgrade( +/*============================*/ + /* out: TRUE if format_id was + 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; - format_id = (flags & DICT_TF_FORMAT_MASK) >> DICT_TF_FORMAT_SHIFT; - ut_a(name); ut_a(file_format_max.name != NULL); ut_a(format_id <= DICT_TF_FORMAT_MAX);