Commit e1e34b51 authored by unknown's avatar unknown

Bug#7626

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