22 #include "user_transaction.h"
26 #include "ndb_schema.hpp"
27 #include "ndb_error.hpp"
47 const SubscriberNumber number,
48 const Location new_location,
49 const ChangedBy changed_by,
50 const ChangedTime changed_time,
51 BenchmarkTime * transaction_time){
55 DEBUG2(
"T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
64 if (MyTransaction == NULL)
65 error_handler(
"T1-1: startTranscation", pNDB->getNdbErrorString(), 0);
68 CHECK_NULL(MyOperation,
"T1: getNdbOperation", MyTransaction);
70 check = MyOperation->updateTuple();
71 CHECK_MINUS_ONE(check,
"T1: updateTuple",
74 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
76 CHECK_MINUS_ONE(check,
"T1: equal subscriber",
79 check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
80 (
char *)&new_location);
81 CHECK_MINUS_ONE(check,
"T1: setValue location",
84 check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
86 CHECK_MINUS_ONE(check,
"T1: setValue changed_by",
89 check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
91 CHECK_MINUS_ONE(check,
"T1: setValue changed_time",
94 check = MyTransaction->
execute( Commit );
95 CHECK_MINUS_ONE(check,
"T1: Commit",
100 get_time(transaction_time);
101 time_diff(transaction_time, &start);
121 const SubscriberNumber number,
122 Location * readLocation,
123 ChangedBy changed_by,
124 ChangedTime changed_time,
125 SubscriberName subscriberName,
126 BenchmarkTime * transaction_time){
130 DEBUG2(
"T2(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
139 if (MyTransaction == NULL)
140 error_handler(
"T2-1: startTranscation", pNDB->getNdbErrorString(), 0);
143 CHECK_NULL(MyOperation,
"T2: getNdbOperation",
147 check = MyOperation->readTuple();
148 CHECK_MINUS_ONE(check,
"T2: readTuple",
151 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
153 CHECK_MINUS_ONE(check,
"T2: equal subscriber",
156 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
157 (
char *)readLocation);
158 CHECK_NULL(check2,
"T2: getValue location",
161 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
163 CHECK_NULL(check2,
"T2: getValue changed_by",
166 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
168 CHECK_NULL(check2,
"T2: getValue changed_time",
171 check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME,
173 CHECK_NULL(check2,
"T2: getValue name",
176 check = MyTransaction->
execute( Commit );
177 CHECK_MINUS_ONE(check,
"T2: Commit",
182 get_time(transaction_time);
183 time_diff(transaction_time, &start);
206 const SubscriberNumber inNumber,
207 const SubscriberSuffix inSuffix,
208 const ServerId inServerId,
209 const ServerBit inServerBit,
210 SessionDetails outSessionDetails,
211 ChangedBy outChangedBy,
212 ChangedTime outChangedTime,
213 Location * outLocation,
214 BranchExecuted * outBranchExecuted,
215 BenchmarkTime * outTransactionTime){
217 DEBUG3(
"T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
222 ActiveSessions sessions;
223 Permission permission;
232 if (MyTransaction == NULL)
233 error_handler(
"T3-1: startTranscation", pNDB->getNdbErrorString(), 0);
236 CHECK_NULL(MyOperation,
"T3-1: getNdbOperation",
239 check = MyOperation->readTuple();
240 CHECK_MINUS_ONE(check,
"T3-1: readTuple",
243 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
245 CHECK_MINUS_ONE(check,
"T3-1: equal subscriber",
248 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
249 (
char *)outLocation);
250 CHECK_NULL(check2,
"T3-1: getValue location",
253 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
255 CHECK_NULL(check2,
"T3-1: getValue changed_by",
258 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
260 CHECK_NULL(check2,
"T3-1: getValue changed_time",
263 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
265 CHECK_NULL(check2,
"T3-1: getValue group",
268 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
270 CHECK_NULL(check2,
"T3-1: getValue sessions",
273 check = MyTransaction->
execute( NoCommit );
274 CHECK_MINUS_ONE(check,
"T3-1: NoCommit",
280 CHECK_NULL(MyOperation,
"T3-2: getNdbOperation",
284 check = MyOperation->readTuple();
285 CHECK_MINUS_ONE(check,
"T3-2: readTuple",
288 check = MyOperation->equal(IND_GROUP_ID,
290 CHECK_MINUS_ONE(check,
"T3-2: equal group",
293 check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ,
294 (
char *)&permission);
295 CHECK_NULL(check2,
"T3-2: getValue allow_read",
298 check = MyTransaction->
execute( NoCommit );
299 CHECK_MINUS_ONE(check,
"T3-2: NoCommit",
302 if(((permission & inServerBit) == inServerBit) &&
303 ((sessions & inServerBit) == inServerBit)){
310 CHECK_NULL(MyOperation,
"T3-3: getNdbOperation",
313 check = MyOperation->readTuple();
314 CHECK_MINUS_ONE(check,
"T3-3: readTuple",
317 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
319 CHECK_MINUS_ONE(check,
"T3-3: equal number",
322 check = MyOperation->equal(IND_SESSION_SERVER,
324 CHECK_MINUS_ONE(check,
"T3-3: equal server id",
327 check2 = MyOperation->getValue(IND_SESSION_DATA,
328 (
char *)outSessionDetails);
329 CHECK_NULL(check2,
"T3-3: getValue session details",
334 CHECK_NULL(MyOperation,
"T3-4: getNdbOperation",
337 check = MyOperation->interpretedUpdateTuple();
338 CHECK_MINUS_ONE(check,
"T3-4: interpretedUpdateTuple",
341 check = MyOperation->equal(IND_SERVER_ID,
343 CHECK_MINUS_ONE(check,
"T3-4: equal serverId",
346 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
348 CHECK_MINUS_ONE(check,
"T3-4: equal suffix",
351 check = MyOperation->incValue(IND_SERVER_READS, (uint32)1);
352 CHECK_MINUS_ONE(check,
"T3-4: inc value",
354 (* outBranchExecuted) = 1;
356 (* outBranchExecuted) = 0;
359 check = MyTransaction->
execute( Commit );
360 CHECK_MINUS_ONE(check,
"T3: Commit",
366 get_time(outTransactionTime);
367 time_diff(outTransactionTime, &start);
391 const SubscriberNumber inNumber,
392 const SubscriberSuffix inSuffix,
393 const ServerId inServerId,
394 const ServerBit inServerBit,
395 const SessionDetails inSessionDetails,
396 ChangedBy outChangedBy,
397 ChangedTime outChangedTime,
398 Location * outLocation,
399 DoRollback inDoRollback,
400 BranchExecuted * outBranchExecuted,
401 BenchmarkTime * outTransactionTime){
403 DEBUG3(
"T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
408 ActiveSessions sessions;
409 Permission permission;
418 if (MyTransaction == NULL)
419 error_handler(
"T4-1: startTranscation", pNDB->getNdbErrorString(), 0);
422 CHECK_NULL(MyOperation,
"T4-1: getNdbOperation",
425 check = MyOperation->interpretedUpdateTuple();
426 CHECK_MINUS_ONE(check,
"T4-1: readTuple",
429 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
431 CHECK_MINUS_ONE(check,
"T4-1: equal subscriber",
434 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
435 (
char *)outLocation);
436 CHECK_NULL(check2,
"T4-1: getValue location",
439 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
441 CHECK_NULL(check2,
"T4-1: getValue changed_by",
444 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
446 CHECK_NULL(check2,
"T4-1: getValue changed_time",
449 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
451 CHECK_NULL(check2,
"T4-1: getValue group",
454 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
456 CHECK_NULL(check2,
"T4-1: getValue sessions",
459 check = MyOperation->incValue(IND_SUBSCRIBER_SESSIONS,
460 (uint32)inServerBit);
461 CHECK_MINUS_ONE(check,
"T4-4: inc value",
464 check = MyTransaction->
execute( NoCommit );
465 CHECK_MINUS_ONE(check,
"T4-1: NoCommit",
471 CHECK_NULL(MyOperation,
"T4-2: getNdbOperation",
474 check = MyOperation->readTuple();
475 CHECK_MINUS_ONE(check,
"T4-2: readTuple",
478 check = MyOperation->equal(IND_GROUP_ID,
480 CHECK_MINUS_ONE(check,
"T4-2: equal group",
483 check2 = MyOperation->getValue(IND_GROUP_ALLOW_INSERT,
484 (
char *)&permission);
485 CHECK_NULL(check2,
"T4-2: getValue allow_insert",
488 check = MyTransaction->
execute( NoCommit );
489 CHECK_MINUS_ONE(check,
"T4-2: NoCommit",
492 if(((permission & inServerBit) == inServerBit) &&
493 ((sessions & inServerBit) == 0)){
495 DEBUG(
"inserting - ");
500 CHECK_NULL(MyOperation,
"T4-3: getNdbOperation",
503 check = MyOperation->insertTuple();
504 CHECK_MINUS_ONE(check,
"T4-3: insertTuple",
507 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
509 CHECK_MINUS_ONE(check,
"T4-3: equal number",
512 check = MyOperation->equal(IND_SESSION_SERVER,
514 CHECK_MINUS_ONE(check,
"T4-3: equal server id",
517 check = MyOperation->setValue(SESSION_DATA,
518 (
char *)inSessionDetails);
519 CHECK_MINUS_ONE(check,
"T4-3: setValue session details",
526 CHECK_NULL(MyOperation,
"T4-5: getNdbOperation",
529 check = MyOperation->interpretedUpdateTuple();
530 CHECK_MINUS_ONE(check,
"T4-5: interpretedUpdateTuple",
533 check = MyOperation->equal(IND_SERVER_ID,
535 CHECK_MINUS_ONE(check,
"T4-5: equal serverId",
538 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
540 CHECK_MINUS_ONE(check,
"T4-5: equal suffix",
543 check = MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1);
544 CHECK_MINUS_ONE(check,
"T4-5: inc value",
547 (* outBranchExecuted) = 1;
549 DEBUG1(
"%s", ((permission & inServerBit) ?
"permission - " :
"no permission - "));
550 DEBUG1(
"%s", ((sessions & inServerBit) ?
"in session - " :
"no in session - "));
551 (* outBranchExecuted) = 0;
554 if(!inDoRollback && (* outBranchExecuted)){
556 check = MyTransaction->
execute( Commit );
557 CHECK_MINUS_ONE(check,
"T4: Commit",
561 check = MyTransaction->
execute(Rollback);
562 CHECK_MINUS_ONE(check,
"T4:Rollback",
569 get_time(outTransactionTime);
570 time_diff(outTransactionTime, &start);
593 const SubscriberNumber inNumber,
594 const SubscriberSuffix inSuffix,
595 const ServerId inServerId,
596 const ServerBit inServerBit,
597 ChangedBy outChangedBy,
598 ChangedTime outChangedTime,
599 Location * outLocation,
600 DoRollback inDoRollback,
601 BranchExecuted * outBranchExecuted,
602 BenchmarkTime * outTransactionTime){
604 DEBUG3(
"T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
611 ActiveSessions sessions;
612 Permission permission;
621 if (MyTransaction == NULL)
622 error_handler(
"T5-1: startTranscation", pNDB->getNdbErrorString(), 0);
625 CHECK_NULL(MyOperation,
"T5-1: getNdbOperation",
628 check = MyOperation->interpretedUpdateTuple();
629 CHECK_MINUS_ONE(check,
"T5-1: readTuple",
632 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
634 CHECK_MINUS_ONE(check,
"T5-1: equal subscriber",
637 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
638 (
char *)outLocation);
639 CHECK_NULL(check2,
"T5-1: getValue location",
642 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
644 CHECK_NULL(check2,
"T5-1: getValue changed_by",
647 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
649 CHECK_NULL(check2,
"T5-1: getValue changed_time",
652 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
654 CHECK_NULL(check2,
"T5-1: getValue group",
657 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
659 CHECK_NULL(check2,
"T5-1: getValue sessions",
662 check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS,
663 (uint32)inServerBit);
664 CHECK_MINUS_ONE(check,
"T5-4: dec value",
667 check = MyTransaction->
execute( NoCommit );
668 CHECK_MINUS_ONE(check,
"T5-1: NoCommit",
674 CHECK_NULL(MyOperation,
"T5-2: getNdbOperation",
678 check = MyOperation->readTuple();
679 CHECK_MINUS_ONE(check,
"T5-2: readTuple",
682 check = MyOperation->equal(IND_GROUP_ID,
684 CHECK_MINUS_ONE(check,
"T5-2: equal group",
687 check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE,
688 (
char *)&permission);
689 CHECK_NULL(check2,
"T5-2: getValue allow_delete",
692 check = MyTransaction->
execute( NoCommit );
693 CHECK_MINUS_ONE(check,
"T5-2: NoCommit",
696 if(((permission & inServerBit) == inServerBit) &&
697 ((sessions & inServerBit) == inServerBit)){
699 DEBUG(
"deleting - ");
703 CHECK_NULL(MyOperation,
"T5-3: getNdbOperation",
706 check = MyOperation->deleteTuple();
707 CHECK_MINUS_ONE(check,
"T5-3: deleteTuple",
710 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
712 CHECK_MINUS_ONE(check,
"T5-3: equal number",
715 check = MyOperation->equal(IND_SESSION_SERVER,
717 CHECK_MINUS_ONE(check,
"T5-3: equal server id",
724 CHECK_NULL(MyOperation,
"T5-5: getNdbOperation",
728 check = MyOperation->interpretedUpdateTuple();
729 CHECK_MINUS_ONE(check,
"T5-5: interpretedUpdateTuple",
732 check = MyOperation->equal(IND_SERVER_ID,
734 CHECK_MINUS_ONE(check,
"T5-5: equal serverId",
737 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
739 CHECK_MINUS_ONE(check,
"T5-5: equal suffix",
742 check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1);
743 CHECK_MINUS_ONE(check,
"T5-5: inc value",
746 (* outBranchExecuted) = 1;
748 DEBUG1(
"%s", ((permission & inServerBit) ?
"permission - " :
"no permission - "));
749 DEBUG1(
"%s", ((sessions & inServerBit) ?
"in session - " :
"no in session - "));
750 (* outBranchExecuted) = 0;
753 if(!inDoRollback && (* outBranchExecuted)){
755 check = MyTransaction->
execute( Commit );
756 CHECK_MINUS_ONE(check,
"T5: Commit",
760 check = MyTransaction->
execute(Rollback);
761 CHECK_MINUS_ONE(check,
"T5:Rollback",
768 get_time(outTransactionTime);
769 time_diff(outTransactionTime, &start);