MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Jimmy Yang Date:April 30 2010 12:47am
Subject:bzr commit into mysql-trunk-innodb branch (jimmy.yang:3043) Bug#53165
View as plain text  
#At file:///home/jy/work/mysql5.5_2/mysql-trunk/ based on revid:sunny.bains@stripped

 3043 Jimmy Yang	2010-04-29
      Fix bug #53165 Setting innodb_change_buffering=DEFAULT produces incorrect
      result

    modified:
      storage/innobase/handler/ha_innodb.cc
=== modified file 'storage/innobase/handler/ha_innodb.cc'
--- a/storage/innobase/handler/ha_innodb.cc	2010-04-22 22:15:56 +0000
+++ b/storage/innobase/handler/ha_innodb.cc	2010-04-30 00:45:35 +0000
@@ -10551,6 +10551,32 @@ innodb_old_blocks_pct_update(
 }
 
 /*************************************************************//**
+Find corresponding ibuf_use_t value that indexes into
+innobase_change_buffering_values[] array.
+@return	corresponding IBUF_USE_* value for the input variable
+name, or IBUF_USE_COUNT if not able to find a match */
+static
+ibuf_use_t
+innodb_find_change_buffering_value(
+/*===============================*/
+	const char*	input_name)	/*!< in: input change buffering
+					option name */
+{
+	ulint	use;
+
+	for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
+	     use++) {
+		/* foundd a match */
+		if (!innobase_strcasecmp(
+			input_name, innobase_change_buffering_values[use])) {
+			return((ibuf_use_t)use);
+		}
+	}
+
+	return(IBUF_USE_COUNT);
+}
+
+/*************************************************************//**
 Check if it is a valid value of innodb_change_buffering.  This function is
 registered as a callback with MySQL.
 @return	0 for valid innodb_change_buffering */
@@ -10575,16 +10601,17 @@ innodb_change_buffering_validate(
 	change_buffering_input = value->val_str(value, buff, &len);
 
 	if (change_buffering_input != NULL) {
-		ulint	use;
+		ibuf_use_t	use;
+
+		use = innodb_find_change_buffering_value(
+			change_buffering_input);
+
+		if (use != IBUF_USE_COUNT) {
+			/* Find a matching change_buffering option value. */
+			*static_cast<const char**>(save) =
+				innobase_change_buffering_values[use];
 
-		for (use = 0; use < UT_ARR_SIZE(innobase_change_buffering_values);
-		     use++) {
-			if (!innobase_strcasecmp(
-				    change_buffering_input,
-				    innobase_change_buffering_values[use])) {
-				*(ibuf_use_t*) save = (ibuf_use_t) use;
-				return(0);
-			}
+			return(0);
 		}
 	}
 
@@ -10592,27 +10619,38 @@ innodb_change_buffering_validate(
 }
 
 /****************************************************************//**
-Update the system variable innodb_change_buffering using the "saved"
-value. This function is registered as a callback with MySQL. */
+Update tHe system variable innodb_change_buffering using the "saved"
+value. THis function is registered as a callback with MySQL. */
 static
 void
 innodb_change_buffering_update(
 /*===========================*/
-	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 */
-	const void*			save)		/*!< in: immediate result
-							from check function */
+	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 */
+	const void*			save)	/*!< in: immediate result
+						from check function */
 {
+	ibuf_use_t	use;
+
 	ut_a(var_ptr != NULL);
 	ut_a(save != NULL);
-	ut_a((*(ibuf_use_t*) save) < IBUF_USE_COUNT);
 
-	ibuf_use = *(const ibuf_use_t*) save;
+	use = innodb_find_change_buffering_value(
+		*static_cast<const char*const*>(save));
 
-	*(const char**) var_ptr = innobase_change_buffering_values[ibuf_use];
+	if (use != IBUF_USE_COUNT) {
+		/* Found the right option */
+		ibuf_use = use;
+		*(const char**) var_ptr = *static_cast<const char*const*>(save);
+	} else {
+		/* Option should be validated when coming to this function.
+		Raise an error if innodb_find_change_buffering_value()
+		not able to find corresponding value */
+		ut_error;
+	}
 }
 
 static int show_innodb_vars(THD *thd, SHOW_VAR *var, char *buff)
@@ -10967,7 +11005,7 @@ static MYSQL_SYSVAR_STR(change_buffering
   "Buffer changes to reduce random access: "
   "OFF, ON, inserting, deleting, changing, or purging.",
   innodb_change_buffering_validate,
-  innodb_change_buffering_update, NULL);
+  innodb_change_buffering_update, "all");
 
 static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
   PLUGIN_VAR_RQCMDARG,


Attachment: [text/bzr-bundle] bzr/jimmy.yang@oracle.com-20100430004535-8ysm74fw75fz5zqo.bundle
Thread
bzr commit into mysql-trunk-innodb branch (jimmy.yang:3043) Bug#53165Jimmy Yang30 Apr