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){
220 ActiveSessions sessions;
221 Permission permission;
230 if (MyTransaction == NULL)
231 error_handler(
"T3-1: startTranscation", pNDB->getNdbErrorString(), 0);
234 CHECK_NULL(MyOperation,
"T3-1: getNdbOperation",
237 check = MyOperation->readTuple();
238 CHECK_MINUS_ONE(check,
"T3-1: readTuple",
241 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
243 CHECK_MINUS_ONE(check,
"T3-1: equal subscriber",
246 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
247 (
char *)outLocation);
248 CHECK_NULL(check2,
"T3-1: getValue location",
251 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
253 CHECK_NULL(check2,
"T3-1: getValue changed_by",
256 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
258 CHECK_NULL(check2,
"T3-1: getValue changed_time",
261 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
263 CHECK_NULL(check2,
"T3-1: getValue group",
266 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
268 CHECK_NULL(check2,
"T3-1: getValue sessions",
271 check = MyTransaction->
execute( NoCommit );
272 CHECK_MINUS_ONE(check,
"T3-1: NoCommit",
278 CHECK_NULL(MyOperation,
"T3-2: getNdbOperation",
282 check = MyOperation->readTuple();
283 CHECK_MINUS_ONE(check,
"T3-2: readTuple",
286 check = MyOperation->equal(IND_GROUP_ID,
288 CHECK_MINUS_ONE(check,
"T3-2: equal group",
291 check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ,
292 (
char *)&permission);
293 CHECK_NULL(check2,
"T3-2: getValue allow_read",
296 check = MyTransaction->
execute( NoCommit );
297 CHECK_MINUS_ONE(check,
"T3-2: NoCommit",
300 DEBUG3(
"T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
302 if(((permission & inServerBit) == inServerBit) &&
303 ((sessions & inServerBit) == inServerBit)){
309 CHECK_NULL(MyOperation,
"T3-3: getNdbOperation",
312 check = MyOperation->simpleRead();
313 CHECK_MINUS_ONE(check,
"T3-3: readTuple",
316 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
318 CHECK_MINUS_ONE(check,
"T3-3: equal number",
321 check = MyOperation->equal(IND_SESSION_SERVER,
323 CHECK_MINUS_ONE(check,
"T3-3: equal server id",
326 check2 = MyOperation->getValue(IND_SESSION_DATA,
327 (
char *)outSessionDetails);
328 CHECK_NULL(check2,
"T3-3: getValue session details",
333 CHECK_NULL(MyOperation,
"T3-4: getNdbOperation",
336 check = MyOperation->interpretedUpdateTuple();
337 CHECK_MINUS_ONE(check,
"T3-4: interpretedUpdateTuple",
340 check = MyOperation->equal(IND_SERVER_ID,
342 CHECK_MINUS_ONE(check,
"T3-4: equal serverId",
345 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
347 CHECK_MINUS_ONE(check,
"T3-4: equal suffix",
350 check = MyOperation->incValue(IND_SERVER_READS, (uint32)1);
351 CHECK_MINUS_ONE(check,
"T3-4: inc value",
353 (* outBranchExecuted) = 1;
355 (* outBranchExecuted) = 0;
358 check = MyTransaction->
execute( Commit );
359 CHECK_MINUS_ONE(check,
"T3: Commit",
365 get_time(outTransactionTime);
366 time_diff(outTransactionTime, &start);
390 const SubscriberNumber inNumber,
391 const SubscriberSuffix inSuffix,
392 const ServerId inServerId,
393 const ServerBit inServerBit,
394 const SessionDetails inSessionDetails,
395 ChangedBy outChangedBy,
396 ChangedTime outChangedTime,
397 Location * outLocation,
398 DoRollback inDoRollback,
399 BranchExecuted * outBranchExecuted,
400 BenchmarkTime * outTransactionTime){
405 ActiveSessions sessions;
406 Permission permission;
415 if (MyTransaction == NULL)
416 error_handler(
"T4-1: startTranscation", pNDB->getNdbErrorString(), 0);
419 CHECK_NULL(MyOperation,
"T4-1: getNdbOperation",
422 check = MyOperation->interpretedUpdateTuple();
423 CHECK_MINUS_ONE(check,
"T4-1: readTuple",
426 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
428 CHECK_MINUS_ONE(check,
"T4-1: equal subscriber",
431 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
432 (
char *)outLocation);
433 CHECK_NULL(check2,
"T4-1: getValue location",
436 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
438 CHECK_NULL(check2,
"T4-1: getValue changed_by",
441 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
443 CHECK_NULL(check2,
"T4-1: getValue changed_time",
446 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
448 CHECK_NULL(check2,
"T4-1: getValue group",
451 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
453 CHECK_NULL(check2,
"T4-1: getValue sessions",
456 check = MyOperation->incValue(IND_SUBSCRIBER_SESSIONS,
457 (uint32)inServerBit);
458 CHECK_MINUS_ONE(check,
"T4-4: inc value",
461 check = MyTransaction->
execute( NoCommit );
462 CHECK_MINUS_ONE(check,
"T4-1: NoCommit",
468 CHECK_NULL(MyOperation,
"T4-2: getNdbOperation",
471 check = MyOperation->readTuple();
472 CHECK_MINUS_ONE(check,
"T4-2: readTuple",
475 check = MyOperation->equal(IND_GROUP_ID,
477 CHECK_MINUS_ONE(check,
"T4-2: equal group",
480 check2 = MyOperation->getValue(IND_GROUP_ALLOW_INSERT,
481 (
char *)&permission);
482 CHECK_NULL(check2,
"T4-2: getValue allow_insert",
485 check = MyTransaction->
execute( NoCommit );
486 CHECK_MINUS_ONE(check,
"T4-2: NoCommit",
489 DEBUG3(
"T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
491 if(((permission & inServerBit) == inServerBit) &&
492 ((sessions & inServerBit) == 0)){
494 DEBUG(
"inserting - ");
499 CHECK_NULL(MyOperation,
"T4-3: getNdbOperation",
502 check = MyOperation->insertTuple();
503 CHECK_MINUS_ONE(check,
"T4-3: insertTuple",
506 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
508 CHECK_MINUS_ONE(check,
"T4-3: equal number",
511 check = MyOperation->equal(IND_SESSION_SERVER,
513 CHECK_MINUS_ONE(check,
"T4-3: equal server id",
516 check = MyOperation->setValue(SESSION_DATA,
517 (
char *)inSessionDetails);
518 CHECK_MINUS_ONE(check,
"T4-3: setValue session details",
525 CHECK_NULL(MyOperation,
"T4-5: getNdbOperation",
528 check = MyOperation->interpretedUpdateTuple();
529 CHECK_MINUS_ONE(check,
"T4-5: interpretedUpdateTuple",
532 check = MyOperation->equal(IND_SERVER_ID,
534 CHECK_MINUS_ONE(check,
"T4-5: equal serverId",
537 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
539 CHECK_MINUS_ONE(check,
"T4-5: equal suffix",
542 check = MyOperation->incValue(IND_SERVER_INSERTS, (uint32)1);
543 CHECK_MINUS_ONE(check,
"T4-5: inc value",
546 (* outBranchExecuted) = 1;
548 DEBUG1(
"%s", ((permission & inServerBit) ?
"permission - " :
"no permission - "));
549 DEBUG1(
"%s", ((sessions & inServerBit) ?
"in session - " :
"no in session - "));
550 (* outBranchExecuted) = 0;
553 if(!inDoRollback && (* outBranchExecuted)){
555 check = MyTransaction->
execute( Commit );
556 CHECK_MINUS_ONE(check,
"T4: Commit",
560 check = MyTransaction->
execute(Rollback);
561 CHECK_MINUS_ONE(check,
"T4:Rollback",
568 get_time(outTransactionTime);
569 time_diff(outTransactionTime, &start);
592 const SubscriberNumber inNumber,
593 const SubscriberSuffix inSuffix,
594 const ServerId inServerId,
595 const ServerBit inServerBit,
596 ChangedBy outChangedBy,
597 ChangedTime outChangedTime,
598 Location * outLocation,
599 DoRollback inDoRollback,
600 BranchExecuted * outBranchExecuted,
601 BenchmarkTime * outTransactionTime){
608 ActiveSessions sessions;
609 Permission permission;
618 if (MyTransaction == NULL)
619 error_handler(
"T5-1: startTranscation", pNDB->getNdbErrorString(), 0);
622 CHECK_NULL(MyOperation,
"T5-1: getNdbOperation",
625 check = MyOperation->interpretedUpdateTuple();
626 CHECK_MINUS_ONE(check,
"T5-1: readTuple",
629 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
631 CHECK_MINUS_ONE(check,
"T5-1: equal subscriber",
634 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
635 (
char *)outLocation);
636 CHECK_NULL(check2,
"T5-1: getValue location",
639 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
641 CHECK_NULL(check2,
"T5-1: getValue changed_by",
644 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
646 CHECK_NULL(check2,
"T5-1: getValue changed_time",
649 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
651 CHECK_NULL(check2,
"T5-1: getValue group",
654 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
656 CHECK_NULL(check2,
"T5-1: getValue sessions",
659 check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS,
660 (uint32)inServerBit);
661 CHECK_MINUS_ONE(check,
"T5-4: dec value",
664 check = MyTransaction->
execute( NoCommit );
665 CHECK_MINUS_ONE(check,
"T5-1: NoCommit",
671 CHECK_NULL(MyOperation,
"T5-2: getNdbOperation",
675 check = MyOperation->readTuple();
676 CHECK_MINUS_ONE(check,
"T5-2: readTuple",
679 check = MyOperation->equal(IND_GROUP_ID,
681 CHECK_MINUS_ONE(check,
"T5-2: equal group",
684 check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE,
685 (
char *)&permission);
686 CHECK_NULL(check2,
"T5-2: getValue allow_delete",
689 check = MyTransaction->
execute( NoCommit );
690 CHECK_MINUS_ONE(check,
"T5-2: NoCommit",
693 DEBUG3(
"T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
695 if(((permission & inServerBit) == inServerBit) &&
696 ((sessions & inServerBit) == inServerBit)){
698 DEBUG(
"deleting - ");
702 CHECK_NULL(MyOperation,
"T5-3: getNdbOperation",
705 check = MyOperation->deleteTuple();
706 CHECK_MINUS_ONE(check,
"T5-3: deleteTuple",
709 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
711 CHECK_MINUS_ONE(check,
"T5-3: equal number",
714 check = MyOperation->equal(IND_SESSION_SERVER,
716 CHECK_MINUS_ONE(check,
"T5-3: equal server id",
723 CHECK_NULL(MyOperation,
"T5-5: getNdbOperation",
727 check = MyOperation->interpretedUpdateTuple();
728 CHECK_MINUS_ONE(check,
"T5-5: interpretedUpdateTuple",
731 check = MyOperation->equal(IND_SERVER_ID,
733 CHECK_MINUS_ONE(check,
"T5-5: equal serverId",
736 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
738 CHECK_MINUS_ONE(check,
"T5-5: equal suffix",
741 check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1);
742 CHECK_MINUS_ONE(check,
"T5-5: inc value",
745 (* outBranchExecuted) = 1;
747 DEBUG1(
"%s", ((permission & inServerBit) ?
"permission - " :
"no permission - "));
748 DEBUG1(
"%s", ((sessions & inServerBit) ?
"in session - " :
"no in session - "));
749 (* outBranchExecuted) = 0;
752 if(!inDoRollback && (* outBranchExecuted)){
754 check = MyTransaction->
execute( Commit );
755 CHECK_MINUS_ONE(check,
"T5: Commit",
759 check = MyTransaction->
execute(Rollback);
760 CHECK_MINUS_ONE(check,
"T5:Rollback",
767 get_time(outTransactionTime);
768 time_diff(outTransactionTime, &start);