MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DBA

Classes

struct  DBA_ColumnDesc
struct  DBA_ColumnBinding
struct  DBA_BulkReadResultSet

Macros

#define DBA_BINDING(ColName, Type, Struct, Field)
#define DBA_BINDING_PTR(Struct, Field, ColBindings, NbCBindings)
#define DBA_INVALID_REQID   0

Typedefs

typedef int DBA_ErrorCode_t
typedef struct DBA_ColumnDesc DBA_ColumnDesc_t
typedef struct DBA_ColumnBinding DBA_ColumnBinding_t
typedef struct DBA_Binding DBA_Binding_t
typedef long DBA_ReqId_t
typedef void(* DBA_AsyncCallbackFn_t )(DBA_ReqId_t ReqId, DBA_Error_t Status, DBA_ErrorCode_t ErrorCode)
typedef struct
DBA_BulkReadResultSet 
DBA_BulkReadResultSet_t

Enumerations

enum  DBA_Error_t {
  DBA_NO_ERROR = 0, DBA_NOT_IMPLEMENTED = -1, DBA_NDB_ERROR = -2, DBA_ERROR = -3,
  DBA_APPLICATION_ERROR = 1, DBA_NO_DATA = 2, DBA_CONSTRAINT_VIOLATION = 3, DBA_SCHEMA_ERROR = 4,
  DBA_INSUFFICIENT_SPACE = 5, DBA_TEMPORARY_ERROR = 6, DBA_TIMEOUT = 7, DBA_OVERLOAD = 8,
  DBA_UNKNOWN_RESULT = 9
}
enum  DBA_DataTypes_t { DBA_CHAR, DBA_INT }

Functions

