List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:June 8 2005 10:33pm
Subject:bk commit into 5.0 tree (jimw:1.1960)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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.1960 05/06/08 15:33:47 jimw@stripped +3 -0
  Merge mysql.com:/home/jimw/my/mysql-5.0-10543
  into  mysql.com:/home/jimw/my/mysql-5.0-clean

  sql/sql_table.cc
    1.251 05/06/08 15:33:43 jimw@stripped +0 -0
    Auto merged

  sql/field.h
    1.160 05/06/08 15:33:43 jimw@stripped +0 -0
    Auto merged

  sql/field.cc
    1.262 05/06/08 15:33:43 jimw@stripped +0 -0
    Auto merged

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-clean/RESYNC

--- 1.261/sql/field.cc	2005-05-25 18:11:44 -07:00
+++ 1.262/sql/field.cc	2005-06-08 15:33:43 -07:00
@@ -19,7 +19,7 @@
 ** This file implements classes defined in field.h
 *****************************************************************************/
 
-#ifdef __GNUC__
+#ifdef USE_PRAGMA_IMPLEMENTATION
 #pragma implementation				// gcc: Class implementation
 #endif
 
@@ -2479,7 +2479,7 @@
   int err;
 
   if ((err= int2my_decimal(E_DEC_FATAL_ERROR & ~E_DEC_OVERFLOW,
-                           nr, unsigned_flag, &decimal_value)))
+                           nr, false, &decimal_value)))
   {
     if (check_overflow(err))
       set_value_on_overflow(&decimal_value, decimal_value.sign());
@@ -5889,31 +5889,32 @@
   char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE];
   uint length;
   bool use_scientific_notation= TRUE;
+  uint char_length= field_length / charset()->mbmaxlen;
   /*
     Check fabs(nr) against longest value that can be stored in field,
     which depends on whether the value is < 1 or not, and negative or not
   */
   double anr= fabs(nr);
   int neg= (nr < 0.0) ? 1 : 0;
-  if (field_length > 4 && field_length < 32 &&
-      (anr < 1.0 ? anr > 1/(log_10[max(0,(int) field_length-neg-2)]) /* -2 for "0." */
-                 : anr < log_10[field_length-neg]-1))
+  if (char_length > 4 && char_length < 32 &&
+      (anr < 1.0 ? anr > 1/(log_10[max(0,(int) char_length-neg-2)]) /* -2 for "0." */
+                 : anr < log_10[char_length-neg]-1))
     use_scientific_notation= FALSE;
 
   length= (uint) my_sprintf(buff, (buff, "%-.*g",
                                    (use_scientific_notation ?
-                                    max(0, (int)field_length-neg-5) :
-                                    field_length),
+                                    max(0, (int)char_length-neg-5) :
+                                    char_length),
                                    nr));
   /*
     +1 below is because "precision" in %g above means the
     max. number of significant digits, not the output width.
     Thus the width can be larger than number of significant digits by 1
     (for decimal point)
-    the test for field_length < 5 is for extreme cases,
+    the test for char_length < 5 is for extreme cases,
     like inserting 500.0 in char(1)
   */
-  DBUG_ASSERT(field_length < 5 || length <= field_length+1);
+  DBUG_ASSERT(char_length < 5 || length <= char_length+1);
   return store((const char *) buff, length, charset());
 }
 
@@ -7865,7 +7866,7 @@
 
 int Field_bit::store(double nr)
 {
-  return (Field_bit::store((longlong) nr));
+  return store((longlong) nr);
 }
 
 
@@ -8048,7 +8049,8 @@
       (delta == 0 && bits && (uint) (uchar) *from >= (uint) (1 << bits)))
   {
     memset(ptr, 0xff, field_length);
-    *ptr&= ((1 << bits) - 1); /* set first byte */
+    if (bits)
+      *ptr&= ((1 << bits) - 1); /* set first byte */
     set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1);
     return 1;
   }

--- 1.159/sql/field.h	2005-05-25 08:33:25 -07:00
+++ 1.160/sql/field.h	2005-06-08 15:33:43 -07:00
@@ -119,6 +119,7 @@
   virtual Item_result result_type () const=0;
   virtual Item_result cmp_type () const { return result_type(); }
   virtual Item_result cast_to_int_type () const { return result_type(); }
+  static bool type_can_have_key_part(enum_field_types);
   static enum_field_types field_type_merge(enum_field_types, enum_field_types);
   static Item_result result_merge_type(enum_field_types);
   bool eq(Field *field)

--- 1.250/sql/sql_table.cc	2005-06-06 11:21:27 -07:00
+++ 1.251/sql/sql_table.cc	2005-06-08 15:33:43 -07:00
@@ -3393,12 +3393,25 @@
 	continue;				// Field is removed
       uint key_part_length=key_part->length;
       if (cfield->field)			// Not new field
-      {						// Check if sub key
-	if (cfield->field->type() != FIELD_TYPE_BLOB &&
-	    (cfield->field->pack_length() == key_part_length ||
-	     cfield->length <= key_part_length /
-			       key_part->field->charset()->mbmaxlen))
-	  key_part_length=0;			// Use whole field
+      {
+        /*
+          If the field can't have only a part used in a key according to its
+          new type, or should not be used partially according to its
+          previous type, or the field length is less than the key part
+          length, unset the key part length.
+
+          We also unset the key part length if it is the same as the
+          old field's length, so the whole new field will be used.
+
+          BLOBs may have cfield->length == 0, which is why we test it before
+          checking whether cfield->length < key_part_length (in chars).
+         */
+        if (!Field::type_can_have_key_part(cfield->field->type()) ||
+            !Field::type_can_have_key_part(cfield->sql_type) ||
+            cfield->field->field_length == key_part_length ||
+	    (cfield->length && (cfield->length < key_part_length /
+                                key_part->field->charset()->mbmaxlen)))
+	  key_part_length= 0;			// Use whole field
       }
       key_part_length /= key_part->field->charset()->mbmaxlen;
       key_parts.push_back(new key_part_spec(cfield->field_name,
Thread
bk commit into 5.0 tree (jimw:1.1960)Jim Winstead9 Jun