/usr/include/qof/sql_parser.h is in libqof-dev 0.8.7-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | #ifndef SQL_PARSER_H
#define SQL_PARSER_H
#include <glib.h>
#define YY_NO_UNISTD_H
typedef struct sql_statement sql_statement;
typedef struct sql_select_statement sql_select_statement;
typedef struct sql_insert_statement sql_insert_statement;
typedef struct sql_update_statement sql_update_statement;
typedef struct sql_delete_statement sql_delete_statement;
typedef struct sql_table sql_table;
typedef struct sql_where sql_where;
typedef struct sql_condition sql_condition;
typedef struct sql_order_field sql_order_field;
typedef struct sql_field sql_field;
typedef struct sql_field_item sql_field_item;
typedef struct param_spec param_spec;
/*
* global SQL statement structures
*/
typedef enum
{
SQL_select,
SQL_insert,
SQL_delete,
SQL_update
}
sql_statement_type;
struct sql_statement
{
sql_statement_type type;
char *full_query;
void *statement;
};
struct sql_select_statement
{
int distinct;
GList *fields; /* list of sql_field */
GList *from; /* list of sql_table */
sql_where *where;
GList *order; /* list of sql_order_field */
GList *group;
};
struct sql_insert_statement
{
sql_table *table;
GList *fields;
GList *values;
};
struct sql_update_statement
{
sql_table *table;
GList *set;
sql_where *where;
};
struct sql_delete_statement
{
sql_table *table;
sql_where *where;
};
/*
* Fields structures
*/
typedef enum
{
SQL_name,
SQL_equation,
SQL_inlineselect,
SQL_function
}
sql_field_type;
typedef enum
{
SQL_plus,
SQL_minus,
SQL_times,
SQL_div
}
sql_field_operator;
struct sql_field_item
{
sql_field_type type;
union
{
GList *name;
struct
{
sql_field_item *left;
sql_field_item *right;
sql_field_operator op;
}
equation;
sql_select_statement *select;
struct
{
gchar *funcname;
GList *funcarglist;
} function;
} d;
};
struct sql_field
{
sql_field_item *item;
char *as;
GList *param_spec;
};
typedef enum
{
PARAM_name,
PARAM_descr,
PARAM_type,
PARAM_isparam,
PARAM_nullok
} param_spec_type;
struct param_spec
{
param_spec_type type;
char *content;
};
/*
* Tables structures
*/
typedef enum
{
SQL_simple,
SQL_nestedselect
}
sql_table_type;
typedef enum
{
SQL_cross_join, /* default */
SQL_inner_join,
SQL_left_join,
SQL_right_join,
SQL_full_join
}
sql_join_type;
struct sql_table
{
sql_table_type type;
union
{
char *simple;
sql_select_statement *select;
}
d;
char *as;
sql_join_type join_type;
sql_where *join_cond;
};
/*
* Conditions structures
*/
typedef enum
{
SQL_eq,
SQL_is,
SQL_isnot,
SQL_in,
SQL_like,
SQL_notin,
SQL_between,
SQL_gt,
SQL_lt,
SQL_geq,
SQL_leq,
SQL_diff
}
sql_condition_operator;
struct sql_condition
{
sql_condition_operator op;
union
{
struct
{
sql_field *left;
sql_field *right;
}
pair;
struct
{
sql_field *field;
sql_field *lower;
sql_field *upper;
}
between;
}
d;
};
typedef enum
{
SQL_and,
SQL_or
}
sql_logic_operator;
typedef enum
{
SQL_single,
SQL_negated,
SQL_pair
}
sql_where_type;
struct sql_where
{
sql_where_type type;
union
{
sql_condition *single;
sql_where *negated;
struct
{
sql_where *left;
sql_where *right;
sql_logic_operator op;
}
pair;
}
d;
};
/*
* ORDER BY structure
*/
typedef enum
{
SQL_asc,
SQL_desc
}
sql_ordertype;
struct sql_order_field
{
sql_ordertype order_type;
GList *name;
};
int sql_display (sql_statement * statement);
int sql_destroy (sql_statement * statement);
char *sql_stringify (sql_statement * statement);
sql_statement *sql_parse (char *sql_statement);
sql_statement *sql_parse_with_error (char *sql_statement, GError ** error);
int sql_statement_append_field (sql_statement * statement, char *tablename,
char *fieldname, char *as);
int sql_statement_append_tablejoin (sql_statement * statement,
char *lefttable, char *righttable,
char *leftfield, char *rightfield);
int sql_statement_append_where (sql_statement * statement, char *leftfield,
char *rightfield, sql_logic_operator logicopr,
sql_condition_operator condopr);
GList *sql_statement_get_fields (sql_statement * statement);
GList *sql_statement_get_tables (sql_statement * statement);
void sql_statement_free_tables (GList * tables);
void sql_statement_free_fields (GList * fields);
char *sql_statement_get_first_table (sql_statement * statement);
gint sql_statement_get_wherejoin_ontable (sql_statement * statement,
gchar * ontable, GList ** leftfield,
GList ** rightfield,
sql_condition_operator * condopr);
#endif /* SQL_PARSER_H */
|