66 #ifndef __ARASTORAGE_ARA_STORAGE_H 67 #define __ARASTORAGE_ARA_STORAGE_H 78 #define INVALID_TUPLE (tuple_id_t)-1 79 #define INVALID_CURSOR_VALUE -1 81 #define DB_ERROR(result_code) ((result_code) < DB_OK) 82 #define DB_SUCCESS(result_code) !DB_ERROR(result_code) 85 #define DB_INT_MAX INT_MAX 86 #define DB_INT_MIN INT_MIN + 1 88 #define DB_LONG_MAX LONG_MAX 89 #define DB_LONG_MIN LONG_MIN + 1 91 #ifdef CONFIG_HAVE_DOUBLE 92 #define DB_DOUBLE_MAX DBL_MAX 93 #define DB_DOUBLE_MIN DBL_MIN + 1 95 #define DB_DOUBLE_MAX FLT_MAX 96 #define DB_DOUBLE_MIN FLT_MIN + 1 100 #define DB_INT_ERROR INT_MIN 101 #define DB_LONG_ERROR LONG_MIN 102 #ifdef CONFIG_HAVE_DOUBLE 103 #define DB_DOUBLE_ERROR DBL_MIN 105 #define DB_DOUBLE_ERROR FLT_MIN 111 #define DB_FINISHED_MSG "Iteration finished" 112 #define DB_OK_MSG "Operation succeeded" 113 #define DB_LIMIT_ERROR_MSG "Limit reached" 114 #define DB_ALLOCATION_ERROR_MSG "Allocation error" 115 #define DB_STORAGE_ERROR_MSG "Storage error" 116 #define DB_PARSING_ERROR_MSG "Parsing error" 117 #define DB_NAME_ERROR_MSG "Invalid name" 118 #define DB_RELATIONAL_ERROR_MSG "Semantic error" 119 #define DB_TYPE_ERROR_MSG "Type error" 120 #define DB_IMPLEMENTATION_ERROR_MSG "Implementation error" 121 #define DB_INDEX_ERROR_MSG "Index error" 122 #define DB_BUSY_ERROR_MSG "Busy with processing" 123 #define DB_INCONSISTENCY_ERROR_MSG "Inconsistent handle" 124 #define DB_ARGUMENT_ERROR_MSG "Invalid argument" 125 #define DB_FULL_ERROR_MSG "Tuple limit reached" 126 #define DB_CURSOR_ERROR_MSG "Cursor Error" 127 #define DB_UNKNOWN_ERROR_MSG "Unknown result code" 128 #define DB_EMPTY_CURSOR_ERROR_MSG "Empty Cursor" 135 DB_ALLOCATION_ERROR = -2,
136 DB_STORAGE_ERROR = -3,
137 DB_PARSING_ERROR = -4,
139 DB_RELATIONAL_ERROR = -6,
141 DB_IMPLEMENTATION_ERROR = -8,
144 DB_INCONSISTENCY_ERROR = -11,
145 DB_ARGUMENT_ERROR = -12,
147 DB_CURSOR_ERROR = -14,
148 DB_EMPTY_CURSOR_ERROR = -15
151 typedef enum db_result_e db_result_t;
154 DOMAIN_UNSPECIFIED = 0,
161 typedef enum domain_e domain_t;
165 typedef struct _db_handle_s db_handle_t;
168 typedef struct _db_cursor_s db_cursor_t;
170 typedef int db_storage_id_t;
172 typedef uint32_t cursor_row_t;
174 typedef uint32_t tuple_id_t;
176 typedef uint8_t attribute_id_t;
181 typedef int (*db_output_function_t)(
const char *, ...);
183 static db_output_function_t output = printf;
218 db_result_t
db_exec(
char *format);
228 db_cursor_t *
db_query(
char *format);
330 db_result_t
cursor_move_to(db_cursor_t *cursor, tuple_id_t row_id);
429 #ifdef CONFIG_ARCH_FLOAT_H 440 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...