List:Commits« Previous MessageNext Message »
From:Martin Skold Date:March 12 2008 6:56pm
Subject:bk commit into 5.1 tree (mskold:1.2552) BUG#31233
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of mskold.  When mskold 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, 2008-03-12 19:55:57+01:00, mskold@stripped +3 -0
  bug#31233 mysql_alter_table() fails to drop UNIQUE KEY: Adpted patch to new online alter interface

  mysql-test/suite/ndb/r/ndb_alter_table_online.result@stripped, 2008-03-12 19:55:49+01:00, mskold@stripped +40 -0
    bug#31233 mysql_alter_table() fails to drop UNIQUE KEY: Adpted patch to new online alter interface

  mysql-test/suite/ndb/t/ndb_alter_table_online.test@stripped, 2008-03-12 19:55:49+01:00, mskold@stripped +39 -0
    bug#31233 mysql_alter_table() fails to drop UNIQUE KEY: Adpted patch to new online alter interface

  sql/sql_table.cc@stripped, 2008-03-12 19:55:48+01:00, mskold@stripped +22 -4
    bug#31233 mysql_alter_table() fails to drop UNIQUE KEY: Adpted patch to new online alter interface

diff -Nrup a/mysql-test/suite/ndb/r/ndb_alter_table_online.result b/mysql-test/suite/ndb/r/ndb_alter_table_online.result
--- a/mysql-test/suite/ndb/r/ndb_alter_table_online.result	2008-01-24 16:45:36 +01:00
+++ b/mysql-test/suite/ndb/r/ndb_alter_table_online.result	2008-03-12 19:55:49 +01:00
@@ -472,6 +472,46 @@ name
 truncate ndb_show_tables_results;
 DROP TABLE t1;
 ****************************************
+* Adding dropping primary key
+****************************************
+CREATE TABLE t1 (a INT UNSIGNED NOT NULL) ENGINE NDB;
+$PK Bigunsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
+PRIMARY KEY($PK) - UniqueHashIndex
+ALTER ONLINE TABLE t1 ADD PRIMARY KEY (a);
+ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 ADD PRIMARY KEY (a)'
+ALTER OFFLINE TABLE t1 ADD PRIMARY KEY (a);
+a Unsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
+PRIMARY KEY(a) - UniqueHashIndex
+PRIMARY(a) - OrderedIndex
+ALTER ONLINE TABLE t1 DROP PRIMARY KEY;
+ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 DROP PRIMARY KEY'
+ALTER OFFLINE TABLE t1 DROP PRIMARY KEY;
+$PK Bigunsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
+PRIMARY KEY($PK) - UniqueHashIndex
+CREATE ONLINE UNIQUE INDEX pk ON t1(a);
+ERROR 42000: This version of MySQL doesn't yet support 'CREATE ONLINE UNIQUE INDEX pk ON t1(a)'
+CREATE OFFLINE UNIQUE INDEX pk ON t1(a);
+a Unsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
+PRIMARY KEY(a) - UniqueHashIndex
+ALTER ONLINE TABLE t1 DROP INDEX PK;
+ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 DROP INDEX PK'
+ALTER OFFLINE TABLE t1 DROP INDEX PK;
+$PK Bigunsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
+PRIMARY KEY($PK) - UniqueHashIndex
+DROP TABLE t1;
+CREATE TABLE t1 (a INT UNSIGNED) ENGINE NDB;
+ALTER ONLINE TABLE t1 ADD b INT UNIQUE;
+ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 ADD b INT UNIQUE'
+ALTER OFFLINE TABLE t1 ADD b INT UNIQUE;
+$PK Bigunsigned PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
+PRIMARY KEY($PK) - UniqueHashIndex
+ALTER ONLINE TABLE t1 ADD c INT NOT NULL UNIQUE;
+ERROR 42000: This version of MySQL doesn't yet support 'ALTER ONLINE TABLE t1 ADD c INT NOT NULL UNIQUE'
+ALTER OFFLINE TABLE t1 ADD c INT NOT NULL UNIQUE;
+c Int PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY
+PRIMARY KEY(c) - UniqueHashIndex
+DROP TABLE t1;
+****************************************
 * Add column c as nullable TEXT and BLOB
 ****************************************
 CREATE TABLE t1 (a INT UNSIGNED  AUTO_INCREMENT KEY, b INT DEFAULT 2 COLUMN_FORMAT DYNAMIC) ENGINE NDB;
