MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbTransaction.hpp
1 /*
2  Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #ifndef NdbTransaction_H
19 #define NdbTransaction_H
20 
21 #include <ndb_types.h>
22 #include "NdbError.hpp"
23 #include "NdbDictionary.hpp"
24 #include "Ndb.hpp"
25 #include "NdbOperation.hpp"
26 #include "NdbIndexScanOperation.hpp"
27 
28 class NdbTransaction;
29 class NdbScanOperation;
31 class NdbIndexOperation;
32 class NdbApiSignal;
33 class Ndb;
34 class NdbBlob;
35 class NdbInterpretedCode;
36 class NdbQueryImpl;
37 class NdbQueryDef;
38 class NdbQuery;
39 class NdbQueryParamValue;
40 class NdbLockHandle;
41 
42 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
43 // to be documented later
51 typedef void (* NdbAsynchCallback)(int, NdbTransaction*, void*);
52 #endif
53 
54 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
55 enum AbortOption {
56  DefaultAbortOption = NdbOperation::DefaultAbortOption,
57  CommitIfFailFree = NdbOperation::AbortOnError,
58  TryCommit = NdbOperation::AbortOnError,
59  AbortOnError= NdbOperation::AbortOnError,
60  CommitAsMuchAsPossible = NdbOperation::AO_IgnoreError,
61  AO_IgnoreError= NdbOperation::AO_IgnoreError
62 };
63 enum ExecType {
64  NoExecTypeDef = -1,
65  Prepare,
66  NoCommit,
67  Commit,
68  Rollback
69 };
70 #endif
71 
115 /* FUTURE IMPLEMENTATION:
116  * Later a prepare mode will be added when Ndb supports Prepare-To-Commit
117  * The NdbTransaction can deliver the Transaction Id of the transaction.
118  * After committing a transaction it is also possible to retrieve the
119  * global transaction checkpoint which the transaction was put in.
120  *
121  * FUTURE IMPLEMENTATION:
122  * There are three methods for acquiring the NdbOperation.
123  * -# The first method is the normal where a table name is
124  * provided. In this case the primary key must be supplied through
125  * the use of the NdbOperation::equal methods on the NdbOperation object.
126  * -# The second method provides the tuple identity of the tuple to be
127  * read. The tuple identity contains a table identifier and will
128  * thus be possible to use to ensure the attribute names provided
129  * are correct. If an object-oriented layer is put on top of NDB
130  * Cluster it is essential that all tables derived from a base
131  * class has the same attributes with the same type and the same
132  * name. Thus the application can use the tuple identity and need
133  * not known the table of the tuple. As long as the table is
134  * derived from the known base class everything is ok.
135  * It is not possible to provide any primary key since it is
136  * already supplied with the call to NdbTransaction::getNdbOperation.
137  * -# The third method is used when a scanned tuple is to be transferred to
138  * another transaction. In this case it is not possible to define the
139  * primary key since it came along from the scanned tuple.
140  *
141  */
142 
143 class NdbRecord;
144 
146 {
147 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
148  friend class Ndb;
149  friend class NdbOperation;
150  friend class NdbScanOperation;
151  friend class NdbIndexOperation;
152  friend class NdbIndexScanOperation;
153  friend class NdbBlob;
154  friend class ha_ndbcluster;
155  friend class NdbQueryImpl;
156  friend class NdbQueryOperationImpl;
157 #endif
158 
159 public:
160 #ifdef NDBAPI_50_COMPAT
161  enum AbortOption {
162  DefaultAbortOption = NdbOperation::DefaultAbortOption,
163  CommitIfFailFree = NdbOperation::AbortOnError,
164  TryCommit = NdbOperation::AbortOnError,
165  AbortOnError= NdbOperation::AbortOnError,
166  CommitAsMuchAsPossible = NdbOperation::AO_IgnoreError,
167  AO_IgnoreError= NdbOperation::AO_IgnoreError
168  };
169 #endif
170 
171 
175  enum ExecType {
176 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
180 #endif
182 
183 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
184  ::NoCommit
185 #endif
187 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
188  ::Commit
189 #endif
191 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
192  = ::Rollback
193 #endif
194  };
195 
196 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
197 
200  Ndb * getNdb() {
201  return theNdb;
202  }
203 #endif
204 
205 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
206 
216  NdbOperation* getNdbOperation(const char* aTableName);
217 #endif
218 
231 
232 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
233 
241  NdbScanOperation* getNdbScanOperation(const char* aTableName);
242 #endif
243 
254 
255 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
256 
265  NdbIndexScanOperation* getNdbIndexScanOperation(const char* anIndexName,
266  const char* aTableName);
268  (const NdbDictionary::Index *anIndex, const NdbDictionary::Table *aTable);
269 #endif
270 
281  (const NdbDictionary::Index *anIndex);
282 
283 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
284 
294  NdbIndexOperation* getNdbIndexOperation(const char* anIndexName,
295  const char* aTableName);
297  const NdbDictionary::Table *aTable);
298 #endif
299 
311 
339 #ifndef NDBAPI_50_COMPAT
340  int execute(ExecType execType,
342  int force = 0 );
343 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
344  int execute(::ExecType execType,
345  ::AbortOption abortOption = ::DefaultAbortOption,
346  int force = 0 ) {
347  return execute ((ExecType)execType,
348  (NdbOperation::AbortOption)abortOption,
349  force); }
350 #endif
351 #else
352 
357  int execute(ExecType execType, NdbOperation::AbortOption, int force);
358 
359  int execute(NdbTransaction::ExecType execType,
360  NdbTransaction::AbortOption abortOption = AbortOnError,
361  int force = 0)
362  {
363  int ret = execute ((ExecType)execType,
364  (NdbOperation::AbortOption)abortOption,
365  force);
366  if (ret || (abortOption != AO_IgnoreError && theError.code))
367  return -1;
368  return 0;
369  }
370 #endif
371 
372 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
373  // to be documented later
397 #ifndef NDBAPI_50_COMPAT
398  void executeAsynchPrepare(ExecType execType,
399  NdbAsynchCallback callback,
400  void* anyObject,
402 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
403  void executeAsynchPrepare(::ExecType execType,
404  NdbAsynchCallback callback,
405  void* anyObject,
406  ::AbortOption ao = ::DefaultAbortOption) {
407  executeAsynchPrepare((ExecType)execType, callback, anyObject,
409 #endif
410 #else
411 
415  void executeAsynchPrepare(ExecType execType,
416  NdbAsynchCallback callback,
417  void* anyObject,
419 
421  NdbAsynchCallback callback,
422  void *anyObject,
423  NdbTransaction::AbortOption abortOption = NdbTransaction::AbortOnError)
424  {
425  executeAsynchPrepare((ExecType)execType, callback, anyObject,
426  (NdbOperation::AbortOption)abortOption);
427  }
428 #endif
429 
443 #ifndef NDBAPI_50_COMPAT
444  void executeAsynch(ExecType aTypeOfExec,
445  NdbAsynchCallback aCallback,
446  void* anyObject,
448  int forceSend= 0);
449 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
450  void executeAsynch(::ExecType aTypeOfExec,
451  NdbAsynchCallback aCallback,
452  void* anyObject,
453  ::AbortOption abortOption= ::DefaultAbortOption,
454  int forceSend= 0)
455  { executeAsynch((ExecType)aTypeOfExec, aCallback, anyObject,
456  (NdbOperation::AbortOption)abortOption, forceSend); }
457 #endif
458 #else
459 
463  void executeAsynch(ExecType aTypeOfExec,
464  NdbAsynchCallback aCallback,
465  void* anyObject,
467  int forceSend= 0);
468  void executeAsynch(NdbTransaction::ExecType aTypeOfExec,
469  NdbAsynchCallback aCallback,
470  void* anyObject,
471  NdbTransaction::AbortOption abortOption = AbortOnError)
472  {
473  executeAsynch((ExecType)aTypeOfExec, aCallback, anyObject,
474  (NdbOperation::AbortOption)abortOption, 0);
475  }
476 #endif
477 #endif
478 
489  int refresh();
490 
496 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
497 
506 #endif
507  void close();
508 
509 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
510 
524  int restart();
525 #endif
526 
556  int getGCI(Uint64 * gciptr);
557 
561  int getGCI();
562 
568  Uint64 getTransactionId();
569 
579  };
580 
587 
600  const NdbError & getNdbError() const;
601 
614 
625  const NdbOperation* getNdbErrorOperation() const;
626 
632  int getNdbErrorLine();
633 
654  const NdbOperation * getNextCompletedOperation(const NdbOperation * op)const;
655 
656 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
657  const NdbOperation* getFirstDefinedOperation()const{return theFirstOpInList;}
658  const NdbOperation* getLastDefinedOperation()const{return theLastOpInList;}
659 
669  int executePendingBlobOps(Uint8 flags = 0xFF);
670 
674  Uint32 getConnectedNodeId(); // Get Connected node id
675 #endif
676 
677  /*
678  * NdbRecord primary key and unique key operations.
679  *
680  * If the key_rec passed in is for a table, the operation will be a primary
681  * key operation. If it is for an index, it will be a unique key operation
682  * using that index.
683  *
684  * The key_row passed in defines the primary or unique key of the affected
685  * tuple, and must remain valid until execute() is called. The key_rec must
686  * include all columns of the key.
687  *
688  * The mask, if != NULL, defines a subset of attributes to read, update, or
689  * insert. Only if (mask[attrId >> 3] & (1<<(attrId & 7))) is set is the
690  * column affected. The mask is copied by the methods, so need not remain
691  * valid after the call returns.
692  *
693  * For unique index operations, the attr_rec must refer to the underlying
694  * table of the index.
695  *
696  * OperationOptions can be used to give finer-grained control of operation
697  * definition. An OperationOptions structure is passed with flags
698  * indicating which operation definition options are present. Not all
699  * operation types support all operation options. See the definition of
700  * the OperationOptions structure for more information on individual options.
701  *
702  * Operation type Supported OperationOptions flags
703  * -------------- --------------------------------
704  * readTuple OO_ABORTOPTION, OO_GETVALUE,
705  * OO_PARTITION_ID, OO_INTERPRETED
706  * insertTuple OO_ABORTOPTION, OO_SETVALUE,
707  * OO_PARTITION_ID, OO_ANYVALUE
708  * updateTuple OO_ABORTOPTION, OO_SETVALUE,
709  * OO_PARTITION_ID, OO_INTERPRETED,
710  * OO_ANYVALUE
711  * writeTuple OO_ABORTOPTION, OO_SETVALUE,
712  * OO_PARTITION_ID, OO_ANYVALUE
713  * deleteTuple OO_ABORTOPTION, OO_GETVALUE,
714  * OO_PARTITION_ID, OO_INTERPRETED,
715  * OO_ANYVALUE
716  *
717  * The sizeOfOptions optional parameter is used to allow this interface
718  * to be backwards compatible with previous definitions of the OperationOptions
719  * structure. If an unusual size is detected by the interface implementation,
720  * it can use this to determine how to interpret the passed OperationOptions
721  * structure. To enable this functionality, the caller should pass
722  * sizeof(NdbOperation::OperationOptions) for this argument.
723  */
724  const NdbOperation *readTuple(const NdbRecord *key_rec, const char *key_row,
725  const NdbRecord *result_rec, char *result_row,
727  const unsigned char *result_mask= 0,
728  const NdbOperation::OperationOptions *opts = 0,
729  Uint32 sizeOfOptions = 0);
730  const NdbOperation *insertTuple(const NdbRecord *key_rec, const char *key_row,
731  const NdbRecord *attr_rec, const char *attr_row,
732  const unsigned char *mask= 0,
733  const NdbOperation::OperationOptions *opts = 0,
734  Uint32 sizeOfOptions = 0);
735  const NdbOperation *insertTuple(const NdbRecord *combined_rec, const char *combined_row,
736  const unsigned char *mask = 0,
737  const NdbOperation::OperationOptions *opts = 0,
738  Uint32 sizeOfOptions = 0);
739  const NdbOperation *updateTuple(const NdbRecord *key_rec, const char *key_row,
740  const NdbRecord *attr_rec, const char *attr_row,
741  const unsigned char *mask= 0,
742  const NdbOperation::OperationOptions *opts = 0,
743  Uint32 sizeOfOptions = 0);
744  const NdbOperation *writeTuple(const NdbRecord *key_rec, const char *key_row,
745  const NdbRecord *attr_rec, const char *attr_row,
746  const unsigned char *mask= 0,
747  const NdbOperation::OperationOptions *opts = 0,
748  Uint32 sizeOfOptions = 0);
749  const NdbOperation *deleteTuple(const NdbRecord *key_rec, const char *key_row,
750  const NdbRecord *result_rec, char *result_row = 0,
751  const unsigned char *result_mask = 0,
752  const NdbOperation::OperationOptions *opts = 0,
753  Uint32 sizeOfOptions = 0);
754 
755 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
756  const NdbOperation *refreshTuple(const NdbRecord *key_rec, const char *key_row,
757  const NdbOperation::OperationOptions *opts = 0,
758  Uint32 sizeOfOptions = 0);
759 #endif
760 
784  scanTable(const NdbRecord *result_record,
786  const unsigned char *result_mask= 0,
787  const NdbScanOperation::ScanOptions *options = 0,
788  Uint32 sizeOfOptions = 0);
789 
828  scanIndex(const NdbRecord *key_record,
829  const NdbRecord *result_record,
831  const unsigned char *result_mask = 0,
832  const NdbIndexScanOperation::IndexBound *bound = 0,
833  const NdbScanOperation::ScanOptions *options = 0,
834  Uint32 sizeOfOptions = 0);
835 
845  NdbQuery*
847  const NdbQueryParamValue paramValue[]= 0,
849 
850  /* LockHandle methods */
851  /*
852  * Shared or Exclusive locks taken by read operations in a transaction
853  * are normally held until the transaction commits or aborts.
854  * Shared or Exclusive *read* locks can be released before transaction
855  * commit or abort time by requesting a LockHandle when defining the
856  * read operation. Any time after the read operation has been executed,
857  * the LockHandle can be used to create a new Unlock operation. When
858  * the Unlock operation is executed, the row lock placed by the read
859  * operation will be released.
860  *
861  * The steps are :
862  * 1) Define the primary key read operation in the normal way
863  * with lockmode LM_Read or LM_Exclusive
864  *
865  * 2) Call NdbOperation::getLockHandle() during operation definition
866  * (Or set the OO_LOCKHANDLE operation option when calling
867  * NdbTransaction::readTuple() for NdbRecord)
868  *
869  * 3) Call NdbTransaction::execute()
870  * (Row will be locked from here as normal)
871  *
872  * 4) Use the read data, make zero or more calls to
873  * NdbTransaction::execute() etc.
874  *
875  * 5) Call NdbTransaction::unlock(NdbLockHandle*), passing in the
876  * const LockHandle* from 2) to create an Unlock operation.
877  *
878  * 6) Call NdbTransaction::execute()
879  * (Row will be unlocked from here)
880  *
881  * Notes
882  * - As with other operation types, Unlock operations can be batched.
883  * - Each LockHandle object refers to a lock placed on a row by a single
884  * primary key read operation. A single row in the database may have
885  * concurrent multiple lock holders (of mode LM_Read) and may have
886  * multiple lock holders pending (LM_Exclusive), so releasing the
887  * claim of one lock holder may not result in a change to the
888  * observable lock status of the row.
889  * - LockHandles are supported for Scan lock takeover operations - the
890  * lockhandle must be requested before the locktakeover is executed.
891  * - LockHandles and Unlock operations are not supported for Unique Index
892  * read operations.
893  */
894 
895  /* unlock
896  *
897  * This method creates an Unlock operation on the current transaction.
898  * When executed, the Unlock operation will remove the lock referenced
899  * by the passed LockHandle.
900  *
901  * The unlock operation can fail, for example due to the row being
902  * unlocked already. In this scenario, the AbortOption specifies how
903  * this will be handled.
904  * The default is that errors will cause transaction abort.
905  */
906  const NdbOperation* unlock(const NdbLockHandle* lockHandle,
908 
909  /* releaseLockHandle
910  * This method is used to release a LockHandle object once it
911  * is no longer required.
912  * For NdbRecord primary key read operations, this cannot be
913  * called until the associated read operation has executed.
914  * All LockHandles associated with a transaction are released
915  * when it is closed.
916  */
917  int releaseLockHandle(const NdbLockHandle* lockHandle);
918 
919  /* Get maximum number of pending Blob read/write bytes before
920  * an automatic execute() occurs
921  */
922  Uint32 getMaxPendingBlobReadBytes() const;
923  Uint32 getMaxPendingBlobWriteBytes() const;
924 
925  /* Set maximum number of pending Blob read/write bytes before
926  * an automatic execute() occurs
927  */
928  void setMaxPendingBlobReadBytes(Uint32 bytes);
929  void setMaxPendingBlobWriteBytes(Uint32 bytes);
930 
931 private:
935  void releaseCompletedOperations();
936  void releaseCompletedQueries();
937 
938  typedef Uint64 TimeMillis_t;
939  /**************************************************************************
940  * These methods are service methods to other classes in the NDBAPI. *
941  **************************************************************************/
942 
943  /**************************************************************************
944  * These are the create and delete methods of this class. *
945  **************************************************************************/
946  NdbTransaction(Ndb* aNdb);
947  ~NdbTransaction();
948 
949  int init(); // Initialize connection object for new transaction
950 
951  int executeNoBlobs(ExecType execType,
953  int force = 0 );
954 
959  void setConnectedNodeId( Uint32 nodeId, Uint32 sequence);
960 
961  void setMyBlockReference( int ); // Set my block refrerence
962  void setTC_ConnectPtr( Uint32 ); // Sets TC Connect pointer
963  int getTC_ConnectPtr(); // Gets TC Connect pointer
964  void setBuddyConPtr(Uint32); // Sets Buddy Con Ptr
965  Uint32 getBuddyConPtr(); // Gets Buddy Con Ptr
966  NdbTransaction* next(); // Returns the next pointer
967  void next(NdbTransaction*); // Sets the next pointer
968 
969  enum ConStatusType {
970  NotConnected,
971  Connecting,
972  Connected,
973  DisConnecting,
974  ConnectFailure
975  };
976  ConStatusType Status(); // Read the status information
977  void Status(ConStatusType); // Set the status information
978 
979  Uint32 get_send_size(); // Get size to send
980  void set_send_size(Uint32); // Set size to send;
981 
982  int receiveTCSEIZECONF(const NdbApiSignal* anApiSignal);
983  int receiveTCSEIZEREF(const NdbApiSignal* anApiSignal);
984  int receiveTCRELEASECONF(const NdbApiSignal* anApiSignal);
985  int receiveTCRELEASEREF(const NdbApiSignal* anApiSignal);
986  int receiveTC_COMMITCONF(const class TcCommitConf *, Uint32 len);
987  int receiveTCKEYCONF(const class TcKeyConf *, Uint32 aDataLength);
988  int receiveTCKEY_FAILCONF(const class TcKeyFailConf *);
989  int receiveTCKEY_FAILREF(const NdbApiSignal* anApiSignal);
990  int receiveTC_COMMITREF(const NdbApiSignal* anApiSignal);
991  int receiveTCROLLBACKCONF(const NdbApiSignal* anApiSignal);
992  int receiveTCROLLBACKREF(const NdbApiSignal* anApiSignal);
993  int receiveTCROLLBACKREP(const NdbApiSignal* anApiSignal);
994  int receiveTCINDXREF(const NdbApiSignal*);
995  int receiveSCAN_TABREF(const NdbApiSignal*);
996  int receiveSCAN_TABCONF(const NdbApiSignal*, const Uint32*, Uint32 len);
997 
998  int doSend(); // Send all operations
999  int sendROLLBACK(); // Send of an ROLLBACK
1000  int sendTC_HBREP(); // Send a TCHBREP signal;
1001  int sendCOMMIT(); // Send a TC_COMMITREQ signal;
1002  void setGCI(int GCI); // Set the global checkpoint identity
1003 
1004  int OpCompleteFailure();
1005  int OpCompleteSuccess();
1006 
1007  void OpSent(); // Operation Sent with success
1008 
1009  // Free connection related resources and close transaction
1010  void release();
1011 
1012  // Release all operations in connection
1013  void releaseOperations();
1014 
1015  // Release all cursor operations in connection
1016  void releaseOps(NdbOperation*);
1017  void releaseQueries(NdbQueryImpl*);
1018  void releaseScanOperations(NdbIndexScanOperation*);
1019  bool releaseScanOperation(NdbIndexScanOperation** listhead,
1020  NdbIndexScanOperation** listtail,
1021  NdbIndexScanOperation* op);
1022  void releaseLockHandles();
1023 
1024  // Set the transaction identity of the transaction
1025  void setTransactionId(Uint64 aTransactionId);
1026 
1027  // Indicate something went wrong in the definition phase
1028  void setErrorCode(int anErrorCode);
1029 
1030  // Indicate something went wrong in the definition phase
1031  void setOperationErrorCode(int anErrorCode);
1032 
1033  // Indicate something went wrong in the definition phase
1034  void setOperationErrorCodeAbort(int anErrorCode, int abortOption = -1);
1035 
1036  int checkMagicNumber(); // Verify correct object
1037  NdbOperation* getNdbOperation(const class NdbTableImpl* aTable,
1038  NdbOperation* aNextOp = 0,
1039  bool useRec= false);
1040 
1042  NdbIndexOperation* getNdbIndexOperation(const class NdbIndexImpl* anIndex,
1043  const class NdbTableImpl* aTable,
1044  NdbOperation* aNextOp = 0,
1045  bool useRec= false);
1047  const NdbTableImpl* table);
1048 
1050  NdbOperation::LockMode lock_mode,
1051  NdbOperation::AbortOption default_ao,
1052  const NdbRecord *key_record,
1053  const char *key_row,
1054  const NdbRecord *attribute_record,
1055  const char *attribute_row,
1056  const unsigned char *mask,
1057  const NdbOperation::OperationOptions *opts,
1058  Uint32 sizeOfOptions,
1059  const NdbLockHandle* lh = 0);
1060 
1061  void handleExecuteCompletion();
1062 
1063  /****************************************************************************
1064  * These are the private variables of this class.
1065  ****************************************************************************/
1066 
1067  Uint32 ptr2int();
1068  Uint32 theId;
1069 
1070  // Keeps track of what the send method should do.
1071  enum SendStatusType {
1072  NotInit,
1073  InitState,
1074  sendOperations,
1075  sendCompleted,
1076  sendCOMMITstate,
1077  sendABORT,
1078  sendABORTfail,
1079  sendTC_ROLLBACK,
1080  sendTC_COMMIT,
1081  sendTC_OP
1082  };
1083  SendStatusType theSendStatus;
1084  NdbAsynchCallback theCallbackFunction; // Pointer to the callback function
1085  void* theCallbackObject; // The callback object pointer
1086  Uint32 theTransArrayIndex; // Current index in a transaction
1087  // array for this object
1088  TimeMillis_t theStartTransTime; // Start time of the transaction
1089 
1090  NdbError theError; // Errorcode on transaction
1091  int theErrorLine; // Method number of last error in NdbOperation
1092  NdbOperation* theErrorOperation; // The NdbOperation where the error occurred
1093 
1094  Ndb* theNdb; // Pointer to Ndb object
1095  NdbTransaction* theNext; // Next pointer. Used in idle list.
1096 
1097  NdbOperation* theFirstOpInList; // First operation in defining list.
1098  NdbOperation* theLastOpInList; // Last operation in defining list.
1099 
1100  NdbOperation* theFirstExecOpInList; // First executing operation in list
1101  NdbOperation* theLastExecOpInList; // Last executing operation in list.
1102 
1103 
1104  NdbOperation* theCompletedFirstOp; // First & last operation in completed
1105  NdbOperation* theCompletedLastOp; // operation list.
1106 
1107  Uint32 theNoOfOpSent; // How many operations have been sent
1108  Uint32 theNoOfOpCompleted; // How many operations have completed
1109  Uint32 theMyRef; // Our block reference
1110  Uint32 theTCConPtr; // Transaction Co-ordinator connection pointer.
1111  Uint64 theTransactionId; // theTransactionId of the transaction
1112  Uint64 theGlobalCheckpointId; // The gloabl checkpoint identity of the transaction
1113  Uint64 *p_latest_trans_gci; // Reference to latest gci for connection
1114  ConStatusType theStatus; // The status of the connection
1115  enum CompletionStatus {
1116  NotCompleted,
1117  CompletedSuccess,
1118  CompletedFailure,
1119  DefinitionFailure
1120  } theCompletionStatus; // The Completion status of the transaction
1121  CommitStatusType theCommitStatus; // The commit status of the transaction
1122  Uint32 theMagicNumber; // Magic Number to verify correct object
1123  // Current meanings :
1124  // 0x00FE11DC : NdbTransaction not in use
1125  // 0x37412619 : NdbTransaction in use
1126  // 0x00FE11DF : NdbTransaction for scan operation
1127  // scan definition not yet complete
1128  Uint32 thePriority; // Transaction Priority
1129 
1130  enum ReturnType { ReturnSuccess, ReturnFailure };
1131  ReturnType theReturnStatus; // Did we have any read/update/delete failing
1132  // to find the tuple.
1133  bool theTransactionIsStarted;
1134  bool theInUseState;
1135  bool theSimpleState;
1136 
1137  enum ListState {
1138  NotInList,
1139  InPreparedList,
1140  InSendList,
1141  InCompletedList
1142  } theListState;
1143 
1144  Uint32 theDBnode; // The database node we are connected to
1145  Uint32 theNodeSequence; // The sequence no of the db node
1146  bool theReleaseOnClose;
1147 
1155  Uint32 m_db_nodes[2];
1156  Uint32 m_failed_db_nodes[2];
1157 
1158  int report_node_failure(Uint32 id);
1159 
1160  // Scan operations
1161  bool m_waitForReply;
1162  NdbIndexScanOperation* m_theFirstScanOperation;
1163  NdbIndexScanOperation* m_theLastScanOperation;
1164 
1165  NdbIndexScanOperation* m_firstExecutedScanOp;
1166 
1167  // Scan operations or queries:
1168  // The operation or query actually performing the scan.
1169  // (Only one of theScanningOp/m_scanningQuery be non-NULL,
1170  // which indirectly indicates the type)
1171  NdbScanOperation* theScanningOp;
1172 
1173  Uint32 theBuddyConPtr;
1174  // optim: any blobs
1175  bool theBlobFlag;
1176  Uint8 thePendingBlobOps;
1177  Uint32 maxPendingBlobReadBytes;
1178  Uint32 maxPendingBlobWriteBytes;
1179  Uint32 pendingBlobReadBytes;
1180  Uint32 pendingBlobWriteBytes;
1181  inline bool hasBlobOperation() { return theBlobFlag; }
1182 
1183  static void sendTC_COMMIT_ACK(class NdbImpl *, NdbApiSignal *,
1184  Uint32 transId1, Uint32 transId2,
1185  Uint32 aBlockRef);
1186 
1187  void completedFail(const char * s);
1188 #ifdef VM_TRACE
1189  void printState();
1190 #endif
1191  bool checkState_TransId(const Uint32 * transId) const;
1192 
1193  void remove_list(NdbOperation*& head, NdbOperation*);
1194  void define_scan_op(NdbIndexScanOperation*);
1195 
1196  NdbLockHandle* m_theFirstLockHandle;
1197  NdbLockHandle* m_theLastLockHandle;
1198 
1199  NdbLockHandle* getLockHandle();
1200 
1201  friend class HugoOperations;
1202  friend struct Ndb_free_list_t<NdbTransaction>;
1203 
1204  NdbTransaction(const NdbTransaction&); // Not impl.
1205  NdbTransaction&operator=(const NdbTransaction&);
1206 
1207  // Query operation (aka multicursor)
1208  NdbQueryImpl* m_firstQuery; // First query in defining list.
1209  NdbQueryImpl* m_firstExecQuery; // First query to send for execution
1210  NdbQueryImpl* m_firstActiveQuery; // First query actively executing, or completed
1211 
1212  // Scan operations or queries:
1213  // The operation or query actually performing the scan.
1214  // (Only one of theScanningOp/m_scanningQuery be non-NULL,
1215  // which indirectly indicates the type)
1216  NdbQueryImpl* m_scanningQuery;
1217 
1218  Uint32 m_tcRef;
1219 };
1220 
1221 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1222 
1223 inline
1224 Uint32
1225 NdbTransaction::get_send_size()
1226 {
1227  return 0;
1228 }
1229 
1230 inline
1231 void
1232 NdbTransaction::set_send_size(Uint32 send_size)
1233 {
1234  (void)send_size; //unused
1235  return;
1236 }
1237 
1238 #ifdef NDB_NO_DROPPED_SIGNAL
1239 #include <stdlib.h>
1240 #endif
1241 
1242 inline
1243 int
1244 NdbTransaction::checkMagicNumber()
1245 {
1246  if (theMagicNumber == 0x37412619)
1247  return 0;
1248  else {
1249 #ifdef NDB_NO_DROPPED_SIGNAL
1250  abort();
1251 #endif
1252  return -1;
1253  }
1254 }
1255 
1256 inline
1257 bool
1258 NdbTransaction::checkState_TransId(const Uint32 * transId) const {
1259  const Uint32 tTmp1 = transId[0];
1260  const Uint32 tTmp2 = transId[1];
1261  Uint64 tRecTransId = (Uint64)tTmp1 + ((Uint64)tTmp2 << 32);
1262  bool b = theStatus == Connected && theTransactionId == tRecTransId;
1263  return b;
1264 }
1265 
1266 /************************************************************************************************
1267 void setTransactionId(Uint64 aTransactionId);
1268 
1269 Remark: Set the transaction identity.
1270 ************************************************************************************************/
1271 inline
1272 void
1273 NdbTransaction::setTransactionId(Uint64 aTransactionId)
1274 {
1275  theTransactionId = aTransactionId;
1276 }
1277 
1278 inline
1279 void
1280 NdbTransaction::setConnectedNodeId(Uint32 aNode, Uint32 aSequenceNo)
1281 {
1282  theDBnode = aNode;
1283  theNodeSequence = aSequenceNo;
1284 }
1285 /******************************************************************************
1286 int getConnectedNodeId();
1287 
1288 Return Value: Return theDBnode.
1289 Remark: Get Connected node id.
1290 ******************************************************************************/
1291 inline
1292 Uint32
1294 {
1295  return theDBnode;
1296 }
1297 /******************************************************************************
1298 void setMyBlockReference(int aBlockRef);
1299 
1300 Parameters: aBlockRef: The block refrerence.
1301 Remark: Set my block refrerence.
1302 ******************************************************************************/
1303 inline
1304 void
1305 NdbTransaction::setMyBlockReference(int aBlockRef)
1306 {
1307  theMyRef = aBlockRef;
1308 }
1309 /******************************************************************************
1310 void setTC_ConnectPtr(Uint32 aTCConPtr);
1311 
1312 Parameters: aTCConPtr: The connection pointer.
1313 Remark: Sets TC Connect pointer.
1314 ******************************************************************************/
1315 inline
1316 void
1317 NdbTransaction::setTC_ConnectPtr(Uint32 aTCConPtr)
1318 {
1319  theTCConPtr = aTCConPtr;
1320 }
1321 
1322 /******************************************************************************
1323 int getTC_ConnectPtr();
1324 
1325 Return Value: Return theTCConPtr.
1326 Remark: Gets TC Connect pointer.
1327 ******************************************************************************/
1328 inline
1329 int
1330 NdbTransaction::getTC_ConnectPtr()
1331 {
1332  return theTCConPtr;
1333 }
1334 
1335 inline
1336 void
1337 NdbTransaction::setBuddyConPtr(Uint32 aBuddyConPtr)
1338 {
1339  theBuddyConPtr = aBuddyConPtr;
1340 }
1341 
1342 inline
1343 Uint32 NdbTransaction::getBuddyConPtr()
1344 {
1345  return theBuddyConPtr;
1346 }
1347 
1348 /******************************************************************************
1349 NdbTransaction* next();
1350 
1351 inline
1352 void
1353 NdbTransaction::setBuddyConPtr(Uint32 aBuddyConPtr)
1354 {
1355  theBuddyConPtr = aBuddyConPtr;
1356 }
1357 
1358 inline
1359 Uint32 NdbTransaction::getBuddyConPtr()
1360 {
1361  return theBuddyConPtr;
1362 }
1363 
1364 Return Value: Return next pointer to NdbTransaction object.
1365 Remark: Get the next pointer.
1366 ******************************************************************************/
1367 inline
1369 NdbTransaction::next()
1370 {
1371  return theNext;
1372 }
1373 
1374 /******************************************************************************
1375 void next(NdbTransaction aTransaction);
1376 
1377 Parameters: aTransaction: The connection object.
1378 Remark: Sets the next pointer.
1379 ******************************************************************************/
1380 inline
1381 void
1382 NdbTransaction::next(NdbTransaction* aTransaction)
1383 {
1384  theNext = aTransaction;
1385 }
1386 
1387 /******************************************************************************
1388 ConStatusType Status();
1389 
1390 Return Value Return the ConStatusType.
1391 Parameters: aStatus: The status.
1392 Remark: Sets Connect status.
1393 ******************************************************************************/
1394 inline
1395 NdbTransaction::ConStatusType
1396 NdbTransaction::Status()
1397 {
1398  return theStatus;
1399 }
1400 
1401 /******************************************************************************
1402 void Status(ConStatusType aStatus);
1403 
1404 Parameters: aStatus: The status.
1405 Remark: Sets Connect status.
1406 ******************************************************************************/
1407 inline
1408 void
1409 NdbTransaction::Status( ConStatusType aStatus )
1410 {
1411  theStatus = aStatus;
1412 }
1413 
1414 
1415 /******************************************************************************
1416 void OpSent();
1417 
1418 Remark: An operation was sent with success that expects a response.
1419 ******************************************************************************/
1420 inline
1421 void
1422 NdbTransaction::OpSent()
1423 {
1424  theNoOfOpSent++;
1425 }
1426 
1427 /******************************************************************************
1428 void executePendingBlobOps();
1429 ******************************************************************************/
1430 inline
1431 int
1433 {
1434  if (thePendingBlobOps & flags) {
1435  // not executeNoBlobs because there can be new ops with blobs
1436  return execute(NoCommit);
1437  }
1438  return 0;
1439 }
1440 
1441 inline
1442 Uint32
1443 NdbTransaction::ptr2int(){
1444  return theId;
1445 }
1446 
1448 
1449 #endif // ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1450 
1451 #endif