2004-06-14 15:01:06 -04:00
|
|
|
#ifndef __query__
|
|
|
|
#define __query__
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/* node opcodes */
|
|
|
|
qot_empty,
|
|
|
|
|
|
|
|
/* conjunctions */
|
|
|
|
qot_and,
|
|
|
|
qot_or,
|
|
|
|
|
|
|
|
/* negation */
|
|
|
|
qot_not,
|
|
|
|
|
|
|
|
/* arithmetic */
|
|
|
|
qot_eq,
|
|
|
|
qot_ne,
|
|
|
|
qot_le,
|
|
|
|
qot_lt,
|
|
|
|
qot_ge,
|
|
|
|
qot_gt,
|
|
|
|
|
|
|
|
/* string */
|
|
|
|
qot_is,
|
|
|
|
qot_begins,
|
|
|
|
qot_ends,
|
|
|
|
qot_contains,
|
|
|
|
|
|
|
|
/* constant opcode */
|
|
|
|
qot_const,
|
|
|
|
|
|
|
|
/* field types */
|
|
|
|
qft_i32,
|
|
|
|
qft_i64,
|
|
|
|
qft_string
|
|
|
|
|
|
|
|
} query_type_t;
|
|
|
|
|
|
|
|
typedef struct query_field_ query_field_t;
|
|
|
|
struct query_field_
|
|
|
|
{
|
2005-03-14 01:17:28 -05:00
|
|
|
query_type_t type;
|
2006-02-26 03:46:24 -05:00
|
|
|
const char* name;
|
2005-03-14 01:17:28 -05:00
|
|
|
const char* fieldname;
|
2004-06-14 15:01:06 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct query_node_ query_node_t;
|
|
|
|
struct query_node_
|
|
|
|
{
|
2006-02-26 03:46:24 -05:00
|
|
|
query_type_t type;
|
2004-06-14 15:01:06 -04:00
|
|
|
union {
|
2006-02-26 03:46:24 -05:00
|
|
|
query_node_t* node;
|
|
|
|
const query_field_t* field;
|
|
|
|
int constant;
|
|
|
|
} left;
|
2004-06-14 15:01:06 -04:00
|
|
|
union {
|
2006-02-26 03:46:24 -05:00
|
|
|
query_node_t* node;
|
|
|
|
int i32;
|
|
|
|
long long i64;
|
|
|
|
char* str;
|
|
|
|
} right;
|
2004-06-14 15:01:06 -04:00
|
|
|
};
|
|
|
|
|
2005-03-14 01:17:28 -05:00
|
|
|
extern char *query_build_sql(char *query);
|
2004-06-14 15:01:06 -04:00
|
|
|
|
|
|
|
#endif
|