Loading ndb/examples/ndbapi_event_example/ndbapi_event.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -70,12 +70,13 @@ * mysql> use TEST_DB; * mysql> create table TAB0 (COL0 int primary key, COL1 int, COL11 int) engine=ndb; * * In another window start ndbapi_example5, wait until properly started * In another window start ndbapi_event, wait until properly started * * mysql> insert into TAB0 values (1,2,3); * mysql> insert into TAB0 values (2,2,3); * mysql> insert into TAB0 values (3,2,9); * mysql> insert into TAB0 values (1,2,3); insert into TAB0 values (2,2,3); insert into TAB0 values (3,2,9); update TAB0 set COL1=10 where COL0=1; delete from TAB0 where COL0=1; * * you should see the data popping up in the example window * Loading ndb/include/kernel/trigger_definitions.h +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ struct TriggerActionTime { }; struct TriggerEvent { /** TableEvent must match 1 << TriggerEvent */ enum Value { TE_INSERT = 0, TE_DELETE = 1, Loading ndb/include/ndbapi/NdbDictionary.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -915,6 +915,9 @@ public: /** * Specifies the type of database operations an Event listens to */ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** TableEvent must match 1 << TriggerEvent */ #endif enum TableEvent { TE_INSERT=1, ///< Insert event on table TE_DELETE=2, ///< Delete event on table Loading ndb/src/ndbapi/NdbEventOperationImpl.cpp +20 −8 Original line number Diff line number Diff line Loading @@ -224,8 +224,7 @@ NdbEventOperationImpl::execute() int hasSubscriber; int r= m_bufferHandle->prepareAddSubscribeEvent(m_eventImpl->m_eventId, int r= m_bufferHandle->prepareAddSubscribeEvent(this, hasSubscriber /*return value*/); m_error.code= 4709; Loading Loading @@ -697,10 +696,11 @@ NdbGlobalEventBufferHandle::drop(NdbGlobalEventBufferHandle *handle) } */ int NdbGlobalEventBufferHandle::prepareAddSubscribeEvent(Uint32 eventId, int& hasSubscriber) NdbGlobalEventBufferHandle::prepareAddSubscribeEvent (NdbEventOperationImpl *eventOp, int& hasSubscriber) { ADD_DROP_LOCK_GUARDR(int,real_prepareAddSubscribeEvent(this, eventId, hasSubscriber)); ADD_DROP_LOCK_GUARDR(int,real_prepareAddSubscribeEvent(this, eventOp, hasSubscriber)); } void NdbGlobalEventBufferHandle::addSubscribeEvent Loading Loading @@ -893,11 +893,13 @@ NdbGlobalEventBuffer::real_remove(NdbGlobalEventBufferHandle *h) int NdbGlobalEventBuffer::real_prepareAddSubscribeEvent (NdbGlobalEventBufferHandle *aHandle, Uint32 eventId, int& hasSubscriber) (NdbGlobalEventBufferHandle *aHandle, NdbEventOperationImpl *eventOp, int& hasSubscriber) { DBUG_ENTER("NdbGlobalEventBuffer::real_prepareAddSubscribeEvent"); int i; int bufferId= -1; Uint32 eventId= eventOp->m_eventId; // add_drop_lock(); // only one thread can do add or drop at a time Loading Loading @@ -939,6 +941,7 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent bufferId= NO_ID(0, bufferId); b.gId= eventId; b.eventType= (Uint32)eventOp->m_eventImpl->mi_type; if ((b.p_buf_mutex= NdbMutex_Create()) == NULL) { ndbout_c("NdbGlobalEventBuffer: NdbMutex_Create() failed"); Loading Loading @@ -1137,6 +1140,8 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, #ifdef EVENT_DEBUG int n = NO(bufferId); #endif if ( b.eventType & (1 << (Uint32)sdata->operation) ) { if (b.subs) { #ifdef EVENT_DEBUG Loading Loading @@ -1175,6 +1180,13 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, #endif } } else { #ifdef EVENT_DEBUG ndbout_c("skipped"); #endif } DBUG_RETURN(0); } Loading ndb/src/ndbapi/NdbEventOperationImpl.hpp +4 −2 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public: //static NdbGlobalEventBufferHandle *init(int MAX_NUMBER_ACTIVE_EVENTS); // returns bufferId 0-N if ok otherwise -1 int prepareAddSubscribeEvent(Uint32 eventId, int& hasSubscriber); int prepareAddSubscribeEvent(NdbEventOperationImpl *, int& hasSubscriber); void unprepareAddSubscribeEvent(int bufferId); void addSubscribeEvent(int bufferId, NdbEventOperationImpl *ndbEventOperationImpl); Loading Loading @@ -133,7 +133,8 @@ private: int MAX_NUMBER_ACTIVE_EVENTS); int real_prepareAddSubscribeEvent(NdbGlobalEventBufferHandle *h, Uint32 eventId, int& hasSubscriber); NdbEventOperationImpl *, int& hasSubscriber); void real_unprepareAddSubscribeEvent(int bufferId); void real_addSubscribeEvent(int bufferId, void *ndbEventOperation); Loading Loading @@ -177,6 +178,7 @@ private: // local mutex for each event/buffer NdbMutex *p_buf_mutex; Uint32 gId; Uint32 eventType; struct Data { SubTableData *sdata; LinearSectionPtr ptr[3]; Loading Loading
ndb/examples/ndbapi_event_example/ndbapi_event.cpp +6 −5 Original line number Diff line number Diff line Loading @@ -70,12 +70,13 @@ * mysql> use TEST_DB; * mysql> create table TAB0 (COL0 int primary key, COL1 int, COL11 int) engine=ndb; * * In another window start ndbapi_example5, wait until properly started * In another window start ndbapi_event, wait until properly started * * mysql> insert into TAB0 values (1,2,3); * mysql> insert into TAB0 values (2,2,3); * mysql> insert into TAB0 values (3,2,9); * mysql> insert into TAB0 values (1,2,3); insert into TAB0 values (2,2,3); insert into TAB0 values (3,2,9); update TAB0 set COL1=10 where COL0=1; delete from TAB0 where COL0=1; * * you should see the data popping up in the example window * Loading
ndb/include/kernel/trigger_definitions.h +1 −0 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ struct TriggerActionTime { }; struct TriggerEvent { /** TableEvent must match 1 << TriggerEvent */ enum Value { TE_INSERT = 0, TE_DELETE = 1, Loading
ndb/include/ndbapi/NdbDictionary.hpp +3 −0 Original line number Diff line number Diff line Loading @@ -915,6 +915,9 @@ public: /** * Specifies the type of database operations an Event listens to */ #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL /** TableEvent must match 1 << TriggerEvent */ #endif enum TableEvent { TE_INSERT=1, ///< Insert event on table TE_DELETE=2, ///< Delete event on table Loading
ndb/src/ndbapi/NdbEventOperationImpl.cpp +20 −8 Original line number Diff line number Diff line Loading @@ -224,8 +224,7 @@ NdbEventOperationImpl::execute() int hasSubscriber; int r= m_bufferHandle->prepareAddSubscribeEvent(m_eventImpl->m_eventId, int r= m_bufferHandle->prepareAddSubscribeEvent(this, hasSubscriber /*return value*/); m_error.code= 4709; Loading Loading @@ -697,10 +696,11 @@ NdbGlobalEventBufferHandle::drop(NdbGlobalEventBufferHandle *handle) } */ int NdbGlobalEventBufferHandle::prepareAddSubscribeEvent(Uint32 eventId, int& hasSubscriber) NdbGlobalEventBufferHandle::prepareAddSubscribeEvent (NdbEventOperationImpl *eventOp, int& hasSubscriber) { ADD_DROP_LOCK_GUARDR(int,real_prepareAddSubscribeEvent(this, eventId, hasSubscriber)); ADD_DROP_LOCK_GUARDR(int,real_prepareAddSubscribeEvent(this, eventOp, hasSubscriber)); } void NdbGlobalEventBufferHandle::addSubscribeEvent Loading Loading @@ -893,11 +893,13 @@ NdbGlobalEventBuffer::real_remove(NdbGlobalEventBufferHandle *h) int NdbGlobalEventBuffer::real_prepareAddSubscribeEvent (NdbGlobalEventBufferHandle *aHandle, Uint32 eventId, int& hasSubscriber) (NdbGlobalEventBufferHandle *aHandle, NdbEventOperationImpl *eventOp, int& hasSubscriber) { DBUG_ENTER("NdbGlobalEventBuffer::real_prepareAddSubscribeEvent"); int i; int bufferId= -1; Uint32 eventId= eventOp->m_eventId; // add_drop_lock(); // only one thread can do add or drop at a time Loading Loading @@ -939,6 +941,7 @@ NdbGlobalEventBuffer::real_prepareAddSubscribeEvent bufferId= NO_ID(0, bufferId); b.gId= eventId; b.eventType= (Uint32)eventOp->m_eventImpl->mi_type; if ((b.p_buf_mutex= NdbMutex_Create()) == NULL) { ndbout_c("NdbGlobalEventBuffer: NdbMutex_Create() failed"); Loading Loading @@ -1137,6 +1140,8 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, #ifdef EVENT_DEBUG int n = NO(bufferId); #endif if ( b.eventType & (1 << (Uint32)sdata->operation) ) { if (b.subs) { #ifdef EVENT_DEBUG Loading Loading @@ -1175,6 +1180,13 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId, #endif } } else { #ifdef EVENT_DEBUG ndbout_c("skipped"); #endif } DBUG_RETURN(0); } Loading
ndb/src/ndbapi/NdbEventOperationImpl.hpp +4 −2 Original line number Diff line number Diff line Loading @@ -79,7 +79,7 @@ public: //static NdbGlobalEventBufferHandle *init(int MAX_NUMBER_ACTIVE_EVENTS); // returns bufferId 0-N if ok otherwise -1 int prepareAddSubscribeEvent(Uint32 eventId, int& hasSubscriber); int prepareAddSubscribeEvent(NdbEventOperationImpl *, int& hasSubscriber); void unprepareAddSubscribeEvent(int bufferId); void addSubscribeEvent(int bufferId, NdbEventOperationImpl *ndbEventOperationImpl); Loading Loading @@ -133,7 +133,8 @@ private: int MAX_NUMBER_ACTIVE_EVENTS); int real_prepareAddSubscribeEvent(NdbGlobalEventBufferHandle *h, Uint32 eventId, int& hasSubscriber); NdbEventOperationImpl *, int& hasSubscriber); void real_unprepareAddSubscribeEvent(int bufferId); void real_addSubscribeEvent(int bufferId, void *ndbEventOperation); Loading Loading @@ -177,6 +178,7 @@ private: // local mutex for each event/buffer NdbMutex *p_buf_mutex; Uint32 gId; Uint32 eventType; struct Data { SubTableData *sdata; LinearSectionPtr ptr[3]; Loading