Classes | |
| struct | DBA_ColumnDesc |
| struct | DBA_BulkReadResultSet |
Defines | |
| #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 DBA_ColumnDesc | DBA_ColumnDesc_t |
| typedef long | DBA_ReqId_t |
| typedef void(*) | DBA_AsyncCallbackFn_t (DBA_ReqId_t ReqId, DBA_Error_t Status, DBA_ErrorCode_t ErrorCode) |
| typedef 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 } |
Enumerator | |
| 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 | |
| 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_t * | DBA_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) |
Variables | |
| DBA_DataTypes_t | DBA_ColumnDesc::DataType |
| Size_t | DBA_ColumnDesc::Size |
| Boolean_t | DBA_ColumnDesc::IsKey |
| Boolean_t | DBA_BulkReadResultSet::RowFoundIndicator |
| #define DBA_BINDING | ( | ColName, | |||
| Type, | |||||
| Struct, | |||||
| Field | ) |
Value:
{ ColName, Type, PCN_SIZE_OF( Struct, Field ), \
PCN_OFFSET_OF( Struct, Field ), 0, 0 }
| ColName | Name of column in db table | |
| Type | Column/field type. | |
| Struct | Structure | |
| Field | Field in structure |
| #define DBA_BINDING_PTR | ( | Struct, | |||
| Field, | |||||
| ColBindings, | |||||
| NbCBindings | ) |
Value:
{ 0, DBA_CHAR, NbCBindings, PCN_OFFSET_OF( Struct, Field ), \
1, ColBindings }
| #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.
| 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).
| ReqId | Request identifier | |
| Status | Status of the request | |
| ErrorCode | Error code given by NDB |
| typedef struct DBA_BulkReadResultSet DBA_BulkReadResultSet_t |
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 struct DBA_ColumnDesc DBA_ColumnDesc_t |
Column description. Used for creating tables.
| typedef int DBA_ErrorCode_t |
| typedef long DBA_ReqId_t |
| enum DBA_DataTypes_t |
| enum DBA_Error_t |
Possible error status for DBA functions.
Definition at line 113 of file dba.h.
00113 { 00114 DBA_NO_ERROR = 0, 00116 DBA_NOT_IMPLEMENTED = -1, 00117 DBA_NDB_ERROR = -2, 00118 DBA_ERROR = -3, 00120 DBA_APPLICATION_ERROR = 1, 00122 DBA_NO_DATA = 2, 00123 DBA_CONSTRAINT_VIOLATION = 3, 00125 DBA_SCHEMA_ERROR = 4, 00126 DBA_INSUFFICIENT_SPACE = 5, 00127 DBA_TEMPORARY_ERROR = 6, 00128 DBA_TIMEOUT = 7, 00130 DBA_OVERLOAD = 8, 00131 DBA_UNKNOWN_RESULT = 9 00133 } DBA_Error_t;
| DBA_APPLICATION_ERROR = 1 |
Function called with invalid argument(s) or other application errors
| DBA_CONSTRAINT_VIOLATION = 3 |
There already exists a row with that PK
| DBA_ERROR = -3 |
Uncategorised error from DBA implementation
| DBA_INSUFFICIENT_SPACE = 5 |
The DB is full
| DBA_NDB_ERROR = -2 |
Uncategorised error from NDB
| DBA_NO_DATA = 2 |
No row with specified PK existed
| DBA_NOT_IMPLEMENTED = -1 |
Function not implemented
| DBA_OVERLOAD = 8 |
The DB is overloaded
| DBA_SCHEMA_ERROR = 4 |
Table already exists
| DBA_TEMPORARY_ERROR = 6 |
Some temporary problem occured
| DBA_TIMEOUT = 7 |
The request timed out, probably due to dead-lock
| DBA_UNKNOWN_RESULT = 9 |
| DBA_ReqId_t DBA_ArrayDeleteRows | ( | const DBA_Binding_t * | pBinding, | |
| const void * | 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_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)
| pBinding | Binding between table columns and struct fields. | |
| pData | Array of structures. Only fields part of the primary key needs to be set. The other fields in the binding will be populated. | |
| NbRows | No of rows to read (i.e. length of pData array) |
| 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)
| pBinding | Binding between table columns and struct fields. | |
| pData | Array 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. | |
| NbRows | No of rows to update (i.e. length of pData array). |
| DBA_ReqId_t DBA_ArrayWriteRows | ( | const DBA_Binding_t * | pBinding, | |
| const void * | pData, | |||
| int | NbRows, | |||
| DBA_AsyncCallbackFn_t | CbFunc | |||
| ) |
| 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
| pBinding | Binding between table columns and struct fields. | |
| pData | Array 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. | |
| NbRows | No of rows to read (i.e. length of pData array) |
| DBA_Error_t DBA_Close | ( | void | ) |
Close connection to NDB cluster and free allocated memory.
| 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.
| TableName | table | |
| NbCol | number of columns bindings | |
| ColBinding | bindings | |
| StructSz | Sizeof structure. |
| DBA_Error_t DBA_CreateTable | ( | const char * | TableName, | |
| int | NbColumns, | |||
| const DBA_ColumnDesc_t | Columns[] | |||
| ) |
Create a table.
| TableName | Name of table to create. | |
| NbColumns | numbers of columns. | |
| Columns | Column descriptions. |
| DBA_ReqId_t DBA_DeleteRows | ( | const DBA_Binding_t * | pBinding, | |
| const void *const | pData[], | |||
| int | NbRows, | |||
| DBA_AsyncCallbackFn_t | CbFunc | |||
| ) |
| DBA_Error_t DBA_DestroyBinding | ( | DBA_Binding_t * | Binding | ) |
Destroys a DBA_Binding_t allocated with DBA_CreateBinding.
| pBinding | Pointer to binding. |
| DBA_Error_t DBA_DropTable | ( | const char * | TableName | ) |
Destroy a table.
| TableName | Table name. |
| const char* DBA_GetErrorMsg | ( | DBA_Error_t | ) |
| DBA_Error_t DBA_GetLatestError | ( | ) |
Get latest DBA error.
| const char* DBA_GetLatestErrorMsg | ( | ) |
Get latest error string associated with DBA_GetLatestError().
Only applicable to synchronous methods.
| DBA_ErrorCode_t DBA_GetLatestNdbError | ( | ) |
Get latest NDB error.
| const char* DBA_GetNdbErrorMsg | ( | DBA_ErrorCode_t | ) |
| DBA_Error_t DBA_GetParameter | ( | int | ParameterId, | |
| int * | Value | |||
| ) |
| DBA_ReqId_t DBA_InsertRows | ( | const DBA_Binding_t * | pBinding, | |
| const void *const | pData[], | |||
| int | NbRows, | |||
| 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 | |||
| ) |
Delete one row for each specified binding (as one transaction).
| pBindings | Array of pointers to bindings. | |
| pData | Array of pointers to structures. | |
| NbBindings | No of bindings (tables) to insert into i.e. length of arrays pBindings and pData |
| 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).
| pBindings | Array of pointers to bindings. | |
| pData | Array of pointers to structures. | |
| NbBindings | No of bindings (tables) to insert into, i.e. length of arrays pBindings and pData |
| 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).
| pBindings | Array of pointers to bindings. | |
| pData | Array of pointers to structures. | |
| NbBindings | No of bindings (tables) to insert into i.e. length of arrays pBindings and pData |
| 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).
| pBindings | Array of pointers to bindings. | |
| pData | Array of pointers to structures. | |
| NbBindings | No of bindings (tables) to insert into i.e. length of arrays pBindings and pData |
| 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).
| pBindings | Array of pointers to bindings. | |
| pData | Array of pointers to structures. | |
| NbBindings | No of bindings (tables) to insert into i.e. length of arrays pBindings and pData |
| DBA_Error_t DBA_Open | ( | ) |
Initialize DBA library and connect to NDB Cluster.
| 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)
| pBinding | Binding between table columns and struct fields. | |
| pData | Array of pointers to structures. Only fields part of the primary key needs to be set. The other fields in the binding will be populated. | |
| NbRows | No of rows to read (i.e. length of pData array) |
| DBA_Error_t DBA_SetParameter | ( | int | ParameterId, | |
| int | Value | |||
| ) |
The DBA_ColumnBinding_t is used to describe a binding between one column and one field of a C struct.
typedef struct Address {
char StreetName[30];
int StreetNumber;
} Address_t;
typdef struct Person {
char Name[30];
Address_t * AddressPtr;
} Person_t; For example, if the field Name of a Person_t data structure is bound to the column "NAME", the corresponding binding would be defined as:
*
DBA_ColumnBinding_t NameBinding = DBA_BINDING( "name", DBA_CHAR, Person_t, Name );
There is also the DBA_BINDING_PTR which is used when several linked structures should be put into one table.
For example, if data in a Person_t data structure should be saved in the same table as the Address_t data structure (as the address belongs to the person), the corresponding binding would be defined as:
*
DBA_ColumnBinding_t AddrBinding[AddrLen]; This binding describes how the
fields in the Address_t
structure is linked to the
table PERSON_ADDRESS
DBA_ColumnBinding_t AddressBinding = DBA_BINDING_PTR(Person_t, AddressPtr, AddrBinding, AddrLen);
*/ struct DBA_ColumnBinding { const char* Name; /**< Name of table column */ DBA_DataTypes_t DataType; /**< Type of member in structure */ Size_t Size; /**< Size in bytes of member or no of DBA_ColumnBinding's when doing ptr binding */ Size_t Offset; /**< Offset of the member */
Boolean_t Ptr; /**< True if binding is of ptr type */ const struct DBA_ColumnBinding * SubBinding; /**< Address of Binding Ptr valid if Ptr is true */ };
/** Typedef: DBA_ColumnBinding */ typedef struct DBA_ColumnBinding DBA_ColumnBinding_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. */ typedef struct DBA_Binding DBA_Binding_t;
/* --- Exported functions --- */
/** 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 *
| Boolean_t DBA_TableExists | ( | const char * | TableName | ) |
Test for existence of a table.
| TableName | Table name. |
| 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)
| pBinding | Binding between table columns and struct fields. | |
| pData | Array 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. | |
| NbRows | No of rows to update (i.e. length of pData array). |
| 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)
| pBinding | Binding between table columns and struct fields. | |
| pData | Array of pointers to structures. | |
| NbRows | No of rows to update/insert (i.e. length of pData array) |
DBA_DataTypes_t DBA_ColumnDesc::DataType [inherited] |
Boolean_t DBA_ColumnDesc::IsKey [inherited] |
Boolean_t DBA_BulkReadResultSet::RowFoundIndicator [inherited] |
Size_t DBA_ColumnDesc::Size [inherited] |
1.4.7

