influxdb/parser/query_types.h

132 lines
2.4 KiB
C
Raw Normal View History

#include <stddef.h>
#define FALSE 0
#define TRUE !FALSE
// #define DEBUG
typedef struct {
size_t size;
char **elems;
} array;
struct value_t;
2013-10-03 17:11:48 +00:00
typedef struct {
size_t size;
struct value_t **elems;
} value_array;
typedef struct value_t {
char *name;
enum {
VALUE_REGEX,
VALUE_INT,
2013-10-16 17:27:53 +00:00
VALUE_FLOAT,
VALUE_BOOLEAN,
VALUE_STRING,
VALUE_INTO_NAME,
VALUE_TABLE_NAME,
VALUE_SIMPLE_NAME,
VALUE_DURATION,
VALUE_WILDCARD,
VALUE_FUNCTION_CALL,
VALUE_EXPRESSION
} value_type;
char *alias;
char is_case_insensitive;
value_array *args;
} value;
typedef struct condition_t {
char is_bool_expression;
void *left;
char* op; /* AND, OR or NULL if there's no right operand */
struct condition_t *right;
} condition;
typedef struct groupby_clause_t {
value_array *elems;
value *fill_function;
} groupby_clause;
2013-10-07 16:35:04 +00:00
typedef struct {
int first_line;
int first_column;
int last_line;
int last_column;
2013-10-07 16:35:04 +00:00
char *err;
} error;
typedef struct {
value *name;
char *alias;
} table_name;
typedef struct {
size_t size;
table_name **elems;
} table_name_array;
typedef struct {
enum {
FROM_ARRAY,
FROM_MERGE,
FROM_INNER_JOIN
} from_clause_type;
// in case of merge or join, it's guaranteed that the names array
// will have two table names only and they aren't regex.
table_name_array *names;
} from_clause;
2013-12-23 22:30:21 +00:00
typedef struct {
value *target;
value *backfill_function;
2013-12-23 22:30:21 +00:00
} into_clause;
typedef struct {
value_array *c;
from_clause *from_clause;
groupby_clause *group_by;
2013-12-23 22:30:21 +00:00
into_clause *into_clause;
condition *where_condition;
2013-10-07 21:13:53 +00:00
int limit;
char ascending;
2014-03-09 03:28:54 +00:00
char explain;
} select_query;
typedef struct {
from_clause *from_clause;
condition *where_condition;
error *error;
} delete_query;
typedef struct {
value *name;
} drop_series_query;
2013-12-23 22:30:21 +00:00
typedef struct {
int id;
} drop_query;
typedef struct {
select_query *select_query;
delete_query *delete_query;
drop_series_query *drop_series_query;
2013-12-23 22:30:21 +00:00
drop_query *drop_query;
2013-12-18 17:28:38 +00:00
char list_series_query;
2013-12-23 22:30:21 +00:00
char list_continuous_queries_query;
error *error;
} query;
2013-10-03 15:54:39 +00:00
2013-10-08 14:48:19 +00:00
// some funcs for freeing our types
void free_array(array *array);
void free_value_array(value_array *array);
void free_value(value *value);
void free_condition(condition *condition);
void free_error (error *error);
// this is the api that is used in GO
2013-10-03 15:54:39 +00:00
query parse_query(char *const query_s);
2013-10-03 17:11:48 +00:00
void close_query (query *q);