List:Commits« Previous MessageNext Message »
From:Jon Olav Hauglid Date:April 10 2012 9:06am
Subject:bzr push into mysql-trunk branch (jon.hauglid:3856 to 3857) WL#6255
View as plain text  
 3857 Jon Olav Hauglid	2012-04-10
      WL#6255 Online ALTER TABLE…MODIFY…NOT NULL, ADD FOREIGN KEY
      
      Pre-requisite patch.
      
      This patch splits the Alter_inplace_info handler flag
      ALTER_COLUMN_NULLABLE in two - ALTER_COLUMN_NULLABLE
      for changing a NOT NULL column to NULL, and
      ALTER_COLUMN_NOT_NULLABLE for changing a NULL column
      to NOT NULL. This is done to make it easier for storage
      engines as these two operations have different requirements.

    modified:
      mysql-test/r/alter_table.result
      mysql-test/t/alter_table.test
      sql/handler.h
      sql/sql_table.cc
 3856 Manish Kumar	2012-04-10 [merge]
      upmerge from mysql-5.5 -> mysql-trunk
     @ mysql-test/suite/rpl/r/rpl_report_port.result
        Updated the corresponding result file.
     @ mysql-test/suite/rpl/t/rpl_report_port.test
        Added the restart server option before ending the test.

    removed:
      mysql-test/suite/rpl/t/rpl_report_port-slave.opt
    modified:
      mysql-test/suite/rpl/r/rpl_report_port.result
      mysql-test/suite/rpl/t/rpl_report_port.test
=== modified file 'mysql-test/r/alter_table.result'
--- a/mysql-test/r/alter_table.result	2012-03-08 14:22:07 +0000
+++ b/mysql-test/r/alter_table.result	2012-04-10 08:45:55 +0000
@@ -1747,6 +1747,12 @@ info: Records: 2  Duplicates: 0  Warning
 ALTER TABLE tm1 MODIFY COLUMN c INT NOT NULL;
 affected rows: 2
 info: Records: 2  Duplicates: 0  Warnings: 0
+ALTER TABLE ti1 MODIFY COLUMN c INT NULL;
+affected rows: 2
+info: Records: 2  Duplicates: 0  Warnings: 0
+ALTER TABLE tm1 MODIFY COLUMN c INT NULL;
+affected rows: 2
+info: Records: 2  Duplicates: 0  Warnings: 0
 ALTER TABLE ti1 MODIFY COLUMN h VARCHAR(30);
 affected rows: 2
 info: Records: 2  Duplicates: 0  Warnings: 0

=== modified file 'mysql-test/t/alter_table.test'
--- a/mysql-test/t/alter_table.test	2012-02-01 14:09:34 +0000
+++ b/mysql-test/t/alter_table.test	2012-04-10 08:45:55 +0000
@@ -1476,9 +1476,12 @@ ALTER TABLE ti1 MODIFY COLUMN e INT AFTE
 ALTER TABLE tm1 MODIFY COLUMN e INT AFTER h;
 ALTER TABLE ti1 MODIFY COLUMN e INT FIRST;
 ALTER TABLE tm1 MODIFY COLUMN e INT FIRST;
-# This will set both ALTER_COLUMN_NULLABLE and COLUMN_DEFAULT_VALUE
+# This will set both ALTER_COLUMN_NOT_NULLABLE and COLUMN_DEFAULT_VALUE
 ALTER TABLE ti1 MODIFY COLUMN c INT NOT NULL;
 ALTER TABLE tm1 MODIFY COLUMN c INT NOT NULL;
+# This will set both ALTER_COLUMN_NULLABLE and COLUMN_DEFAULT_VALUE
+ALTER TABLE ti1 MODIFY COLUMN c INT NULL;
+ALTER TABLE tm1 MODIFY COLUMN c INT NULL;
 # This will set both ALTER_COLUMN_EQUAL_PACK_LENGTH and COLUMN_DEFAULT_VALUE
 ALTER TABLE ti1 MODIFY COLUMN h VARCHAR(30);
 ALTER TABLE tm1 MODIFY COLUMN h VARCHAR(30);

=== modified file 'sql/handler.h'
--- a/sql/handler.h	2012-03-28 11:25:37 +0000
+++ b/sql/handler.h	2012-04-10 08:45:55 +0000
@@ -996,23 +996,26 @@ public:
   // Reorder column
   static const HA_ALTER_FLAGS ALTER_COLUMN_ORDER         = 1L << 11;
 
-  // Change column from NULL to NOT NULL or vice versa
+  // Change column from NOT NULL to NULL
   static const HA_ALTER_FLAGS ALTER_COLUMN_NULLABLE      = 1L << 12;
 
+  // Change column from NULL to NOT NULL
+  static const HA_ALTER_FLAGS ALTER_COLUMN_NOT_NULLABLE  = 1L << 13;
+
   // Set or remove default column value
-  static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT       = 1L << 13;
+  static const HA_ALTER_FLAGS ALTER_COLUMN_DEFAULT       = 1L << 14;
 
   // Add foreign key
-  static const HA_ALTER_FLAGS ADD_FOREIGN_KEY            = 1L << 14;
+  static const HA_ALTER_FLAGS ADD_FOREIGN_KEY            = 1L << 15;
 
   // Drop foreign key
-  static const HA_ALTER_FLAGS DROP_FOREIGN_KEY           = 1L << 15;
+  static const HA_ALTER_FLAGS DROP_FOREIGN_KEY           = 1L << 16;
 
   // table_options changed, see HA_CREATE_INFO::used_fields for details.
-  static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION       = 1L << 16;
+  static const HA_ALTER_FLAGS CHANGE_CREATE_OPTION       = 1L << 17;
 
   // Table is renamed
-  static const HA_ALTER_FLAGS ALTER_RENAME               = 1L << 17;
+  static const HA_ALTER_FLAGS ALTER_RENAME               = 1L << 18;
 
   /**
     Create options (like MAX_ROWS) for the new version of table.

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2012-03-23 09:56:55 +0000
+++ b/sql/sql_table.cc	2012-04-10 08:45:55 +0000
@@ -5340,7 +5340,14 @@ static bool fill_alter_inplace_info(THD
       /* Check that NULL behavior is same for old and new fields */
       if ((new_field->flags & NOT_NULL_FLAG) !=
           (uint) (field->flags & NOT_NULL_FLAG))
-        ha_alter_info->handler_flags|= Alter_inplace_info::ALTER_COLUMN_NULLABLE;
+      {
+        if (new_field->flags & NOT_NULL_FLAG)
+          ha_alter_info->handler_flags|=
+            Alter_inplace_info::ALTER_COLUMN_NOT_NULLABLE;
+        else
+          ha_alter_info->handler_flags|=
+            Alter_inplace_info::ALTER_COLUMN_NULLABLE;
+      }
 
       /*
         We do not detect changes to default values in this loop.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (jon.hauglid:3856 to 3857) WL#6255Jon Olav Hauglid10 Apr