59 #include <my_global.h>
107 #define APIERROR(error) \
108 { std::cout << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
109 << error.code << ", msg: " << error.message << "." << std::endl; \
112 int myCreateEvent(
Ndb* myNdb,
113 const char *eventName,
114 const char *eventTableName,
115 const char **eventColumnName,
116 const int noEventColumnName,
119 int main(
int argc,
char** argv)
123 std::cout <<
"Arguments are <connect_string cluster> <timeout> [m(merge events)|d(debug)].\n";
126 const char *connectstring = argv[1];
127 int timeout = atoi(argv[2]);
129 bool merge_events = argc > 3 && strchr(argv[3],
'm') != 0;
131 bool dbug = argc > 3 && strchr(argv[3],
'd') != 0;
132 if (dbug) DBUG_PUSH(
"d:t:");
133 if (dbug) putenv(
"API_SIGNAL_LOG=-");
139 int r= cluster_connection->
connect(5 ,
145 <<
"Cluster connect failed, possibly resolved with more retries.\n";
151 <<
"Cluster connect failed.\n";
157 std::cout <<
"Cluster was not ready within 30 secs." << std::endl;
161 Ndb* myNdb=
new Ndb(cluster_connection,
166 const char *eventName=
"CHNG_IN_t0";
167 const char *eventTableName=
"t0";
168 const int noEventColumnName= 5;
169 const char *eventColumnName[noEventColumnName]=
190 while (j < timeout) {
194 printf(
"create EventOperation\n");
199 printf(
"get values\n");
200 RA_BH recAttr[noEventColumnName];
201 RA_BH recAttrPre[noEventColumnName];
203 for (i = 0; i < noEventColumnName; i++) {
205 recAttr[
i].ra = op->
getValue(eventColumnName[i]);
207 }
else if (merge_events) {
209 recAttrPre[
i].bh = op->getPreBlobHandle(eventColumnName[i]);
222 while (i < timeout) {
228 assert(the_op == op);
232 printf(
"%u INSERT", i);
235 printf(
"%u DELETE", i);
238 printf(
"%u UPDATE", i);
243 printf(
" gci=%d\n", (
int)op->
getGCI());
244 for (k = 0; k <= 1; k++) {
245 printf(k == 0 ?
"post: " :
"pre : ");
246 for (l = 0; l < noEventColumnName; l++) {
248 NdbRecAttr* ra = k == 0 ? recAttr[l].ra : recAttrPre[l].ra;
254 printf(
"%-5.4s", ra->
aRef());
256 printf(
"%-5s",
"NULL");
259 }
else if (merge_events) {
261 NdbBlob* bh = k == 0 ? recAttr[l].bh : recAttrPre[l].bh;
262 bh->getDefined(isNull);
268 unsigned char*
buf =
new unsigned char [length];
269 memset(buf,
'X', length);
277 unsigned char c = buf[i++];
279 while (i < n && buf[i] == c)
283 printf(
"%u%c", m, c);
289 printf(
"%-5s",
"NULL");
314 delete cluster_connection;
319 int myCreateEvent(
Ndb* myNdb,
320 const char *eventName,
321 const char *eventTableName,
322 const char **eventColumnNames,
323 const int noEventColumnNames,
338 myEvent.addEventColumns(noEventColumnNames, eventColumnNames);
339 myEvent.mergeEvents(merge_events);
346 printf(
"Event creation failed, event exists\n");
347 printf(
"dropping Event...\n");