44 #define DEBUG DEBUG_NONE
47 static unsigned char char_buf[DB_MAX_CHAR_SIZE_PER_ROW];
48 static uint8_t next_free_offset;
50 static aql_attribute_t *
51 get_attribute(aql_adt_t *adt,
char *name)
55 for(i = 0; i < AQL_ATTRIBUTE_COUNT(adt); i++) {
56 if(strcmp(adt->attributes[i].name, name) == 0) {
57 return &adt->attributes[i];
63 static unsigned char *
64 save_char(
unsigned char *ptr,
size_t length)
66 unsigned char *start_ptr;
68 if(length + next_free_offset > DB_MAX_CHAR_SIZE_PER_ROW) {
72 start_ptr = char_buf + next_free_offset;
73 memcpy(start_ptr, ptr, length);
74 next_free_offset += length;
80 aql_clear(aql_adt_t *adt)
85 adt->optype = AQL_TYPE_NONE;
86 adt->relation_count = 0;
87 adt->attribute_count = 0;
90 memset(adt->aggregators, 0,
sizeof(adt->aggregators));
94 aql_add_attribute(aql_adt_t *adt,
char *name, domain_t domain,
95 unsigned element_size,
int processed_only)
97 aql_attribute_t *attr;
99 if(adt->attribute_count == AQL_ATTRIBUTE_LIMIT) {
100 return DB_LIMIT_ERROR;
103 if(processed_only && get_attribute(adt, name)) {
109 attr = &adt->attributes[adt->attribute_count++];
111 if(strlen(name) + 1 >
sizeof(attr->name)) {
112 return DB_LIMIT_ERROR;
115 strcpy(attr->name, name);
116 attr->domain = domain;
117 attr->element_size = element_size;
118 attr->flags = processed_only ? ATTRIBUTE_FLAG_NO_STORE : 0;
124 aql_add_value(aql_adt_t *adt, domain_t domain,
void *value_ptr)
126 attribute_value_t *value;
128 if(adt->value_count == AQL_ATTRIBUTE_LIMIT) {
129 return DB_LIMIT_ERROR;
132 value = &adt->values[adt->value_count++];
133 value->domain = domain;
137 VALUE_LONG(value) = *(
long *)value_ptr;
140 VALUE_STRING(value) = save_char(value_ptr, strlen(value_ptr) + 1);
141 if(VALUE_STRING(value) !=
NULL) {
145 return DB_TYPE_ERROR;
Definitions and declarations for AQL, the Antelope Query Language.
#define NULL
The null pointer.
A set of debugging macros.