1
/* Copyright (C) 2003 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
16
#ifndef NdbOperation_H
17
#define NdbOperation_H
19
#include <ndb_types.h>
20
#include "ndbapi_limits.h"
21
#include "NdbError.hpp"
22
#include "NdbReceiver.hpp"
23
#include "NdbDictionary.hpp"
36
* @brief Class of operations for use in transactions.
40
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
42
friend class NdbTransaction;
43
friend class NdbScanOperation;
44
friend class NdbScanReceiver;
45
friend class NdbScanFilter;
46
friend class NdbScanFilterImpl;
47
friend class NdbReceiver;
53
* @name Define Standard Operation Type
58
* Different access types (supported by sub-classes of NdbOperation)
62
PrimaryKeyAccess ///< Read, insert, update, or delete using pk
63
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
66
,UniqueIndexAccess ///< Read, update, or delete using unique index
67
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
68
= 1 // NdbIndexOperation
70
,TableScan ///< Full table scan
71
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
72
= 2 // NdbScanOperation
74
,OrderedIndexScan ///< Ordered index scan
75
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
76
= 3 // NdbIndexScanOperation
81
* Lock when performing read
85
LM_Read ///< Read with shared lock
86
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
89
,LM_Exclusive ///< Read with exclusive lock
90
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
93
,LM_CommittedRead ///< Ignore locks, read last committed value
94
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
98
LM_SimpleRead = 3 ///< Read with shared lock, but release lock directly
102
* How should transaction be handled if operation fails.
104
* If AO_IgnoreError, a failure in one operation will not abort the
105
* transaction, and NdbTransaction::execute() will return 0 (success). Use
106
* NdbOperation::getNdbError() to check for errors from individual
109
* If AbortOnError, a failure in one operation will abort the transaction
110
* and cause NdbTransaction::execute() to return -1.
112
* Abort option can be set on execute(), or in the individual operation.
113
* Setting AO_IgnoreError or AbortOnError in execute() overrides the settings
114
* on individual operations. Setting DefaultAbortOption in execute() (the
115
* default) causes individual operation settings to be used.
117
* For READ, default is AO_IgnoreError
118
* DML, default is AbortOnError
119
* CommittedRead does _only_ support AO_IgnoreError
122
DefaultAbortOption = -1,///< Use default as specified by op-type
123
AbortOnError = 0, ///< Abort transaction on failed operation
124
AO_IgnoreError = 2 ///< Transaction continues on failed operation
128
* Define the NdbOperation to be a standard operation of type insertTuple.
129
* When calling NdbTransaction::execute, this operation
130
* adds a new tuple to the table.
132
* @return 0 if successful otherwise -1.
134
virtual int insertTuple();
137
* Define the NdbOperation to be a standard operation of type updateTuple.
138
* When calling NdbTransaction::execute, this operation
139
* updates a tuple in the table.
141
* @return 0 if successful otherwise -1.
143
virtual int updateTuple();
146
* Define the NdbOperation to be a standard operation of type writeTuple.
147
* When calling NdbTransaction::execute, this operation
148
* writes a tuple to the table.
149
* If the tuple exists, it updates it, otherwise an insert takes place.
151
* @return 0 if successful otherwise -1.
153
virtual int writeTuple();
156
* Define the NdbOperation to be a standard operation of type deleteTuple.
157
* When calling NdbTransaction::execute, this operation
160
* @return 0 if successful otherwise -1.
162
virtual int deleteTuple();
165
* Define the NdbOperation to be a standard operation of type readTuple.
166
* When calling NdbTransaction::execute, this operation
169
* @return 0 if successful otherwise -1.
171
virtual int readTuple(LockMode);
173
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
175
* Define the NdbOperation to be a standard operation of type readTuple.
176
* When calling NdbTransaction::execute, this operation
179
* @return 0 if successful otherwise -1.
181
virtual int readTuple();
184
* Define the NdbOperation to be a standard operation of type
185
* readTupleExclusive.
186
* When calling NdbTransaction::execute, this operation
187
* read a tuple using an exclusive lock.
189
* @return 0 if successful otherwise -1.
191
virtual int readTupleExclusive();
194
* Define the NdbOperation to be a standard operation of type
196
* When calling NdbTransaction::execute, this operation
197
* reads an existing tuple (using shared read lock),
198
* but releases lock immediately after read.
200
* @note Using this operation twice in the same transaction
201
* may produce different results (e.g. if there is another
202
* transaction which updates the value between the
205
* Note that simpleRead can read the value from any database node while
206
* standard read always read the value on the database node which is
207
* primary for the record.
209
* @return 0 if successful otherwise -1.
211
virtual int simpleRead();
214
* Define the NdbOperation to be a standard operation of type committedRead.
215
* When calling NdbTransaction::execute, this operation
216
* read latest committed value of the record.
218
* This means that if another transaction is updating the
219
* record, then the current transaction will not wait.
220
* It will instead use the latest committed value of the
222
* dirtyRead is a deprecated name for committedRead
224
* @return 0 if successful otherwise -1.
227
virtual int dirtyRead();
230
* Define the NdbOperation to be a standard operation of type committedRead.
231
* When calling NdbTransaction::execute, this operation
232
* read latest committed value of the record.
234
* This means that if another transaction is updating the
235
* record, then the current transaction will not wait.
236
* It will instead use the latest committed value of the
239
* @return 0 if successful otherwise -1.
241
virtual int committedRead();
244
* Define the NdbOperation to be a standard operation of type dirtyUpdate.
245
* When calling NdbTransaction::execute, this operation
246
* updates without two-phase commit.
248
* @return 0 if successful otherwise -1.
250
virtual int dirtyUpdate();
253
* Define the NdbOperation to be a standard operation of type dirtyWrite.
254
* When calling NdbTransaction::execute, this operation
255
* writes without two-phase commit.
257
* @return 0 if successful otherwise -1.
259
virtual int dirtyWrite();
262
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
263
/** @} *********************************************************************/
265
* @name Define Interpreted Program Operation Type
270
* Update a tuple using an interpreted program.
272
* @return 0 if successful otherwise -1.
274
virtual int interpretedUpdateTuple();
277
* Delete a tuple using an interpreted program.
279
* @return 0 if successful otherwise -1.
281
virtual int interpretedDeleteTuple();
284
/** @} *********************************************************************/
287
* @name Specify Search Conditions
291
* Define a search condition with equality.
292
* The condition is true if the attribute has the given value.
293
* To set search conditions on multiple attributes,
294
* use several equals (then all of them must be satisfied for the
295
* tuple to be selected).
297
* @note For insertTuple() it is also allowed to define the
298
* search key by using setValue().
300
* @note There are 10 versions of equal() with
301
* slightly different parameters.
303
* @note If attribute has fixed size, value must include all bytes.
304
* In particular a Char must be native-blank padded.
305
* If attribute has variable size, value must start with
306
* 1 or 2 little-endian length bytes (2 if Long*).
308
* @param anAttrName Attribute name
309
* @param aValue Attribute value.
310
* @return -1 if unsuccessful.
312
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
313
int equal(const char* anAttrName, const char* aValue, Uint32 len);
315
int equal(const char* anAttrName, const char* aValue);
316
int equal(const char* anAttrName, Int32 aValue);
317
int equal(const char* anAttrName, Uint32 aValue);
318
int equal(const char* anAttrName, Int64 aValue);
319
int equal(const char* anAttrName, Uint64 aValue);
320
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
321
int equal(Uint32 anAttrId, const char* aValue, Uint32 len);
323
int equal(Uint32 anAttrId, const char* aValue);
324
int equal(Uint32 anAttrId, Int32 aValue);
325
int equal(Uint32 anAttrId, Uint32 aValue);
326
int equal(Uint32 anAttrId, Int64 aValue);
327
int equal(Uint32 anAttrId, Uint64 aValue);
329
/** @} *********************************************************************/
331
* @name Specify Attribute Actions for Operations
336
* Defines a retrieval operation of an attribute value.
337
* The NDB API allocate memory for the NdbRecAttr object that
338
* will hold the returned attribute value.
340
* @note Note that it is the applications responsibility
341
* to allocate enough memory for aValue (if non-NULL).
342
* The buffer aValue supplied by the application must be
343
* aligned appropriately. The buffer is used directly
344
* (avoiding a copy penalty) only if it is aligned on a
345
* 4-byte boundary and the attribute size in bytes
346
* (i.e. NdbRecAttr::attrSize times NdbRecAttr::arraySize is
349
* @note There are two versions of NdbOperation::getValue with
350
* slightly different parameters.
352
* @note This method does not fetch the attribute value from
353
* the database! The NdbRecAttr object returned by this method
354
* is <em>not</em> readable/printable before the
355
* transaction has been executed with NdbTransaction::execute.
357
* @param anAttrName Attribute name
358
* @param aValue If this is non-NULL, then the attribute value
359
* will be returned in this parameter.<br>
360
* If NULL, then the attribute value will only
361
* be stored in the returned NdbRecAttr object.
362
* @return An NdbRecAttr object to hold the value of
363
* the attribute, or a NULL pointer
364
* (indicating error).
366
NdbRecAttr* getValue(const char* anAttrName, char* aValue = 0);
367
NdbRecAttr* getValue(Uint32 anAttrId, char* aValue = 0);
368
NdbRecAttr* getValue(const NdbDictionary::Column*, char* val = 0);
371
* Define an attribute to set or update in query.
373
* To set a NULL value, use the following construct:
375
* setValue("ATTR_NAME", (char*)NULL);
378
* There are a number of NdbOperation::setValue methods that
379
* take a certain type as input
380
* (pass by value rather than passing a pointer).
381
* As the interface is currently implemented it is the responsibility
382
* of the application programmer to use the correct types.
384
* The NDB API will however check that the application sends
385
* a correct length to the interface as given in the length parameter.
386
* The passing of char* as the value can contain any type or
388
* If length is not provided or set to zero,
389
* then the API will assume that the pointer
390
* is correct and not bother with checking it.
392
* @note For insertTuple() the NDB API will automatically detect that
393
* it is supposed to use equal() instead.
395
* @note For insertTuple() it is not necessary to use
396
* setValue() on key attributes before other attributes.
398
* @note There are 14 versions of NdbOperation::setValue with
399
* slightly different parameters.
401
* @note See note under equal() about value format and length.
403
* @param anAttrName Name (or Id) of attribute.
404
* @param aValue Attribute value to set.
405
* @return -1 if unsuccessful.
407
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
408
int setValue(const char* anAttrName, const char* aValue, Uint32 len);
410
int setValue(const char* anAttrName, const char* aValue);
411
int setValue(const char* anAttrName, Int32 aValue);
412
int setValue(const char* anAttrName, Uint32 aValue);
413
int setValue(const char* anAttrName, Int64 aValue);
414
int setValue(const char* anAttrName, Uint64 aValue);
415
int setValue(const char* anAttrName, float aValue);
416
int setValue(const char* anAttrName, double aValue);
417
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
418
int setAnyValue(Uint32 aValue);
421
#ifndef DOXYGEN_SHOULD_SKIP_DEPRECATED
422
int setValue(Uint32 anAttrId, const char* aValue, Uint32 len);
424
int setValue(Uint32 anAttrId, const char* aValue);
425
int setValue(Uint32 anAttrId, Int32 aValue);
426
int setValue(Uint32 anAttrId, Uint32 aValue);
427
int setValue(Uint32 anAttrId, Int64 aValue);
428
int setValue(Uint32 anAttrId, Uint64 aValue);
429
int setValue(Uint32 anAttrId, float aValue);
430
int setValue(Uint32 anAttrId, double aValue);
433
* This method replaces getValue/setValue for blobs. It creates
434
* a blob handle NdbBlob. A second call with same argument returns
435
* the previously created handle. The handle is linked to the
436
* operation and is maintained automatically.
438
* See NdbBlob for details.
440
virtual NdbBlob* getBlobHandle(const char* anAttrName);
441
virtual NdbBlob* getBlobHandle(Uint32 anAttrId);
443
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
444
/** @} *********************************************************************/
446
* @name Specify Interpreted Program Instructions
451
* Interpreted program instruction: Add a value to an attribute.
453
* @note Destroys the contents of registers 6 and 7.
454
* (The instruction uses these registers for its operation.)
456
* @note There are four versions of NdbOperation::incValue with
457
* slightly different parameters.
459
* @param anAttrName Attribute name.
460
* @param aValue Value to add.
461
* @return -1 if unsuccessful.
463
int incValue(const char* anAttrName, Uint32 aValue);
464
int incValue(const char* anAttrName, Uint64 aValue);
465
int incValue(Uint32 anAttrId, Uint32 aValue);
466
int incValue(Uint32 anAttrId, Uint64 aValue);
469
* Interpreted program instruction:
470
* Subtract a value from an attribute in an interpreted operation.
472
* @note Destroys the contents of registers 6 and 7.
473
* (The instruction uses these registers for its operation.)
475
* @note There are four versions of NdbOperation::subValue with
476
* slightly different parameters.
478
* @param anAttrName Attribute name.
479
* @param aValue Value to subtract.
480
* @return -1 if unsuccessful.
482
int subValue(const char* anAttrName, Uint32 aValue);
483
int subValue(const char* anAttrName, Uint64 aValue);
484
int subValue(Uint32 anAttrId, Uint32 aValue);
485
int subValue(Uint32 anAttrId, Uint64 aValue);
488
* Interpreted program instruction:
489
* Define a jump label in an interpreted operation.
491
* @note The labels are automatically numbered starting with 0.
492
* The parameter used by NdbOperation::def_label should
493
* match the automatic numbering to make it easier to
494
* debug the interpreted program.
496
* @param labelNumber Label number.
497
* @return -1 if unsuccessful.
499
int def_label(int labelNumber);
502
* Interpreted program instruction:
503
* Add two registers into a third.
505
* @param RegSource1 First register.
506
* @param RegSource2 Second register.
507
* @param RegDest Destination register where the result will be stored.
508
* @return -1 if unsuccessful.
510
int add_reg(Uint32 RegSource1, Uint32 RegSource2, Uint32 RegDest);
513
* Interpreted program instruction:
514
* Substract RegSource2 from RegSource1 and put the result in RegDest.
516
* @param RegSource1 First register.
517
* @param RegSource2 Second register.
518
* @param RegDest Destination register where the result will be stored.
519
* @return -1 if unsuccessful.
521
int sub_reg(Uint32 RegSource1, Uint32 RegSource2, Uint32 RegDest);
524
* Interpreted program instruction:
525
* Load a constant into a register.
527
* @param RegDest Destination register.
528
* @param Constant Value to load.
529
* @return -1 if unsuccessful.
531
int load_const_u32(Uint32 RegDest, Uint32 Constant);
532
int load_const_u64(Uint32 RegDest, Uint64 Constant);
535
* Interpreted program instruction:
536
* Load NULL value into a register.
538
* @param RegDest Destination register.
539
* @return -1 if unsuccessful.
541
int load_const_null(Uint32 RegDest);
544
* Interpreted program instruction:
545
* Read an attribute into a register.
547
* @param anAttrName Attribute name.
548
* @param RegDest Destination register.
549
* @return -1 if unsuccessful.
551
int read_attr(const char* anAttrName, Uint32 RegDest);
554
* Interpreted program instruction:
555
* Write an attribute from a register.
557
* @param anAttrName Attribute name.
558
* @param RegSource Source register.
559
* @return -1 if unsuccessful.
561
int write_attr(const char* anAttrName, Uint32 RegSource);
564
* Interpreted program instruction:
565
* Read an attribute into a register.
567
* @param anAttrId the attribute id.
568
* @param RegDest the destination register.
569
* @return -1 if unsuccessful.
571
int read_attr(Uint32 anAttrId, Uint32 RegDest);
574
* Interpreted program instruction:
575
* Write an attribute from a register.
577
* @param anAttrId the attribute id.
578
* @param RegSource the source register.
579
* @return -1 if unsuccessful.
581
int write_attr(Uint32 anAttrId, Uint32 RegSource);
584
* Interpreted program instruction:
585
* Define a search condition. Last two letters in the function name
586
* describes the search condition.
587
* The condition compares RegR with RegL and therefore appears
597
* @param RegLvalue left value.
598
* @param RegRvalue right value.
599
* @param Label the label to jump to.
600
* @return -1 if unsuccessful.
602
int branch_ge(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
603
int branch_gt(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
604
int branch_le(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
605
int branch_lt(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
606
int branch_eq(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
607
int branch_ne(Uint32 RegLvalue, Uint32 RegRvalue, Uint32 Label);
610
* Interpreted program instruction:
611
* Jump to Label if RegLvalue is not NULL.
613
* @param RegLvalue the value to check.
614
* @param Label the label to jump to.
615
* @return -1 if unsuccessful.
617
int branch_ne_null(Uint32 RegLvalue, Uint32 Label);
620
* Interpreted program instruction:
621
* Jump to Label if RegLvalue is equal to NULL.
623
* @param RegLvalue Value to check.
624
* @param Label Label to jump to.
625
* @return -1 if unsuccessful.
627
int branch_eq_null(Uint32 RegLvalue, Uint32 Label);
630
* Interpreted program instruction:
633
* @param Label Label to jump to.
634
* @return -1 if unsuccessful.
636
int branch_label(Uint32 Label);
639
* Interpreted program instruction: branch after memcmp
640
* @param ColId Column to check
641
* @param Label Label to jump to
642
* @return -1 if unsuccessful
644
int branch_col_eq_null(Uint32 ColId, Uint32 Label);
645
int branch_col_ne_null(Uint32 ColId, Uint32 Label);
648
* Interpreted program instruction: branch after memcmp
649
* @param ColId column to check
650
* @param val search value
651
* @param len length of search value
652
* @param nopad force non-padded comparison for a Char column
653
* @param Label label to jump to
654
* @return -1 if unsuccessful
656
int branch_col_eq(Uint32 ColId, const void * val, Uint32 len,
657
bool nopad, Uint32 Label);
658
int branch_col_ne(Uint32 ColId, const void * val, Uint32 len,
659
bool nopad, Uint32 Label);
660
int branch_col_lt(Uint32 ColId, const void * val, Uint32 len,
661
bool nopad, Uint32 Label);
662
int branch_col_le(Uint32 ColId, const void * val, Uint32 len,
663
bool nopad, Uint32 Label);
664
int branch_col_gt(Uint32 ColId, const void * val, Uint32 len,
665
bool nopad, Uint32 Label);
666
int branch_col_ge(Uint32 ColId, const void * val, Uint32 len,
667
bool nopad, Uint32 Label);
669
* The argument is always plain char, even if the field is varchar
670
* (changed in 5.0.22).
672
int branch_col_like(Uint32 ColId, const void *, Uint32 len,
673
bool nopad, Uint32 Label);
674
int branch_col_notlike(Uint32 ColId, const void *, Uint32 len,
675
bool nopad, Uint32 Label);
678
* Interpreted program instruction: Exit with Ok
680
* For scanning transactions,
681
* end interpreted operation and return the row to the application.
683
* For non-scanning transactions,
684
* exit interpreted program.
686
* @return -1 if unsuccessful.
688
int interpret_exit_ok();
691
* Interpreted program instruction: Exit with Not Ok
693
* For scanning transactions,
694
* continue with the next row without returning the current row.
696
* For non-scanning transactions,
697
* abort the whole transaction.
699
* @note A method also exists without the error parameter.
701
* @param ErrorCode An error code given by the application programmer.
702
* @return -1 if unsuccessful.
704
int interpret_exit_nok(Uint32 ErrorCode);
705
int interpret_exit_nok();
709
* Interpreted program instruction:
711
* For scanning transactions,
712
* return this row, but no more from this fragment
714
* For non-scanning transactions,
715
* abort the whole transaction.
717
* @return -1 if unsuccessful.
719
int interpret_exit_last_row();
722
* Interpreted program instruction:
723
* Define a subroutine in an interpreted operation.
725
* @param SubroutineNumber the subroutine number.
726
* @return -1 if unsuccessful.
728
int def_subroutine(int SubroutineNumber);
731
* Interpreted program instruction:
734
* @param Subroutine the subroutine to call.
735
* @return -1 if unsuccessful.
737
int call_sub(Uint32 Subroutine);
740
* Interpreted program instruction:
743
* @return -1 if unsuccessful.
748
/** @} *********************************************************************/
751
* @name Error Handling
756
* Get the latest error code.
758
* @return error code.
760
const NdbError & getNdbError() const;
763
* Get the method number where the error occured.
765
* @return method number where the error occured.
767
int getNdbErrorLine();
770
* Get table name of this operation.
772
const char* getTableName() const;
775
* Get table object for this operation
777
const NdbDictionary::Table * getTable() const;
780
* Get the type of access for this operation
782
Type getType() const;
784
/** @} *********************************************************************/
786
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
791
ReadRequest = 0, ///< Read operation
792
UpdateRequest = 1, ///< Update Operation
793
InsertRequest = 2, ///< Insert Operation
794
DeleteRequest = 3, ///< Delete Operation
795
WriteRequest = 4, ///< Write Operation
796
ReadExclusive = 5, ///< Read exclusive
797
OpenScanRequest, ///< Scan Operation
798
OpenRangeScanRequest, ///< Range scan operation
799
NotDefined2, ///< Internal for debugging
800
NotDefined ///< Internal for debugging
805
* Return lock mode for operation
807
LockMode getLockMode() const { return theLockMode; }
810
* Get/set abort option
812
AbortOption getAbortOption() const;
813
int setAbortOption(AbortOption);
815
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
818
* Set/get partition key
820
void setPartitionId(Uint32 id);
821
void setPartitionHash(Uint32 key);
822
void setPartitionHash(const Uint64 *, Uint32 len);
823
Uint32 getPartitionId() const;
826
int handle_distribution_key(const Uint64 *, Uint32 len);
828
/******************************************************************************
829
* These are the methods used to create and delete the NdbOperation objects.
830
*****************************************************************************/
833
/******************************************************************************
834
* These methods are service routines used by the other NDB API classes.
835
*****************************************************************************/
836
//--------------------------------------------------------------
837
// Initialise after allocating operation to a transaction
838
//--------------------------------------------------------------
839
int init(const class NdbTableImpl*, NdbTransaction* aCon);
840
void initInterpreter();
842
NdbOperation(Ndb* aNdb, Type aType = PrimaryKeyAccess);
843
virtual ~NdbOperation();
844
void next(NdbOperation*); // Set next pointer
845
NdbOperation* next(); // Get next pointer
848
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
849
NdbTransaction* getNdbTransaction();
850
const NdbOperation* next() const;
851
const NdbRecAttr* getFirstRecAttr() const;
862
ExecInterpretedValue,
873
OperationStatus Status(); // Read the status information
875
void Status(OperationStatus); // Set the status information
877
void NdbCon(NdbTransaction*); // Set reference to connection
880
virtual void release(); // Release all operations
882
// the operations object.
883
void setStartIndicator();
885
/******************************************************************************
886
* The methods below is the execution part of the NdbOperation
887
* class. This is where the NDB signals are sent and received. The
888
* operation can send TC[KEY/INDX]REQ, [INDX]ATTRINFO.
889
* It can receive TC[KEY/INDX]CONF, TC[KEY/INDX]REF, [INDX]ATTRINFO.
890
* When an operation is received in its fulness or a refuse message
891
* was sent, then the connection object is told about this situation.
892
*****************************************************************************/
894
int doSend(int ProcessorId, Uint32 lastFlag);
895
virtual int prepareSend(Uint32 TC_ConnectPtr,
896
Uint64 TransactionId,
898
virtual void setLastFlag(NdbApiSignal* signal, Uint32 lastFlag);
900
int prepareSendInterpreted(); // Help routine to prepare*
902
int receiveTCKEYREF(NdbApiSignal*);
904
int checkMagicNumber(bool b = true); // Verify correct object
906
int checkState_TransId(NdbApiSignal* aSignal);
908
/******************************************************************************
909
* These are support methods only used locally in this class.
910
******************************************************************************/
912
virtual int equal_impl(const NdbColumnImpl*,const char* aValue);
913
virtual NdbRecAttr* getValue_impl(const NdbColumnImpl*, char* aValue = 0);
914
int setValue(const NdbColumnImpl* anAttrObject, const char* aValue);
915
NdbBlob* getBlobHandle(NdbTransaction* aCon, const NdbColumnImpl* anAttrObject);
916
int incValue(const NdbColumnImpl* anAttrObject, Uint32 aValue);
917
int incValue(const NdbColumnImpl* anAttrObject, Uint64 aValue);
918
int subValue(const NdbColumnImpl* anAttrObject, Uint32 aValue);
919
int subValue(const NdbColumnImpl* anAttrObject, Uint64 aValue);
920
int read_attr(const NdbColumnImpl* anAttrObject, Uint32 RegDest);
921
int write_attr(const NdbColumnImpl* anAttrObject, Uint32 RegSource);
922
int branch_reg_reg(Uint32 type, Uint32, Uint32, Uint32);
923
int branch_col(Uint32 type, Uint32, const void *, Uint32, bool, Uint32 Label);
924
int branch_col_null(Uint32 type, Uint32 col, Uint32 Label);
926
// Handle ATTRINFO signals
927
int insertATTRINFO(Uint32 aData);
928
int insertATTRINFOloop(const Uint32* aDataPtr, Uint32 aLength);
930
int insertKEYINFO(const char* aValue,
931
Uint32 aStartPosition,
932
Uint32 aKeyLenInByte);
933
void reorderKEYINFO();
935
virtual void setErrorCode(int aErrorCode);
936
virtual void setErrorCodeAbort(int aErrorCode);
938
void handleFailedAI_ElemLen(); // When not all attribute data
941
int incCheck(const NdbColumnImpl* anAttrObject);
942
int initial_interpreterCheck();
943
int intermediate_interpreterCheck();
944
int read_attrCheck(const NdbColumnImpl* anAttrObject);
945
int write_attrCheck(const NdbColumnImpl* anAttrObject);
947
int insertCall(Uint32 aCall);
948
int insertBranch(Uint32 aBranch);
950
Uint32 ptr2int() { return theReceiver.getId(); };
952
// get table or index key from prepared signals
953
int getKeyFromTCREQ(Uint32* data, Uint32 & size);
955
virtual void setReadLockMode(LockMode lockMode);
957
/******************************************************************************
958
* These are the private variables that are defined in the operation objects.
959
*****************************************************************************/
963
NdbReceiver theReceiver;
965
NdbError theError; // Errorcode
966
int theErrorLine; // Error line
968
Ndb* theNdb; // Point back to the Ndb object.
969
NdbTransaction* theNdbCon; // Point back to the connection object.
970
NdbOperation* theNext; // Next pointer to operation.
973
NdbApiSignal* theTCREQ; // The TC[KEY/INDX]REQ signal object
974
NdbApiSignal* theSCAN_TABREQ;
977
NdbApiSignal* theFirstATTRINFO; // The first ATTRINFO signal object
978
NdbApiSignal* theCurrentATTRINFO; // The current ATTRINFO signal object
979
Uint32 theTotalCurrAI_Len; // The total number of attribute info
980
// words currently defined
981
Uint32 theAI_LenInCurrAI; // The number of words defined in the
982
// current ATTRINFO signal
983
NdbApiSignal* theLastKEYINFO; // The first KEYINFO signal object
985
class NdbLabel* theFirstLabel;
986
class NdbLabel* theLastLabel;
987
class NdbBranch* theFirstBranch;
988
class NdbBranch* theLastBranch;
989
class NdbCall* theFirstCall;
990
class NdbCall* theLastCall;
991
class NdbSubroutine* theFirstSubroutine;
992
class NdbSubroutine* theLastSubroutine;
993
Uint32 theNoOfLabels;
994
Uint32 theNoOfSubroutines;
996
Uint32* theKEYINFOptr; // Pointer to where to write KEYINFO
997
Uint32* theATTRINFOptr; // Pointer to where to write ATTRINFO
999
const class NdbTableImpl* m_currentTable; // The current table
1000
const class NdbTableImpl* m_accessTable; // Index table (== current for pk)
1002
// Set to TRUE when a tuple key attribute has been defined.
1003
Uint32 theTupleKeyDefined[NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY][3];
1005
Uint32 theTotalNrOfKeyWordInSignal; // The total number of
1006
// keyword in signal.
1008
Uint32 theTupKeyLen; // Length of the tuple key in words
1010
Uint8 theNoOfTupKeyLeft; // The number of tuple key attributes
1011
OperationType theOperationType; // Read Request, Update Req......
1013
LockMode theLockMode; // Can be set to WRITE if read operation
1014
OperationStatus theStatus; // The status of the operation.
1016
Uint32 theMagicNumber; // Magic number to verify that object
1018
Uint32 theScanInfo; // Scan info bits (take over flag etc)
1019
Uint32 theDistributionKey; // Distribution Key size if used
1021
Uint32 theSubroutineSize; // Size of subroutines for interpretation
1022
Uint32 theInitialReadSize; // Size of initial reads for interpretation
1023
Uint32 theInterpretedSize; // Size of interpretation
1024
Uint32 theFinalUpdateSize; // Size of final updates for interpretation
1025
Uint32 theFinalReadSize; // Size of final reads for interpretation
1027
Uint8 theStartIndicator; // Indicator of whether start operation
1028
Uint8 theCommitIndicator; // Indicator of whether commit operation
1029
Uint8 theSimpleIndicator; // Indicator of whether simple operation
1030
Uint8 theDirtyIndicator; // Indicator of whether dirty operation
1031
Uint8 theInterpretIndicator; // Indicator of whether interpreted operation
1032
Int8 theDistrKeyIndicator_; // Indicates whether distr. key is used
1033
Uint8 m_no_disk_flag;
1036
Uint16 m_keyInfoGSN;
1037
Uint16 m_attrInfoGSN;
1039
// Blobs in this operation
1040
NdbBlob* theBlobList;
1043
* Abort option per operation, used by blobs.
1044
* See also comments on enum AbortOption.
1049
* For blob impl, option to not propagate error to trans level.
1050
* Could be AO_IgnoreError variant if we want it public.
1051
* Ignored unless AO_IgnoreError is also set.
1053
Int8 m_noErrorPropagation;
1055
friend struct Ndb_free_list_t<NdbOperation>;
1058
#ifdef NDB_NO_DROPPED_SIGNAL
1062
#ifndef DOXYGEN_SHOULD_SKIP_INTERNAL
1066
NdbOperation::checkMagicNumber(bool b)
1068
if (theMagicNumber != 0xABCDEF01){
1069
#ifdef NDB_NO_DROPPED_SIGNAL
1079
NdbOperation::setStartIndicator()
1081
theStartIndicator = 1;
1086
NdbOperation::getNdbErrorLine()
1088
return theErrorLine;
1091
/******************************************************************************
1092
void next(NdbOperation* aNdbOperation);
1094
Parameters: aNdbOperation: Pointers to the NdbOperation object.
1095
Remark: Set the next variable of the operation object.
1096
******************************************************************************/
1099
NdbOperation::next(NdbOperation* aNdbOperation)
1101
theNext = aNdbOperation;
1104
/******************************************************************************
1105
NdbOperation* next();
1107
Return Value: Return next pointer to NdbOperation object.
1108
Remark: Get the next variable of the operation object.
1109
******************************************************************************/
1112
NdbOperation::next()
1119
NdbOperation::next() const
1126
NdbOperation::getFirstRecAttr() const
1128
return theReceiver.theFirstRecAttr;
1131
/******************************************************************************
1134
Return Value Return the Type.
1135
Remark: Gets type of access.
1136
******************************************************************************/
1139
NdbOperation::getType() const
1144
/******************************************************************************
1145
OperationStatus Status();
1147
Return Value Return the OperationStatus.
1148
Parameters: aStatus: The status.
1149
Remark: Sets Operation status.
1150
******************************************************************************/
1152
NdbOperation::OperationStatus
1153
NdbOperation::Status()
1158
/******************************************************************************
1159
void Status(OperationStatus aStatus);
1161
Parameters: aStatus: The status.
1162
Remark: Sets Operation
1164
******************************************************************************/
1167
NdbOperation::Status( OperationStatus aStatus )
1169
theStatus = aStatus;
1172
/******************************************************************************
1173
void NdbCon(NdbTransaction* aNdbCon);
1175
Parameters: aNdbCon: Pointers to NdbTransaction object.
1176
Remark: Set the reference to the connection in the operation object.
1177
******************************************************************************/
1180
NdbOperation::NdbCon(NdbTransaction* aNdbCon)
1182
theNdbCon = aNdbCon;
1187
NdbOperation::equal(const char* anAttrName, const char* aValue, Uint32 len)
1189
return equal(anAttrName, aValue);
1194
NdbOperation::equal(const char* anAttrName, Int32 aPar)
1196
return equal(anAttrName, (const char*)&aPar, (Uint32)4);
1201
NdbOperation::equal(const char* anAttrName, Uint32 aPar)
1203
return equal(anAttrName, (const char*)&aPar, (Uint32)4);
1208
NdbOperation::equal(const char* anAttrName, Int64 aPar)
1210
return equal(anAttrName, (const char*)&aPar, (Uint32)8);
1215
NdbOperation::equal(const char* anAttrName, Uint64 aPar)
1217
return equal(anAttrName, (const char*)&aPar, (Uint32)8);
1222
NdbOperation::equal(Uint32 anAttrId, const char* aValue, Uint32 len)
1224
return equal(anAttrId, aValue);
1229
NdbOperation::equal(Uint32 anAttrId, Int32 aPar)
1231
return equal(anAttrId, (const char*)&aPar, (Uint32)4);
1236
NdbOperation::equal(Uint32 anAttrId, Uint32 aPar)
1238
return equal(anAttrId, (const char*)&aPar, (Uint32)4);
1243
NdbOperation::equal(Uint32 anAttrId, Int64 aPar)
1245
return equal(anAttrId, (const char*)&aPar, (Uint32)8);
1250
NdbOperation::equal(Uint32 anAttrId, Uint64 aPar)
1252
return equal(anAttrId, (const char*)&aPar, (Uint32)8);
1257
NdbOperation::setValue(const char* anAttrName, const char* aValue, Uint32 len)
1259
return setValue(anAttrName, aValue);
1264
NdbOperation::setValue(const char* anAttrName, Int32 aPar)
1266
return setValue(anAttrName, (const char*)&aPar, (Uint32)4);
1271
NdbOperation::setValue(const char* anAttrName, Uint32 aPar)
1273
return setValue(anAttrName, (const char*)&aPar, (Uint32)4);
1278
NdbOperation::setValue(const char* anAttrName, Int64 aPar)
1280
return setValue(anAttrName, (const char*)&aPar, (Uint32)8);
1285
NdbOperation::setValue(const char* anAttrName, Uint64 aPar)
1287
return setValue(anAttrName, (const char*)&aPar, (Uint32)8);
1292
NdbOperation::setValue(const char* anAttrName, float aPar)
1294
return setValue(anAttrName, (const char*)&aPar, (Uint32)4);
1299
NdbOperation::setValue(const char* anAttrName, double aPar)
1301
return setValue(anAttrName, (const char*)&aPar, (Uint32)8);
1306
NdbOperation::setValue(Uint32 anAttrId, const char* aValue, Uint32 len)
1308
return setValue(anAttrId, aValue);
1313
NdbOperation::setValue(Uint32 anAttrId, Int32 aPar)
1315
return setValue(anAttrId, (const char*)&aPar, (Uint32)4);
1320
NdbOperation::setValue(Uint32 anAttrId, Uint32 aPar)
1322
return setValue(anAttrId, (const char*)&aPar, (Uint32)4);
1327
NdbOperation::setValue(Uint32 anAttrId, Int64 aPar)
1329
return setValue(anAttrId, (const char*)&aPar, (Uint32)8);
1334
NdbOperation::setValue(Uint32 anAttrId, Uint64 aPar)
1336
return setValue(anAttrId, (const char*)&aPar, (Uint32)8);
1341
NdbOperation::setValue(Uint32 anAttrId, float aPar)
1343
return setValue(anAttrId, (char*)&aPar, (Uint32)4);
1348
NdbOperation::setValue(Uint32 anAttrId, double aPar)
1350
return setValue(anAttrId, (const char*)&aPar, (Uint32)8);