List:Commits« Previous MessageNext Message »
From:ahristov Date:October 24 2006 3:17pm
Subject:bk commit into 5.1 tree (andrey:1.2325)
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of andrey. When andrey 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@stripped, 2006-10-24 17:16:51+02:00, andrey@stripped +1 -0
  savepoint

  sql/sql_table.cc@stripped, 2006-10-24 17:16:43+02:00, andrey@stripped +46 -12
    savepoint

# 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:	andrey
# Host:	example.com
# Root:	/work/bug22909/my51

--- 1.368/sql/sql_table.cc	2006-10-24 17:17:03 +02:00
+++ 1.369/sql/sql_table.cc	2006-10-24 17:17:03 +02:00
@@ -4582,6 +4582,7 @@ bool mysql_create_like_table(THD* thd, T
   bool res= TRUE;
   enum legacy_db_type not_used;
   HA_CREATE_INFO *create_info;
+  TABLE *table_ptr;
 
   TABLE_LIST src_tables_list;
   DBUG_ENTER("mysql_create_like_table");
@@ -4633,9 +4634,7 @@ bool mysql_create_like_table(THD* thd, T
     }
   }
 
-  /* 
-     create like should be not allowed for Views, Triggers, ... 
-  */
+  /* Create like should be not allowed for Views, Triggers, ... */
   if (mysql_frm_type(thd, src_path, &not_used) != FRMTYPE_TABLE)
   {
     my_error(ER_WRONG_OBJECT, MYF(0), src_db, src_table, "BASE TABLE");
@@ -4715,6 +4714,50 @@ bool mysql_create_like_table(THD* thd, T
   }
 
   /*
+    Let's open and lock the table: it will be closed (and
+    unlocked) by close_thread_tables() at the end of the
+    statement anyway.
+  */
+  if (!(table_ptr= open_ltable(thd, table, TL_WRITE)))
+    goto err;
+
+  /*
+    Check validity of default values because the old table could have
+    default values which are invalid in this version. For example,
+    see bug#22909.
+    We set read_set because ASSERT_COLUMN_MARKED_FOR_READ in ::val_str()
+    will crash us otherwise.
+    We set write_set because ASSERT_COLUMN_MARKED_FOR_WRITE in ::store()
+    will crash us otherwise.
+  */
+  bitmap_set_all(table_ptr->read_set);
+  bitmap_set_all(table_ptr->write_set);
+  for (Field **field= table_ptr->field; *field; field++)
+  {
+    char field_value_buffer[STRING_BUFFER_USUAL_SIZE];
+    String field_value(field_value_buffer, sizeof(field_value_buffer),
+                       &my_charset_bin);
+
+    if ((*field)->is_null_in_record((uchar*)table_ptr->s->default_values))
+    {
+      (*field)->set_null();
+      // is null
+    }
+    else
+    {
+      (*field)->set_notnull();
+      (*field)->val_str(&field_value, (char*) (table_ptr->s->default_values +
+                                               (*field)->offset()));
+      if ((*field)->store(field_value.c_ptr_safe(), field_value.length(),
+                          &my_charset_bin))
+      {
+        my_error(ER_INVALID_DEFAULT, MYF(0), (*field)->field_name);
+        goto err;
+      }
+    }
+  }
+
+  /*
     We have to write the query before we unlock the tables.
   */
   if (thd->current_stmt_binlog_row_based)
@@ -4745,16 +4788,7 @@ bool mysql_create_like_table(THD* thd, T
         char buf[2048];
         String query(buf, sizeof(buf), system_charset_info);
         query.length(0);  // Have to zero it since constructor doesn't
-        TABLE *table_ptr;
         int error;
-
-        /*
-          Let's open and lock the table: it will be closed (and
-          unlocked) by close_thread_tables() at the end of the
-          statement anyway.
-         */
-        if (!(table_ptr= open_ltable(thd, table, TL_READ_NO_INSERT)))
-          goto err;
 
         int result= store_create_info(thd, table, &query, create_info);
 
Thread
bk commit into 5.1 tree (andrey:1.2325)ahristov24 Oct