List:Commits« Previous MessageNext Message »
From:Frazer Clement Date:November 27 2009 1:17pm
Subject:bzr commit into mysql-5.1-telco-6.2 branch (frazer:3045) Bug#28116
View as plain text  
#At file:///home/frazer/bzr/mysql-5.1-telco-6.2/

 3045 Frazer Clement	2009-11-27
      Bug#28116 : Crash in getBlobHandle() when called before setting full key with equal()
      modified:
        storage/ndb/src/ndbapi/NdbOperationDefine.cpp
        storage/ndb/test/ndbapi/testBlobs.cpp
        storage/ndb/test/run-test/daily-basic-tests.txt

=== modified file 'storage/ndb/src/ndbapi/NdbOperationDefine.cpp'
--- a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp	2009-05-26 18:53:34 +0000
+++ b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp	2009-11-27 13:17:22 +0000
@@ -698,6 +698,26 @@ NdbOperation::getBlobHandle(NdbTransacti
     return NULL;
   }
 
+  /* Check key fully defined for key operations */
+  switch (theStatus)
+  {
+  case TupleKeyDefined:
+  case GetValue:
+  case SetValue:
+  case FinalGetValue:
+  case ExecInterpretedValue:
+  case SetValueInterpreted:
+    /* All ok states to create a Blob Handle in */
+    break;
+  default:
+  {
+    /* Unexpected state to be obtaining Blob handle */
+    /* Invalid usage of blob attribute */
+    setErrorCodeAbort(4264);
+    return NULL;
+  }
+  }
+
   tBlob = theNdb->getNdbBlob();
   if (tBlob == NULL)
     return NULL;

=== modified file 'storage/ndb/test/ndbapi/testBlobs.cpp'
--- a/storage/ndb/test/ndbapi/testBlobs.cpp	2009-11-27 13:13:26 +0000
+++ b/storage/ndb/test/ndbapi/testBlobs.cpp	2009-11-27 13:17:22 +0000
@@ -3998,27 +3998,83 @@ bugtest_27370()
 }
 
 static int
-bugtest_48973()
+bugtest_28116()
 {
-  DBG("bug test 48973 - Assertion failed at NdbOperationSearch.cpp line 509");
+  DBG("bug test 28116 - Crash in getBlobHandle() when called without full key");
 
-  /* Attempt to insert tuple with Blob column, without setting the key at all */
-  calcTups(true);
-  
-  Tup& tup = g_tups[0];
-  CHK((g_con = g_ndb->startTransaction()) != 0);
-  CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0);
-  CHK(g_opr->insertTuple() ==0);
-  CHK(getBlobHandles(g_opr) != 0);
+  if (g_opt.m_pk2chr.m_len == 0)
+  {
+    DBG("  ... skipped, requires multi-column primary key.");
+    return 0;
+  }
 
-  /* 4264 == Invalid usage of Blob attribute */
-  CHK(g_con->getNdbError().code == 4264);
-  CHK(g_opr->getNdbError().code == 4264);
+  for (unsigned k = 0; k < g_opt.m_rows; k++) {
+    Tup& tup = g_tups[k];
+    CHK((g_con = g_ndb->startTransaction()) != 0);
+    CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0);
+    int reqType = urandom(4);
+    switch(reqType) {
+    case 0:
+    {
+      DBG("Read");
+      CHK(g_opr->readTuple() == 0);
+      break;
+    }
+    case 1:
+    {
+      DBG("Insert");
+      CHK(g_opr->insertTuple() == 0);
+      break;
+    }
+    case 2:
+    {
+      DBG("Update");
+      CHK(g_opr->updateTuple() == 0);
+      break;
+    }
+    case 3:
+    default:
+    {
+      DBG("Delete");
+      CHK(g_opr->deleteTuple() == 0);
+      break;
+    }
+    }
+    switch (urandom(3)) {
+    case 0:
+    {
+      DBG("  No keys");
+      break;
+    }
+    case 1:
+    {
+      DBG("  Pk1 only");
+      CHK(g_opr->equal("PK1", tup.m_pk1) == 0);
+      break;
+    }
+    case 2:
+    default:
+    {
+      DBG("  Pk2/3 only");
+      if (g_opt.m_pk2chr.m_len != 0)
+      {
+        CHK(g_opr->equal("PK2", tup.m_pk2) == 0);
+        CHK(g_opr->equal("PK3", tup.m_pk3) == 0);
+      }
+      break;
+    }
+    }
+    /* Deliberately no equal() on rest of primary key, to provoke error. */
+    CHK(g_opr->getBlobHandle("BL1") == 0);
 
-  g_ndb->closeTransaction(g_con);
+    /* 4264 - Invalid usage of Blob attribute */
+    CHK(g_con->getNdbError().code == 4264);
+    CHK(g_opr->getNdbError().code == 4264);
 
-  g_opr = 0;
-  g_con = 0;
+    g_ndb->closeTransaction(g_con);
+    g_opr = 0;
+    g_con = 0;
+  }
   return 0;
 }
 
@@ -4032,7 +4088,7 @@ static struct {
   { 36756, bugtest_36756 },
   { 45768, bugtest_45768 },
   { 48040, bugtest_48040 },
-  { 48973, bugtest_48973 }
+  { 28116, bugtest_28116 }
 };
 
 NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535)

=== modified file 'storage/ndb/test/run-test/daily-basic-tests.txt'
--- a/storage/ndb/test/run-test/daily-basic-tests.txt	2009-11-27 13:13:26 +0000
+++ b/storage/ndb/test/run-test/daily-basic-tests.txt	2009-11-27 13:17:22 +0000
@@ -1380,5 +1380,5 @@ args: -n DDInsertFailUpdateBatch D1 D2
 
 max-time: 300
 cmd: testBlobs
-args: -skip hp -bug 48973
+args: -skip hp -bug 28116
 

Thread
bzr commit into mysql-5.1-telco-6.2 branch (frazer:3045) Bug#28116Frazer Clement27 Nov