added doxygen documentation
This commit is contained in:
parent
21503300ca
commit
85b9ed2cf2
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
|
||||||
|
test:
|
||||||
|
@echo "Compiling..."
|
||||||
|
@make clean -C src/ >/dev/null || exit 1
|
||||||
|
@make tests -C src/ >/dev/null || exit 1
|
||||||
|
@make grammar_test -C src/ >/dev/null || exit 1
|
||||||
|
@echo "Running tests:"
|
||||||
|
@./bin/grammar_test -f "test/valid_queries.sql"
|
||||||
|
@./bin/tests
|
||||||
|
|
||||||
|
|
||||||
|
docs: FORCE
|
||||||
|
doxygen docs/doxy.conf
|
||||||
|
|
||||||
|
|
||||||
|
FORCE:
|
|
@ -0,0 +1 @@
|
||||||
|
__doxygen__/
|
|
@ -0,0 +1,21 @@
|
||||||
|
# Developer Documentation
|
||||||
|
|
||||||
|
This page contains information about how to extend this parser with new functionalities.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Extending the Grammar
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
|
||||||
|
## Implementing Statement Class
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
|
||||||
|
## Implementing Tests
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
@PROJECT_NAME = "SQL Parser for Hyrise (C++)"
|
||||||
|
|
||||||
|
@OUTPUT_DIRECTORY = docs/__doxygen__/
|
||||||
|
@GENERATE_LATEX = NO
|
||||||
|
@GENERATE_HTML = YES
|
||||||
|
|
||||||
|
@INPUT = README.md \
|
||||||
|
docs/ \
|
||||||
|
src/parser/SQLParser.h \
|
||||||
|
src/parser/SQLParser.cpp \
|
||||||
|
src/lib/ \
|
||||||
|
|
||||||
|
|
||||||
|
@RECURSIVE = YES
|
|
@ -1,9 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
echo "Compiling..."
|
|
||||||
make clean -C src/ >/dev/null || exit 1
|
|
||||||
make tests -C src/ >/dev/null || exit 1
|
|
||||||
make grammar_test -C src/ >/dev/null || exit 1
|
|
||||||
|
|
||||||
echo "Running tests:"
|
|
||||||
./bin/grammar_test -f "test/valid_queries.sql"
|
|
||||||
./bin/tests
|
|
|
@ -24,6 +24,10 @@ typedef enum {
|
||||||
|
|
||||||
typedef struct Expr Expr;
|
typedef struct Expr Expr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class Expr
|
||||||
|
* @brief Represents SQL expressions (i.e. literals, operators, column_refs)
|
||||||
|
*/
|
||||||
struct Expr {
|
struct Expr {
|
||||||
/**
|
/**
|
||||||
* Operator types. These are important for expressions of type kExprOperator
|
* Operator types. These are important for expressions of type kExprOperator
|
||||||
|
|
|
@ -8,6 +8,10 @@ namespace hsql {
|
||||||
|
|
||||||
// TODO: try to replace the List wrapper by directly using std::vector
|
// TODO: try to replace the List wrapper by directly using std::vector
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class List
|
||||||
|
* @brief Classed interface to std::vector (may be replaced with std::vector)
|
||||||
|
*/
|
||||||
template <typename _T>
|
template <typename _T>
|
||||||
class List {
|
class List {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -9,9 +9,10 @@ struct SelectStatement;
|
||||||
struct JoinDefinition;
|
struct JoinDefinition;
|
||||||
struct TableRef;
|
struct TableRef;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TableRef
|
* @enum TableRefType
|
||||||
* Holds reference to tables. Can be either table names or a select statement.
|
* Types table references
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kTableName,
|
kTableName,
|
||||||
|
@ -21,8 +22,10 @@ typedef enum {
|
||||||
} TableRefType;
|
} TableRefType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct TableRef
|
||||||
|
* @brief Holds reference to tables. Can be either table names or a select statement.
|
||||||
|
*/
|
||||||
struct TableRef {
|
struct TableRef {
|
||||||
TableRef(TableRefType type) :
|
TableRef(TableRefType type) :
|
||||||
type(type),
|
type(type),
|
||||||
|
@ -33,7 +36,12 @@ struct TableRef {
|
||||||
list(NULL),
|
list(NULL),
|
||||||
join(NULL) {}
|
join(NULL) {}
|
||||||
|
|
||||||
virtual ~TableRef(); // defined in destructors.cpp
|
virtual ~TableRef() {
|
||||||
|
delete name;
|
||||||
|
delete alias;
|
||||||
|
delete select;
|
||||||
|
delete list;
|
||||||
|
}
|
||||||
|
|
||||||
TableRefType type;
|
TableRefType type;
|
||||||
|
|
||||||
|
@ -59,9 +67,9 @@ struct TableRef {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Following are definitions needed to specify join tables
|
* @enum JoinType
|
||||||
|
* Types of joins
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
kJoinInner,
|
kJoinInner,
|
||||||
kJoinOuter,
|
kJoinOuter,
|
||||||
|
@ -69,8 +77,10 @@ typedef enum {
|
||||||
kJoinRight,
|
kJoinRight,
|
||||||
} JoinType;
|
} JoinType;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Definition of a join table
|
* @struct JoinDefinition
|
||||||
|
* @brief Definition of a join table
|
||||||
*/
|
*/
|
||||||
struct JoinDefinition {
|
struct JoinDefinition {
|
||||||
JoinDefinition() :
|
JoinDefinition() :
|
||||||
|
@ -79,7 +89,11 @@ struct JoinDefinition {
|
||||||
condition(NULL),
|
condition(NULL),
|
||||||
type(kJoinInner) {}
|
type(kJoinInner) {}
|
||||||
|
|
||||||
virtual ~JoinDefinition(); // defined in destructors.cpp
|
virtual ~JoinDefinition() {
|
||||||
|
delete left;
|
||||||
|
delete right;
|
||||||
|
delete condition;
|
||||||
|
}
|
||||||
|
|
||||||
TableRef* left;
|
TableRef* left;
|
||||||
TableRef* right;
|
TableRef* right;
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
|
|
||||||
|
|
||||||
#include "sqllib.h"
|
|
||||||
|
|
||||||
namespace hsql {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SQLStatement.h
|
|
||||||
*/
|
|
||||||
SQLStatement::~SQLStatement() { /* empty */ }
|
|
||||||
SQLStatementList::~SQLStatementList() {
|
|
||||||
delete parser_msg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ImportStatement.h
|
|
||||||
*/
|
|
||||||
ImportStatement::~ImportStatement() {
|
|
||||||
delete file_path;
|
|
||||||
delete table_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* InsertStatement.h
|
|
||||||
*/
|
|
||||||
InsertStatement::~InsertStatement() {
|
|
||||||
delete table_name;
|
|
||||||
delete columns;
|
|
||||||
delete values;
|
|
||||||
delete select;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DeleteStatement.h
|
|
||||||
*/
|
|
||||||
DeleteStatement::~DeleteStatement() {
|
|
||||||
delete table_name;
|
|
||||||
delete expr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UpdateStatement.h
|
|
||||||
*/
|
|
||||||
UpdateStatement::~UpdateStatement() {
|
|
||||||
delete table;
|
|
||||||
delete updates;
|
|
||||||
delete where;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SelectStatement.h
|
|
||||||
*/
|
|
||||||
SelectStatement::~SelectStatement() {
|
|
||||||
delete from_table;
|
|
||||||
delete select_list;
|
|
||||||
delete where_clause;
|
|
||||||
delete group_by;
|
|
||||||
delete order;
|
|
||||||
delete limit;
|
|
||||||
}
|
|
||||||
OrderDescription::~OrderDescription() {
|
|
||||||
delete expr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* CreateStatement.h
|
|
||||||
*/
|
|
||||||
CreateStatement::~CreateStatement() {
|
|
||||||
delete columns;
|
|
||||||
delete file_path;
|
|
||||||
delete table_name;
|
|
||||||
}
|
|
||||||
ColumnDefinition::~ColumnDefinition() {
|
|
||||||
delete name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
PrepareStatement::~PrepareStatement() {
|
|
||||||
delete stmt;
|
|
||||||
delete name;
|
|
||||||
}
|
|
||||||
ExecuteStatement::~ExecuteStatement() {
|
|
||||||
delete name;
|
|
||||||
delete parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Table.h
|
|
||||||
*/
|
|
||||||
TableRef::~TableRef() {
|
|
||||||
delete name;
|
|
||||||
delete alias;
|
|
||||||
delete select;
|
|
||||||
delete list;
|
|
||||||
}
|
|
||||||
JoinDefinition::~JoinDefinition() {
|
|
||||||
delete left;
|
|
||||||
delete right;
|
|
||||||
delete condition;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace hsql
|
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
namespace hsql {
|
namespace hsql {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct ColumnDefinition
|
* @struct ColumnDefinition
|
||||||
|
* @brief Represents definition of a table column
|
||||||
*/
|
*/
|
||||||
struct ColumnDefinition {
|
struct ColumnDefinition {
|
||||||
enum DataType {
|
enum DataType {
|
||||||
|
@ -20,16 +20,18 @@ struct ColumnDefinition {
|
||||||
name(name),
|
name(name),
|
||||||
type(type) {}
|
type(type) {}
|
||||||
|
|
||||||
virtual ~ColumnDefinition(); // defined in destructors.cpp
|
virtual ~ColumnDefinition() {
|
||||||
|
delete name;
|
||||||
|
}
|
||||||
|
|
||||||
char* name;
|
char* name;
|
||||||
DataType type;
|
DataType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct CreateStatement
|
* @struct CreateStatement
|
||||||
* CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)
|
* @brief Represents "CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)"
|
||||||
* CREATE TABLE students FROM TBL FILE 'test/students.tbl'
|
|
||||||
*/
|
*/
|
||||||
struct CreateStatement : SQLStatement {
|
struct CreateStatement : SQLStatement {
|
||||||
enum CreateType {
|
enum CreateType {
|
||||||
|
@ -45,7 +47,11 @@ struct CreateStatement : SQLStatement {
|
||||||
file_path(NULL),
|
file_path(NULL),
|
||||||
table_name(NULL) {};
|
table_name(NULL) {};
|
||||||
|
|
||||||
virtual ~CreateStatement(); // defined in destructors.cpp
|
virtual ~CreateStatement() {
|
||||||
|
delete columns;
|
||||||
|
delete file_path;
|
||||||
|
delete table_name;
|
||||||
|
}
|
||||||
|
|
||||||
CreateType type;
|
CreateType type;
|
||||||
bool if_not_exists;
|
bool if_not_exists;
|
||||||
|
|
|
@ -8,8 +8,7 @@ namespace hsql {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct DeleteStatement
|
* @struct DeleteStatement
|
||||||
* DELETE FROM students WHERE grade > 3.0
|
* @brief Represents "DELETE FROM students WHERE grade > 3.0"
|
||||||
* DELETE FROM students <=> TRUNCATE students
|
|
||||||
*
|
*
|
||||||
* If expr == NULL => delete all rows (truncate)
|
* If expr == NULL => delete all rows (truncate)
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +18,11 @@ struct DeleteStatement : SQLStatement {
|
||||||
table_name(NULL),
|
table_name(NULL),
|
||||||
expr(NULL) {};
|
expr(NULL) {};
|
||||||
|
|
||||||
virtual ~DeleteStatement(); // defined in destructors.cpp
|
virtual ~DeleteStatement() {
|
||||||
|
delete table_name;
|
||||||
|
delete expr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char* table_name;
|
char* table_name;
|
||||||
Expr* expr;
|
Expr* expr;
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
|
|
||||||
namespace hsql {
|
namespace hsql {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct DropStatement
|
||||||
|
* @brief Represents "DROP TABLE"
|
||||||
|
*/
|
||||||
struct DropStatement : SQLStatement {
|
struct DropStatement : SQLStatement {
|
||||||
enum EntityType {
|
enum EntityType {
|
||||||
kTable,
|
kTable,
|
||||||
|
@ -19,14 +24,13 @@ struct DropStatement : SQLStatement {
|
||||||
type(type),
|
type(type),
|
||||||
name(NULL) {}
|
name(NULL) {}
|
||||||
|
|
||||||
|
|
||||||
EntityType type;
|
|
||||||
const char* name;
|
|
||||||
|
|
||||||
|
|
||||||
virtual ~DropStatement() {
|
virtual ~DropStatement() {
|
||||||
delete name;
|
delete name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EntityType type;
|
||||||
|
const char* name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace hsql {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct ExecuteStatement
|
* @struct ExecuteStatement
|
||||||
*
|
* @brief Represents "EXECUTE ins_prep(100, "test", 2.3);"
|
||||||
*/
|
*/
|
||||||
struct ExecuteStatement : SQLStatement {
|
struct ExecuteStatement : SQLStatement {
|
||||||
ExecuteStatement() :
|
ExecuteStatement() :
|
||||||
|
@ -16,7 +16,10 @@ struct ExecuteStatement : SQLStatement {
|
||||||
name(NULL),
|
name(NULL),
|
||||||
parameters(NULL) {}
|
parameters(NULL) {}
|
||||||
|
|
||||||
virtual ~ExecuteStatement(); // defined in destructors.cpp
|
virtual ~ExecuteStatement() {
|
||||||
|
delete name;
|
||||||
|
delete parameters;
|
||||||
|
}
|
||||||
|
|
||||||
const char* name;
|
const char* name;
|
||||||
List<Expr*>* parameters;
|
List<Expr*>* parameters;
|
||||||
|
|
|
@ -10,6 +10,7 @@ namespace hsql {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct ImportStatement
|
* @struct ImportStatement
|
||||||
|
* @brief Represents "IMPORT"
|
||||||
*/
|
*/
|
||||||
struct ImportStatement : SQLStatement {
|
struct ImportStatement : SQLStatement {
|
||||||
enum ImportType {
|
enum ImportType {
|
||||||
|
@ -24,7 +25,11 @@ struct ImportStatement : SQLStatement {
|
||||||
file_path(NULL),
|
file_path(NULL),
|
||||||
table_name(NULL) {};
|
table_name(NULL) {};
|
||||||
|
|
||||||
virtual ~ImportStatement(); // defined in destructors.cpp
|
virtual ~ImportStatement() {
|
||||||
|
delete file_path;
|
||||||
|
delete table_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ImportType type;
|
ImportType type;
|
||||||
const char* file_path;
|
const char* file_path;
|
||||||
|
|
|
@ -9,8 +9,7 @@ namespace hsql {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct InsertStatement
|
* @struct InsertStatement
|
||||||
* INSERT INTO students VALUES ('Max', 1112233, 'Musterhausen', 2.3)
|
* @brief Represents "INSERT INTO students VALUES ('Max', 1112233, 'Musterhausen', 2.3)"
|
||||||
* INSERT INTO employees SELECT * FROM stundents
|
|
||||||
*/
|
*/
|
||||||
struct InsertStatement : SQLStatement {
|
struct InsertStatement : SQLStatement {
|
||||||
enum InsertType {
|
enum InsertType {
|
||||||
|
@ -26,7 +25,12 @@ struct InsertStatement : SQLStatement {
|
||||||
values(NULL),
|
values(NULL),
|
||||||
select(NULL) {}
|
select(NULL) {}
|
||||||
|
|
||||||
virtual ~InsertStatement(); // defined in destructors.cpp
|
virtual ~InsertStatement() {
|
||||||
|
delete table_name;
|
||||||
|
delete columns;
|
||||||
|
delete values;
|
||||||
|
delete select;
|
||||||
|
}
|
||||||
|
|
||||||
InsertType type;
|
InsertType type;
|
||||||
const char* table_name;
|
const char* table_name;
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace hsql {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct PrepareStatement
|
* @struct PrepareStatement
|
||||||
*
|
* @brief Represents "PREPARE ins_prep: SELECT * FROM t1 WHERE c1 = ? AND c2 = ?"
|
||||||
*/
|
*/
|
||||||
struct PrepareStatement : SQLStatement {
|
struct PrepareStatement : SQLStatement {
|
||||||
PrepareStatement() :
|
PrepareStatement() :
|
||||||
|
@ -17,7 +17,10 @@ struct PrepareStatement : SQLStatement {
|
||||||
name(NULL),
|
name(NULL),
|
||||||
stmt(NULL) {}
|
stmt(NULL) {}
|
||||||
|
|
||||||
virtual ~PrepareStatement(); // defined in destructors.cpp
|
virtual ~PrepareStatement() {
|
||||||
|
delete stmt;
|
||||||
|
delete name;
|
||||||
|
}
|
||||||
|
|
||||||
const char* name;
|
const char* name;
|
||||||
SQLStatement* stmt;
|
SQLStatement* stmt;
|
||||||
|
|
|
@ -21,28 +21,33 @@ typedef enum {
|
||||||
kStmtDrop,
|
kStmtDrop,
|
||||||
kStmtPrepare,
|
kStmtPrepare,
|
||||||
kStmtExecute,
|
kStmtExecute,
|
||||||
// Following types are not supported yet
|
|
||||||
kStmtExport,
|
kStmtExport,
|
||||||
kStmtRename,
|
kStmtRename,
|
||||||
kStmtAlter
|
kStmtAlter
|
||||||
} StatementType;
|
} StatementType;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct SQLStatement
|
||||||
|
* @brief Base class for every SQLStatement
|
||||||
|
*/
|
||||||
struct SQLStatement {
|
struct SQLStatement {
|
||||||
SQLStatement(StatementType type) :
|
SQLStatement(StatementType type) :
|
||||||
_type(type) {};
|
_type(type) {};
|
||||||
|
|
||||||
virtual ~SQLStatement(); // defined in destructors.cpp
|
virtual ~SQLStatement() {}
|
||||||
|
|
||||||
|
|
||||||
virtual StatementType type() { return _type; }
|
virtual StatementType type() { return _type; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StatementType _type;
|
StatementType _type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct SQLStatementList
|
||||||
|
* @brief Represents the result of the SQLParser. If parsing was successful it is a list of SQLStatement.
|
||||||
|
*/
|
||||||
class SQLStatementList : public List<SQLStatement*> {
|
class SQLStatementList : public List<SQLStatement*> {
|
||||||
public:
|
public:
|
||||||
SQLStatementList() :
|
SQLStatementList() :
|
||||||
|
@ -55,7 +60,9 @@ public:
|
||||||
isValid(true),
|
isValid(true),
|
||||||
parser_msg(NULL) {};
|
parser_msg(NULL) {};
|
||||||
|
|
||||||
virtual ~SQLStatementList(); // defined in destructors.cpp
|
virtual ~SQLStatementList() {
|
||||||
|
delete parser_msg;
|
||||||
|
}
|
||||||
|
|
||||||
bool isValid;
|
bool isValid;
|
||||||
const char* parser_msg;
|
const char* parser_msg;
|
||||||
|
|
|
@ -9,9 +9,11 @@
|
||||||
namespace hsql {
|
namespace hsql {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct OrderDescription
|
* @struct OrderDescription
|
||||||
* Description of the order by clause within a select statement
|
* @brief Description of the order by clause within a select statement
|
||||||
|
*
|
||||||
* TODO: hold multiple expressions to be sorted by
|
* TODO: hold multiple expressions to be sorted by
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -24,7 +26,9 @@ struct OrderDescription {
|
||||||
type(type),
|
type(type),
|
||||||
expr(expr) {}
|
expr(expr) {}
|
||||||
|
|
||||||
virtual ~OrderDescription(); // defined in destructors.cpp
|
virtual ~OrderDescription() {
|
||||||
|
delete expr;
|
||||||
|
}
|
||||||
|
|
||||||
OrderType type;
|
OrderType type;
|
||||||
Expr* expr;
|
Expr* expr;
|
||||||
|
@ -32,7 +36,7 @@ struct OrderDescription {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct LimitDescription
|
* @struct LimitDescription
|
||||||
* Description of the limit clause within a select statement
|
* @brief Description of the limit clause within a select statement
|
||||||
*/
|
*/
|
||||||
const int64_t kNoLimit = -1;
|
const int64_t kNoLimit = -1;
|
||||||
const int64_t kNoOffset = -1;
|
const int64_t kNoOffset = -1;
|
||||||
|
@ -47,7 +51,8 @@ struct LimitDescription {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @struct SelectStatement
|
* @struct SelectStatement
|
||||||
* Representation of a full select statement.
|
* @brief Representation of a full select statement.
|
||||||
|
*
|
||||||
* TODO: add union_order and union_limit
|
* TODO: add union_order and union_limit
|
||||||
*/
|
*/
|
||||||
struct SelectStatement : SQLStatement {
|
struct SelectStatement : SQLStatement {
|
||||||
|
@ -61,7 +66,14 @@ struct SelectStatement : SQLStatement {
|
||||||
order(NULL),
|
order(NULL),
|
||||||
limit(NULL) {};
|
limit(NULL) {};
|
||||||
|
|
||||||
virtual ~SelectStatement(); // defined in destructors.cpp
|
virtual ~SelectStatement() {
|
||||||
|
delete from_table;
|
||||||
|
delete select_list;
|
||||||
|
delete where_clause;
|
||||||
|
delete group_by;
|
||||||
|
delete order;
|
||||||
|
delete limit;
|
||||||
|
}
|
||||||
|
|
||||||
TableRef* from_table;
|
TableRef* from_table;
|
||||||
List<Expr*>* select_list;
|
List<Expr*>* select_list;
|
||||||
|
|
|
@ -5,11 +5,21 @@
|
||||||
|
|
||||||
namespace hsql {
|
namespace hsql {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct UpdateClause
|
||||||
|
* @brief Represents "column = value" expressions
|
||||||
|
*/
|
||||||
struct UpdateClause {
|
struct UpdateClause {
|
||||||
char* column;
|
char* column;
|
||||||
Expr* value;
|
Expr* value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct UpdateStatement
|
||||||
|
* @brief Represents "UPDATE"
|
||||||
|
*/
|
||||||
struct UpdateStatement : SQLStatement {
|
struct UpdateStatement : SQLStatement {
|
||||||
UpdateStatement() :
|
UpdateStatement() :
|
||||||
SQLStatement(kStmtUpdate),
|
SQLStatement(kStmtUpdate),
|
||||||
|
@ -17,7 +27,11 @@ struct UpdateStatement : SQLStatement {
|
||||||
updates(NULL),
|
updates(NULL),
|
||||||
where(NULL) {}
|
where(NULL) {}
|
||||||
|
|
||||||
virtual ~UpdateStatement(); // defined in destructors.cpp
|
virtual ~UpdateStatement() {
|
||||||
|
delete table;
|
||||||
|
delete updates;
|
||||||
|
delete where;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: switch to char* instead of TableRef
|
// TODO: switch to char* instead of TableRef
|
||||||
TableRef* table;
|
TableRef* table;
|
||||||
|
|
|
@ -6,6 +6,13 @@
|
||||||
|
|
||||||
namespace hsql {
|
namespace hsql {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \mainpage SQLParser (C++)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Main class for parsing SQL strings
|
||||||
|
*/
|
||||||
class SQLParser {
|
class SQLParser {
|
||||||
public:
|
public:
|
||||||
static SQLStatementList* parseSQLString(const char* sql);
|
static SQLStatementList* parseSQLString(const char* sql);
|
||||||
|
|
Loading…
Reference in New Issue