List:Internals« Previous MessageNext Message »
From:antony Date:April 27 2005 8:51am
Subject:bk commit into 4.0 tree (acurtis:1.2052)
View as plain text  
Below is the list of changes that have just been committed into a local
4.0 repository of acurtis. When acurtis 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://www.mysql.com/doc/I/n/Installing_source_tree.html

ChangeSet
  1.2052 05/02/03 16:57:05 acurtis@stripped +3 -0
  Bug#6236
    Implicit NOT NULL not set on ALTER of PK columns

  sql/sql_table.cc
    1.193 05/02/03 16:56:58 acurtis@stripped +17 -6
    Bug#6236
      Implicit NOT NULL not set on ALTER of PK columns

  mysql-test/t/alter_table.test
    1.21 05/02/03 16:56:58 acurtis@stripped +13 -0
    Bug#6236
      Test for bug

  mysql-test/r/alter_table.result
    1.20 05/02/03 16:56:58 acurtis@stripped +20 -0
    Bug#6236
      Test for bug

# 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:	acurtis
# Host:	xiphis.org
# Root:	/.amd_mnt/bk.anubis/host/work-acurtis/bug6236

--- 1.192/sql/sql_table.cc	2004-12-02 21:52:23 +00:00
+++ 1.193/sql/sql_table.cc	2005-02-03 16:56:58 +00:00
@@ -1794,6 +1794,11 @@
     }
 
     KEY_PART_INFO *key_part= key_info->key_part;
+    enum Key::Keytype key_type= key_info->flags & HA_NOSAME ?
+				 (!my_strcasecmp(key_name, "PRIMARY") ?
+				  Key::PRIMARY  : Key::UNIQUE) :
+                                 (key_info->flags & HA_FULLTEXT ?
+                                 Key::FULLTEXT : Key::MULTIPLE);
     key_parts.empty();
     for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
     {
@@ -1823,16 +1828,22 @@
 	     cfield->pack_length <= key_part_length))
 	  key_part_length=0;			// Use whole field
       }
+      if (!(cfield->flags & NOT_NULL_FLAG))
+      {
+	if (key_type == Key::PRIMARY)
+	{
+	  /* Implicitly set primary key fields to NOT NULL for ISO conf. */
+	  cfield->flags|= NOT_NULL_FLAG;
+	  cfield->pack_flag&= ~FIELDFLAG_MAYBE_NULL;
+	}
+        else
+          key_info->flags|= HA_NULL_PART_KEY;
+      }
       key_parts.push_back(new key_part_spec(cfield->field_name,
 					    key_part_length));
     }
     if (key_parts.elements)
-      key_list.push_back(new Key(key_info->flags & HA_NOSAME ?
-				 (!my_strcasecmp(key_name, "PRIMARY") ?
-				  Key::PRIMARY  : Key::UNIQUE) :
-                                 (key_info->flags & HA_FULLTEXT ?
-                                 Key::FULLTEXT : Key::MULTIPLE),
-				 key_name,key_parts));
+      key_list.push_back(new Key(key_type,key_name,key_parts));
   }
   key_it.rewind();
   {

--- 1.19/mysql-test/r/alter_table.result	2004-12-30 20:00:04 +00:00
+++ 1.20/mysql-test/r/alter_table.result	2005-02-03 16:56:58 +00:00
@@ -386,3 +386,23 @@
 rename table t1 to `t1\\`;
 Incorrect table name 't1\\'
 drop table t1;
+drop table if exists t1, t2;
+create table t1 ( a varchar(10) not null primary key ) engine=myisam;
+create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
+flush tables;
+alter table t1 modify a varchar(10);
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(10) NOT NULL default '',
+  PRIMARY KEY  (`a`)
+) TYPE=MRG_MyISAM UNION=(t1)
+flush tables;
+alter table t1 modify a varchar(10) not null;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `a` varchar(10) NOT NULL default '',
+  PRIMARY KEY  (`a`)
+) TYPE=MRG_MyISAM UNION=(t1)
+drop table if exists t1, t2;

--- 1.20/mysql-test/t/alter_table.test	2004-07-26 09:52:37 +01:00
+++ 1.21/mysql-test/t/alter_table.test	2005-02-03 16:56:58 +00:00
@@ -254,3 +254,16 @@
 rename table t1 to `t1\\`;
 drop table t1;
 
+#
+# BUG#6236 - ALTER TABLE MODIFY should set implicit NOT NULL on PK columns
+#
+drop table if exists t1, t2;
+create table t1 ( a varchar(10) not null primary key ) engine=myisam;
+create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1);
+flush tables;
+alter table t1 modify a varchar(10);
+show create table t2;
+flush tables;
+alter table t1 modify a varchar(10) not null;
+show create table t2;
+drop table if exists t1, t2;
Thread
bk commit into 4.0 tree (acurtis:1.2052)antony27 Apr