2.3.17 The NdbBlob Class

2.3.17.1 NdbBlob Types
2.3.17.2 NdbBlob Methods

Abstract

This class represents a handle to a BLOB column and provides read and write access to BLOB column values. This object has a number of different states and provides several modes of access to BLOB data; these are also described in this section.

Parent class.  None

Child classes.  None

Description.  An instance of NdbBlob is created using the NdbOperation::getBlobHandle() method during the operation preparation phase. (See Section 2.3.24, “The NdbOperation Class”.) This object acts as a handle on a BLOB column.

BLOB Data Storage.  BLOB data is stored in 2 locations:

The inline and data segment sizes can be set using the appropriate Column methods when the table is created. See Section 2.3.2, “The Column Class”, for more information about these methods.

Data Access Types.  NdbBlob supports 3 types of data access: These data access types can be applied in combination, provided that they are used in the order given above.

BLOB Operations.  BLOB operations take effect when the next transaction is executed. In some cases, NdbBlob is forced to perform implicit execution. To avoid this, you should always operate on complete blob data segments. NdbBlob also supports reading post- or pre-blob data from events. The handle can be read after the next event on the main table has been retrieved. The data becomes available immediately. (See Section 2.3.20, “The NdbEventOperation Class”, for more information.)

BLOBs and NdbOperations.  NdbOperation methods acting on NdbBlob objects have the following characteristics:.

Known Issues.  The following are known issues or limitations encountered when working with NdbBlob objects:

Methods.  The following table lists the public methods of this class and the purpose or use of each method:

MethodPurpose / Use
blobsFirstBlob()Gets the first blob in a list.
blobsNextBlob()Gets the next blob in a list
getBlobEventName()Gets a blob event name
getBlobTableName()Gets a blob data segment's table name.
getColumn()Gets a blob column.
getLength()Gets the length of a blob, in bytes
getNdbError()Gets an error (an NdbError object)
getNdbOperation()Get a pointer to the operation (NdbOperation object) to which this NdbBlob object belonged when created.
getNull()Checks whether a blob value is NULL
getPos()Gets the current position for reading/writing
getState()Gets the state of an NdbBlob object
getValue()Prepares to read a blob value
getVersion()Checks whether a blob is statement-based or event-based
readData()Reads data from a blob
setActiveHook()Defines a callback for blob handle activation
setNull()Sets a blob to NULL
setPos()Sets the position at which to begin reading/writing
setValue()Prepares to insert or update a blob value
truncate()Truncates a blob to a given length
writeData()Writes blob data
Note

getBlobTableName() and getBlobEventName() are static methods.

Tip

Most NdbBlob methods (nearly all of those whose return type is int) return 0 on success and -1 in the event of failure.

For detailed descriptions, signatures, and examples of use for each of these methods, see Section 2.3.17.2, “NdbBlob Methods”.

Types.  The public types defined by NdbBlob are shown here:

TypePurpose / Use
ActiveHook()Callback for NdbBlob::setActiveHook()
State()Represents the states that may be assumed by the NdbBlob.

For a discussion of each of these types, along with its possible values, see Section 2.3.17.1, “NdbBlob Types”.

Class diagram.  This diagram shows all the available methods and types of the NdbBlob class:

Public methods and types of the NdbBlob class.