diff -Nrup a/mysql-test/suite/ndb/t/ndb_alter_table_online.test b/mysql-test/suite/ndb/t/ndb_alter_table_online.test
--- a/mysql-test/suite/ndb/t/ndb_alter_table_online.test	2008-01-24 16:45:36 +01:00
+++ b/mysql-test/suite/ndb/t/ndb_alter_table_online.test	2008-03-12 19:55:49 +01:00
@@ -445,6 +445,45 @@ truncate ndb_show_tables_results;
 
 DROP TABLE t1;
 
+#####################################
+# Adding dropping primary key
+######################################
+# Bug:31233
+######################################
+--echo ****************************************
+--echo * Adding dropping primary key
+--echo ****************************************
+CREATE TABLE t1 (a INT UNSIGNED NOT NULL) ENGINE NDB;
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+--error ER_NOT_SUPPORTED_YET
+ALTER ONLINE TABLE t1 ADD PRIMARY KEY (a);
+ALTER OFFLINE TABLE t1 ADD PRIMARY KEY (a);
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+--error ER_NOT_SUPPORTED_YET
+ALTER ONLINE TABLE t1 DROP PRIMARY KEY;
+ALTER OFFLINE TABLE t1 DROP PRIMARY KEY;
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+--error ER_NOT_SUPPORTED_YET
+CREATE ONLINE UNIQUE INDEX pk ON t1(a);
+CREATE OFFLINE UNIQUE INDEX pk ON t1(a);
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+--error ER_NOT_SUPPORTED_YET
+ALTER ONLINE TABLE t1 DROP INDEX PK;
+ALTER OFFLINE TABLE t1 DROP INDEX PK;
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+DROP TABLE t1;
+
+CREATE TABLE t1 (a INT UNSIGNED) ENGINE NDB;
+--error ER_NOT_SUPPORTED_YET
+ALTER ONLINE TABLE t1 ADD b INT UNIQUE;
+ALTER OFFLINE TABLE t1 ADD b INT UNIQUE;
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+--error ER_NOT_SUPPORTED_YET
+ALTER ONLINE TABLE t1 ADD c INT NOT NULL UNIQUE;
+ALTER OFFLINE TABLE t1 ADD c INT NOT NULL UNIQUE;
+--exec $NDB_TOOLS_DIR/ndb_desc --no-defaults -d test t1 | grep PRIMARY
+DROP TABLE t1;
+
 ######################################
 # Alter dynmaic table, add TEXT column
 ######################################
diff -Nrup a/sql/sql_table.cc b/sql/sql_table.cc
--- a/sql/sql_table.cc	2008-03-12 15:55:02 +01:00
+++ b/sql/sql_table.cc	2008-03-12 19:55:48 +01:00
@@ -5457,7 +5457,7 @@ compare_tables(THD *thd,
     }
     if (table_key >= table_key_end)
     {
-      bool is_not_null;
+      bool is_not_null= true;
       bool no_pk= ((table->s->primary_key == MAX_KEY) ||
                    alter_flags->is_set(HA_DROP_PK_INDEX));
 
@@ -5476,9 +5476,26 @@ compare_tables(THD *thd,
           Check if all fields in key are declared
           NOT NULL
          */
-        is_not_null=
-          (is_not_null && 
-           (!table->field[key_part->fieldnr]->maybe_null()));
+        if (key_part->fieldnr < table->s->fields)
+        {
+          is_not_null=
+            (is_not_null && 
+             (!table->field[key_part->fieldnr]->maybe_null()));
+        }
+        else
+        {
+          /* Index is defined over a newly added column */
+          List_iterator_fast<Create_field>
+            new_field_it(alter_info->create_list);
+          Create_field *new_field;
+          uint fieldnr;
+
+          for (fieldnr= 0, new_field= new_field_it++;
+               fieldnr != key_part->fieldnr;
+               fieldnr++, new_field= new_field_it++);
+          is_not_null=
+            (is_not_null && (new_field->flags & NOT_NULL_FLAG));
+        }
       }
       if (new_key->flags & HA_NOSAME)
       {
@@ -5486,6 +5503,7 @@ compare_tables(THD *thd,
            or if adding first unique key
            defined on non-nullable 
         */
+        DBUG_PRINT("info",("no_pk %s, candidate_key_count %u, is_not_null %s", (no_pk)?"yes":"no", candidate_key_count, (is_not_null)?"yes":"no"));
         if ((!my_strcasecmp(system_charset_info,
                             new_key->name, primary_key_name)) ||
             (no_pk && candidate_key_count == 0 && is_not_null))
Thread
bk commit into 5.1 tree (mskold:1.2552) BUG#31233Martin Skold12 Mar