Commit 4e4dffb4 authored by tomas@poseidon.ndb.mysql.com's avatar tomas@poseidon.ndb.mysql.com

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0-ndb

into poseidon.ndb.mysql.com:/home/tomas/mysql-5.0-ndb
parents 013f9bbf e9a43dda
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
*/ */
#include <NdbApi.hpp> #include <NdbApi.hpp>
#include <ndberror.h>
// Used for cout // Used for cout
#include <stdio.h> #include <stdio.h>
...@@ -160,10 +161,9 @@ int main() ...@@ -160,10 +161,9 @@ int main()
// set up the callbacks // set up the callbacks
printf("execute\n"); printf("execute\n");
if (op->execute()) { // This starts changes to "start flowing" // This starts changes to "start flowing"
printf("operation execution failed\n"); if (op->execute())
exit(-1); APIERROR(op->getNdbError());
}
int i= 0; int i= 0;
while(i < 40) { while(i < 40) {
...@@ -251,7 +251,7 @@ int myCreateEvent(Ndb* myNdb, ...@@ -251,7 +251,7 @@ int myCreateEvent(Ndb* myNdb,
// Add event to database // Add event to database
if (myDict->createEvent(myEvent) == 0) if (myDict->createEvent(myEvent) == 0)
myEvent.print(); myEvent.print();
else if (myDict->getNdbError().code == 4709) { else if (myDict->getNdbError().code == NDBERR_EVENT_NAME_ALEADY_EXISTS) {
printf("Event creation failed, event exists\n"); printf("Event creation failed, event exists\n");
printf("dropping Event...\n"); printf("dropping Event...\n");
if (myDict->dropEvent(eventName)) APIERROR(myDict->getNdbError()); if (myDict->dropEvent(eventName)) APIERROR(myDict->getNdbError());
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#ifndef CREATE_EVNT_HPP #ifndef CREATE_EVNT_HPP
#define CREATE_EVNT_HPP #define CREATE_EVNT_HPP
#include <ndberror.h>
#include "SignalData.hpp" #include "SignalData.hpp"
#include <NodeBitmask.hpp> #include <NodeBitmask.hpp>
#include <signaldata/DictTabInfo.hpp> #include <signaldata/DictTabInfo.hpp>
...@@ -365,7 +366,7 @@ struct CreateEvntRef { ...@@ -365,7 +366,7 @@ struct CreateEvntRef {
SeizeError = 703, SeizeError = 703,
TooManyEvents = 4707, TooManyEvents = 4707,
EventNameTooLong = 4708, EventNameTooLong = 4708,
EventExists = 4709, EventNameExists = NDBERR_EVENT_NAME_ALEADY_EXISTS,
EventNotFound = 4731, EventNotFound = 4731,
AttributeNotStored = 4245, AttributeNotStored = 4245,
AttributeNullable = 4246, AttributeNullable = 4246,
......
...@@ -199,6 +199,13 @@ public: ...@@ -199,6 +199,13 @@ public:
*/ */
Uint32 getLatestGCI(); Uint32 getLatestGCI();
/**
* Get the latest error
*
* @return Error object.
*/
const struct NdbError & getNdbError() const;
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
/* /*
* *
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#ifndef NDBERROR_H #ifndef NDBERROR_H
#define NDBERROR_H #define NDBERROR_H
#define NDBERR_EVENT_NAME_ALEADY_EXISTS 746
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
......
...@@ -7849,7 +7849,7 @@ void Dbdict::createEventUTIL_EXECUTE(Signal *signal, ...@@ -7849,7 +7849,7 @@ void Dbdict::createEventUTIL_EXECUTE(Signal *signal,
break; break;
case ZALREADYEXIST: case ZALREADYEXIST:
jam(); jam();
evntRecPtr.p->m_errorCode = CreateEvntRef::EventExists; evntRecPtr.p->m_errorCode = CreateEvntRef::EventNameExists;
break; break;
default: default:
jam(); jam();
......
...@@ -15,23 +15,9 @@ ...@@ -15,23 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*****************************************************************************
* Name: NdbEventOperation.cpp
* Include:
* Link:
* Author: Tomas Ulin MySQL AB
* Date: 2003-11-21
* Version: 0.1
* Description: Event support
* Documentation:
* Adjust: 2003-11-21 Tomas Ulin First version.
****************************************************************************/
#include <Ndb.hpp> #include <Ndb.hpp>
#include <signaldata/SumaImpl.hpp> #include <NdbError.hpp>
#include <portlib/NdbMem.h> #include <portlib/NdbMem.h>
#include <transporter/TransporterDefinitions.hpp>
#include <NdbEventOperation.hpp>
#include "NdbEventOperationImpl.hpp" #include "NdbEventOperationImpl.hpp"
#include "NdbDictionaryImpl.hpp" #include "NdbDictionaryImpl.hpp"
...@@ -123,3 +109,7 @@ NdbEventOperation::wait(void *p, int aMillisecondNumber) ...@@ -123,3 +109,7 @@ NdbEventOperation::wait(void *p, int aMillisecondNumber)
NdbEventOperation::NdbEventOperation(NdbEventOperationImpl& impl) NdbEventOperation::NdbEventOperation(NdbEventOperationImpl& impl)
: m_impl(impl) {} : m_impl(impl) {}
const struct NdbError &
NdbEventOperation::getNdbError() const {
return m_impl.getNdbError();
}
...@@ -223,13 +223,17 @@ NdbEventOperationImpl::execute() ...@@ -223,13 +223,17 @@ NdbEventOperationImpl::execute()
int hasSubscriber; int hasSubscriber;
m_bufferId = int r=
m_bufferHandle->prepareAddSubscribeEvent(m_eventImpl->m_eventId, m_bufferHandle->prepareAddSubscribeEvent(m_eventImpl->m_eventId,
hasSubscriber /* return value */); hasSubscriber /* return value */);
m_error.code= 4709;
m_eventImpl->m_bufferId = m_bufferId; if (r < 0)
return -1;
int r = -1; m_eventImpl->m_bufferId = m_bufferId = (Uint32)r;
r = -1;
if (m_bufferId >= 0) { if (m_bufferId >= 0) {
// now we check if there's already a subscriber // now we check if there's already a subscriber
...@@ -363,11 +367,11 @@ NdbEventOperationImpl::next(int *pOverrun) ...@@ -363,11 +367,11 @@ NdbEventOperationImpl::next(int *pOverrun)
#ifdef EVENT_DEBUG #ifdef EVENT_DEBUG
printf("after values sz=%u\n", ptr[1].sz); printf("after values sz=%u\n", ptr[1].sz);
for(int i=0; i < ptr[1].sz; i++) for(int i=0; i < (int)ptr[1].sz; i++)
printf ("H'%.8X ",ptr[1].p[i]); printf ("H'%.8X ",ptr[1].p[i]);
printf("\n"); printf("\n");
printf("before values sz=%u\n", ptr[2].sz); printf("before values sz=%u\n", ptr[2].sz);
for(int i=0; i < ptr[2].sz; i++) for(int i=0; i < (int)ptr[2].sz; i++)
printf ("H'%.8X ",ptr[2].p[i]); printf ("H'%.8X ",ptr[2].p[i]);
printf("\n"); printf("\n");
#endif #endif
...@@ -871,6 +875,7 @@ int ...@@ -871,6 +875,7 @@ int
NdbGlobalEventBuffer::real_prepareAddSubscribeEvent NdbGlobalEventBuffer::real_prepareAddSubscribeEvent
(NdbGlobalEventBufferHandle *aHandle, Uint32 eventId, int& hasSubscriber) (NdbGlobalEventBufferHandle *aHandle, Uint32 eventId, int& hasSubscriber)
{ {
DBUG_ENTER("NdbGlobalEventBuffer::real_prepareAddSubscribeEvent");
int i; int i;
int bufferId = -1; int bufferId = -1;
...@@ -900,7 +905,10 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent ...@@ -900,7 +905,10 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent
} else { } else {
ndbout_c("prepareAddSubscribeEvent: Can't accept more subscribers"); ndbout_c("prepareAddSubscribeEvent: Can't accept more subscribers");
// add_drop_unlock(); // add_drop_unlock();
return -1; DBUG_PRINT("error",("Can't accept more subscribers:"
" bufferId=%d, m_no=%d, m_max=%d",
bufferId, m_no, m_max));
DBUG_RETURN(-1);
} }
} }
...@@ -976,7 +984,7 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent ...@@ -976,7 +984,7 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent
/* we now have a lock on the prepare so that no one can mess with this /* we now have a lock on the prepare so that no one can mess with this
* unlock comes in unprepareAddSubscribeEvent or addSubscribeEvent * unlock comes in unprepareAddSubscribeEvent or addSubscribeEvent
*/ */
return bufferId; DBUG_RETURN(bufferId);
} }
void void
......
...@@ -14,21 +14,13 @@ ...@@ -14,21 +14,13 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/*****************************************************************************
* Name: NdbEventOperationImpl.hpp
* Include:
* Link:
* Author: Tomas Ulin MySQL AB
* Date: 2003-11-21
* Version: 0.1
* Description: Event support
* Documentation:
* Adjust: 2003-11-21 Tomas Ulin First version.
****************************************************************************/
#ifndef NdbEventOperationImpl_H #ifndef NdbEventOperationImpl_H
#define NdbEventOperationImpl_H #define NdbEventOperationImpl_H
#include <NdbEventOperation.hpp>
#include <signaldata/SumaImpl.hpp>
#include <transporter/TransporterDefinitions.hpp>
class NdbGlobalEventBufferHandle; class NdbGlobalEventBufferHandle;
class NdbEventOperationImpl : public NdbEventOperation { class NdbEventOperationImpl : public NdbEventOperation {
public: public:
...@@ -61,6 +53,9 @@ public: ...@@ -61,6 +53,9 @@ public:
void print(); void print();
void printAll(); void printAll();
const NdbError & getNdbError() const;
NdbError m_error;
Ndb *m_ndb; Ndb *m_ndb;
NdbEventImpl *m_eventImpl; NdbEventImpl *m_eventImpl;
NdbGlobalEventBufferHandle *m_bufferHandle; NdbGlobalEventBufferHandle *m_bufferHandle;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <NdbOperation.hpp> #include <NdbOperation.hpp>
#include <NdbTransaction.hpp> #include <NdbTransaction.hpp>
#include <NdbBlob.hpp> #include <NdbBlob.hpp>
#include "NdbEventOperationImpl.hpp"
static void static void
update(const NdbError & _err){ update(const NdbError & _err){
...@@ -73,3 +73,10 @@ NdbBlob::getNdbError() const { ...@@ -73,3 +73,10 @@ NdbBlob::getNdbError() const {
update(theError); update(theError);
return theError; return theError;
} }
const
NdbError &
NdbEventOperationImpl::getNdbError() const {
update(m_error);
return m_error;
}
...@@ -303,7 +303,8 @@ ErrorBundle ErrorCodes[] = { ...@@ -303,7 +303,8 @@ ErrorBundle ErrorCodes[] = {
{ 4707, AE, "Too many event have been defined"}, { 4707, AE, "Too many event have been defined"},
{ 4708, AE, "Event name is too long"}, { 4708, AE, "Event name is too long"},
{ 4709, AE, "Event already exists"}, { 4709, AE, "Can't accept more subscribers"},
{ NDBERR_EVENT_NAME_ALEADY_EXISTS, AE, "Event name already exists"},
{ 4710, AE, "Event not found"}, { 4710, AE, "Event not found"},
{ 4711, AE, "Creation of event failed"}, { 4711, AE, "Creation of event failed"},
......
...@@ -32,6 +32,46 @@ int runCreateEvent(NDBT_Context* ctx, NDBT_Step* step) ...@@ -32,6 +32,46 @@ int runCreateEvent(NDBT_Context* ctx, NDBT_Step* step)
return NDBT_OK; return NDBT_OK;
} }
int runCreateDropEventOperation(NDBT_Context* ctx, NDBT_Step* step)
{
int loops = ctx->getNumLoops();
int records = ctx->getNumRecords();
HugoTransactions hugoTrans(*ctx->getTab());
EventOperationStats stats;
Ndb *pNdb=GETNDB(step);
const NdbDictionary::Table& tab= *ctx->getTab();
NdbEventOperation *pOp;
char eventName[1024];
sprintf(eventName,"%s_EVENT",tab.getName());
int noEventColumnName = tab.getNoOfColumns();
for (int i= 0; i < loops; i++)
{
#if 1
if (hugoTrans.eventOperation(GETNDB(step), (void*)&stats, 0) != 0){
return NDBT_FAILED;
}
#else
g_info << "create EventOperation\n";
pOp = pNdb->createEventOperation(eventName, 100);
if ( pOp == NULL ) {
g_err << "Event operation creation failed\n";
return NDBT_FAILED;
}
g_info << "dropping event operation" << endl;
int res = pNdb->dropEventOperation(pOp);
if (res != 0) {
g_err << "operation execution failed\n";
return NDBT_FAILED;
}
#endif
}
return NDBT_OK;
}
int theThreadIdCounter = 0; int theThreadIdCounter = 0;
int runEventOperation(NDBT_Context* ctx, NDBT_Step* step) int runEventOperation(NDBT_Context* ctx, NDBT_Step* step)
...@@ -122,6 +162,13 @@ TESTCASE("BasicEventOperation", ...@@ -122,6 +162,13 @@ TESTCASE("BasicEventOperation",
STEP(runEventLoad); STEP(runEventLoad);
FINALIZER(runDropEvent); FINALIZER(runDropEvent);
} }
TESTCASE("CreateDropEventOperation",
"Verify that we can Create and Drop many times"
"NOTE! No errors are allowed!" ){
INITIALIZER(runCreateEvent);
STEP(runCreateDropEventOperation);
FINALIZER(runDropEvent);
}
NDBT_TESTSUITE_END(test_event); NDBT_TESTSUITE_END(test_event);
#if 0 #if 0
......
...@@ -826,6 +826,7 @@ struct receivedEvent { ...@@ -826,6 +826,7 @@ struct receivedEvent {
}; };
int XXXXX = 0; int XXXXX = 0;
int int
HugoTransactions::eventOperation(Ndb* pNdb, void* pstats, HugoTransactions::eventOperation(Ndb* pNdb, void* pstats,
int records) { int records) {
...@@ -896,7 +897,9 @@ HugoTransactions::eventOperation(Ndb* pNdb, void* pstats, ...@@ -896,7 +897,9 @@ HugoTransactions::eventOperation(Ndb* pNdb, void* pstats,
// set up the callbacks // set up the callbacks
g_info << function << "execute\n"; g_info << function << "execute\n";
if (pOp->execute()) { // This starts changes to "start flowing" if (pOp->execute()) { // This starts changes to "start flowing"
g_err << function << "operation execution failed\n"; g_err << function << "operation execution failed: \n";
g_err << pOp->getNdbError().code << " "
<< pOp->getNdbError().message << endl;
return NDBT_FAILED; return NDBT_FAILED;
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include <ndb_global.h> #include <ndb_global.h>
#include <my_pthread.h>
#include "NDBT.hpp" #include "NDBT.hpp"
#include "NDBT_Test.hpp" #include "NDBT_Test.hpp"
...@@ -476,7 +477,9 @@ extern "C" ...@@ -476,7 +477,9 @@ extern "C"
void * void *
runStep_C(void * s) runStep_C(void * s)
{ {
my_thread_init();
runStep(s); runStep(s);
my_thread_end();
NdbThread_Exit(0); NdbThread_Exit(0);
return NULL; return NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment