List:Commits« Previous MessageNext Message »
From:monty Date:June 30 2006 5:29pm
Subject:bk commit into 4.1 tree (monty:1.2525) BUG#11228
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of monty. When monty 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.2525 06/06/30 18:29:27 monty@stripped +3 -0
  Reverted wrong bug fix (Bug#11228)

  sql/table.cc
    1.135 06/06/30 18:29:25 monty@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/t/key.test
    1.24 06/06/30 18:29:25 monty@stripped +1 -0
    Added SHOW CREATE TABLE, which is the proper way to check for table definitions

  mysql-test/r/key.result
    1.27 06/06/30 18:29:25 monty@stripped +9 -1
    Fixed result after removing wrong bug fix

# 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:	monty
# Host:	narttu.mysql.fi
# Root:	/home/my/mysql-4.1

--- 1.134/sql/table.cc	2006-06-23 11:19:24 +03:00
+++ 1.135/sql/table.cc	2006-06-30 18:29:25 +03:00
@@ -567,6 +567,27 @@
       if (outparam->key_info[key].flags & HA_FULLTEXT)
 	outparam->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 ||
+	      outparam->field[fieldnr-1]->null_ptr ||
+	      outparam->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++)
       {
 	if (new_field_pack_flag <= 1)

--- 1.26/mysql-test/r/key.result	2006-06-23 11:19:24 +03:00
+++ 1.27/mysql-test/r/key.result	2006-06-30 18:29:25 +03:00
@@ -332,8 +332,16 @@
 UNIQUE i2idx (i2));
 desc t1;
 Field	Type	Null	Key	Default	Extra
-i1	int(11)		UNI	0	
+i1	int(11)		PRI	0	
 i2	int(11)		UNI	0	
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `i1` int(11) NOT NULL default '0',
+  `i2` int(11) NOT NULL default '0',
+  UNIQUE KEY `i1idx` (`i1`),
+  UNIQUE KEY `i2idx` (`i2`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
 drop table t1;
 create table t1 (
 c1 int,

--- 1.23/mysql-test/t/key.test	2006-06-23 11:19:24 +03:00
+++ 1.24/mysql-test/t/key.test	2006-06-30 18:29:25 +03:00
@@ -330,6 +330,7 @@
  UNIQUE i1idx (i1),
  UNIQUE i2idx (i2));
 desc t1;
+show create table t1;
 drop table t1;
 
 #
Thread
bk commit into 4.1 tree (monty:1.2525) BUG#11228monty30 Jun