Commit e1e34b51 authored by unknown's avatar unknown

Bug#7626

parent 0928b660
......@@ -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
*
......
......@@ -56,6 +56,7 @@ struct TriggerActionTime {
};
struct TriggerEvent {
/** TableEvent must match 1 << TriggerEvent */
enum Value {
TE_INSERT = 0,
TE_DELETE = 1,
......
......@@ -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
......
......@@ -224,9 +224,8 @@ NdbEventOperationImpl::execute()
int hasSubscriber;
int r=
m_bufferHandle->prepareAddSubscribeEvent(m_eventImpl->m_eventId,
hasSubscriber /* return value */);
int r= m_bufferHandle->prepareAddSubscribeEvent(this,
hasSubscriber /*return value*/);
m_error.code= 4709;
if (r < 0)
......@@ -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
......@@ -891,13 +891,15 @@ NdbGlobalEventBuffer::real_remove(NdbGlobalEventBufferHandle *h)
exit(-1);
}
int
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
......@@ -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");
......@@ -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
......@@ -1175,6 +1180,13 @@ NdbGlobalEventBuffer::real_insertDataL(int bufferId,
#endif
}
}
else
{
#ifdef EVENT_DEBUG
ndbout_c("skipped");
#endif
}
DBUG_RETURN(0);
}
......
......@@ -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);
......@@ -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);
......@@ -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];
......
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