45 static db_output_function_t output = printf;
55 db_set_output_function(db_output_function_t f)
61 db_get_result_message(db_result_t code)
65 return "Iteration finished";
67 return "Operation succeeded";
69 return "Limit reached";
70 case DB_ALLOCATION_ERROR:
71 return "Allocation error";
72 case DB_STORAGE_ERROR:
73 return "Storage error";
74 case DB_PARSING_ERROR:
75 return "Parsing error";
77 return "Invalid name";
78 case DB_RELATIONAL_ERROR:
79 return "Semantic error";
82 case DB_IMPLEMENTATION_ERROR:
83 return "Implementation error";
87 return "Busy with processing";
88 case DB_INCONSISTENCY_ERROR:
89 return "Inconsistent handle";
90 case DB_ARGUMENT_ERROR:
91 return "Invalid argument";
93 return "Unknown result code";
98 db_print_header(db_handle_t *handle)
103 output(
"[relation = %s, attributes = (", handle->result_rel->name);
104 attr =
list_head(handle->result_rel->attributes);
105 for(column = 0; column < handle->ncolumns; column++) {
107 return DB_IMPLEMENTATION_ERROR;
108 }
else if(attr->flags & ATTRIBUTE_FLAG_NO_STORE) {
111 output(
"%s%s", column > 0 ?
", " :
"", attr->name);
119 db_print_tuple(db_handle_t *handle)
122 attribute_value_t value;
125 output(
"Row %lu:\t", (
unsigned long)handle->current_row);
127 for(column = 0; column < handle->ncolumns; column++) {
128 result = db_get_value(&value, handle, column);
129 if(DB_ERROR(result)) {
130 output(
"Unable to get the value for row %lu, column %u: %s\n",
131 (
unsigned long)handle->current_row, column,
132 db_get_result_message(result));
136 switch(value.domain) {
138 output(
"\"%s\"\t", VALUE_STRING(&value));
141 output(
"%d\t", (
int)VALUE_INT(&value));
144 output(
"%ld\t", (
long)VALUE_LONG(&value));
147 output(
"\nUnrecognized domain: %d\n", value.domain);
148 return DB_IMPLEMENTATION_ERROR;
157 db_processing(db_handle_t *handle)
159 return handle->flags & DB_HANDLE_FLAG_PROCESSING;
Declarations of the main Antelope functions.
#define NULL
The null pointer.
void * list_head(list_t list)
Get a pointer to the first element of a list.