List:Internals« Previous MessageNext Message »
From:jonas Date:December 14 2005 10:57am
Subject:bk commit into 5.0 tree (jonas:1.2047) BUG#15682
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jonas. When jonas 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.2047 05/12/14 10:57:09 jonas@stripped +7 -0
  bug#15682 - ndb - invalid handling of varchar in position/rnd_pos

  sql/ha_ndbcluster.cc
    1.216 05/12/14 10:57:06 jonas@stripped +20 -2
    Fix varchar keys in position/rnd_pos

  ndb/src/ndbapi/ndberror.c
    1.43 05/12/14 10:57:06 jonas@stripped +1 -1
    New error code

  ndb/src/kernel/vm/SimulatedBlock.cpp
    1.22 05/12/14 10:57:06 jonas@stripped +8 -2
    Handle invalid key gracefully

  ndb/src/kernel/blocks/dbtc/DbtcMain.cpp
    1.88 05/12/14 10:57:06 jonas@stripped +16 -1
    Handle invalid key gracefully

  ndb/src/kernel/blocks/dbtc/Dbtc.hpp
    1.32 05/12/14 10:57:06 jonas@stripped +2 -0
    New error code for invalid key

  mysql-test/t/ndb_basic.test
    1.31 05/12/14 10:57:06 jonas@stripped +11 -0
    bug#15682 - invalid handling of varchar in position/rnd_pos

  mysql-test/r/ndb_basic.result
    1.29 05/12/14 10:57:06 jonas@stripped +16 -0
    bug#15682 - invalid handling of varchar in position/rnd_pos

# 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:	jonas
# Host:	perch.ndb.mysql.com
# Root:	/home/jonas/src/mysql-5.0

--- 1.28/mysql-test/r/ndb_basic.result	2005-05-19 20:38:45 +02:00
+++ 1.29/mysql-test/r/ndb_basic.result	2005-12-14 10:57:06 +01:00
@@ -673,3 +673,19 @@
 a
 2
 drop table atablewithareallylongandirritatingname;
+create table t1 (f1 varchar(50), f2 text,f3 int, primary key(f1)) engine=NDB;
+insert into t1 (f1,f2,f3)VALUES("111111","aaaaaa",1);
+insert into t1 (f1,f2,f3)VALUES("222222","bbbbbb",2);
+select * from t1 order by f1;
+f1	f2	f3
+111111	aaaaaa	1
+222222	bbbbbb	2
+select * from t1 order by f2;
+f1	f2	f3
+111111	aaaaaa	1
+222222	bbbbbb	2
+select * from t1 order by f3;
+f1	f2	f3
+111111	aaaaaa	1
+222222	bbbbbb	2
+drop table t1;

--- 1.30/mysql-test/t/ndb_basic.test	2005-07-28 16:09:48 +02:00
+++ 1.31/mysql-test/t/ndb_basic.test	2005-12-14 10:57:06 +01:00
@@ -615,3 +615,14 @@
 insert into atablewithareallylongandirritatingname values (2);
 select * from atablewithareallylongandirritatingname;
 drop table atablewithareallylongandirritatingname;
+
+#
+# Bug#15682
+#
+create table t1 (f1 varchar(50), f2 text,f3 int, primary key(f1)) engine=NDB;
+insert into t1 (f1,f2,f3)VALUES("111111","aaaaaa",1);
+insert into t1 (f1,f2,f3)VALUES("222222","bbbbbb",2);
+select * from t1 order by f1;
+select * from t1 order by f2;
+select * from t1 order by f3;
+drop table t1;

--- 1.31/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2005-10-05 16:35:20 +02:00
+++ 1.32/ndb/src/kernel/blocks/dbtc/Dbtc.hpp	2005-12-14 10:57:06 +01:00
@@ -141,6 +141,8 @@
 #define ZALREADYEXIST 630
 #define ZINCONSISTENTHASHINDEX 892
 #define ZNOTUNIQUE 893
