HyriseSQLParser/src/lib/SelectStatement.h

78 lines
1.4 KiB
C
Raw Normal View History

2014-11-07 01:09:06 +01:00
#ifndef __SELECT_STATEMENT_H__
#define __SELECT_STATEMENT_H__
#include "Statement.h"
#include "Expr.h"
#include "List.h"
#include "Table.h"
namespace hsql {
/**
* @struct OrderDescription
* Description of the order by clause within a select statement
* TODO: hold multiple expressions to be sorted by
*/
typedef enum {
kOrderAsc,
kOrderDesc
} OrderType;
struct OrderDescription {
2014-11-13 01:27:47 +01:00
OrderDescription(OrderType type, Expr* expr) :
type(type),
expr(expr) {}
2014-11-07 15:21:54 +01:00
virtual ~OrderDescription(); // defined in destructors.cpp
2014-11-07 01:09:06 +01:00
OrderType type;
Expr* expr;
};
/**
* @struct LimitDescription
* Description of the limit clause within a select statement
*/
const int64_t kNoLimit = -1;
const int64_t kNoOffset = -1;
struct LimitDescription {
2014-11-13 01:27:47 +01:00
LimitDescription(int64_t limit, int64_t offset) :
limit(limit),
offset(offset) {}
2014-11-07 01:09:06 +01:00
int64_t limit;
int64_t offset;
};
/**
* @struct SelectStatement
* Representation of a full select statement.
*/
struct SelectStatement : Statement {
2014-11-13 01:27:47 +01:00
SelectStatement() :
Statement(kStmtSelect),
from_table(NULL),
select_list(NULL),
where_clause(NULL),
group_by(NULL),
order(NULL),
limit(NULL),
union_select(NULL) {};
2014-11-07 15:21:54 +01:00
virtual ~SelectStatement(); // defined in destructors.cpp
2014-11-07 01:09:06 +01:00
TableRef* from_table;
List<Expr*>* select_list;
2014-11-13 01:27:47 +01:00
Expr* where_clause;
2014-11-07 01:09:06 +01:00
List<Expr*>* group_by;
2014-11-13 01:27:47 +01:00
SelectStatement* union_select;
2014-11-07 01:09:06 +01:00
OrderDescription* order;
LimitDescription* limit;
};
} // namespace hsql
#endif