MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NdbOperation.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 NdbOperation_H
19 #define NdbOperation_H
20 
21 #include <ndb_types.h>
22 #include "ndbapi_limits.h"
23 #include "NdbError.hpp"
24 #include "NdbReceiver.hpp"
25 #include "NdbDictionary.hpp"
26 #include "Ndb.hpp"
27 
28 class Ndb;
29 class NdbApiSignal;
30 class NdbRecAttr;
31 class NdbOperation;
32 class NdbTransaction;
33 class NdbColumnImpl;
34 class NdbBlob;
35 class TcKeyReq;
36 class NdbRecord;
37 class NdbInterpretedCode;
38 struct GenericSectionPtr;
39 class NdbLockHandle;
40 
46 {
47 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
48  friend class Ndb;
49  friend class NdbTransaction;
50  friend class NdbScanOperation;
51  friend class NdbScanReceiver;
52  friend class NdbScanFilter;
53  friend class NdbScanFilterImpl;
54  friend class NdbReceiver;
55  friend class NdbBlob;
56 #endif
57 
58 public:
68  enum Type {
70 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
71  = 0 // NdbOperation
72 #endif
74 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
75  = 1 // NdbIndexOperation
76 #endif
78 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
79  = 2 // NdbScanOperation
80 #endif
82 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
83  = 3 // NdbIndexScanOperation
84 #endif
85  };
86 
91  enum LockMode {
93 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
94  = 0
95 #endif
97 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
98  = 1
99 #endif
101 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
102  = 2,
103  LM_Dirty = 2,
104 #endif
106  };
107 
128  enum AbortOption {
132  };
133 
141  virtual int insertTuple();
142 
150  virtual int updateTuple();
151 
160  virtual int writeTuple();
161 
169  virtual int deleteTuple();
170 
178  virtual int readTuple(LockMode);
179 
180 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
181 
188  virtual int readTuple();
189 
198  virtual int readTupleExclusive();
199 
218  virtual int simpleRead();
219 
234  virtual int dirtyRead();
235 
248  virtual int committedRead();
249 
257  virtual int dirtyUpdate();
258 
266  virtual int dirtyWrite();
267 #endif
268 
269 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
270 
281  virtual int interpretedUpdateTuple();
282 
288  virtual int interpretedDeleteTuple();
289 #endif
290 
319 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
320  int equal(const char* anAttrName, const char* aValue, Uint32 len);
321 #endif
322  int equal(const char* anAttrName, const char* aValue);
323  int equal(const char* anAttrName, Int32 aValue);
324  int equal(const char* anAttrName, Uint32 aValue);
325  int equal(const char* anAttrName, Int64 aValue);
326  int equal(const char* anAttrName, Uint64 aValue);
327 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
328  int equal(Uint32 anAttrId, const char* aValue, Uint32 len);
329 #endif
330  int equal(Uint32 anAttrId, const char* aValue);
331  int equal(Uint32 anAttrId, Int32 aValue);
332  int equal(Uint32 anAttrId, Uint32 aValue);
333  int equal(Uint32 anAttrId, Int64 aValue);
334  int equal(Uint32 anAttrId, Uint64 aValue);
335 
373  NdbRecAttr* getValue(const char* anAttrName, char* aValue = 0);
374  NdbRecAttr* getValue(Uint32 anAttrId, char* aValue = 0);
375  NdbRecAttr* getValue(const NdbDictionary::Column*, char* val = 0);
376 
414 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
415  int setValue(const char* anAttrName, const char* aValue, Uint32 len);
416 #endif
417  int setValue(const char* anAttrName, const char* aValue);
418  int setValue(const char* anAttrName, Int32 aValue);
419  int setValue(const char* anAttrName, Uint32 aValue);
420  int setValue(const char* anAttrName, Int64 aValue);
421  int setValue(const char* anAttrName, Uint64 aValue);
422  int setValue(const char* anAttrName, float aValue);
423  int setValue(const char* anAttrName, double aValue);
424 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
425  int setAnyValue(Uint32 aValue);
426  int setOptimize(Uint32 options);
427 #endif
428 
429 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
430  int setValue(Uint32 anAttrId, const char* aValue, Uint32 len);
431 #endif
432  int setValue(Uint32 anAttrId, const char* aValue);
433  int setValue(Uint32 anAttrId, Int32 aValue);
434  int setValue(Uint32 anAttrId, Uint32 aValue);
435  int setValue(Uint32 anAttrId, Int64 aValue);
436  int setValue(Uint32 anAttrId, Uint64 aValue);
437  int setValue(Uint32 anAttrId, float aValue);
438  int setValue(Uint32 anAttrId, double aValue);
439 
457  virtual NdbBlob* getBlobHandle(const char* anAttrName);
458  virtual NdbBlob* getBlobHandle(Uint32 anAttrId);
459  virtual NdbBlob* getBlobHandle(const char* anAttrName) const;
460  virtual NdbBlob* getBlobHandle(Uint32 anAttrId) const;
461 
462 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
463 
485  int incValue(const char* anAttrName, Uint32 aValue);
486  int incValue(const char* anAttrName, Uint64 aValue);
487  int incValue(Uint32 anAttrId, Uint32 aValue);
488  int incValue(Uint32 anAttrId, Uint64 aValue);
489 
507  int subValue(const char* anAttrName, Uint32 aValue);
508  int subValue(const char* anAttrName, Uint64 aValue);
509  int subValue(Uint32 anAttrId, Uint32 aValue);
510  int subValue(Uint32 anAttrId, Uint64 aValue);
511 
527  int def_label(int labelNumber);
528 
541  int add_reg(Uint32 RegSource1, Uint32 RegSource2, Uint32 RegDest);
542 
555  int sub_reg(Uint32 RegSource1, Uint32 RegSource2, Uint32 RegDest);
556 
568  int load_const_u32(Uint32 RegDest, Uint32 Constant);
569  int load_const_u64(Uint32 RegDest, Uint64 Constant);
570 
581  int load_const_null(Uint32 RegDest);
582 
594  int read_attr(const char* anAttrName, Uint32 RegDest);
595 
607  int write_attr(const char* anAttrName, Uint32 RegSource);
608 
620  int read_attr(Uint32 anAttrId, Uint32 RegDest);
621 
633  int write_attr(Uint32 anAttrId, Uint32 RegSource);
634 
657  int branch_ge(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
658  int branch_gt(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
659  int branch_le(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
660  int branch_lt(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
661  int branch_eq(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
662  int branch_ne(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
663 
675  int branch_ne_null(Uint32 RegLvalue, Uint32 Label);
676 
688  int branch_eq_null(Uint32 RegLvalue, Uint32 Label);
689 
700  int branch_label(Uint32 Label);
701 
712  int branch_col_eq_null(Uint32 ColId, Uint32 Label);
713  int branch_col_ne_null(Uint32 ColId, Uint32 Label);
714 
728  int branch_col_eq(Uint32 ColId, const void * val, Uint32 len,
729  bool nopad, Uint32 Label);
730  int branch_col_ne(Uint32 ColId, const void * val, Uint32 len,
731  bool nopad, Uint32 Label);
732  int branch_col_lt(Uint32 ColId, const void * val, Uint32 len,
733  bool nopad, Uint32 Label);
734  int branch_col_le(Uint32 ColId, const void * val, Uint32 len,
735  bool nopad, Uint32 Label);
736  int branch_col_gt(Uint32 ColId, const void * val, Uint32 len,
737  bool nopad, Uint32 Label);
738  int branch_col_ge(Uint32 ColId, const void * val, Uint32 len,
739  bool nopad, Uint32 Label);
752  int branch_col_like(Uint32 ColId, const void *, Uint32 len,
753  bool nopad, Uint32 Label);
754  int branch_col_notlike(Uint32 ColId, const void *, Uint32 len,
755  bool nopad, Uint32 Label);
756 
781  int branch_col_and_mask_eq_mask(Uint32 ColId, const void *, Uint32 len,
782  bool nopad, Uint32 Label);
783  int branch_col_and_mask_ne_mask(Uint32 ColId, const void *, Uint32 len,
784  bool nopad, Uint32 Label);
785  int branch_col_and_mask_eq_zero(Uint32 ColId, const void *, Uint32 len,
786  bool nopad, Uint32 Label);
787  int branch_col_and_mask_ne_zero(Uint32 ColId, const void *, Uint32 len,
788  bool nopad, Uint32 Label);
789 
798  int interpret_exit_ok();
799 
811  int interpret_exit_nok(Uint32 ErrorCode);
812  int interpret_exit_nok();
813 
814 
826 
837  int def_subroutine(int SubroutineNumber);
838 
849  int call_sub(Uint32 Subroutine);
850 
860  int ret_sub();
861 #endif
862 
875  const NdbError & getNdbError() const;
876 
882 #ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
883  int getNdbErrorLine();
884 #endif
885  int getNdbErrorLine() const;
886 
891  const char* getTableName() const;
892 
897  const NdbDictionary::Table * getTable() const;
898 
902  Type getType() const;
903 
906 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
907 
917  RefreshRequest = 6,
923  };
924 #endif
925 
929  LockMode getLockMode() const { return theLockMode; }
930 
934  AbortOption getAbortOption() const;
935  int setAbortOption(AbortOption);
936 
940  virtual NdbTransaction* getNdbTransaction() const;
941 
942 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
943 
947  void setPartitionId(Uint32 id);
948  Uint32 getPartitionId() const;
949 #endif
950 
951  /* Specification of an extra value to get
952  * as part of an NdbRecord operation.
953  * Inputs :
954  * To specify an extra value to read, the
955  * caller must provide a column, and a
956  * (optionally NULL) appStorage pointer.
957  * Outputs :
958  * After the operation is defined, the
959  * recAttr member will contain a pointer
960  * to the NdbRecAttr object for receiving
961  * the data.
962  *
963  * appStorage pointer
964  * If the appStorage pointer is null, then
965  * the received value will be stored in
966  * memory managed by the NdbRecAttr object.
967  *
968  * If the appStorage pointer is non-null then
969  * the received value will be stored at the
970  * location pointed to (and will still be
971  * accessable via the NdbRecAttr object).
972  * It is the caller's responsibility to
973  * ensure that :
974  * - appStorage points to sufficient space
975  * to store any returned data.
976  * - Memory pointed to by appStorage is not
977  * reused/freed until after the execute()
978  * call returns.
979  *
980  * Limitation : Blob reads cannot be specified
981  * using GetValueSpec.
982  */
984  {
985  const NdbDictionary::Column *column;
986  void *appStorage;
987  NdbRecAttr *recAttr;
988  };
989 
990  /* Specification of an extra value to set
991  * as part of an NdbRecord operation.
992  * The value ptr must point to the value
993  * to set, or NULL if the attribute is to
994  * be set to NULL.
995  * The pointed to value is copied when the
996  * operation is defined and need not remain
997  * in place until execution time.
998  *
999  * Limitation : Blobs cannot be set using
1000  * SetValueSpec.
1001  */
1003  {
1004  const NdbDictionary::Column *column;
1005  const void * value;
1006  };
1007 
1008  /*
1009  * OperationOptions
1010  * These are options passed to the NdbRecord primary key and scan
1011  * takeover operation methods defined in the NdbTransaction and
1012  * NdbScanOperation classes.
1013  *
1014  * Each option type is marked as present by setting the corresponding
1015  * bit in the optionsPresent field. Only the option types marked in the
1016  * optionsPresent structure need have sensible data.
1017  * All data is copied out of the OperationOptions structure (and any
1018  * subtended structures) at operation definition time.
1019  * If no options are required, then NULL may be passed as the
1020  * OperationOptions pointer.
1021  *
1022  * Most methods take a supplementary sizeOfOptions parameter. This
1023  * is optional, and is intended to allow the interface implementation
1024  * to remain backwards compatible with older un-recompiled clients
1025  * that may pass an older (smaller) version of the OperationOptions
1026  * structure. This effect is achieved by passing
1027  * sizeof(OperationOptions) into this parameter.
1028  */
1030  {
1031  /*
1032  * Which options are present. See below for option details
1033  */
1034  Uint64 optionsPresent;
1035  enum Flags { OO_ABORTOPTION = 0x01,
1036  OO_GETVALUE = 0x02,
1037  OO_SETVALUE = 0x04,
1038  OO_PARTITION_ID = 0x08,
1039  OO_INTERPRETED = 0x10,
1040  OO_ANYVALUE = 0x20,
1041  OO_CUSTOMDATA = 0x40,
1042  OO_LOCKHANDLE = 0x80,
1043  OO_QUEUABLE = 0x100,
1044  OO_NOT_QUEUABLE = 0x200,
1045  OO_DEFERRED_CONSTAINTS = 0x400
1046  };
1047 
1048  /* An operation-specific abort option.
1049  * Only necessary if the default abortoption behaviour
1050  * is not satisfactory
1051  */
1052  AbortOption abortOption;
1053 
1054  /* Extra column values to be read */
1055  GetValueSpec *extraGetValues;
1056  Uint32 numExtraGetValues;
1057 
1058  /* Extra column values to be set */
1059  const SetValueSpec *extraSetValues;
1060  Uint32 numExtraSetValues;
1061 
1062  /* Specific partition to execute this operation on */
1063  Uint32 partitionId;
1064 
1065  /* Interpreted code to be executed in this operation
1066  * Only supported for update operations currently
1067  */
1068  const NdbInterpretedCode *interpretedCode;
1069 
1070  /* anyValue to be used for this operation */
1071  Uint32 anyValue;
1072 
1073  /* customData ptr for this operation */
1074  void * customData;
1075  };
1076 
1077  /* getLockHandle
1078  * Returns a pointer to this operation's LockHandle.
1079  * For NdbRecord, the lock handle must first be requested using
1080  * the OO_LOCKHANDLE operation option.
1081  * For non-NdbRecord operations, this call can be used alone.
1082  * The returned LockHandle cannot be used until the operation
1083  * has been executed.
1084  */
1085  const NdbLockHandle* getLockHandle() const;
1086  const NdbLockHandle* getLockHandle();
1087 
1088 protected:
1089 /******************************************************************************
1090  * These are the methods used to create and delete the NdbOperation objects.
1091  *****************************************************************************/
1092 
1093  bool needReply();
1094 /******************************************************************************
1095  * These methods are service routines used by the other NDB API classes.
1096  *****************************************************************************/
1097 //--------------------------------------------------------------
1098 // Initialise after allocating operation to a transaction
1099 //--------------------------------------------------------------
1100  int init(const class NdbTableImpl*, NdbTransaction* aCon, bool useRec);
1101  void initInterpreter();
1102 
1103  NdbOperation(Ndb* aNdb, Type aType = PrimaryKeyAccess);
1104  virtual ~NdbOperation();
1105  void next(NdbOperation*); // Set next pointer
1106  NdbOperation* next(); // Get next pointer
1107 
1108 public:
1109 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1110  const NdbOperation* next() const;
1111  const NdbRecAttr* getFirstRecAttr() const;
1112 
1113  void* getCustomData() const { return m_customData; }
1114  void setCustomData(void* p) { m_customData = p; }
1115 protected:
1116  void* m_customData;
1117 #endif
1118 protected:
1119 
1120  /*
1121  Methods that define the operation (readTuple(), getValue(), etc). can be
1122  called in any order, but not all are valid.
1123 
1124  To keep track of things, we store a 'current state of definitin operation'
1125  in member 'theStatus', with possible values given here.
1126  */
1127  enum OperationStatus
1128  {
1129  /*
1130  Init: Initial state after getting NdbOperation.
1131  At this point, the type of operation must be set (insertTuple(),
1132  readTuple(), etc.).
1133 
1134  */
1135  Init,
1136  /*
1137  OperationDefined: State in which the primary key search condition is
1138  defined with equal().
1139  */
1140  OperationDefined,
1141  /*
1142  TupleKeyDefined: All parts of the primary key have been specified with
1143  equal().
1144  */
1145  TupleKeyDefined,
1146  /*
1147  GetValue: The state in which the attributes to read are defined with
1148  calls to getValue(). For interpreted operations, these are the initial
1149  reads, before the interpreted program.
1150  */
1151  GetValue,
1152  /*
1153  SetValue: The state in which attributes to update are defined with
1154  calls to setValue().
1155  */
1156  SetValue,
1157  /*
1158  ExecInterpretedValue: The state in which the interpreted program is
1159  defined.
1160  */
1161  ExecInterpretedValue,
1162  /*
1163  SetValueInterpreted: Updates after interpreted program.
1164  */
1165  SetValueInterpreted,
1166  /*
1167  FinalGetValue: Attributes to read after interpreted program.
1168  */
1169  FinalGetValue,
1170  /*
1171  SubroutineExec: In the middle of a subroutine definition being defined.
1172  */
1173  SubroutineExec,
1174  /*
1175  SubroutineEnd: A subroutine has been fully defined, but a new subroutine
1176  definition may still be defined after.
1177  */
1178  SubroutineEnd,
1179  /*
1180  WaitResponse: Operation has been sent to kernel, waiting for reply.
1181  */
1182  WaitResponse,
1183  /*
1184  Finished: The TCKEY{REF,CONF} signal for this operation has been
1185  received.
1186  */
1187  Finished,
1188  /*
1189  NdbRecord: For operations using NdbRecord. Built in a single call (like
1190  NdbTransaction::readTuple(), and no state transitions possible before
1191  execute().
1192  */
1193  UseNdbRecord
1194  };
1195 
1196  OperationStatus Status(); // Read the status information
1197 
1198  void Status(OperationStatus); // Set the status information
1199 
1200  void NdbCon(NdbTransaction*); // Set reference to connection
1201  // object.
1202 
1203  virtual void release(); // Release all operations
1204  // connected to
1205  // the operations object.
1206  void postExecuteRelease(); // Release resources
1207  // no longer needed after
1208  // exceute
1209  void setStartIndicator();
1210 
1211  /* Utility method to 'add' operation options to an NdbOperation
1212  *
1213  * @return 0 for success. NDBAPI to set error otherwise.
1214  */
1215  static int handleOperationOptions (const OperationType type,
1216  const OperationOptions *opts,
1217  const Uint32 sizeOfOptions,
1218  NdbOperation *op);
1219 
1220 /******************************************************************************
1221  * The methods below is the execution part of the NdbOperation
1222  * class. This is where the NDB signals are sent and received. The
1223  * operation can send TC[KEY/INDX]REQ, [INDX]ATTRINFO.
1224  * It can receive TC[KEY/INDX]CONF, TC[KEY/INDX]REF, [INDX]ATTRINFO.
1225  * When an operation is received in its fulness or a refuse message
1226  * was sent, then the connection object is told about this situation.
1227  *****************************************************************************/
1228 
1229  int doSendKeyReq(int processorId, GenericSectionPtr* secs, Uint32 numSecs);
1230  int doSend(int ProcessorId, Uint32 lastFlag);
1231  virtual int prepareSend(Uint32 TC_ConnectPtr,
1232  Uint64 TransactionId,
1233  AbortOption);
1234  virtual void setLastFlag(NdbApiSignal* signal, Uint32 lastFlag);
1235 
1236  int prepareSendInterpreted(); // Help routine to prepare*
1237 
1238  int initInterpretedInfo(const NdbInterpretedCode *code,
1239  Uint32*& interpretedInfo,
1240  Uint32* stackSpace,
1241  Uint32 stackSpaceEntries,
1242  Uint32*& dynamicSpace);
1243 
1244  void freeInterpretedInfo(Uint32*& dynamicSpace);
1245 
1246 
1247  /* Method for adding signals for an interpreted program
1248  * to the signal train
1249  */
1250  int buildInterpretedProgramSignals(Uint32 aTC_ConnectPtr,
1251  Uint64 aTransId,
1252  Uint32 **attrInfoPtr,
1253  Uint32 *remain,
1254  const NdbInterpretedCode *code,
1255  Uint32 *interpretedWorkspace,
1256  bool mainProgram,
1257  Uint32 &wordsWritten);
1258 
1259  // Method which prepares signals at operation definition time.
1260  int buildSignalsNdbRecord(Uint32 aTC_ConnectPtr, Uint64 aTransId,
1261  const Uint32 * read_mask);
1262 
1263  // Method which does final preparations at execute time.
1264  int prepareSendNdbRecord(AbortOption ao);
1265 
1266  /* Helper routines for buildSignalsNdbRecord(). */
1267  Uint32 fillTcKeyReqHdr(TcKeyReq *tcKeyReq,
1268  Uint32 connectPtr,
1269  Uint64 transId);
1270  int allocKeyInfo();
1271  int allocAttrInfo();
1272  int insertKEYINFO_NdbRecord(const char *value,
1273  Uint32 byteSize);
1274  int insertATTRINFOHdr_NdbRecord(Uint32 attrId,
1275  Uint32 attrLen);
1276  int insertATTRINFOData_NdbRecord(const char *value,
1277  Uint32 size);
1278 
1279  int receiveTCKEYREF(const NdbApiSignal*);
1280 
1281  int checkMagicNumber(bool b = true); // Verify correct object
1282 
1283  int checkState_TransId(const NdbApiSignal* aSignal);
1284 
1285 /******************************************************************************
1286  * These are support methods only used locally in this class.
1287 ******************************************************************************/
1288 
1289  virtual int equal_impl(const NdbColumnImpl*,const char* aValue);
1290  virtual NdbRecAttr* getValue_impl(const NdbColumnImpl*, char* aValue = 0);
1291  NdbRecAttr* getValue_NdbRecord(const NdbColumnImpl* tAttrInfo, char* aValue);
1292  int setValue(const NdbColumnImpl* anAttrObject, const char* aValue);
1293  NdbBlob* getBlobHandle(NdbTransaction* aCon, const NdbColumnImpl* anAttrObject);
1294  NdbBlob* getBlobHandle(NdbTransaction* aCon, const NdbColumnImpl* anAttrObject) const;
1295  int incValue(const NdbColumnImpl* anAttrObject, Uint32 aValue);
1296  int incValue(const NdbColumnImpl* anAttrObject, Uint64 aValue);
1297  int subValue(const NdbColumnImpl* anAttrObject, Uint32 aValue);
1298  int subValue(const NdbColumnImpl* anAttrObject, Uint64 aValue);
1299  int read_attr(const NdbColumnImpl* anAttrObject, Uint32 RegDest);
1300  int write_attr(const NdbColumnImpl* anAttrObject, Uint32 RegSource);
1301  int branch_reg_reg(Uint32 type, Uint32, Uint32, Uint32);
1302  int branch_col(Uint32 type, Uint32, const void *, Uint32, Uint32 Label);
1303  int branch_col_null(Uint32 type, Uint32 col, Uint32 Label);
1304  NdbBlob *linkInBlobHandle(NdbTransaction *aCon,
1305  const NdbColumnImpl *column,
1306  NdbBlob * & lastPtr);
1307  int getBlobHandlesNdbRecord(NdbTransaction* aCon, const Uint32 * mask);
1308  int getBlobHandlesNdbRecordDelete(NdbTransaction* aCon,
1309  bool checkReadSet, const Uint32 * mask);
1310 
1311  // Handle ATTRINFO signals
1312  int insertATTRINFO(Uint32 aData);
1313  int insertATTRINFOloop(const Uint32* aDataPtr, Uint32 aLength);
1314 
1315  int insertKEYINFO(const char* aValue,
1316  Uint32 aStartPosition,
1317  Uint32 aKeyLenInByte);
1318  void reorderKEYINFO();
1319 
1320  virtual void setErrorCode(int aErrorCode) const;
1321  virtual void setErrorCodeAbort(int aErrorCode) const;
1322 
1323  bool isNdbRecordOperation();
1324  int incCheck(const NdbColumnImpl* anAttrObject);
1325  int initial_interpreterCheck();
1326  int intermediate_interpreterCheck();
1327  int read_attrCheck(const NdbColumnImpl* anAttrObject);
1328  int write_attrCheck(const NdbColumnImpl* anAttrObject);
1329  int labelCheck();
1330  int insertCall(Uint32 aCall);
1331  int insertBranch(Uint32 aBranch);
1332 
1333  Uint32 ptr2int() { return theReceiver.getId(); };
1334  Uint32 ptr2int() const { return theReceiver.getId(); };
1335 
1336  // get table or index key from prepared signals
1337  int getKeyFromTCREQ(Uint32* data, Uint32 & size);
1338 
1339  int getLockHandleImpl();
1340  int prepareGetLockHandle();
1341  int prepareGetLockHandleNdbRecord();
1342 
1343  virtual void setReadLockMode(LockMode lockMode);
1344 
1345 /******************************************************************************
1346  * These are the private variables that are defined in the operation objects.
1347  *****************************************************************************/
1348 
1349  Type m_type;
1350 
1351  NdbReceiver theReceiver;
1352 
1353  NdbError theError; // Errorcode
1354  int theErrorLine; // Error line
1355 
1356  Ndb* theNdb; // Point back to the Ndb object.
1357  NdbTransaction* theNdbCon; // Point back to the connection object.
1358  NdbOperation* theNext; // Next pointer to operation.
1359 
1360  union {
1361  NdbApiSignal* theTCREQ; // The TC[KEY/INDX]REQ signal object
1362  NdbApiSignal* theSCAN_TABREQ;
1363  NdbApiSignal* theRequest;
1364  };
1365 
1366  NdbApiSignal* theFirstATTRINFO; // The first ATTRINFO signal object
1367  NdbApiSignal* theCurrentATTRINFO; // The current ATTRINFO signal object
1368  Uint32 theTotalCurrAI_Len; // The total number of attribute info
1369  // words currently defined
1370  Uint32 theAI_LenInCurrAI; // The number of words defined in the
1371  // current ATTRINFO signal
1372  NdbApiSignal* theLastKEYINFO; // The first KEYINFO signal object
1373 
1374  class NdbLabel* theFirstLabel;
1375  class NdbLabel* theLastLabel;
1376  class NdbBranch* theFirstBranch;
1377  class NdbBranch* theLastBranch;
1378  class NdbCall* theFirstCall;
1379  class NdbCall* theLastCall;
1380  class NdbSubroutine* theFirstSubroutine;
1381  class NdbSubroutine* theLastSubroutine;
1382  Uint32 theNoOfLabels;
1383  Uint32 theNoOfSubroutines;
1384 
1385  Uint32* theKEYINFOptr; // Pointer to where to write KEYINFO
1386  Uint32 keyInfoRemain; // KeyInfo space in current signal
1387  Uint32* theATTRINFOptr; // Pointer to where to write ATTRINFO
1388  Uint32 attrInfoRemain; // AttrInfo space in current signal
1389 
1390  /*
1391  The table object for the table to read or modify (for index operations,
1392  it is the table being indexed.)
1393  */
1394  const class NdbTableImpl* m_currentTable;
1395 
1396  /*
1397  The table object for the index used to access the table. For primary key
1398  lookups, it is equal to m_currentTable.
1399  */
1400  const class NdbTableImpl* m_accessTable;
1401 
1402  // Set to TRUE when a tuple key attribute has been defined.
1403  Uint32 theTupleKeyDefined[NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY][3];
1404 
1405  Uint32 theTotalNrOfKeyWordInSignal; // The total number of
1406  // keyword in signal.
1407 
1408  Uint32 theTupKeyLen; // Length of the tuple key in words
1409  // left until done
1410  Uint8 theNoOfTupKeyLeft; // The number of tuple key attributes
1411  OperationType theOperationType; // Read Request, Update Req......
1412 
1413  LockMode theLockMode; // Can be set to WRITE if read operation
1414  OperationStatus theStatus; // The status of the operation.
1415 
1416  Uint32 theMagicNumber; // Magic number to verify that object
1417  // is correct
1418  Uint32 theScanInfo; // Scan info bits (take over flag etc)
1419  Uint32 theDistributionKey; // Distribution Key size if used
1420 
1421  Uint32 theSubroutineSize; // Size of subroutines for interpretation
1422  Uint32 theInitialReadSize; // Size of initial reads for interpretation
1423  Uint32 theInterpretedSize; // Size of interpretation
1424  Uint32 theFinalUpdateSize; // Size of final updates for interpretation
1425  Uint32 theFinalReadSize; // Size of final reads for interpretation
1426 
1427  Uint8 theStartIndicator; // Indicator of whether start operation
1428  Uint8 theCommitIndicator; // Indicator of whether commit operation
1429  Uint8 theSimpleIndicator; // Indicator of whether simple operation
1430  Uint8 theDirtyIndicator; // Indicator of whether dirty operation
1431  Uint8 theInterpretIndicator; // Indicator of whether interpreted operation
1432  // Note that scan operations always have this
1433  // set true
1434  Int8 theDistrKeyIndicator_; // Indicates whether distr. key is used
1435 
1436  enum OP_FLAGS {
1437  OF_NO_DISK = 0x1,
1438 
1439  /*
1440  For NdbRecord, this flag indicates that we need to send the Event-attached
1441  word set by setAnyValue().
1442  */
1443  OF_USE_ANY_VALUE = 0x2,
1444  OF_QUEUEABLE = 0x4,
1445  OF_DEFERRED_CONSTRAINTS = 0x8
1446  };
1447  Uint8 m_flags;
1448 
1449  Uint8 _unused1;
1450 
1451  Uint16 m_tcReqGSN;
1452  Uint16 m_keyInfoGSN;
1453  Uint16 m_attrInfoGSN;
1454 
1455  /*
1456  Members for NdbRecord operations.
1457  ToDo: We might overlap these (with anonymous unions) with members used
1458  for NdbRecAttr access (theKEYINFOptr etc), to save a bit of memory. Not
1459  sure if it is worth the loss of code clarity though.
1460  */
1461 
1462  /*
1463  NdbRecord describing the placement of Primary key in row.
1464  As a special case, we set this to NULL for scan lock take-over operations,
1465  in which case the m_key_row points to keyinfo obtained from the KEYINFO20
1466  signal.
1467  */
1468  const NdbRecord *m_key_record;
1469  /* Row containing the primary key to operate on, or KEYINFO20 data. */
1470  const char *m_key_row;
1471  /* Size in words of keyinfo in m_key_row. */
1472  Uint32 m_keyinfo_length;
1473  /*
1474  NdbRecord describing attributes to update (or read for scans).
1475  We also use m_attribute_record!=NULL to indicate that the operation is
1476  using the NdbRecord interface (as opposed to NdbRecAttr).
1477  */
1478  const NdbRecord *m_attribute_record;
1479  /* Row containing the update values. */
1480  const char *m_attribute_row;
1481  /*
1482  Bitmask to disable selected columns.
1483  Do not use clas Bitmask/BitmaskPOD here, to avoid having to
1484  #include <Bitmask.hpp> in application code.
1485  */
1486  Uint32 m_unused_read_mask[(128+31)>>5];
1487  /* Interpreted program for NdbRecord operations. */
1488  const NdbInterpretedCode *m_interpreted_code;
1489 
1490  /* Ptr to supplied SetValueSpec for NdbRecord */
1491  const SetValueSpec *m_extraSetValues;
1492  Uint32 m_numExtraSetValues;
1493 
1494  Uint32 m_any_value; // Valid if m_use_any_value!=0
1495 
1496  // Blobs in this operation
1497  NdbBlob* theBlobList;
1498 
1499  // ONLY for blob V2 implementation (not virtual, only PK ops)
1500  NdbRecAttr*
1501  getVarValue(const NdbColumnImpl*, char* aBareValue, Uint16* aLenLoc);
1502  int
1503  setVarValue(const NdbColumnImpl*, const char* aBareValue, const Uint16& aLen);
1504 
1505  /*
1506  * Abort option per operation, used by blobs.
1507  * See also comments on enum AbortOption.
1508  */
1509  Int8 m_abortOption;
1510 
1511  /*
1512  * For blob impl, option to not propagate error to trans level.
1513  * Could be AO_IgnoreError variant if we want it public.
1514  * Ignored unless AO_IgnoreError is also set.
1515  */
1516  Int8 m_noErrorPropagation;
1517 
1518  friend struct Ndb_free_list_t<NdbOperation>;
1519 
1520  Uint32 repack_read(Uint32 len);
1521 
1522  NdbLockHandle* theLockHandle;
1523 
1524  bool m_blob_lock_upgraded; /* Did Blob code upgrade LM_CommittedRead
1525  * to LM_Read?
1526  */
1527 
1528 private:
1529  NdbOperation(const NdbOperation&); // Not impl.
1530  NdbOperation&operator=(const NdbOperation&);
1531 };
1532 
1533 #ifdef NDB_NO_DROPPED_SIGNAL
1534 #include <stdlib.h>
1535 #endif
1536 
1537 #ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1538 
1539 inline
1540 int
1541 NdbOperation::checkMagicNumber(bool b)
1542 {
1543 #ifndef NDB_NO_DROPPED_SIGNAL
1544  (void)b; // unused param in this context
1545 #endif
1546  if (theMagicNumber != 0xABCDEF01){
1547 #ifdef NDB_NO_DROPPED_SIGNAL
1548  if(b) abort();
1549 #endif
1550  return -1;
1551  }
1552  return 0;
1553 }
1554 
1555 inline
1556 void
1557 NdbOperation::setStartIndicator()
1558 {
1559  theStartIndicator = 1;
1560 }
1561 
1562 inline
1563 int
1565 {
1566  // delegate to overloaded const function for same semantics
1567  const NdbOperation * const cthis = this;
1568  return cthis->NdbOperation::getNdbErrorLine();
1569 }
1570 
1571 inline
1572 int
1574 {
1575  return theErrorLine;
1576 }
1577 
1578 /******************************************************************************
1579 void next(NdbOperation* aNdbOperation);
1580 
1581 Parameters: aNdbOperation: Pointers to the NdbOperation object.
1582 Remark: Set the next variable of the operation object.
1583 ******************************************************************************/
1584 inline
1585 void
1586 NdbOperation::next(NdbOperation* aNdbOperation)
1587 {
1588  theNext = aNdbOperation;
1589 }
1590 
1591 /******************************************************************************
1592 NdbOperation* next();
1593 
1594 Return Value: Return next pointer to NdbOperation object.
1595 Remark: Get the next variable of the operation object.
1596 ******************************************************************************/
1597 inline
1598 NdbOperation*
1599 NdbOperation::next()
1600 {
1601  return theNext;
1602 }
1603 
1604 inline
1605 const NdbOperation*
1606 NdbOperation::next() const
1607 {
1608  return theNext;
1609 }
1610 
1611 inline
1612 const NdbRecAttr*
1613 NdbOperation::getFirstRecAttr() const
1614 {
1615  return theReceiver.theFirstRecAttr;
1616 }
1617 
1618 /******************************************************************************
1619 Type getType()
1620 
1621 Return Value Return the Type.
1622 Remark: Gets type of access.
1623 ******************************************************************************/
1624 inline
1627 {
1628  return m_type;
1629 }
1630 
1631 /******************************************************************************
1632 OperationStatus Status();
1633 
1634 Return Value Return the OperationStatus.
1635 Parameters: aStatus: The status.
1636 Remark: Sets Operation status.
1637 ******************************************************************************/
1638 inline
1639 NdbOperation::OperationStatus
1640 NdbOperation::Status()
1641 {
1642  return theStatus;
1643 }
1644 
1645 /******************************************************************************
1646 void Status(OperationStatus aStatus);
1647 
1648 Parameters: aStatus: The status.
1649 Remark: Sets Operation
1650  status.
1651 ******************************************************************************/
1652 inline
1653 void
1654 NdbOperation::Status( OperationStatus aStatus )
1655 {
1656  theStatus = aStatus;
1657 }
1658 
1659 /******************************************************************************
1660 void NdbCon(NdbTransaction* aNdbCon);
1661 
1662 Parameters: aNdbCon: Pointers to NdbTransaction object.
1663 Remark: Set the reference to the connection in the operation object.
1664 ******************************************************************************/
1665 inline
1666 void
1667 NdbOperation::NdbCon(NdbTransaction* aNdbCon)
1668 {
1669  theNdbCon = aNdbCon;
1670 }
1671 
1672 inline
1673 int
1674 NdbOperation::equal(const char* anAttrName, const char* aValue,
1675  Uint32 len)
1676 {
1677  (void)len; // unused
1678  return equal(anAttrName, aValue);
1679 }
1680 
1681 inline
1682 int
1683 NdbOperation::equal(const char* anAttrName, Int32 aPar)
1684 {
1685  return equal(anAttrName, (const char*)&aPar, (Uint32)4);
1686 }
1687 
1688 inline
1689 int
1690 NdbOperation::equal(const char* anAttrName, Uint32 aPar)
1691 {
1692  return equal(anAttrName, (const char*)&aPar, (Uint32)4);
1693 }
1694 
1695 inline
1696 int
1697 NdbOperation::equal(const char* anAttrName, Int64 aPar)
1698 {
1699  return equal(anAttrName, (const char*)&aPar, (Uint32)8);
1700 }
1701 
1702 inline
1703 int
1704 NdbOperation::equal(const char* anAttrName, Uint64 aPar)
1705 {
1706  return equal(anAttrName, (const char*)&aPar, (Uint32)8);
1707 }
1708 
1709 inline
1710 int
1711 NdbOperation::equal(Uint32 anAttrId, const char* aValue,
1712  Uint32 len)
1713 {
1714  (void)len; // unused
1715  return equal(anAttrId, aValue);
1716 }
1717 
1718 inline
1719 int
1720 NdbOperation::equal(Uint32 anAttrId, Int32 aPar)
1721 {
1722  return equal(anAttrId, (const char*)&aPar, (Uint32)4);
1723 }
1724 
1725 inline
1726 int
1727 NdbOperation::equal(Uint32 anAttrId, Uint32 aPar)
1728 {
1729  return equal(anAttrId, (const char*)&aPar, (Uint32)4);
1730 }
1731 
1732 inline
1733 int
1734 NdbOperation::equal(Uint32 anAttrId, Int64 aPar)
1735 {
1736  return equal(anAttrId, (const char*)&aPar, (Uint32)8);
1737 }
1738 
1739 inline
1740 int
1741 NdbOperation::equal(Uint32 anAttrId, Uint64 aPar)
1742 {
1743  return equal(anAttrId, (const char*)&aPar, (Uint32)8);
1744 }
1745 
1746 inline
1747 int
1748 NdbOperation::setValue(const char* anAttrName, const char* aValue,
1749  Uint32 len)
1750 {
1751  (void)len; // unused
1752  return setValue(anAttrName, aValue);
1753 }
1754 
1755 inline
1756 int
1757 NdbOperation::setValue(const char* anAttrName, Int32 aPar)
1758 {
1759  return setValue(anAttrName, (const char*)&aPar, (Uint32)4);
1760 }
1761 
1762 inline
1763 int
1764 NdbOperation::setValue(const char* anAttrName, Uint32 aPar)
1765 {
1766  return setValue(anAttrName, (const char*)&aPar, (Uint32)4);
1767 }
1768 
1769 inline
1770 int
1771 NdbOperation::setValue(const char* anAttrName, Int64 aPar)
1772 {
1773  return setValue(anAttrName, (const char*)&aPar, (Uint32)8);
1774 }
1775 
1776 inline
1777 int
1778 NdbOperation::setValue(const char* anAttrName, Uint64 aPar)
1779 {
1780  return setValue(anAttrName, (const char*)&aPar, (Uint32)8);
1781 }
1782 
1783 inline
1784 int
1785 NdbOperation::setValue(const char* anAttrName, float aPar)
1786 {
1787  return setValue(anAttrName, (const char*)&aPar, (Uint32)4);
1788 }
1789 
1790 inline
1791 int
1792 NdbOperation::setValue(const char* anAttrName, double aPar)
1793 {
1794  return setValue(anAttrName, (const char*)&aPar, (Uint32)8);
1795 }
1796 
1797 inline
1798 int
1799 NdbOperation::setValue(Uint32 anAttrId, const char* aValue,
1800  Uint32 len)
1801 {
1802  (void)len; // unused
1803  return setValue(anAttrId, aValue);
1804 }
1805 
1806 inline
1807 int
1808 NdbOperation::setValue(Uint32 anAttrId, Int32 aPar)
1809 {
1810  return setValue(anAttrId, (const char*)&aPar, (Uint32)4);
1811 }
1812 
1813 inline
1814 int
1815 NdbOperation::setValue(Uint32 anAttrId, Uint32 aPar)
1816 {
1817  return setValue(anAttrId, (const char*)&aPar, (Uint32)4);
1818 }
1819 
1820 inline
1821 int
1822 NdbOperation::setValue(Uint32 anAttrId, Int64 aPar)
1823 {
1824  return setValue(anAttrId, (const char*)&aPar, (Uint32)8);
1825 }
1826 
1827 inline
1828 int
1829 NdbOperation::setValue(Uint32 anAttrId, Uint64 aPar)
1830 {
1831  return setValue(anAttrId, (const char*)&aPar, (Uint32)8);
1832 }
1833 
1834 inline
1835 int
1836 NdbOperation::setValue(Uint32 anAttrId, float aPar)
1837 {
1838  return setValue(anAttrId, (char*)&aPar, (Uint32)4);
1839 }
1840 
1841 inline
1842 int
1843 NdbOperation::setValue(Uint32 anAttrId, double aPar)
1844 {
1845  return setValue(anAttrId, (const char*)&aPar, (Uint32)8);
1846 }
1847 
1848 #endif // doxygen
1849 
1850 #endif