Index: mysql-5.1-telco-6.2/storage/ndb/test/ndbapi/testBlobs.cpp =================================================================== --- mysql-5.1-telco-6.2.orig/storage/ndb/test/ndbapi/testBlobs.cpp 2009-11-24 17:44:47.000000000 +0000 +++ mysql-5.1-telco-6.2/storage/ndb/test/ndbapi/testBlobs.cpp 2009-11-25 14:15:20.000000000 +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) Index: mysql-5.1-telco-6.2/storage/ndb/src/ndbapi/NdbOperationDefine.cpp =================================================================== --- mysql-5.1-telco-6.2.orig/storage/ndb/src/ndbapi/NdbOperationDefine.cpp 2009-11-25 14:11:31.000000000 +0000 +++ mysql-5.1-telco-6.2/storage/ndb/src/ndbapi/NdbOperationDefine.cpp 2009-11-25 14:12:26.000000000 +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; Index: mysql-5.1-telco-6.2/storage/ndb/test/run-test/daily-basic-tests.txt =================================================================== --- mysql-5.1-telco-6.2.orig/storage/ndb/test/run-test/daily-basic-tests.txt 2009-11-24 17:46:50.000000000 +0000 +++ mysql-5.1-telco-6.2/storage/ndb/test/run-test/daily-basic-tests.txt 2009-11-25 14:15:26.000000000 +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