Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
45738d53
Commit
45738d53
authored
Jan 05, 2005
by
tomas@poseidon.ndb.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ndbapi event code cleanup
+ some more docs on event
parent
fa5127e2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
39 deletions
+90
-39
ndb/examples/ndbapi_event_example/ndbapi_event.cpp
ndb/examples/ndbapi_event_example/ndbapi_event.cpp
+22
-25
ndb/include/kernel/signaldata/CreateEvnt.hpp
ndb/include/kernel/signaldata/CreateEvnt.hpp
+6
-7
ndb/include/ndbapi/NdbDictionary.hpp
ndb/include/ndbapi/NdbDictionary.hpp
+43
-4
ndb/src/ndbapi/NdbDictionaryImpl.cpp
ndb/src/ndbapi/NdbDictionaryImpl.cpp
+2
-3
ndb/src/ndbapi/ndberror.c
ndb/src/ndbapi/ndberror.c
+17
-0
No files found.
ndb/examples/ndbapi_event_example/ndbapi_event.cpp
View file @
45738d53
...
...
@@ -36,7 +36,7 @@
*
* NdbDictionary::Event
* setTable()
* add
t
ableEvent()
* add
T
ableEvent()
* addEventColumn()
*
* NdbEventOperation
...
...
@@ -63,12 +63,12 @@
* another process (e.g. flexBench -l 0 -stdtables).
* We want to monitor what happens with columns COL0, COL2, COL11
*
* or together with the mysql
cluster
client;
* or together with the mysql client;
*
* shell> mysql
cluster
-u root
* shell> mysql -u root
* mysql> create database TEST_DB;
* mysql> use TEST_DB;
* mysql> create table TAB0 (COL0 int primary key, COL1 int, COL11 int);
* mysql> create table TAB0 (COL0 int primary key, COL1 int, COL11 int)
engine=ndb
;
*
* In another window start ndbapi_example5, wait until properly started
*
...
...
@@ -199,7 +199,7 @@ int main()
printf
(
"NULL"
);
}
if
(
recAttrPre
[
i
]
->
isNULL
()
>=
0
)
{
// we have a value
printf
(
" p
ost
[%u]="
,
i
);
printf
(
" p
re
[%u]="
,
i
);
if
(
recAttrPre
[
i
]
->
isNULL
()
==
0
)
// we have a non-null value
printf
(
"%u"
,
recAttrPre
[
i
]
->
u_32_value
());
else
// we have a null value
...
...
@@ -212,7 +212,7 @@ int main()
;
//printf("timed out\n");
}
// don't want to listen to events anymore
myNdb
->
dropEventOperation
(
op
);
if
(
myNdb
->
dropEventOperation
(
op
))
APIERROR
(
myNdb
->
getNdbError
()
);
j
++
;
}
...
...
@@ -220,7 +220,8 @@ int main()
{
NdbDictionary
::
Dictionary
*
myDict
=
myNdb
->
getDictionary
();
if
(
!
myDict
)
APIERROR
(
myNdb
->
getNdbError
());
myDict
->
dropEvent
(
eventName
);
// remove event from database
// remove event from database
if
(
myDict
->
dropEvent
(
eventName
))
APIERROR
(
myDict
->
getNdbError
());
}
delete
myNdb
;
...
...
@@ -232,8 +233,8 @@ int main()
int
myCreateEvent
(
Ndb
*
myNdb
,
const
char
*
eventName
,
const
char
*
eventTableName
,
const
char
**
eventColumnName
,
const
int
noEventColumnName
)
const
char
**
eventColumnName
s
,
const
int
noEventColumnName
s
)
{
NdbDictionary
::
Dictionary
*
myDict
=
myNdb
->
getDictionary
();
if
(
!
myDict
)
APIERROR
(
myNdb
->
getNdbError
());
...
...
@@ -245,24 +246,20 @@ int myCreateEvent(Ndb* myNdb,
// myEvent.addTableEvent(NdbDictionary::Event::TE_UPDATE);
// myEvent.addTableEvent(NdbDictionary::Event::TE_DELETE);
for
(
int
i
=
0
;
i
<
noEventColumnName
;
i
++
)
myEvent
.
addEventColumn
(
eventColumnName
[
i
]);
myEvent
.
addEventColumns
(
noEventColumnNames
,
eventColumnNames
);
int
res
=
myDict
->
createEvent
(
myEvent
);
// Add event to database
if
(
res
==
0
)
// Add event to database
if
(
myDict
->
createEvent
(
myEvent
)
==
0
)
myEvent
.
print
();
else
{
printf
(
"Event creation failed
\n
"
);
printf
(
"trying drop Event, maybe event exists
\n
"
);
res
=
myDict
->
dropEvent
(
eventName
);
if
(
res
)
exit
(
-
1
);
else
if
(
myDict
->
getNdbError
().
code
==
4709
)
{
printf
(
"Event creation failed, event exists
\n
"
);
printf
(
"dropping Event...
\n
"
);
if
(
myDict
->
dropEvent
(
eventName
))
APIERROR
(
myDict
->
getNdbError
());
// try again
res
=
myDict
->
createEvent
(
myEvent
);
// Add event to database
if
(
res
)
exit
(
-
1
);
}
// Add event to database
if
(
myDict
->
createEvent
(
myEvent
))
APIERROR
(
myDict
->
getNdbError
());
}
else
APIERROR
(
myDict
->
getNdbError
());
return
res
;
return
0
;
}
ndb/include/kernel/signaldata/CreateEvnt.hpp
View file @
45738d53
...
...
@@ -101,7 +101,7 @@ public:
Busy
=
701
,
NotMaster
=
702
,
SeizeError
=
703
,
EventNotFound
=
4
238
,
EventNotFound
=
4
710
,
EventNameTooLong
=
4241
,
TooManyEvents
=
4242
,
BadRequestType
=
4247
,
...
...
@@ -363,11 +363,10 @@ struct CreateEvntRef {
Busy
=
701
,
NotMaster
=
702
,
SeizeError
=
703
,
EventNotFound
=
4238
,
EventExists
=
4239
,
EventNameTooLong
=
4241
,
TooManyEvents
=
4242
,
// EventExists = 4244,
TooManyEvents
=
4707
,
EventNameTooLong
=
4708
,
EventExists
=
4709
,
EventNotFound
=
4731
,
AttributeNotStored
=
4245
,
AttributeNullable
=
4246
,
BadRequestType
=
4247
,
...
...
@@ -376,7 +375,7 @@ struct CreateEvntRef {
InvalidEventType
=
4250
,
NotUnique
=
4251
,
AllocationError
=
4252
,
CreateEventTableFailed
=
4
253
,
CreateEventTableFailed
=
4
711
,
InvalidAttributeOrder
=
4255
,
Temporary
=
0x1
<<
16
};
...
...
ndb/include/ndbapi/NdbDictionary.hpp
View file @
45738d53
...
...
@@ -931,13 +931,50 @@ public:
Event
(
const
char
*
name
);
virtual
~
Event
();
void
setName
(
const
char
*
);
void
setTable
(
const
char
*
);
void
addTableEvent
(
const
TableEvent
);
void
setDurability
(
const
EventDurability
);
/**
* Set unique identifier for the event
*/
void
setName
(
const
char
*
name
);
/**
* Set table for which events should be detected
*/
void
setTable
(
const
char
*
tableName
);
/**
* Add type of event that should be detected
*/
void
addTableEvent
(
const
TableEvent
te
);
/**
* Set durability of the event
*/
void
setDurability
(
const
EventDurability
ed
);
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
void
addColumn
(
const
Column
&
c
);
#endif
/**
* Add a column on which events should be detected
*
* @param attrId Column id
*
* @note errors will mot be detected until createEvent() is called
*/
void
addEventColumn
(
unsigned
attrId
);
/**
* Add a column on which events should be detected
*
* @param columnName Column name
*
* @note errors will mot be detected until createEvent() is called
*/
void
addEventColumn
(
const
char
*
columnName
);
/**
* Add several columns on which events should be detected
*
* @param n Number of columns
* @param columnNames Column names
*
* @note errors will mot be detected until
* NdbDictionary::Dictionary::createEvent() is called
*/
void
addEventColumns
(
int
n
,
const
char
**
columnNames
);
/**
...
...
@@ -950,7 +987,9 @@ public:
*/
virtual
int
getObjectVersion
()
const
;
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
void
print
();
#endif
private:
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
...
...
ndb/src/ndbapi/NdbDictionaryImpl.cpp
View file @
45738d53
...
...
@@ -2236,10 +2236,9 @@ NdbDictionaryImpl::createEvent(NdbEventImpl & evnt)
NdbTableImpl
*
tab
=
getTable
(
evnt
.
getTable
());
if
(
tab
==
0
){
// m_error.code = 3249;
ndbout_c
(
":createEvent: table %s not found"
,
evnt
.
getTable
());
#ifdef EVENT_DEBUG
ndbout_c
(
"NdbDictionaryImpl::createEvent: table not found: %s"
,
evnt
.
getTable
());
ndbout_c
(
"NdbDictionaryImpl::createEvent: table not found: %s"
,
evnt
.
getTable
());
#endif
return
-
1
;
}
...
...
ndb/src/ndbapi/ndberror.c
View file @
45738d53
...
...
@@ -79,6 +79,7 @@ static const char* empty_string = "";
* 4400 - ""
* 4500 - ""
* 4600 - ""
* 4700 - "" Event
* 5000 - Management server
*/
...
...
@@ -296,6 +297,22 @@ ErrorBundle ErrorCodes[] = {
{
4232
,
AE
,
"Parallelism can only be between 1 and 240"
},
{
290
,
AE
,
"Scan not started or has been closed by kernel due to timeout"
},
/**
* Event application errors
*/
{
4707
,
AE
,
"Too many event have been defined"
},
{
4708
,
AE
,
"Event name is too long"
},
{
4709
,
AE
,
"Event already exists"
},
{
4710
,
AE
,
"Event not found"
},
{
4711
,
AE
,
"Creation of event failed"
},
/**
* Event internal errors
*/
{
4731
,
IE
,
"Event not found"
},
/**
* SchemaError
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment