NdbOperation Class Reference

#include <NdbOperation.hpp>

Inheritance diagram for NdbOperation:

NdbIndexOperation NdbScanOperation NdbIndexScanOperation

List of all members.


Detailed Description

Class of operations for use in transactions.

Define Standard Operation Type

Public Member Functions

Specify Search Conditions
Specify Attribute Actions for Operations
Error Handling

Member Enumeration Documentation

Different access types (supported by sub-classes of NdbOperation)

Enumerator:
PrimaryKeyAccess  Read, insert, update, or delete using pk.
UniqueIndexAccess  Read, update, or delete using unique index.
TableScan  Full table scan.
OrderedIndexScan  Ordered index scan.

Lock when performing read

Enumerator:
LM_Read  Read with shared lock.
LM_Exclusive  Read with exclusive lock.
LM_CommittedRead  Ignore locks, read last committed value.


Member Function Documentation

virtual int NdbOperation::insertTuple (  )  [virtual]

Define the NdbOperation to be a standard operation of type insertTuple. When calling NdbTransaction::execute, this operation adds a new tuple to the table.

Returns:
0 if successful otherwise -1.

Reimplemented in NdbIndexOperation.

virtual int NdbOperation::updateTuple (  )  [virtual]

Define the NdbOperation to be a standard operation of type updateTuple. When calling NdbTransaction::execute, this operation updates a tuple in the table.

Returns:
0 if successful otherwise -1.

Reimplemented in NdbIndexOperation.

virtual int NdbOperation::writeTuple (  )  [virtual]

Define the NdbOperation to be a standard operation of type writeTuple. When calling NdbTransaction::execute, this operation writes a tuple to the table. If the tuple exists, it updates it, otherwise an insert takes place.

Returns:
0 if successful otherwise -1.

virtual int NdbOperation::deleteTuple (  )  [virtual]

Define the NdbOperation to be a standard operation of type deleteTuple. When calling NdbTransaction::execute, this operation delete a tuple.

Returns:
0 if successful otherwise -1.

Reimplemented in NdbIndexOperation.

virtual int NdbOperation::readTuple ( LockMode   )  [virtual]

Define the NdbOperation to be a standard operation of type readTuple. When calling NdbTransaction::execute, this operation reads a tuple.

Returns:
0 if successful otherwise -1.

Reimplemented in NdbIndexOperation.

int NdbOperation::equal ( const char *  anAttrName,
const char *  aValue,
Uint32  len = 0 
)

Define a search condition with equality. The condition is true if the attribute has the given value. To set search conditions on multiple attributes, use several equals (then all of them must be satisfied for the tuple to be selected).

Note:
For insertTuple() it is also allowed to define the search key by using setValue().

There are 10 versions of equal() with slightly different parameters.

When using equal() with a string (char *) as second argument, the string needs to be padded with zeros in the following sense:

       // Equal needs strings to be padded with zeros
       strncpy(buf, str, sizeof(buf));
       NdbOperation->equal("Attr1", buf);
Parameters:
anAttrName Attribute name
aValue Attribute value.
len Attribute length expressed in bytes.
Returns:
-1 if unsuccessful.

NdbRecAttr* NdbOperation::getValue ( const char *  anAttrName,
char *  aValue = 0 
)

Defines a retrieval operation of an attribute value. The NDB API allocate memory for the NdbRecAttr object that will hold the returned attribute value.

Note:
Note that it is the applications responsibility to allocate enough memory for aValue (if non-NULL). The buffer aValue supplied by the application must be aligned appropriately. The buffer is used directly (avoiding a copy penalty) only if it is aligned on a 4-byte boundary and the attribute size in bytes (i.e. NdbRecAttr::attrSize times NdbRecAttr::arraySize is a multiple of 4).

There are two versions of NdbOperation::getValue with slightly different parameters.

This method does not fetch the attribute value from the database! The NdbRecAttr object returned by this method is not readable/printable before the transaction has been executed with NdbTransaction::execute.

Parameters:
anAttrName Attribute name
aValue If this is non-NULL, then the attribute value will be returned in this parameter.
If NULL, then the attribute value will only be stored in the returned NdbRecAttr object.
Returns:
An NdbRecAttr object to hold the value of the attribute, or a NULL pointer (indicating error).

virtual int NdbOperation::setValue ( const char *  anAttrName,
const char *  aValue,
Uint32  len = 0 
) [virtual]

Define an attribute to set or update in query.

To set a NULL value, use the following construct:

   setValue("ATTR_NAME", (char*)NULL);

There are a number of NdbOperation::setValue methods that take a certain type as input (pass by value rather than passing a pointer). As the interface is currently implemented it is the responsibility of the application programmer to use the correct types.

The NDB API will however check that the application sends a correct length to the interface as given in the length parameter. The passing of char* as the value can contain any type or any type of array. If length is not provided or set to zero, then the API will assume that the pointer is correct and not bother with checking it.

Note:
For insertTuple() the NDB API will automatically detect that it is supposed to use equal() instead.

For insertTuple() it is not necessary to use setValue() on key attributes before other attributes.

There are 14 versions of NdbOperation::setValue with slightly different parameters.

Parameters:
anAttrName Name (or Id) of attribute.
aValue Attribute value to set.
len Attribute length expressed in bytes.
Returns:
-1 if unsuccessful.

virtual NdbBlob* NdbOperation::getBlobHandle ( const char *  anAttrName  )  [virtual]

This method replaces getValue/setValue for blobs. It creates a blob handle NdbBlob. A second call with same argument returns the previously created handle. The handle is linked to the operation and is maintained automatically.

See NdbBlob for details.

const NdbError& NdbOperation::getNdbError (  )  const

Get the latest error code.

Returns:
error code.

int NdbOperation::getNdbErrorLine (  ) 

Get the method number where the error occured.

Returns:
method number where the error occured.

const char* NdbOperation::getTableName (  )  const

Get table name of this operation.

const NdbDictionary::Table* NdbOperation::getTable (  )  const

Get table object for this operation

const Type NdbOperation::getType (  )  const

Get the type of access for this operation

LockMode NdbOperation::getLockMode (  )  const [inline]

Return lock mode for operation


Documentation generated Mon Sep 29 08:15:18 2008 from mysql source files.
© 2003-2004 MySQL AB