DBA_Error_t DBA_SetParameter (int ParameterId, int Value)
DBA_Error_t DBA_GetParameter (int ParameterId, int *Value)
DBA_Error_t DBA_Open ()
DBA_Error_t DBA_Close (void)
DBA_Error_t DBA_GetLatestError ()
DBA_ErrorCode_t DBA_GetLatestNdbError ()
const char * DBA_GetLatestErrorMsg ()
const char * DBA_GetErrorMsg (DBA_Error_t)
const char * DBA_GetNdbErrorMsg (DBA_ErrorCode_t)
DBA_Error_t DBA_CreateTable (const char *TableName, int NbColumns, const DBA_ColumnDesc_t Columns[])
DBA_Error_t DBA_DropTable (const char *TableName)
Boolean_t DBA_TableExists (const char *TableName)
DBA_Binding_tDBA_CreateBinding (const char *TableName, int NbCol, const DBA_ColumnBinding_t ColsBinding[], Size_t StructSz)
DBA_Error_t DBA_DestroyBinding (DBA_Binding_t *Binding)
DBA_ReqId_t DBA_InsertRows (const DBA_Binding_t *pBinding, const void *const pData[], int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_ArrayInsertRows (const DBA_Binding_t *pBinding, const void *pData, int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_UpdateRows (const DBA_Binding_t *pBinding, const void *const pData[], int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_ArrayUpdateRows (const DBA_Binding_t *pBinding, const void *pData, int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_DeleteRows (const DBA_Binding_t *pBinding, const void *const pData[], int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_ArrayDeleteRows (const DBA_Binding_t *pBinding, const void *pData, int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_WriteRows (const DBA_Binding_t *pBinding, const void *const pData[], int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_ArrayWriteRows (const DBA_Binding_t *pBinding, const void *pData, int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_ReadRows (const DBA_Binding_t *pBinding, void *const pData[], int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_ArrayReadRows (const DBA_Binding_t *pBinding, void *pData, int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_MultiInsertRow (const DBA_Binding_t *const pBindings[], const void *const pData[], int NbBindings, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_MultiUpdateRow (const DBA_Binding_t *const pBindings[], const void *const pData[], int NbBindings, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_MultiWriteRow (const DBA_Binding_t *const pBindings[], const void *const pData[], int NbBindings, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_MultiDeleteRow (const DBA_Binding_t *const pBindings[], const void *const pData[], int NbBindings, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_MultiReadRow (const DBA_Binding_t *const pBindings[], void *const pData[], int NbBindings, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_BulkReadRows (const DBA_Binding_t *pBinding, DBA_BulkReadResultSet_t pData[], int NbRows, DBA_AsyncCallbackFn_t CbFunc)
DBA_ReqId_t DBA_BulkMultiReadRows (const DBA_Binding_t *const pBindings[], DBA_BulkReadResultSet_t pData[], int NbBindings, int NbRows, DBA_AsyncCallbackFn_t CbFunc)

Detailed Description

Macro Definition Documentation

#define DBA_BINDING (   ColName,
  Type,
  Struct,
  Field 
)
Value:
{ ColName, Type, PCN_SIZE_OF( Struct, Field ), \
PCN_OFFSET_OF( Struct, Field ), 0, 0 }

Used to simplify binding definitions. See DBA_ColumnBinding for example.

Parameters
ColNameName of column in db table
TypeColumn/field type.
StructStructure
FieldField in structure
Returns
Arg list for defining binding of type DBA_Binding_t

Definition at line 175 of file dba.h.

#define DBA_BINDING_PTR (   Struct,
  Field,
  ColBindings,
  NbCBindings 
)
Value:
{ 0, DBA_CHAR, NbCBindings, PCN_OFFSET_OF( Struct, Field ), \
1, ColBindings }

Used to simplify ptr binding definitions. See DBA_ColumnBinding for example.

Parameters
StructStructure
FieldField in structure
Returns
Arg list for defining binding of type DBA_Binding_t

Definition at line 187 of file dba.h.

#define DBA_INVALID_REQID   0

An asynchronous call returning this means that the function was called with invalid arguments. The application should check error status with DBA_GetLatestError() etc.

Definition at line 407 of file dba.h.

Typedef Documentation

typedef void(* DBA_AsyncCallbackFn_t)(DBA_ReqId_t ReqId, DBA_Error_t Status, DBA_ErrorCode_t ErrorCode)

Callback function for transactions. Will be called in NBP process (Newton Batch Process).

Note
The implementation of the callback function is not allowed to make an asynchronous database call.
Parameters
ReqIdRequest identifier
StatusStatus of the request
ErrorCodeError code given by NDB
See Also
DBA_Error_t

Definition at line 421 of file dba.h.

typedef struct DBA_Binding DBA_Binding_t

A DBA_Binding_t object is used to establish a binding between one or more columns of a table to the fields of C structs.

It is used with insert, and update and read transactions to define on which columns of the table the operations is performed, and to which members of a C data structure they map.

All key columns must be bound to a field of the struct.

The function DBA_CreateBinding is used to create this binding.

Definition at line 265 of file dba.h.

A structure used for bulk reads. The structure contains a pointer to the data and an indicator. After the bulk read has completed, the indicator is set to 1 if the row was found and to 0 if the row was not found.

Typedef: DBA_ColumnBinding

Definition at line 251 of file dba.h.

Column description. Used for creating tables.

typedef int DBA_ErrorCode_t

Error code. This is the error code that is returned by NDB. Not to be confused by the status returned by the DBA implementation.

Definition at line 141 of file dba.h.

typedef long DBA_ReqId_t

Used to identify a pending db request

Definition at line 400 of file dba.h.

Enumeration Type Documentation

DBA column types

Enumerator:
DBA_CHAR 

String

DBA_INT 

Integer

Definition at line 146 of file dba.h.

Possible error status for DBA functions.

Enumerator:
DBA_NO_ERROR 

Success

DBA_NOT_IMPLEMENTED 

Function not implemented

DBA_NDB_ERROR 

Uncategorised error from NDB

DBA_ERROR 

Uncategorised error from DBA implementation

DBA_APPLICATION_ERROR 

Function called with invalid argument(s) or other application errors

DBA_NO_DATA 

No row with specified PK existed

DBA_CONSTRAINT_VIOLATION 

There already exists a row with that PK

DBA_SCHEMA_ERROR 

Table already exists

DBA_INSUFFICIENT_SPACE 

The DB is full

DBA_TEMPORARY_ERROR 

Some temporary problem occured

DBA_TIMEOUT 

The request timed out, probably due to dead-lock

DBA_OVERLOAD 

The DB is overloaded

DBA_UNKNOWN_RESULT 

It is unknown wheater transaction was commited or aborted

Definition at line 115 of file dba.h.

Function Documentation

DBA_ReqId_t DBA_ArrayDeleteRows ( const DBA_Binding_t pBinding,
const void *  pData,
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Delete row(s) from the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of structures. Only fields part of the primary key needs to be set.
NbRowsNo of rows to delete (i.e. length of pData array)
Returns
Request identifier
DBA_ReqId_t DBA_ArrayInsertRows ( const DBA_Binding_t pBinding,
const void *  pData,
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Insert row(s) in the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of structures.
NbRowsNo of rows to insert (i.e. length of pData array)
Returns
Request identifier
Note
All the table columns must be part of the binding.
DBA_ReqId_t DBA_ArrayReadRows ( const DBA_Binding_t pBinding,
void *  pData,
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Read row(s) from a table of the database (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of structures. Only fields part of the primary key needs to be set. The other fields in the binding will be populated.
NbRowsNo of rows to read (i.e. length of pData array)
Returns
Request identifier
DBA_ReqId_t DBA_ArrayUpdateRows ( const DBA_Binding_t pBinding,
const void *  pData,
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Update row(s) in the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of structures. Fields that are part of the key are used to generate the where clause, the other fields are used to update the row.
NbRowsNo of rows to update (i.e. length of pData array).
Returns
Request identifier
DBA_ReqId_t DBA_ArrayWriteRows ( const DBA_Binding_t pBinding,
const void *  pData,
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Update/Insert row(s) in the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of structures.
NbRowsNo of rows to update/insert (i.e. length of pData array)
Returns
Request identifier
Note
All the table columns must be part of the binding.
DBA_ReqId_t DBA_BulkMultiReadRows ( const DBA_Binding_t *const  pBindings[],
DBA_BulkReadResultSet_t  pData[],
int  NbBindings,
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Read rows from several tables of the database in potentially multiple transactions.

 The pData array must be organized as follows:
   NbRows with DataPtr pointing to structure of type pBindings[0]
   NbRows with DataPtr pointing to structure of type pBindings[1]
   ... 

Meaning that the pData array must be (NbBindings * NbRows) in length.

The user should for each (NbRows * NbBindings) specify the primary key fields.

Parameters
pBindingsArray of pointers to bindings
pDataArray of DBA_BulkReadResultSet_t. With DataPtr pointing to structure. Only the fields which are part of the key need be set. The RowFoundIndicator will be set when the operations returns.
NbBindingsNo of bindings (i.e. length of pBindings array)
NbRowsNo of rows per binding to read
Returns
Request identifier
DBA_ReqId_t DBA_BulkReadRows ( const DBA_Binding_t pBinding,
DBA_BulkReadResultSet_t  pData[],
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Read rows from a table of the database (potentially multiple transactions) The users should for each NbRows specify the fields part of the primary key

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of DBA_BulkReadResultSet_t, with DataPtr pointing to structure. Only the fields which are part of the primary key need be set. The RowFoundIndicator will be set when the request returns.
NbRowsNo of rows to read (i.e. length of pData array)
Returns
Request identifier
DBA_Error_t DBA_Close ( void  )

Close connection to NDB cluster and free allocated memory.

Returns
Error status
DBA_Binding_t* DBA_CreateBinding ( const char *  TableName,
int  NbCol,
const DBA_ColumnBinding_t  ColsBinding[],
Size_t  StructSz 
)

Define a binding between the columns of a table and a C structure.

Parameters
TableNametable
NbColnumber of columns bindings
ColBindingbindings
StructSzSizeof structure.
Returns
Created binding, or NULL if binding could not be created.
DBA_Error_t DBA_CreateTable ( const char *  TableName,
int  NbColumns,
const DBA_ColumnDesc_t  Columns[] 
)

Create a table.

Parameters
TableNameName of table to create.
NbColumnsnumbers of columns.
ColumnsColumn descriptions.
Returns
Status.
DBA_ReqId_t DBA_DeleteRows ( const DBA_Binding_t pBinding,
const void *const  pData[],
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Delete row(s) from the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of pointers to structures. Only fields part of the primary key needs to be set.
NbRowsNo of rows to delete (i.e. length of pData array)
Returns
Request identifier
DBA_Error_t DBA_DestroyBinding ( DBA_Binding_t Binding)

Destroys a DBA_Binding_t allocated with DBA_CreateBinding.

Parameters
pBindingPointer to binding.
Returns
Status.
DBA_Error_t DBA_DropTable ( const char *  TableName)

Destroy a table.

Parameters
TableNameTable name.
Returns
Status.
Note
Not implemented
const char* DBA_GetErrorMsg ( DBA_Error_t  )

Get error msg associated with code

Note
String must not be free by caller of this method
DBA_Error_t DBA_GetLatestError ( )

Get latest DBA error.

Note
Only applicable to synchronous methods
const char* DBA_GetLatestErrorMsg ( )

Get latest error string associated with DBA_GetLatestError().

Note
String must not be free by caller of this method.
Only applicable to synchronous methods.
DBA_ErrorCode_t DBA_GetLatestNdbError ( )

Get latest NDB error.

Note
Only applicable to synchronous methods
const char* DBA_GetNdbErrorMsg ( DBA_ErrorCode_t  )

Get error msg associated with code

Note
String must not be free by caller of this method
DBA_Error_t DBA_GetParameter ( int  ParameterId,
int *  Value 
)

Set DBA configuration parameter. See DBA_SetParameter for description of parameters.

Returns
Status
DBA_ReqId_t DBA_InsertRows ( const DBA_Binding_t pBinding,
const void *const  pData[],
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Insert row(s) in the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of pointers to structures.
NbRowsNo of rows to insert (i.e. length of pData array)
Returns
Request identifier
Note
All the table columns must be part of the binding.
DBA_ReqId_t DBA_MultiDeleteRow ( const DBA_Binding_t *const  pBindings[],
const void *const  pData[],
int  NbBindings,
DBA_AsyncCallbackFn_t  CbFunc 
)

Delete one row for each specified binding (as one transaction).

Parameters
pBindingsArray of pointers to bindings.
pDataArray of pointers to structures.
NbBindingsNo of bindings (tables) to insert into i.e. length of arrays pBindings and pData
Returns
Request identifier
Note
It is valid to specify the same binding twice (with corresponding data pointer) if you want to delete two rows in one table
DBA_ReqId_t DBA_MultiInsertRow ( const DBA_Binding_t *const  pBindings[],
const void *const  pData[],
int  NbBindings,
DBA_AsyncCallbackFn_t  CbFunc 
)

Insert one row for each specified binding (as one transaction).

Parameters
pBindingsArray of pointers to bindings.
pDataArray of pointers to structures.
NbBindingsNo of bindings (tables) to insert into, i.e. length of arrays pBindings and pData
Returns
Request identifier
Note
It is valid to specify the same binding twice (with corresponding data pointer) if you want to insert two rows in one table
DBA_ReqId_t DBA_MultiReadRow ( const DBA_Binding_t *const  pBindings[],
void *const  pData[],
int  NbBindings,
DBA_AsyncCallbackFn_t  CbFunc 
)

Read one row for each specified binding (as one transaction).

Parameters
pBindingsArray of pointers to bindings.
pDataArray of pointers to structures.
NbBindingsNo of bindings (tables) to insert into i.e. length of arrays pBindings and pData
Returns
Request identifier
Note
It is valid to specify the same binding twice (with corresponding data pointer) if you want to read two rows in one table
DBA_ReqId_t DBA_MultiUpdateRow ( const DBA_Binding_t *const  pBindings[],
const void *const  pData[],
int  NbBindings,
DBA_AsyncCallbackFn_t  CbFunc 
)

Update one row for each specified binding (as one transaction).

Parameters
pBindingsArray of pointers to bindings.
pDataArray of pointers to structures.
NbBindingsNo of bindings (tables) to insert into i.e. length of arrays pBindings and pData
Returns
Request identifier
Note
It is valid to specify the same binding twice (with corresponding data pointer) if you want to update two rows in one table
DBA_ReqId_t DBA_MultiWriteRow ( const DBA_Binding_t *const  pBindings[],
const void *const  pData[],
int  NbBindings,
DBA_AsyncCallbackFn_t  CbFunc 
)

Update/insert one row for each specified binding (as one transaction).

Parameters
pBindingsArray of pointers to bindings.
pDataArray of pointers to structures.
NbBindingsNo of bindings (tables) to insert into i.e. length of arrays pBindings and pData
Returns
Request identifier
Note
It is valid to specify the same binding twice (with corresponding data pointer) if you want to update/insert two rows in one table
DBA_Error_t DBA_Open ( )

Initialize DBA library and connect to NDB Cluster.

Returns
Status
DBA_ReqId_t DBA_ReadRows ( const DBA_Binding_t pBinding,
void *const  pData[],
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Read row(s) from a table of the database (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of pointers to structures. Only fields part of the primary key needs to be set. The other fields in the binding will be populated.
NbRowsNo of rows to read (i.e. length of pData array)
Returns
Request identifier
DBA_Error_t DBA_SetParameter ( int  ParameterId,
int  Value 
)

Set DBA configuration parameter

  Id Description                 Default Min  Max
  == =========================== ======= ==== ====
  0  NBP Interval                   10    4   -
  1  Operations/Bulkread          1000    1   5000
  2  Start transaction timeout       0    0   -
  3  Force send algorithm            1    0   2
*
Returns
Status
Boolean_t DBA_TableExists ( const char *  TableName)

Test for existence of a table.

Parameters
TableNameTable name.
Returns
Boolean value indicating if table exists or not.
DBA_ReqId_t DBA_UpdateRows ( const DBA_Binding_t pBinding,
const void *const  pData[],
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Update row(s) in the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of pointers to structures. Fields that are part of the key are used to generate the where clause, the other fields are used to update the row.
NbRowsNo of rows to update (i.e. length of pData array).
Returns
Request identifier
DBA_ReqId_t DBA_WriteRows ( const DBA_Binding_t pBinding,
const void *const  pData[],
int  NbRows,
DBA_AsyncCallbackFn_t  CbFunc 
)

Updates/Inserts row(s) in the table (one transaction)

Parameters
pBindingBinding between table columns and struct fields.
pDataArray of pointers to structures.
NbRowsNo of rows to update/insert (i.e. length of pData array)
Returns
Request identifier
Note
All the table columns must be part of the binding.