MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Tatiana A. Nurnberg Date:June 26 2009 7:13am
Subject:bzr commit into mysql-5.0-bugteam branch (azundris:2784) Bug#43508
View as plain text  
#At file:///misc/mysql/forest/43508/50-43508/ based on revid:joro@stripped

 2784 Tatiana A. Nurnberg	2009-06-26
      Bug#43508: Renaming timestamp or date column triggers table copy
      
      Backported clean-up from bugfix for 5.1; actual fix does not apply to 5.0.
     @ sql/field.cc
        Clean-up. "Because it's right." stuff. Set field's charset
        to BINARY for TIME/TIMESTAMP. Set field's maximum width to
        length-including-delimiters, not compressed length or some
        hocus pocus literals. Setup BINARY flags/charset on create,
        not make.
     @ sql/field.h
        Use human-readable constants for field-size, not some hocus pocus numeric literal. :)
     @ sql/sql_table.cc
        cleanup

    modified:
      sql/field.cc
      sql/field.h
      sql/sql_table.cc
=== modified file 'sql/field.cc'
--- a/sql/field.cc	2009-06-09 16:11:21 +0000
+++ b/sql/field.cc	2009-06-26 07:13:34 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright 2000-2008 MySQL AB, 2008-2009 Sun Microsystems, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -4272,6 +4272,7 @@ Field_timestamp::Field_timestamp(char *p
 {
   /* For 4.0 MYD and 4.0 InnoDB compatibility */
   flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
+  field_charset= &my_charset_bin;
   if (table && !table->timestamp_field && 
       unireg_check != NONE)
   {
@@ -4291,6 +4292,7 @@ Field_timestamp::Field_timestamp(bool ma
 {
   /* For 4.0 MYD and 4.0 InnoDB compatibility */
   flags|= ZEROFILL_FLAG | UNSIGNED_FLAG;
+  field_charset= &my_charset_bin;
   if (table && !table->timestamp_field &&
       unireg_check != NONE)
   {
@@ -8471,7 +8473,7 @@ bool create_field::init(THD *thd, char *
     }
 
     if (length == 0)
-      fld_length= 0; /* purecov: inspected */
+      fld_length= NULL; /* purecov: inspected */
   }
 
   sign_len= fld_type_modifier & UNSIGNED_FLAG ? 0 : 1;
@@ -8624,7 +8626,7 @@ bool create_field::init(THD *thd, char *
     if (fld_length == NULL)
     {
       /* Compressed date YYYYMMDDHHMMSS */
-      length= MAX_DATETIME_COMPRESSED_WIDTH;
+      length= MAX_DATETIME_WIDTH;
     }
     else if (length != MAX_DATETIME_WIDTH)
     {
@@ -8689,7 +8691,7 @@ bool create_field::init(THD *thd, char *
       sql_type= FIELD_TYPE_NEWDATE;
     /* fall trough */
   case FIELD_TYPE_NEWDATE:
-    length= 10;
+    length= MAX_DATE_WIDTH;
     break;
   case FIELD_TYPE_TIME:
     length= 10;
@@ -8770,6 +8772,17 @@ bool create_field::init(THD *thd, char *
     DBUG_RETURN(TRUE);
   }
 
+  switch (fld_type) {
+  case MYSQL_TYPE_DATE:
+  case MYSQL_TYPE_NEWDATE:
+  case MYSQL_TYPE_TIME:
+  case MYSQL_TYPE_DATETIME:
+  case MYSQL_TYPE_TIMESTAMP:
+    charset= &my_charset_bin;
+    flags|= BINCMP_FLAG;
+  default: break;
+  }
+
   DBUG_RETURN(FALSE); /* success */
 }
 
@@ -8879,17 +8892,6 @@ Field *make_field(char *ptr, uint32 fiel
     null_bit= ((uchar) 1) << null_bit;
   }
 
-  switch (field_type)
-  {
-    case FIELD_TYPE_DATE:
-    case FIELD_TYPE_NEWDATE:
-    case FIELD_TYPE_TIME:
-    case FIELD_TYPE_DATETIME:
-    case FIELD_TYPE_TIMESTAMP:
-      field_charset= &my_charset_bin;
-    default: break;
-  }
-
   if (f_is_alpha(pack_flag))
   {
     if (!f_is_packed(pack_flag))

=== modified file 'sql/field.h'
--- a/sql/field.h	2009-06-09 16:11:21 +0000
+++ b/sql/field.h	2009-06-26 07:13:34 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2006 MySQL AB
+/* Copyright 2000-2008 MySQL AB, 2008, 2009 Sun Microsystems, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -931,12 +931,12 @@ public:
   Field_date(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
 	     enum utype unireg_check_arg, const char *field_name_arg,
 	     struct st_table *table_arg, CHARSET_INFO *cs)
-    :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
+    :Field_str(ptr_arg, MAX_DATE_WIDTH, null_ptr_arg, null_bit_arg,
 	       unireg_check_arg, field_name_arg, table_arg, cs)
     {}
   Field_date(bool maybe_null_arg, const char *field_name_arg,
 		 struct st_table *table_arg, CHARSET_INFO *cs)
-    :Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
+    :Field_str((char*) 0, MAX_DATE_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
 	       NONE, field_name_arg, table_arg, cs) {}
   enum_field_types type() const { return FIELD_TYPE_DATE;}
   enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
@@ -1034,12 +1034,12 @@ public:
   Field_datetime(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
 		 enum utype unireg_check_arg, const char *field_name_arg,
 		 struct st_table *table_arg, CHARSET_INFO *cs)
-    :Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
+    :Field_str(ptr_arg, MAX_DATETIME_WIDTH, null_ptr_arg, null_bit_arg,
 	       unireg_check_arg, field_name_arg, table_arg, cs)
     {}
   Field_datetime(bool maybe_null_arg, const char *field_name_arg,
 		 struct st_table *table_arg, CHARSET_INFO *cs)
-    :Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
+    :Field_str((char*) 0, MAX_DATETIME_WIDTH, maybe_null_arg ? (uchar*) "": 0,0,
 	       NONE, field_name_arg, table_arg, cs) {}
   enum_field_types type() const { return FIELD_TYPE_DATETIME;}
 #ifdef HAVE_LONG_LONG

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-06-17 13:54:01 +0000
+++ b/sql/sql_table.cc	2009-06-26 07:13:34 +0000
@@ -726,8 +726,10 @@ static int mysql_prepare_table(THD *thd,
       executing a prepared statement for the second time.
     */
     sql_field->length= sql_field->char_length;
-    if (!sql_field->charset)
+
+    if (sql_field->charset == NULL)
       sql_field->charset= create_info->default_table_charset;
+
     /*
       table_charset is set in ALTER TABLE if we want change character set
       for all varchar/char columns.


Attachment: [text/bzr-bundle] bzr/azundris@mysql.com-20090626071334-8qi7x6dx6ayu0nv7.bundle
Thread
bzr commit into mysql-5.0-bugteam branch (azundris:2784) Bug#43508Tatiana A. Nurnberg26 Jun