66 #ifndef __ARASTORAGE_ARA_STORAGE_H 67 #define __ARASTORAGE_ARA_STORAGE_H 83 #define INVALID_TUPLE (tuple_id_t)-1 84 #define INVALID_CURSOR_VALUE -1 86 #define DB_ERROR(result_code) ((result_code) < DB_OK) 87 #define DB_SUCCESS(result_code) !DB_ERROR(result_code) 90 #define DB_INT_MAX INT_MAX 91 #define DB_INT_MIN INT_MIN + 1 93 #define DB_LONG_MAX LONG_MAX 94 #define DB_LONG_MIN LONG_MIN + 1 96 #ifdef CONFIG_HAVE_DOUBLE 97 #define DB_DOUBLE_MAX DBL_MAX 98 #define DB_DOUBLE_MIN DBL_MIN + 1 100 #define DB_DOUBLE_MAX FLT_MAX 101 #define DB_DOUBLE_MIN FLT_MIN + 1 105 #define DB_INT_ERROR INT_MIN 106 #define DB_LONG_ERROR LONG_MIN 107 #ifdef CONFIG_HAVE_DOUBLE 108 #define DB_DOUBLE_ERROR DBL_MIN 110 #define DB_DOUBLE_ERROR FLT_MIN 116 #define DB_FINISHED_MSG "Iteration finished" 117 #define DB_OK_MSG "Operation succeeded" 118 #define DB_LIMIT_ERROR_MSG "Limit reached" 119 #define DB_ALLOCATION_ERROR_MSG "Allocation error" 120 #define DB_STORAGE_ERROR_MSG "Storage error" 121 #define DB_PARSING_ERROR_MSG "Parsing error" 122 #define DB_NAME_ERROR_MSG "Invalid name" 123 #define DB_RELATIONAL_ERROR_MSG "Semantic error" 124 #define DB_TYPE_ERROR_MSG "Type error" 125 #define DB_IMPLEMENTATION_ERROR_MSG "Implementation error" 126 #define DB_INDEX_ERROR_MSG "Index error" 127 #define DB_BUSY_ERROR_MSG "Busy with processing" 128 #define DB_INCONSISTENCY_ERROR_MSG "Inconsistent handle" 129 #define DB_ARGUMENT_ERROR_MSG "Invalid argument" 130 #define DB_FULL_ERROR_MSG "Tuple limit reached" 131 #define DB_CURSOR_ERROR_MSG "Cursor Error" 132 #define DB_UNKNOWN_ERROR_MSG "Unknown result code" 133 #define DB_EMPTY_CURSOR_ERROR_MSG "Empty Cursor" 140 DB_ALLOCATION_ERROR = -2,
141 DB_STORAGE_ERROR = -3,
142 DB_PARSING_ERROR = -4,
144 DB_RELATIONAL_ERROR = -6,
146 DB_IMPLEMENTATION_ERROR = -8,
149 DB_INCONSISTENCY_ERROR = -11,
150 DB_ARGUMENT_ERROR = -12,
152 DB_CURSOR_ERROR = -14,
153 DB_EMPTY_CURSOR_ERROR = -15
156 typedef enum db_result_e db_result_t;
159 DOMAIN_UNSPECIFIED = 0,
166 typedef enum domain_e domain_t;
170 typedef struct _db_handle_s db_handle_t;
173 typedef struct _db_cursor_s db_cursor_t;
175 typedef int db_storage_id_t;
177 typedef uint32_t cursor_row_t;
179 typedef uint32_t tuple_id_t;
181 typedef uint8_t attribute_id_t;
186 typedef int (*db_output_function_t)(
const char *, ...);
188 static db_output_function_t output = printf;
223 db_result_t
db_exec(
char *format);
233 db_cursor_t *
db_query(
char *format);
335 db_result_t
cursor_move_to(db_cursor_t *cursor, tuple_id_t row_id);
434 #ifdef CONFIG_ARCH_FLOAT_H 445 double cursor_get_double_value(db_cursor_t *cursor,
int attr_index);
cursor_row_t cursor_get_count(db_cursor_t *cursor)
get the number of rows of cursor
domain_t cursor_get_attr_type(db_cursor_t *cursor, int attr_index)
get type of attribute with specific index in cursor
db_result_t db_exec(char *format)
create or remove relations, attributes and indexes in arastorage
db_result_t cursor_move_last(db_cursor_t *cursor)
move current position of cursor to last row
bool cursor_is_last_row(db_cursor_t *cursor)
check whether current position of cursor is last row
db_result_t db_deinit(void)
de-initialize database's resources, it must be called when terminating arastorage ...
db_result_t cursor_move_next(db_cursor_t *cursor)
move current position of cursor to next row
db_result_t cursor_move_first(db_cursor_t *cursor)
move current position of cursor to first row
bool cursor_is_first_row(db_cursor_t *cursor)
check whether current position of cursor is first row
const char * db_get_result_message(db_result_t code)
get string corresponding to each result value of API
cursor_row_t cursor_get_row(db_cursor_t *cursor)
get current position of cursor
char * cursor_get_attr_name(db_cursor_t *cursor, int attr_index)
get name of attribute with specific index in cursor
db_result_t cursor_move_prev(db_cursor_t *cursor)
move current position of cursor to previous row
db_result_t db_print_tuple(db_cursor_t *cursor)
print the tuple data
unsigned char * cursor_get_string_value(db_cursor_t *cursor, int attr_index)
get value of attribute of which the type is DOMAIN_STRING with specific index in current row...
db_result_t cursor_move_to(db_cursor_t *cursor, tuple_id_t row_id)
move current position of cursor to specific row
attribute_id_t cursor_get_attr_index(db_cursor_t *cursor, const char *attr_name)
get index of attribute corresponding name in cursor
db_cursor_t * db_query(char *format)
process query of arastorage
db_result_t db_print_header(db_cursor_t *cursor)
print the name of relation and attributes
db_result_t db_init(void)
initialize database's resources, it must be called for using arastorage
db_result_t db_print_value(db_cursor_t *cursor, int attr_index)
print current row's data with specific attribute index
db_result_t db_cursor_free(db_cursor_t *cursor)
free allocated cursor data, it should be called before application terminated
int cursor_get_int_value(db_cursor_t *cursor, int attr_index)
get value of attribute of which the type is DOMAIN_INT with specific index in current row...
long cursor_get_long_value(db_cursor_t *cursor, int attr_index)
get value of attribute of which the type is DOMAIN_LONG with specific index in current row...