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){
62 if (MyTransaction == NULL)
63 error_handler(
"T1: startTranscation", pNDB->getNdbErrorString(), 0);
66 CHECK_NULL(MyOperation,
"T1: getNdbOperation", MyTransaction);
68 check = MyOperation->updateTuple();
69 CHECK_MINUS_ONE(check,
"T1: updateTuple",
72 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
74 CHECK_MINUS_ONE(check,
"T1: equal subscriber",
77 check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
78 (
char *)&new_location);
79 CHECK_MINUS_ONE(check,
"T1: setValue location",
82 check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
84 CHECK_MINUS_ONE(check,
"T1: setValue changed_by",
87 check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
89 CHECK_MINUS_ONE(check,
"T1: setValue changed_time",
92 check = MyTransaction->
execute( Commit );
93 CHECK_MINUS_ONE(check,
"T1: Commit",
98 get_time(transaction_time);
99 time_diff(transaction_time, &start);
119 const SubscriberNumber number,
120 Location * readLocation,
121 ChangedBy changed_by,
122 ChangedTime changed_time,
123 SubscriberName subscriberName,
124 BenchmarkTime * transaction_time){
135 if (MyTransaction == NULL)
136 error_handler(
"T2: startTranscation", pNDB->getNdbErrorString(), 0);
139 CHECK_NULL(MyOperation,
"T2: getNdbOperation",
143 check = MyOperation->readTuple();
144 CHECK_MINUS_ONE(check,
"T2: readTuple",
147 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
149 CHECK_MINUS_ONE(check,
"T2: equal subscriber",
152 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
153 (
char *)readLocation);
154 CHECK_NULL(check2,
"T2: getValue location",
157 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
159 CHECK_NULL(check2,
"T2: getValue changed_by",
162 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
164 CHECK_NULL(check2,
"T2: getValue changed_time",
167 check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME,
169 CHECK_NULL(check2,
"T2: getValue name",
172 check = MyTransaction->
execute( Commit );
173 CHECK_MINUS_ONE(check,
"T2: Commit",
178 get_time(transaction_time);
179 time_diff(transaction_time, &start);
202 const SubscriberNumber inNumber,
203 const SubscriberSuffix inSuffix,
204 const ServerId inServerId,
205 const ServerBit inServerBit,
206 SessionDetails outSessionDetails,
207 ChangedBy outChangedBy,
208 ChangedTime outChangedTime,
209 Location * outLocation,
210 BranchExecuted * outBranchExecuted,
211 BenchmarkTime * outTransactionTime){
216 ActiveSessions sessions;
217 Permission permission;
226 if (MyTransaction == NULL)
227 error_handler(
"T3-1: startTranscation", pNDB->getNdbErrorString(), 0);
230 CHECK_NULL(MyOperation,
"T3-1: getNdbOperation",
234 check = MyOperation->readTuple();
235 CHECK_MINUS_ONE(check,
"T3-1: readTuple",
238 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
240 CHECK_MINUS_ONE(check,
"T3-1: equal subscriber",
243 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
244 (
char *)outLocation);
245 CHECK_NULL(check2,
"T3-1: getValue location",
248 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
250 CHECK_NULL(check2,
"T3-1: getValue changed_by",
253 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
255 CHECK_NULL(check2,
"T3-1: getValue changed_time",
258 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
260 CHECK_NULL(check2,
"T3-1: getValue group",
263 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
265 CHECK_NULL(check2,
"T3-1: getValue sessions",
268 check = MyTransaction->
execute( NoCommit );
269 CHECK_MINUS_ONE(check,
"T3-1: NoCommit",
275 CHECK_NULL(MyOperation,
"T3-2: getNdbOperation",
279 check = MyOperation->readTuple();
280 CHECK_MINUS_ONE(check,
"T3-2: readTuple",
283 check = MyOperation->equal(IND_GROUP_ID,
285 CHECK_MINUS_ONE(check,
"T3-2: equal group",
288 check2 = MyOperation->getValue(IND_GROUP_ALLOW_READ,
289 (
char *)&permission);
290 CHECK_NULL(check2,
"T3-2: getValue allow_read",
293 check = MyTransaction->
execute( NoCommit );
294 CHECK_MINUS_ONE(check,
"T3-2: NoCommit",
297 DEBUG3(
"T3(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
299 if(((permission & inServerBit) == inServerBit) &&
300 ((sessions & inServerBit) == inServerBit)){
307 CHECK_NULL(MyOperation,
"T3-3: getNdbOperation",
310 check = MyOperation->readTuple();
311 CHECK_MINUS_ONE(check,
"T3-3: readTuple",
314 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
316 CHECK_MINUS_ONE(check,
"T3-3: equal number",
319 check = MyOperation->equal(IND_SESSION_SERVER,
321 CHECK_MINUS_ONE(check,
"T3-3: equal server id",
324 check2 = MyOperation->getValue(IND_SESSION_DATA,
325 (
char *)outSessionDetails);
326 CHECK_NULL(check2,
"T3-3: getValue session details",
329 check = MyTransaction->
execute( NoCommit );
330 CHECK_MINUS_ONE(check,
"T3-3: NoCommit",
336 CHECK_NULL(MyOperation,
"T3-4: getNdbOperation",
339 check = MyOperation->interpretedUpdateTuple();
340 CHECK_MINUS_ONE(check,
"T3-4: interpretedUpdateTuple",
343 check = MyOperation->equal(IND_SERVER_ID,
345 CHECK_MINUS_ONE(check,
"T3-4: equal serverId",
348 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
350 CHECK_MINUS_ONE(check,
"T3-4: equal suffix",
353 check = MyOperation->incValue(IND_SERVER_READS, (uint32)1);
354 CHECK_MINUS_ONE(check,
"T3-4: inc value",
357 check = MyTransaction->
execute( NoCommit );
358 CHECK_MINUS_ONE(check,
"T3-4: NoCommit",
361 (* outBranchExecuted) = 1;
363 (* outBranchExecuted) = 0;
366 check = MyTransaction->
execute( Commit );
367 CHECK_MINUS_ONE(check,
"T3: Commit",
372 get_time(outTransactionTime);
373 time_diff(outTransactionTime, &start);
397 const SubscriberNumber inNumber,
398 const SubscriberSuffix inSuffix,
399 const ServerId inServerId,
400 const ServerBit inServerBit,
401 const SessionDetails inSessionDetails,
402 ChangedBy outChangedBy,
403 ChangedTime outChangedTime,
404 Location * outLocation,
405 DoRollback inDoRollback,
406 BranchExecuted * outBranchExecuted,
407 BenchmarkTime * outTransactionTime){
412 ActiveSessions sessions;
413 Permission permission;
422 if (MyTransaction == NULL)
423 error_handler(
"T4-1: startTranscation", pNDB->getNdbErrorString(), 0);
425 DEBUG3(
"T4(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
430 CHECK_NULL(MyOperation,
"T4-1: getNdbOperation",
434 CHECK_MINUS_ONE(check,
"T4-1: readTuple",
437 check = MyOperation->
equal(IND_SUBSCRIBER_NUMBER,
439 CHECK_MINUS_ONE(check,
"T4-1: equal subscriber",
442 check2 = MyOperation->
getValue(IND_SUBSCRIBER_LOCATION,
443 (
char *)outLocation);
444 CHECK_NULL(check2,
"T4-1: getValue location",
447 check2 = MyOperation->
getValue(IND_SUBSCRIBER_CHANGED_BY,
449 CHECK_NULL(check2,
"T4-1: getValue changed_by",
452 check2 = MyOperation->
getValue(IND_SUBSCRIBER_CHANGED_TIME,
454 CHECK_NULL(check2,
"T4-1: getValue changed_time",
457 check2 = MyOperation->
getValue(IND_SUBSCRIBER_GROUP,
459 CHECK_NULL(check2,
"T4-1: getValue group",
462 check2 = MyOperation->
getValue(IND_SUBSCRIBER_SESSIONS,
464 CHECK_NULL(check2,
"T4-1: getValue sessions",
467 check = MyTransaction->
execute( NoCommit );
468 CHECK_MINUS_ONE(check,
"T4-1: NoCommit",
473 CHECK_NULL(MyOperation,
"T4-2: getNdbOperation",
477 CHECK_MINUS_ONE(check,
"T4-2: readTuple",
480 check = MyOperation->
equal(IND_GROUP_ID,
482 CHECK_MINUS_ONE(check,
"T4-2: equal group",
485 check2 = MyOperation->
getValue(IND_GROUP_ALLOW_INSERT,
486 (
char *)&permission);
487 CHECK_NULL(check2,
"T4-2: getValue allow_insert",
490 check = MyTransaction->
execute( NoCommit );
491 CHECK_MINUS_ONE(check,
"T4-2: NoCommit",
494 if(((permission & inServerBit) == inServerBit) &&
495 ((sessions & inServerBit) == 0)){
497 DEBUG(
"inserting - ");
501 CHECK_NULL(MyOperation,
"T4-3: getNdbOperation",
505 CHECK_MINUS_ONE(check,
"T4-3: insertTuple",
508 check = MyOperation->
equal(IND_SESSION_SUBSCRIBER,
510 CHECK_MINUS_ONE(check,
"T4-3: equal number",
513 check = MyOperation->
equal(IND_SESSION_SERVER,
515 CHECK_MINUS_ONE(check,
"T4-3: equal server id",
518 check = MyOperation->
setValue(SESSION_DATA,
519 (
char *)inSessionDetails);
520 CHECK_MINUS_ONE(check,
"T4-3: setValue session details",
523 check = MyTransaction->
execute( NoCommit );
524 CHECK_MINUS_ONE(check,
"T4-3: NoCommit",
529 CHECK_NULL(MyOperation,
"T4-4: getNdbOperation",
533 CHECK_MINUS_ONE(check,
"T4-4: interpretedUpdateTuple",
536 check = MyOperation->
equal(IND_SUBSCRIBER_NUMBER,
538 CHECK_MINUS_ONE(check,
"T4-4: equal number",
541 check = MyOperation->
incValue(IND_SUBSCRIBER_SESSIONS,
542 (uint32)inServerBit);
543 CHECK_MINUS_ONE(check,
"T4-4: inc value",
546 check = MyTransaction->
execute( NoCommit );
547 CHECK_MINUS_ONE(check,
"T4-4: NoCommit",
552 CHECK_NULL(MyOperation,
"T4-5: getNdbOperation",
556 CHECK_MINUS_ONE(check,
"T4-5: interpretedUpdateTuple",
559 check = MyOperation->
equal(IND_SERVER_ID,
561 CHECK_MINUS_ONE(check,
"T4-5: equal serverId",
564 check = MyOperation->
equal(IND_SERVER_SUBSCRIBER_SUFFIX,
566 CHECK_MINUS_ONE(check,
"T4-5: equal suffix",
569 check = MyOperation->
incValue(IND_SERVER_INSERTS, (uint32)1);
570 CHECK_MINUS_ONE(check,
"T4-5: inc value",
573 check = MyTransaction->
execute( NoCommit );
574 CHECK_MINUS_ONE(check,
"T4-5: NoCommit",
577 (* outBranchExecuted) = 1;
579 DEBUG1(
"%s", ((permission & inServerBit) ?
"permission - " :
"no permission - "));
580 DEBUG1(
"%s", ((sessions & inServerBit) ?
"in session - " :
"no in session - "));
581 (* outBranchExecuted) = 0;
586 check = MyTransaction->
execute( Commit );
587 CHECK_MINUS_ONE(check,
"T4: Commit",
591 check = MyTransaction->
execute(Rollback);
592 CHECK_MINUS_ONE(check,
"T4:Rollback",
599 get_time(outTransactionTime);
600 time_diff(outTransactionTime, &start);
623 const SubscriberNumber inNumber,
624 const SubscriberSuffix inSuffix,
625 const ServerId inServerId,
626 const ServerBit inServerBit,
627 ChangedBy outChangedBy,
628 ChangedTime outChangedTime,
629 Location * outLocation,
630 DoRollback inDoRollback,
631 BranchExecuted * outBranchExecuted,
632 BenchmarkTime * outTransactionTime){
639 ActiveSessions sessions;
640 Permission permission;
649 if (MyTransaction == NULL)
650 error_handler(
"T5-1: startTranscation", pNDB->getNdbErrorString(), 0);
653 CHECK_NULL(MyOperation,
"T5-1: getNdbOperation",
657 check = MyOperation->readTupleExclusive();
658 CHECK_MINUS_ONE(check,
"T5-1: readTuple",
661 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
663 CHECK_MINUS_ONE(check,
"T5-1: equal subscriber",
666 check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
667 (
char *)outLocation);
668 CHECK_NULL(check2,
"T5-1: getValue location",
671 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
673 CHECK_NULL(check2,
"T5-1: getValue changed_by",
676 check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
678 CHECK_NULL(check2,
"T5-1: getValue changed_time",
681 check2 = MyOperation->getValue(IND_SUBSCRIBER_GROUP,
683 CHECK_NULL(check2,
"T5-1: getValue group",
686 check2 = MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
688 CHECK_NULL(check2,
"T5-1: getValue sessions",
691 check = MyTransaction->
execute( NoCommit );
692 CHECK_MINUS_ONE(check,
"T5-1: NoCommit",
698 CHECK_NULL(MyOperation,
"T5-2: getNdbOperation",
702 check = MyOperation->readTuple();
703 CHECK_MINUS_ONE(check,
"T5-2: readTuple",
706 check = MyOperation->equal(IND_GROUP_ID,
708 CHECK_MINUS_ONE(check,
"T5-2: equal group",
711 check2 = MyOperation->getValue(IND_GROUP_ALLOW_DELETE,
712 (
char *)&permission);
713 CHECK_NULL(check2,
"T5-2: getValue allow_delete",
716 check = MyTransaction->
execute( NoCommit );
717 CHECK_MINUS_ONE(check,
"T5-2: NoCommit",
720 DEBUG3(
"T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);
722 if(((permission & inServerBit) == inServerBit) &&
723 ((sessions & inServerBit) == inServerBit)){
725 DEBUG(
"deleting - ");
729 CHECK_NULL(MyOperation,
"T5-3: getNdbOperation",
732 check = MyOperation->deleteTuple();
733 CHECK_MINUS_ONE(check,
"T5-3: deleteTuple",
736 check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
738 CHECK_MINUS_ONE(check,
"T5-3: equal number",
741 check = MyOperation->equal(IND_SESSION_SERVER,
743 CHECK_MINUS_ONE(check,
"T5-3: equal server id",
746 check = MyTransaction->
execute( NoCommit );
747 CHECK_MINUS_ONE(check,
"T5-3: NoCommit",
752 CHECK_NULL(MyOperation,
"T5-4: getNdbOperation",
755 check = MyOperation->interpretedUpdateTuple();
756 CHECK_MINUS_ONE(check,
"T5-4: interpretedUpdateTuple",
759 check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
761 CHECK_MINUS_ONE(check,
"T5-4: equal number",
764 check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS,
765 (uint32)inServerBit);
766 CHECK_MINUS_ONE(check,
"T5-4: dec value",
769 check = MyTransaction->
execute( NoCommit );
770 CHECK_MINUS_ONE(check,
"T5-4: NoCommit",
775 CHECK_NULL(MyOperation,
"T5-5: getNdbOperation",
779 check = MyOperation->interpretedUpdateTuple();
780 CHECK_MINUS_ONE(check,
"T5-5: interpretedUpdateTuple",
783 check = MyOperation->equal(IND_SERVER_ID,
785 CHECK_MINUS_ONE(check,
"T5-5: equal serverId",
788 check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
790 CHECK_MINUS_ONE(check,
"T5-5: equal suffix",
793 check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1);
794 CHECK_MINUS_ONE(check,
"T5-5: inc value",
797 check = MyTransaction->
execute( NoCommit );
798 CHECK_MINUS_ONE(check,
"T5-5: NoCommit",
801 (* outBranchExecuted) = 1;
803 DEBUG1(
"%s", ((permission & inServerBit) ?
"permission - " :
"no permission - "));
804 DEBUG1(
"%s", ((sessions & inServerBit) ?
"in session - " :
"no in session - "));
805 (* outBranchExecuted) = 0;
810 check = MyTransaction->
execute( Commit );
811 CHECK_MINUS_ONE(check,
"T5: Commit",
815 check = MyTransaction->
execute(Rollback);
816 CHECK_MINUS_ONE(check,
"T5:Rollback",
823 get_time(outTransactionTime);
824 time_diff(outTransactionTime, &start);