2017-04-06 18:27:47 +02:00
|
|
|
#ifndef __SQLPARSER__SELECT_STATEMENT_H__
|
|
|
|
#define __SQLPARSER__SELECT_STATEMENT_H__
|
2014-11-07 01:09:06 +01:00
|
|
|
|
2014-12-03 17:43:02 +01:00
|
|
|
#include "SQLStatement.h"
|
2014-11-07 01:09:06 +01:00
|
|
|
#include "Expr.h"
|
|
|
|
#include "Table.h"
|
|
|
|
|
|
|
|
namespace hsql {
|
2017-02-08 02:06:15 +01:00
|
|
|
enum OrderType {
|
|
|
|
kOrderAsc,
|
|
|
|
kOrderDesc
|
|
|
|
};
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
|
|
|
|
// Description of the order by clause within a select statement.
|
2017-02-08 02:06:15 +01:00
|
|
|
struct OrderDescription {
|
|
|
|
OrderDescription(OrderType type, Expr* expr);
|
|
|
|
virtual ~OrderDescription();
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
OrderType type;
|
|
|
|
Expr* expr;
|
|
|
|
};
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
const int64_t kNoLimit = -1;
|
|
|
|
const int64_t kNoOffset = -1;
|
2016-02-27 15:22:22 +01:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
// Description of the limit clause within a select statement.
|
2017-02-08 02:06:15 +01:00
|
|
|
struct LimitDescription {
|
|
|
|
LimitDescription(int64_t limit, int64_t offset);
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
int64_t limit;
|
|
|
|
int64_t offset;
|
|
|
|
};
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
// Description of the group-by clause within a select statement.
|
2017-02-08 02:06:15 +01:00
|
|
|
struct GroupByDescription {
|
|
|
|
GroupByDescription();
|
2017-04-06 17:42:46 +02:00
|
|
|
virtual ~GroupByDescription();
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
std::vector<Expr*>* columns;
|
|
|
|
Expr* having;
|
|
|
|
};
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-04-21 16:15:07 +02:00
|
|
|
// Representation of a full SQL select statement.
|
|
|
|
// TODO: add union_order and union_limit.
|
2017-02-08 02:06:15 +01:00
|
|
|
struct SelectStatement : SQLStatement {
|
|
|
|
SelectStatement();
|
|
|
|
virtual ~SelectStatement();
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
TableRef* fromTable;
|
|
|
|
bool selectDistinct;
|
|
|
|
std::vector<Expr*>* selectList;
|
|
|
|
Expr* whereClause;
|
|
|
|
GroupByDescription* groupBy;
|
2016-02-27 15:01:06 +01:00
|
|
|
|
2017-02-08 02:06:15 +01:00
|
|
|
SelectStatement* unionSelect;
|
2017-03-07 02:30:44 +01:00
|
|
|
std::vector<OrderDescription*>* order;
|
2017-02-08 02:06:15 +01:00
|
|
|
LimitDescription* limit;
|
|
|
|
};
|
2014-11-07 01:09:06 +01:00
|
|
|
|
|
|
|
} // namespace hsql
|
2017-04-21 16:15:07 +02:00
|
|
|
|
|
|
|
#endif
|