2014-10-09 01:30:22 +02:00
|
|
|
/*
|
|
|
|
* Statement.h
|
|
|
|
* Definition of the structure used to build the syntax tree.
|
|
|
|
*/
|
|
|
|
#ifndef __STATEMENT_H__
|
|
|
|
#define __STATEMENT_H__
|
2014-10-20 22:33:36 +02:00
|
|
|
|
2014-10-09 04:09:47 +02:00
|
|
|
#include "Expr.h"
|
2014-10-09 01:30:22 +02:00
|
|
|
#include "List.h"
|
2014-10-22 17:42:05 +02:00
|
|
|
#include "Table.h"
|
2014-10-09 01:30:22 +02:00
|
|
|
|
2014-10-27 11:48:55 +01:00
|
|
|
|
2014-10-09 01:30:22 +02:00
|
|
|
typedef enum {
|
2014-10-27 11:23:31 +01:00
|
|
|
kStmtSelect,
|
|
|
|
kStmtDelete,
|
|
|
|
kStmtInsert,
|
|
|
|
kStmtCreate
|
|
|
|
} StatementType;
|
2014-10-09 01:30:22 +02:00
|
|
|
|
|
|
|
|
2014-10-27 11:48:55 +01:00
|
|
|
const int64_t kNoLimit = -1;
|
|
|
|
const int64_t kNoOffset = -1;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
kOrderNone,
|
|
|
|
kOrderAsc,
|
|
|
|
kOrderDesc
|
|
|
|
} OrderType;
|
|
|
|
|
|
|
|
|
|
|
|
struct OrderDescription {
|
|
|
|
OrderType type;
|
|
|
|
Expr* expr;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-10-22 17:42:05 +02:00
|
|
|
struct Statement {
|
2014-10-27 11:23:31 +01:00
|
|
|
Statement(StatementType type) : type(type) {};
|
|
|
|
StatementType type;
|
2014-10-09 01:30:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-10-22 17:42:05 +02:00
|
|
|
struct SelectStatement : Statement {
|
2014-10-27 11:23:31 +01:00
|
|
|
SelectStatement() : Statement(kStmtSelect) {};
|
2014-10-09 01:30:22 +02:00
|
|
|
|
2014-10-20 22:33:36 +02:00
|
|
|
TableRef* from_table;
|
|
|
|
List<Expr*>* select_list;
|
|
|
|
Expr* where_clause;
|
2014-10-27 11:48:55 +01:00
|
|
|
|
|
|
|
List<Expr*>* group_by;
|
|
|
|
Expr* having;
|
|
|
|
|
|
|
|
OrderDescription *order;
|
|
|
|
int64_t limit;
|
|
|
|
int64_t offset;
|
2014-10-09 01:30:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-10-22 17:42:05 +02:00
|
|
|
struct DeleteStatement : Statement {
|
|
|
|
// TODO
|
|
|
|
};
|
2014-10-09 01:30:22 +02:00
|
|
|
|
2014-10-22 17:42:05 +02:00
|
|
|
struct InsertStatement : Statement {
|
|
|
|
// TODO
|
|
|
|
};
|
2014-10-09 01:30:22 +02:00
|
|
|
|
2014-10-22 17:42:05 +02:00
|
|
|
struct CreateStatement : Statement {
|
|
|
|
// TODO
|
2014-10-09 01:30:22 +02:00
|
|
|
};
|
2014-10-20 22:33:36 +02:00
|
|
|
|
2014-10-22 17:42:05 +02:00
|
|
|
|
2014-10-20 22:33:36 +02:00
|
|
|
#endif // __STATEMENT_H__
|