List:Commits« Previous MessageNext Message »
From:eugene Date:June 30 2006 9:37pm
Subject:bk commit into 5.1 tree (evgen:1.2229) BUG#11228
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of evgen. When evgen 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
  1.2229 06/07/01 01:37:20 evgen@stripped +3 -0
  Reverted wrong bug fix (Bug#11228)

  sql/table.cc
    1.226 06/07/01 01:36:04 evgen@stripped +21 -0
    Reverted wrong bug fix.
    The intention with the original code was to show that MySQL treats the first
    given unique key as a primary key. Clients can use the marked primary key as a
    real primary key to validate row changes in case of conflicting updates.  The
    ODBC driver (and other drivers) may also use this fact to optimize/check
    updates and handle conflicts.  The marked key also shows what some engines, like InnoDB or NDB,
    will use as it's internal primary key.
    For checking if someone has declared a true PRIMARY KEY, one should use 'SHOW CREATE TABLE'

  mysql-test/r/key.result
    1.36 06/07/01 01:34:16 evgen@stripped +9 -1
    Fixed result after removing wrong bug fix

  mysql-test/t/key.test
    1.28 06/07/01 01:33:39 evgen@stripped +1 -0
    Added SHOW CREATE TABLE, which is the proper way to check for table definitions

# 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:	evgen
# Host:	moonbone.local
# Root:	/work/merge-5.1

--- 1.225/sql/table.cc	2006-06-30 16:08:18 +04:00
+++ 1.226/sql/table.cc	2006-07-01 01:36:04 +04:00
@@ -1025,6 +1025,27 @@
       if (share->key_info[key].flags & HA_FULLTEXT)
 	share->key_info[key].algorithm= HA_KEY_ALG_FULLTEXT;
 
+      if (primary_key >= MAX_KEY && (keyinfo->flags & HA_NOSAME))
+      {
+	/*
+	  If the UNIQUE key doesn't have NULL columns and is not a part key
+	  declare this as a primary key.
+	*/
+	primary_key=key;
+	for (i=0 ; i < keyinfo->key_parts ;i++)
+	{
+	  uint fieldnr= key_part[i].fieldnr;
+	  if (!fieldnr ||
+	      share->field[fieldnr-1]->null_ptr ||
+	      share->field[fieldnr-1]->key_length() !=
+	      key_part[i].length)
+	  {
+	    primary_key=MAX_KEY;		// Can't be used
+	    break;
+	  }
+	}
+      }
+
       for (i=0 ; i < keyinfo->key_parts ; key_part++,i++)
       {
         Field *field;

--- 1.35/mysql-test/r/key.result	2006-06-30 16:08:16 +04:00
+++ 1.36/mysql-test/r/key.result	2006-07-01 01:34:16 +04:00
@@ -336,8 +336,16 @@
 UNIQUE i2idx (i2));
 desc t1;
 Field	Type	Null	Key	Default	Extra
-i1	int(11)	NO	UNI		
+i1	int(11)	NO	PRI		
 i2	int(11)	NO	UNI		
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i1` int(11) NOT NULL,
+  `i2` int(11) NOT NULL,
+  UNIQUE KEY `i1idx` (`i1`),
+  UNIQUE KEY `i2idx` (`i2`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 create table t1 (
 c1 int,

--- 1.27/mysql-test/t/key.test	2006-06-30 16:08:16 +04:00
+++ 1.28/mysql-test/t/key.test	2006-07-01 01:33:39 +04:00
@@ -334,6 +334,7 @@
  UNIQUE i1idx (i1),
  UNIQUE i2idx (i2));
 desc t1;
+show create table t1;
 drop table t1;
 
 #
Thread
bk commit into 5.1 tree (evgen:1.2229) BUG#11228eugene1 Jul