This section provides information about the
NdbTransaction class.
- Parent class
None
- Child classes
None
- Description
A transaction is represented in the NDB API by an
NdbTransactionobject, which belongs to anNdbobject and is created usingNdb::startTransaction(). A transaction consists of a list of operations represented by theNdbOperationclass, or by one of its subclasses—NdbScanOperation,NdbIndexOperation, orNdbIndexScanOperation. Each operation access exactly one table.- Methods
-
The following table lists the public methods of this class and the purpose or use of each method:
Table 2.66 NdbTransaction class methods and descriptions
Name Description close()Closes a transaction commitStatus()Gets the transaction's commit status deleteTuple()Delete a tuple using NdbRecordexecute()Executes a transaction executePendingBlobOps()Executes a transaction in NoCommitmode if it includes any blob part operations of the specified types that are not yet executed.getGCI()Gets a transaction's global checkpoint ID (GCI) getMaxPendingBlobReadBytes()Get the current blob read batch size getMaxPendingBlobWriteBytes()Get the current blob write batch size getNdbError()Gets the most recent error getNdbErrorLine()Gets the line number where the most recent error occurred getNdbErrorOperation()Gets the most recent operation which caused an error getNextCompletedOperation()Gets operations that have been executed; used for finding errors getNdbOperation()Gets an NdbOperationgetNdbScanOperation()Gets an NdbScanOperationgetNdbIndexOperation()Gets an NdbIndexOperationgetNdbIndexScanOperation()Gets an NdbIndexScanOperationgetTransactionId()Gets the transaction ID insertTuple()Insert a tuple using NdbRecordreadTuple()Read a tuple using NdbRecordrefresh()Keeps a transaction from timing out releaseLockHandle()Release an NdbLockHandleobject once it is no longer neededscanIndex()Perform an index scan using NdbRecordscanTable()Perform a table scan using NdbRecordsetMaxPendingBlobReadBytes()Set the blob read batch size setMaxPendingBlobWriteBytes()Set the blob write batch size setSchemaObjectOwnerChecks()Enable or disable schema object ownership checks unlock()Create an unlock operation on the current transaction updateTuple()Update a tuple using NdbRecordwriteTuple()Write a tuple using NdbRecordThe methods
readTuple(),insertTuple(),updateTuple(),writeTuple(),deleteTuple(),scanTable(), andscanIndex()require the use ofNdbRecord. - Types
-
NdbTransactiondefines 2 public types as shown in the following table:Table 2.67 NdbTransaction class types and descriptions
Name Description CommitStatusType()Describes the transaction's commit status ExecType()Determines whether the transaction should be committed or rolled back
Using Transactions.
After obtaining an NdbTransaction object, it
is employed as follows:
-
An operation is allocated to the transaction using any one of the following methods:
getNdbOperation()getNdbScanOperation()getNdbIndexOperation()getNdbIndexScanOperation()
Calling one of these methods defines the operation. Several operations can be defined on the same
NdbTransactionobject, in which case they are executed in parallel. When all operations are defined, theexecute()method sends them to theNDBkernel for execution. -
The
execute()method returns when theNDBkernel has completed execution of all operations previously defined.All allocated operations should be properly defined before calling the
execute()method. -
execute()operates in one of the three modes listed here:NdbTransaction::NoCommit: Executes operations without committing them.NdbTransaction::Commit: Executes any remaining operation and then commits the complete transaction.NdbTransaction::Rollback: Rolls back the entire transaction.
execute()is also equipped with an extra error handling parameter, which provides the two alternatives listed here:NdbOperation::AbortOnError: Any error causes the transaction to be aborted. This is the default behavior.NdbOperation::AO_IgnoreError: The transaction continues to be executed even if one or more of the operations defined for that transaction fails.
- Description
-
This method closes a transaction. It is equivalent to calling
Ndb::closeTransaction().If the transaction has not yet been committed, it is aborted when this method is called. See Ndb::startTransaction().
- Signature
void close ( void )- Parameters
None.
- Return value
None.
- Description
This method gets the transaction's commit status.
- Signature
CommitStatusType commitStatus ( void )- Parameters
None.
- Return value
The commit status of the transaction, a value of type
CommitStatusType.
This section provides information about the
CommitStatusType data type.
- Description
This type is used to describe a transaction's commit status.
- Enumeration values
-
Possible values are shown, along with descriptions, in the following table:
Table 2.68 NdbTransaction::CommitStatusType values and descriptions
Name Description NotStartedThe transaction has not yet been started. StartedThe transaction has started, but is not yet committed. CommittedThe transaction has completed, and has been committed. AbortedThe transaction was aborted. NeedAbortThe transaction has encountered an error, but has not yet been aborted.
A transaction's commit status ca be read using
commitStatus().
- Description
Deletes a tuple using
NdbRecord.- Signature
const NdbOperation* deleteTuple ( const NdbRecord* key_rec, const char* key_row, const NdbRecord* result_rec, char* result_row, const unsigned char* result_mask = 0, const NdbOperation::OperationOptions* opts = 0, Uint32 sizeOfOptions = 0 )- Parameters
-
This method takes the following parameters:
key_recis a pointer to anNdbRecordfor either a table or an index. If on a table, then the delete operation uses a primary key; if on an index, then the operation uses a unique key. In either case, thekey_recmust include all columns of the key.The
key_rowpassed to this method defines the primary or unique key of the tuple to be deleted, and must remain valid untilexecute()is called.The
result_recis theNdbRecordto be used.The
result_rowcan beNULLif no attributes are to be returned.The
result_mask, if notNULL, defines a subset of attributes to be read and returned to the client. The mask is copied, and so does not need to remain valid after the call to this method returns.OperationOptions(opts) can be used to provide more finely-grained control of operation definitions. AnOperationOptionsstructure is passed with flags indicating which operation definition options are present. Not all operation types support all operation options; for the options supported by each type of operation, see NdbTransaction::readTuple().The optional
sizeOfOptionsparameter provides backward compatibility of this interface with previous definitions of theOperationOptionsstructure. If an unusual size is detected by the interface implementation, it can use this to determine how to interpret the passedOperationOptionsstructure. To enable this functionality, the caller should passsizeof(NdbOperation::OperationOptions)for the value of this argument.
- Return value
A
constpointer to theNdbOperationrepresenting this write operation. The operation can be checked for errors if necessary.
This section provides information about the
ExecType data type.
- Description
This type sets the transaction's execution type; that is, whether it should execute, execute and commit, or abort. It is used as a parameter to the
execute()method. (See NdbTransaction::execute().)- Enumeration values
-
Possible values are shown, along with descriptions, in the following table:
Table 2.69 NdbTransaction::ExecType values and descriptions
Name Description NoCommitThe transaction should execute, but not commit. CommitThe transaction should execute and be committed. RollbackThe transaction should be rolled back.
- Description
This method is used to execute a transaction.
- Signature
int execute ( ExecType execType, NdbOperation::AbortOption abortOption = NdbOperation::DefaultAbortOption, int force = 0 )- Parameters
-
The
execute()method takes the three parameters listed here:The execution type (
ExecTypevalue); see NdbTransaction::ExecType, for more information and possible values.-
An abort option (
NdbOperation::AbortOptionvalue).Errors arising from this method are found with
NdbOperation::getNdbError()rather thanNdbTransaction::getNdbError(). -
A
forceparameter, which determines when operations should be sent to theNDBKernel. It takes ones of the values listed here:0: Nonforced; detected by the adaptive send algorithm.1: Forced; detected by the adaptive send algorithm.2: Nonforced; not detected by the adaptive send algorithm.
See Section 1.4.4, “The Adaptive Send Algorithm”, for more information.
- Return value
Returns
0on success, or-1on failure. The fact that the transaction did not abort does not necessarily mean that each operation was successful; you must check each operation individually for errors.
This method reports a failure if and only if the transaction was aborted. The transaction's error information is set in such cases to reflect the actual error code and category.
In the case where a NoDataFound error is a possibility, you must check for it explicitly, as shown in this example:
Ndb_cluster_connection myConnection;
if( myConnection.connect(4, 5, 1) )
{
cout << "Unable to connect to cluster within 30 secs." << endl;
exit(-1);
}
Ndb myNdb(&myConnection, "test");
// define operations...
myTransaction = myNdb->startTransaction();
if(myTransaction->getNdbError().classification == NdbError:NoDataFound)
{
cout << "No records found." << endl;
// ...
}
myNdb->closeTransaction(myTransaction);
You should be aware that a successful execute()
call guarantees only that the scan request has been assembled and
sent to the transaction coordinator without any errors; it does
not wait for any signals to be sent in reply from the data nodes
before returning.
- Description
This method executes the transaction with
ExecTypeequal toNoCommitif there remain any blob part operations of the given types which have not yet been executed.- Signature
int executePendingBlobOps ( Uint8 flags = 0xFF )- Parameters
The
flagsargument is the result of a bitwiseOR, equal to1 <<, whereoptypeoptypeis anNdbOperation::Type. The default corresponds toNdbOperation::Type::PrimaryKeyAccess.- Return value
Returns
0on success, or-1on failure. The fact that the transaction did not abort does not necessarily mean that each operation was successful; you must check each operation individually for errors.
- Description
-
This method retrieves the transaction's global checkpoint ID (GCI).
Each committed transaction belongs to a GCI. The log for the committed transaction is saved on disk when a global checkpoint occurs.
By comparing the GCI of a transaction with the value of the latest GCI restored in a restarted NDB Cluster, you can determine whether or not the transaction was restored.
Whether or not the global checkpoint with this GCI has been saved on disk cannot be determined by this method.
The GCI for a scan transaction is undefined, since no updates are performed in scan transactions.
No GCI is available until
execute()has been called withExecType::Commit. - Signature
int getGCI ( void )- Parameters
None.
- Return value
The transaction's GCI, or
-1if none is available.
- Description
Gets the current batch size in bytes for blob read operations. When the volume of blob data to be read within a given transaction exceeds this amount, all of the transaction's pending blob read operations are executed.
- Signature
Uint32 getMaxPendingBlobReadBytes ( void ) const- Parameters
None.
- Return value
The current blob read batch size, in bytes. See NdbTransaction::setMaxPendingBlobReadBytes(), for more information.
- Description
Gets the current batch size in bytes for blob write operations. When the volume of blob data to be written within a given transaction exceeds this amount, all of the transaction's pending blob write operations are executed.
- Signature
Uint32 getMaxPendingBlobWriteBytes ( void ) const- Parameters
None.
- Return value
The current blob write batch size, in bytes. See NdbTransaction::setMaxPendingBlobWriteBytes(), for more information.
For additional information about handling errors in transactions, see Section 1.4.2.3.6, “Error Handling”.
- Description
This method return the line number where the most recent error occurred.
- Signature
int getNdbErrorLine ( void )- Parameters
None.
- Return value
The line number of the most recent error.
For additional information about handling errors in transactions, see Section 1.4.2.3.6, “Error Handling”.
- Description
-
This method retrieves the operation that caused an error.
To obtain more information about the actual error, use the
NdbOperation::getNdbError()method of theNdbOperationobject returned bygetNdbErrorOperation(). - Signature
NdbOperation* getNdbErrorOperation ( void )- Parameters
None.
- Return value
A pointer to an
NdbOperation.
For additional information about handling errors in transactions, see Section 1.4.2.3.6, “Error Handling”.
- Description
-
This method is used to create an
NdbIndexOperationassociated with a given table.All index operations within the same transaction must be initialised with this method. Operations must be defined before they are executed.
- Signature
NdbIndexOperation* getNdbIndexOperation ( const NdbDictionary::Index* index )- Parameters
The
Indexobject on which the operation is to be performed.- Return value
A pointer to the new
NdbIndexOperation.
- Description
-
This method is used to create an
NdbIndexScanOperationassociated with a given table.All index scan operations within the same transaction must be initialised with this method. Operations must be defined before they are executed.
- Signature
NdbIndexScanOperation* getNdbIndexScanOperation ( const NdbDictionary::Index* index )- Parameters
The
Indexobject on which the operation is to be performed.- Return value
A pointer to the new
NdbIndexScanOperation.
- Description
-
This method is used to create an
NdbOperationassociated with a given table.All operations within the same transaction must be initialized with this method. Operations must be defined before they are executed.
- Signature
NdbOperation* getNdbOperation ( const NdbDictionary::Table* table )- Parameters
The
Tableobject on which the operation is to be performed.- Return value
A pointer to the new
NdbOperation.
- Description
-
This method is used to create an
NdbScanOperationassociated with a given table.All scan operations within the same transaction must be initialized with this method. Operations must be defined before they are executed.
- Signature
NdbScanOperation* getNdbScanOperation ( const NdbDictionary::Table* table )- Parameters
The
Tableobject on which the operation is to be performed.- Return value
A pointer to the new
NdbScanOperation.
- Description
-
This method is used to retrieve a transaction's completed operations. It is typically used to fetch all operations belonging to a given transaction to check for errors.
NdbTransaction::getNextCompletedOperation(NULL)returns the transaction's firstNdbOperationobject;NdbTransaction::getNextCompletedOperation(returns themyOp)NdbOperationobject defined afterNdbOperationmyOp.This method should only be used after the transaction has been executed, but before the transaction has been closed.
- Signature
const NdbOperation* getNextCompletedOperation ( const NdbOperation* op ) const- Parameters
This method requires a single parameter
op, which is an operation (NdbOperationobject), orNULL.- Return value
The operation following
op, or the first operation defined for the transaction ifgetNextCompletedOperation()was called usingNULL.
- Description
This method is used to obtain the transaction ID.
- Signature
Uint64 getTransactionId ( void )- Parameters
None.
- Return value
The transaction ID, as an unsigned 64-bit integer.
- Description
Inserts a tuple using
NdbRecord.- Signatures
-
const NdbOperation* insertTuple ( const NdbRecord* key_rec, const char* key_row, const NdbRecord* attr_rec, const char* attr_row, const unsigned char* mask = 0, const NdbOperation::OperationOptions* opts = 0, Uint32 sizeOfOptions = 0 )const NdbOperation* insertTuple ( const NdbRecord* combined_rec, const char* combined_row, const unsigned char* mask = 0, const NdbOperation::OperationOptions* opts = 0, Uint32 sizeOfOptions = 0 ) - Parameters
-
insertTuple()takes the following parameters:-
A pointer to an
NdbRecordindicating the record (key_rec) to be inserted.This method can also be called using a single
NdbRecordpointer and singlecharpointer (combined_rec,combined_row) where the singleNdbRecordrepresents record and attribute and data. A row (
key_row) of data to be inserted.A pointer to an
NdbRecordindicating an attribute (attr_rec) to be inserted.A row (
attr_row) of data to be inserted as the attribute.A
maskwhich can be used to filter the columns to be inserted.OperationOptions(opts) can be used to provide more finely-grained control of operation definitions. AnOperationOptionsstructure is passed with flags indicating which operation definition options are present. Not all operation types support all operation options; for the options supported by each type of operation, see NdbTransaction::readTuple().The optional
sizeOfOptionsparameter is used to preserve backward compatibility of this interface with previous definitions of theOperationOptionsstructure. If an unusual size is detected by the interface implementation, it can use this to determine how to interpret the passedOperationOptionsstructure. To enable this functionality, the caller should passsizeof(NdbOperation::OperationOptions)for the value of this argument.
-
- Return value
A
constpointer to theNdbOperationrepresenting this insert operation.
- Description
This method reads a tuple using
NdbRecordobjects.- Signature
const NdbOperation* readTuple ( const NdbRecord* key_rec, const char* key_row, const NdbRecord* result_rec, char* result_row, NdbOperation::LockMode lock_mode = NdbOperation::LM_Read, const unsigned char* result_mask = 0, const NdbOperation::OperationOptions* opts = 0, Uint32 sizeOfOptions = 0 )- Parameters
-
This method takes the following parameters:
key_recis a pointer to anNdbRecordfor either a table or an index. If on a table, then the operation uses a primary key; if on an index, then the operation uses a unique key. In either case, thekey_recmust include all columns of the key.-
The
key_rowpassed to this method defines the primary or unique key of the affected tuple, and must remain valid untilexecute()is called.The mask, if not
NULL, defines a subset of attributes to read, update, or insert. Only if(mask[is set is the column affected. The mask is copied by the methods, so need not remain valid after the call returns.attrId>> 3] & (1<<(attrId& 7))) result_recis a pointer to anNdbRecordused to hold the resultresult_rowdefines a buffer for the result data.lock_modespecifies the lock mode in effect for the operation. See NdbOperation::LockMode, for permitted values and other information.result_maskdefines a subset of attributes to read. Only ifmask[attrId >> 3] & (1<<(attrId & 7))is set is the column affected. The mask is copied, and so need not remain valid after the method call returns.-
OperationOptions(opts) can be used to provide more finely-grained control of operation definitions. AnOperationOptionsstructure is passed with flags indicating which operation definition options are present. Not all operation types support all operation options; the options supported for each type of operation are shown in the following table:Table 2.70 Operation types for NdbTransaction::readTuple() OperationOptions (opts) parameter, with operation options supported by each type
Operation type (Method) OperationOptionsFlags SupportedreadTuple()OO_ABORTOPTION,OO_GETVALUE,OO_PARTITION_ID,OO_INTERPRETEDinsertTuple()OO_ABORTOPTION,OO_SETVALUE,OO_PARTITION_ID,OO_ANYVALUEupdateTuple()OO_ABORTOPTION,OO_SETVALUE,OO_PARTITION_ID,OO_INTERPRETED,OO_ANYVALUEwriteTuple()OO_ABORTOPTION,OO_SETVALUE,OO_PARTITION_ID,OO_ANYVALUEdeleteTuple()OO_ABORTOPTION,OO_GETVALUE,OO_PARTITION_ID,OO_INTERPRETED,OO_ANYVALUE
The optional
sizeOfOptionsparameter is used to preserve backward compatibility of this interface with previous definitions of theOperationOptionsstructure. If an unusual size is detected by the interface implementation, it can use this to determine how to interpret the passedOperationOptionsstructure. To enable this functionality, the caller should passsizeof(NdbOperation::OperationOptions)for the value of this argument.
- Return value
A pointer to the
NdbOperationrepresenting this read operation (this can be used to check for errors).
- Description
-
This method updates the transaction's timeout counter, and thus avoids aborting due to transaction timeout.
It is not advisable to take a lock on a record and maintain it for a extended time since this can impact other transactions.
- Signature
int refresh ( void )- Parameters
None.
- Return value
Returns
0on success,-1on failure.
- Description
-
This method is used to release a lock handle (see NdbOperation::getLockHandle) when it is no longer required. For
NdbRecordprimary key read operations, this cannot be called until the associated read operation has been executed.All lock handles associated with a given transaction are released when that transaction is closed.
- Signature
int releaseLockHandle ( const NdbLockHandle* lockHandle )- Parameters
The
NdbLockHandleobject to be released.- Return value
0 on success.
- Description
Perform an index range scan of a table, with optional ordering.
- Signature
NdbIndexScanOperation* scanIndex ( const NdbRecord* key_record, const NdbRecord* result_record, NdbOperation::LockMode lock_mode = NdbOperation::LM_Read, const unsigned char* result_mask = 0, const NdbIndexScanOperation::IndexBound* bound = 0, const NdbScanOperation::ScanOptions* options = 0, Uint32 sizeOfOptions = 0 )- Parameters
The
key_recorddescribes the index to be scanned. It must be a key record for the index; that is, it must specify, at a minimum, all of the key columns of the index. Thekey_recordmust be created from the index to be scanned (and not from the underlying table).-
The
result_recorddescribes the rows to be returned from the scan. For an ordered index scan,result_recordmust be a key record for the index to be scanned; that is, it must include (at a minimum) all of the columns in the index (the full index key is needed by the NDB API for merge-sorting the ordered rows returned from each fragment).Like the
key_record, theresult_recordmust be created from the underlying table, and not from the index to be scanned. Both thekey_recordandresult_recordNdbRecordstructures must stay in place until the scan operation is closed. The
result_maskpointer is optional. If it is present, only those columns for which the corresponding bits (by attribute ID order) inresult_maskare set are actually retrieved in the scan. Theresult_maskis copied internally, so in contrast toresult_recordit need not be valid whenexecute()is invoked.-
A single
IndexBoundcan be specified either in this call or in a separate call toNdbIndexScanOperation::setBound(). To perform a multi-range read, thescan_flagsin theScanOptionsstructure must includeSF_MULTIRANGE. Additional bounds can be added using successive calls toNdbIndexScanOperation::setBound().To specify an equals bound, use the same row pointer for the
low_keyandhigh_keywith the low and high inclusive bits set.For multi-range scans, the
low_keyandhigh_keypointers must be unique. In other words, it is not permissible to reuse the same row buffer for several different range bounds within a single scan. However, it is permissible to use the same row pointer aslow_keyandhigh_keyin order to specify an equals bound; it is also permissible to reuse the rows after thescanIndex()method returns—that is, they need not remain valid untilexecute()time (unlike theNdbRecordpointers). To specify additional options, pass a
ScanOptionsstructure.The
sizeOfOptionsexists to enable backward compatability for this interface. This parameter indicates the size of theScanOptionsstructure at the time the client was compiled, and enables detection of the use of an old-styleScanOptionsstructure. If this functionality is not required, this argument can be left set to 0.
- Return value
The current
NdbIndexScanOperation, which can be used for error checking.
- Description
This method performs a table scan, using an
NdbRecordobject to read out column data.- Signature
NdbScanOperation* scanTable ( const NdbRecord* result_record, NdbOperation::LockMode lock_mode = NdbOperation::LM_Read, const unsigned char* result_mask = 0, Uint32 scan_flags = 0, Uint32 parallel = 0, Uint32 batch = 0 )- Parameters
-
The
scanTable()method takes the following parameters:A pointer to an
NdbRecordfor storing the result. Thisresult_recordmust remain valid until after theexecute()call has been made.The
lock_modein effect for the operation. See NdbOperation::LockMode, for permitted values and other information.The
result_maskpointer is optional. If it is present, only those columns for which the corresponding bits (by attribute ID order) inresult_maskare set are actually retrieved in the scan. Theresult_maskis copied internally, so in contrast toresult_recordit need not be valid whenexecute()is invoked.scan_flagscan be used to impose ordering and sorting conditions for scans. See NdbScanOperation::ScanFlag, for a list of permitted values.The
parallelargument is the desired parallelism, or0for maximum parallelism (receiving rows from all fragments in parallel), which is the default.batchdetermines whether batching is employed. The default is 0 (off).
- Return value
A pointer to the
NdbScanOperationrepresenting this scan. The operation can be checked for errors if necessary.
- Description
Sets the batch size in bytes for blob read operations. When the volume of blob data to be read within a given transaction exceeds this amount, all of the transaction's pending blob read operations are executed.
- Signature
void setMaxPendingBlobReadBytes ( Uint32 bytes )- Parameters
The batch size, as the number of
bytes. Using 0 causes blob read batching to be disabled, which is the default behavior (for backward compatibility).- Return value
None.
blob read batching can also be controlled in the
mysql client and other MySQL client
application using the MySQL Server's
--ndb-blob-read-batch-bytes
option and its associated MySQL Server system variables.
- Description
Sets the batch size in bytes for blob write operations. When the volume of blob data to be written within a given transaction exceeds this amount, all of the transaction's pending blob write operations are executed.
- Signature
void setMaxPendingBlobWriteBytes ( Uint32 bytes )- Parameters
The batch size, as the number of
bytes. Using 0 causes blob write batching to be disabled, which is the default behavior (for backward compatibility).- Return value
None.
Blob write batching can also be controlled in the
mysql client and other MySQL client
applications in NDB 8.0.30 and later by setting the MySQL
Server's
ndb_replica_blob_write_batch_bytes
server system variable to an appropriate value. You should be
aware that, when
ndb_replica_blob_write_batch_bytesis not
set,the effective blob batch size (that is, the maximum
number of pending bytes to write for blob columns) is determined
by the maximum of the default value of
ndb_replica_blob_write_batch_bytes and the
value set for the
--ndb-blob-write-batch-bytes
MySQL server option. For this reason, you should use
ndb_replica_blob_write_batch_bytes rather
than --ndb-blob-write-batch-bytes.
Prior to NDB 8.0.30, you must use the
--ndb-blob-write-batch-bytes option, or one of
its associated MySQL Server system variables, to set the blob
batch size from mysql or another MySQL client
program.
- Description
-
Enables or disables a schema object ownership check when multiple
Ndb_cluster_connectionobjects are in use. When this check is enabled, objects used by this transaction are checked to make sure that they belong to theNdbDictionaryowned by this connection. This is done by acquiring the schema objects of the same names from the connection and comparing these with the schema objects passed to the transaction. If they do not match, an error is returned.This method is available for debugging purposes. (Bug #19875977) You should be aware that enabling this check carries a performance penalty and for this reason you should avoid doing so in a production setting.
- Signature
void setSchemaObjOwnerChecks ( bool runChecks )- Parameters
A single parameter
runChecks. Usetrueto enable ownership checks,falseto disable them.- Return value
None.
- Description
This method creates an unlock operation on the current transaction; when executed, the unlock operation removes the lock referenced by the
NdbLockHandle(see NdbOperation::getLockHandle) passed to the method.- Signature
const NdbOperation* unlock ( const NdbLockHandle* lockHandle, NdbOperation::AbortOption ao = NdbOperation::DefaultAbortOption )- Parameters
-
A pointer to a lock handle; in addition, optionally, an
AbortOptionvalueao.In the event that the unlock operation fails—for example, due to the row already being unlocked—the
AbortOptionspecifies how this is handled, the default being that errors cause transactions to abort. - Return value
A pointer to an
NdbOperation(the unlock operation created).
- Description
Updates a tuple using an
NdbRecordobject.- Signature
const NdbOperation* updateTuple ( const NdbRecord* key_rec, const char* key_row, const NdbRecord* attr_rec, const char* attr_row, const unsigned char* mask = 0, const NdbOperation::OperationOptions* opts = 0, Uint32 sizeOfOptions = 0 )- Parameters
-
updateTuple()takes the following parameters:key_recis a pointer to anNdbRecordfor either a table or an index. If on a table, then the operation uses a primary key; if on an index, then the operation uses a unique key. In either case, thekey_recmust include all columns of the key.The
key_rowpassed to this method defines the primary or unique key of the affected tuple, and must remain valid untilexecute()is called.-
attr_recis anNdbRecordreferencing the attribute to be updated.NoteFor unique index operations, the
attr_recmust refer to the underlying table of the index, not to the index itself. attr_rowis a buffer containing the new data for the update.The
mask, if notNULL, defines a subset of attributes to be updated. The mask is copied, and so does not need to remain valid after the call to this method returns.OperationOptions(opts) can be used to provide more finely-grained control of operation definitions. AnOperationOptionsstructure is passed with flags indicating which operation definition options are present. Not all operation types support all operation options; for the options supported by each type of operation, see NdbTransaction::readTuple().The optional
sizeOfOptionsparameter is used to preserve backward compatibility of this interface with previous definitions of theOperationOptionsstructure. If an unusual size is detected by the interface implementation, it can use this to determine how to interpret the passedOperationOptionsstructure. To enable this functionality, the caller should passsizeof(NdbOperation::OperationOptions)for the value of this argument.
- Return value
The
NdbOperationrepresenting this operation (can be used to check for errors).
- Description
This method is used with
NdbRecordto write a tuple of data.- Signature
const NdbOperation* writeTuple ( const NdbRecord* key_rec, const char* key_row, const NdbRecord* attr_rec, const char* attr_row, const unsigned char* mask = 0, const NdbOperation::OperationOptions* opts = 0, Uint32 sizeOfOptions = 0 )- Parameters
-
This method takes the following parameters:
key_recis a pointer to anNdbRecordfor either a table or an index. If on a table, then the operation uses a primary key; if on an index, then the operation uses a unique key. In either case, thekey_recmust include all columns of the key.The
key_rowpassed to this method defines the primary or unique key of the tuple to be written, and must remain valid untilexecute()is called.-
attr_recis anNdbRecordreferencing the attribute to be written.For unique index operations, the
attr_recmust refer to the underlying table of the index, not to the index itself. attr_rowis a buffer containing the new data.The
mask, if notNULL, defines a subset of attributes to be written. The mask is copied, and so does not need to remain valid after the call to this method returns.OperationOptions(opts) can be used to provide more finely-grained control of operation definitions. AnOperationOptionsstructure is passed with flags indicating which operation definition options are present. Not all operation types support all operation options; for the options supported by each type of operation, see NdbTransaction::readTuple().The optional
sizeOfOptionsparameter is used to provide backward compatibility of this interface with previous definitions of theOperationOptionsstructure. If an unusual size is detected by the interface implementation, it can use this to determine how to interpret the passedOperationOptionsstructure. To enable this functionality, the caller should passsizeof(NdbOperation::OperationOptions)for the value of this argument.
- Return value
A
constpointer to theNdbOperationrepresenting this write operation. The operation can be checked for errors if and as necessary.