List:Commits« Previous MessageNext Message »
From:Martin Skold Date:September 21 2006 4:49pm
Subject:bk commit into 4.1 tree (mskold:1.2566) BUG#21072
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of marty. When marty 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, 2006-09-21 16:49:07+02:00, mskold@stripped +5 -0
  Bug #21072  Duplicate key error in NDB references wrong key: use MAX_KEY to signal
unknown key

  mysql-test/r/ndb_charset.result@stripped, 2006-09-21 16:48:31+02:00, mskold@stripped +2 -2
    Bug #21072  Duplicate key error in NDB references wrong key: use MAX_KEY to signal
unknown key

  mysql-test/r/ndb_index_unique.result@stripped, 2006-09-21 16:48:31+02:00, mskold@stripped
+5 -5
    Bug #21072  Duplicate key error in NDB references wrong key: use MAX_KEY to signal
unknown key

  mysql-test/r/ndb_update.result@stripped, 2006-09-21 16:48:32+02:00, mskold@stripped +1 -1
    Bug #21072  Duplicate key error in NDB references wrong key: use MAX_KEY to signal
unknown key

  sql/ha_ndbcluster.cc@stripped, 2006-09-21 16:48:31+02:00, mskold@stripped +8 -1
    Bug #21072  Duplicate key error in NDB references wrong key: use MAX_KEY to signal
unknown key

  sql/handler.cc@stripped, 2006-09-21 16:48:31+02:00, mskold@stripped +15 -5
    Bug #21072  Duplicate key error in NDB references wrong key: use MAX_KEY to signal
unknown key

# 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:	mskold
# Host:	linux.site
# Root:	/windows/Linux_space/MySQL/mysql-4.1

--- 1.172/sql/handler.cc	2006-09-21 16:49:12 +02:00
+++ 1.173/sql/handler.cc	2006-09-21 16:49:12 +02:00
@@ -1102,12 +1102,22 @@ void handler::print_error(int error, myf
       /* Write the dupplicated key in the error message */
       char key[MAX_KEY_LENGTH];
       String str(key,sizeof(key),system_charset_info);
-      key_unpack(&str,table,(uint) key_nr);
-      uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY));
-      if (str.length() >= max_length)
+
+      if (key_nr == MAX_KEY)
       {
-	str.length(max_length-4);
-	str.append("...");
+	/* Key is unknown */
+	str.length(0);
+	key_nr= -1;
+      }
+      else
+      {
+	key_unpack(&str,table,(uint) key_nr);
+	uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY));
+	if (str.length() >= max_length)
+	  {
+	    str.length(max_length-4);
+	    str.append("...");
+	  }
       }
       my_error(ER_DUP_ENTRY,MYF(0),str.c_ptr(),key_nr+1);
       DBUG_VOID_RETURN;

--- 1.12/mysql-test/r/ndb_index_unique.result	2006-09-21 16:49:12 +02:00
+++ 1.13/mysql-test/r/ndb_index_unique.result	2006-09-21 16:49:12 +02:00
@@ -22,7 +22,7 @@ select * from t1 where b = 4 order by a;
 a	b	c
 3	4	6
 insert into t1 values(8, 2, 3);
-ERROR 23000: Duplicate entry '8' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 select * from t1 order by a;
 a	b	c
 1	2	3
@@ -89,7 +89,7 @@ a	b	c
 1	1	1
 4	4	NULL
 insert into t1 values(5,1,1);
-ERROR 23000: Duplicate entry '5' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 drop table t1;
 CREATE TABLE t2 (
 a int unsigned NOT NULL PRIMARY KEY,
@@ -112,7 +112,7 @@ select * from t2 where b = 4 order by a;
 a	b	c
 3	4	6
 insert into t2 values(8, 2, 3);
-ERROR 23000: Duplicate entry '8' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 select * from t2 order by a;
 a	b	c
 1	2	3
@@ -177,7 +177,7 @@ pk	a
 3	NULL
 4	4
 insert into t1 values (5,0);
-ERROR 23000: Duplicate entry '5' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 select * from t1 order by pk;
 pk	a
 -1	NULL
@@ -210,7 +210,7 @@ pk	a	b	c
 0	NULL	18	NULL
 1	3	19	abc
 insert into t2 values(2,3,19,'abc');
-ERROR 23000: Duplicate entry '2' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 select * from t2 order by pk;
 pk	a	b	c
 -1	1	17	NULL

--- 1.193/sql/ha_ndbcluster.cc	2006-09-21 16:49:12 +02:00
+++ 1.194/sql/ha_ndbcluster.cc	2006-09-21 16:49:12 +02:00
@@ -454,7 +454,14 @@ int ha_ndbcluster::ndb_err(NdbConnection
   if (res == HA_ERR_FOUND_DUPP_KEY)
   {
     if (m_rows_to_insert == 1)
-      m_dupkey= table->primary_key;
+    {
+      /*
+	We can only distinguish between primary and non-primary
+	violations here, so we need to return MAX_KEY for non-primary
+	to signal that key is unknown
+      */
+      m_dupkey= err.code == 630 ? table->primary_key : MAX_KEY; 
+    }
     else
     {
       /* We are batching inserts, offending key is not available */

--- 1.4/mysql-test/r/ndb_update.result	2006-09-21 16:49:12 +02:00
+++ 1.5/mysql-test/r/ndb_update.result	2006-09-21 16:49:12 +02:00
@@ -18,7 +18,7 @@ pk1	b	c
 2	2	2
 4	1	1
 UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
-ERROR 23000: Duplicate entry '1' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 select * from t1 order by pk1;
 pk1	b	c
 0	0	0

--- 1.4/mysql-test/r/ndb_charset.result	2006-09-21 16:49:12 +02:00
+++ 1.5/mysql-test/r/ndb_charset.result	2006-09-21 16:49:12 +02:00
@@ -78,9 +78,9 @@ unique key(a)
 ) engine=ndb;
 insert into t1 values(1, 'aAa');
 insert into t1 values(2, 'aaa');
-ERROR 23000: Duplicate entry '2' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 insert into t1 values(3, 'AAA');
-ERROR 23000: Duplicate entry '3' for key 1
+ERROR 23000: Duplicate entry '' for key 0
 select * from t1 order by p;
 p	a
 1	aAa
Thread
bk commit into 4.1 tree (mskold:1.2566) BUG#21072Martin Skold21 Sep