+
+#define ZINVALID_KEY 290
 #endif
 
 class Dbtc: public SimulatedBlock {

--- 1.87/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-12-13 11:51:01 +01:00
+++ 1.88/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp	2005-12-14 10:57:06 +01:00
@@ -2313,7 +2313,10 @@
   {
     keyPartLenPtr = keyPartLen;
     dstPos = xfrm_key(tabPtrI, src, dst, sizeof(Tmp) >> 2, keyPartLenPtr);
-    ndbrequire(dstPos);
+    if (unlikely(dstPos == 0))
+    {
+      goto error;
+    }
   } 
   else 
   {
@@ -2334,6 +2337,10 @@
     dstHash[1] = tmp[1];
   }
   return true;  // success
+
+error:
+  terrorCode = ZINVALID_KEY;
+  return false;
 }
 
 /*
@@ -2941,7 +2948,15 @@
   UintR tnoOfStandby;
   UintR tnodeinfo;
 
+  terrorCode = 0;
+
   hash(signal); /* NOW IT IS TIME TO CALCULATE THE HASH VALUE*/
+  
+  if (unlikely(terrorCode))
+  {
+    releaseAtErrorLab(signal);
+    return;
+  }
 
   CacheRecord * const regCachePtr = cachePtr.p;
   TcConnectRecord * const regTcPtr = tcConnectptr.p;

--- 1.21/ndb/src/kernel/vm/SimulatedBlock.cpp	2005-10-04 20:05:53 +02:00
+++ 1.22/ndb/src/kernel/vm/SimulatedBlock.cpp	2005-12-14 10:57:06 +01:00
@@ -1890,7 +1890,10 @@
 	AttributeDescriptor::getType(keyAttr.attributeDescriptor);
       Uint32 lb, len;
       bool ok = NdbSqlUtil::get_var_length(typeId, srcPtr, srcBytes, lb, len);
-      ndbrequire(ok);
+      if (unlikely(!ok))
+      {
+	return 0;
+      }
       Uint32 xmul = cs->strxfrm_multiply;
       if (xmul == 0)
 	xmul = 1;
@@ -1902,7 +1905,10 @@
       Uint32 dstLen = xmul * (srcBytes - lb);
       ndbrequire(dstLen <= ((dstSize - dstPos) << 2));
       int n = NdbSqlUtil::strnxfrm_bug7284(cs, dstPtr, dstLen, srcPtr + lb, len);
-      ndbrequire(n != -1);
+      if (unlikely(n == -1))
+      {
+	return 0;
+      }
       while ((n & 3) != 0) 
       {
 	dstPtr[n++] = 0;

--- 1.215/sql/ha_ndbcluster.cc	2005-10-11 23:59:47 +02:00
+++ 1.216/sql/ha_ndbcluster.cc	2005-12-14 10:57:06 +01:00
@@ -2796,8 +2796,26 @@
         }      
         *buff++= 0;
       }
-      memcpy(buff, record + key_part->offset, key_part->length);
-      buff += key_part->length;
+
+      size_t len = key_part->length;
+      const byte * ptr = record + key_part->offset;
+      Field *field = key_part->field;
+      if ((field->type() ==  MYSQL_TYPE_VARCHAR) &&
+	  ((Field_varstring*)field)->length_bytes == 1)
+      {
+	/** 
+	 * Keys always use 2 bytes length
+	 */
+	buff[0] = ptr[0];
+	buff[1] = 0;
+	memcpy(buff+2, ptr + 1, len);	
+	len += 2;
+      }
+      else
+      {
+	memcpy(buff, ptr, len);
+      }
+      buff += len;
     }
   } 
   else 

--- 1.42/ndb/src/ndbapi/ndberror.c	2005-10-03 20:04:27 +02:00
+++ 1.43/ndb/src/ndbapi/ndberror.c	2005-12-14 10:57:06 +01:00
@@ -227,6 +227,7 @@
   { 277,  IE, "277" },
   { 278,  IE, "278" },
   { 287,  IE, "Index corrupted" },
+  { 290,  IE, "Corrupt key in TC, unable to xfrm" },
   { 631,  IE, "631" },
   { 632,  IE, "632" },
   { 702,  IE, "Request to non-master" },
@@ -295,7 +296,6 @@
   { 4608, AE, "You can not takeOverScan unless you have used openScanExclusive"},
   { 4609, AE, "You must call nextScanResult before trying to takeOverScan"},
   { 4232, AE, "Parallelism can only be between 1 and 240" },
-  { 290,  AE, "Scan not started or has been closed by kernel due to timeout" },
 
   /** 
    * Event schema errors
Thread
bk commit into 5.0 tree (jonas:1.2047) BUG#15682jonas14 Dec