List:Internals« Previous MessageNext Message »
From:Heikki Tuuri Date:April 4 2005 6:27pm
Subject:bk commit into 4.1 tree (heikki:1.2161) BUG#9526
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of heikki. When heikki does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2161 05/04/04 19:27:28 heikki@stripped +1 -0
  ha_innodb.cc:
    Fix bug #9526 in InnoDB: the internal type of an ENUM or SET is an unsigned integer
type, not a character string

  sql/ha_innodb.cc
    1.186 05/04/04 19:26:49 heikki@stripped +35 -17
    Fix bug #9526 in InnoDB: the internal type of an ENUM or SET is an unsigned integer
type, not a character string

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	heikki
# Host:	hundin.mysql.fi
# Root:	/home/heikki/mysql-4.1

--- 1.185/sql/ha_innodb.cc	Fri Mar  4 15:52:16 2005
+++ 1.186/sql/ha_innodb.cc	Mon Apr  4 19:26:49 2005
@@ -1923,8 +1923,11 @@
 ulint
 get_innobase_type_from_mysql_type(
 /*==============================*/
-			/* out: DATA_BINARY, DATA_VARCHAR, ... */
-	Field*	field)	/* in: MySQL field */
+				/* out: DATA_BINARY, DATA_VARCHAR, ... */
+	ulint*	unsigned_flag,	/* out: DATA_UNSIGNED if an 'unsigned type';
+				at least ENUM and SET, and unsigned integer
+				types are 'unsigned types' */
+	Field*	field)		/* in: MySQL field */
 {
 	/* The following asserts try to check that the MySQL type code fits in
 	8 bits: this is used in ibuf and also when DATA_NOT_NULL is ORed to
@@ -1936,6 +1939,27 @@
 	DBUG_ASSERT((ulint)FIELD_TYPE_FLOAT < 256);
 	DBUG_ASSERT((ulint)FIELD_TYPE_DECIMAL < 256);
 
+	if (field->flags & UNSIGNED_FLAG) {
+
+		*unsigned_flag = DATA_UNSIGNED;
+	} else {
+		*unsigned_flag = 0;
+	}
+
+	if (field->real_type() == FIELD_TYPE_ENUM
+	    || field->real_type() == FIELD_TYPE_SET) {
+
+		/* MySQL has field->type() a string type for these, but the
+		data is actually internally stored as an unsigned integer
+		code! */
+
+		*unsigned_flag = DATA_UNSIGNED; /* MySQL has its own unsigned
+						flag set to zero, even though
+						internally this is an unsigned
+						integer type */
+		return(DATA_INT);
+	}
+
 	switch (field->type()) {
 	        /* NOTE that we only allow string types in DATA_MYSQL
 		and DATA_VARMYSQL */
@@ -1968,8 +1992,6 @@
 		case FIELD_TYPE_DATETIME:
 		case FIELD_TYPE_YEAR:
 		case FIELD_TYPE_NEWDATE:
-		case FIELD_TYPE_ENUM:
-		case FIELD_TYPE_SET:
 		case FIELD_TYPE_TIME:
 		case FIELD_TYPE_TIMESTAMP:
 					return(DATA_INT);
@@ -2247,10 +2269,10 @@
 					get_field_offset(table, field);
 
 		templ->mysql_col_len = (ulint) field->pack_length();
-		templ->type = get_innobase_type_from_mysql_type(field);
+		templ->type = get_innobase_type_from_mysql_type(
+					&templ->is_unsigned, field);
 		templ->charset = dtype_get_charset_coll_noninline(
 				index->table->cols[i].type.prtype);
-		templ->is_unsigned = (ulint) (field->flags & UNSIGNED_FLAG);
 
 		if (templ->type == DATA_BLOB) {
 			prebuilt->templ_contains_blob = TRUE;
@@ -2676,9 +2698,8 @@
 		o_len = field->pack_length();
 		n_len = field->pack_length();
 
-		col_type = get_innobase_type_from_mysql_type(field);
-		is_unsigned = (ulint) (field->flags & UNSIGNED_FLAG);
-
+		col_type = get_innobase_type_from_mysql_type(&is_unsigned,
+									field);
 		switch (col_type) {
 
 		case DATA_BLOB:
@@ -3546,19 +3567,14 @@
 	for (i = 0; i < n_cols; i++) {
 		field = form->field[i];
 
-		col_type = get_innobase_type_from_mysql_type(field);
+		col_type = get_innobase_type_from_mysql_type(&unsigned_type,
+								field);
 		if (field->null_ptr) {
 			nulls_allowed = 0;
 		} else {
 			nulls_allowed = DATA_NOT_NULL;
 		}
 
-		if (field->flags & UNSIGNED_FLAG) {
-			unsigned_type = DATA_UNSIGNED;
-		} else {
-			unsigned_type = 0;
-		}
-
 		if (field->binary()) {
 			binary_type = DATA_BINARY_TYPE;
 		} else {
@@ -3612,6 +3628,7 @@
 	ulint		ind_type;
 	ulint		col_type;
 	ulint		prefix_len;
+	ulint		is_unsigned;
   	ulint		i;
   	ulint		j;
 
@@ -3661,7 +3678,8 @@
 
 		ut_a(j < form->fields);
 
-		col_type = get_innobase_type_from_mysql_type(key_part->field);
+		col_type = get_innobase_type_from_mysql_type(
+					&is_unsigned, key_part->field);
 
 		if (DATA_BLOB == col_type
 		    || key_part->length < field->pack_length()) {
Thread
bk commit into 4.1 tree (heikki:1.2161) BUG#9526Heikki Tuuri4 Apr