HyriseSQLParser/src/sql/CreateStatement.h

62 lines
1.4 KiB
C
Raw Normal View History

#ifndef __CREATE_STATEMENT_H__
#define __CREATE_STATEMENT_H__
2014-12-03 17:43:02 +01:00
#include "SQLStatement.h"
namespace hsql {
2016-02-27 15:01:06 +01:00
/**
2016-02-27 15:22:22 +01:00
* Represents definition of a table column
2016-02-27 15:01:06 +01:00
*/
struct ColumnDefinition {
enum DataType {
TEXT,
INT,
DOUBLE
};
ColumnDefinition(char* name, DataType type) :
name(name),
type(type) {}
virtual ~ColumnDefinition() {
delete name;
}
char* name;
DataType type;
};
/**
2016-02-27 15:22:22 +01:00
* Represents SQL Create statements.
* Example: "CREATE TABLE students (name TEXT, student_number INTEGER, city TEXT, grade DOUBLE)"
2016-02-27 15:01:06 +01:00
*/
struct CreateStatement : SQLStatement {
enum CreateType {
kTable,
2016-02-27 15:22:22 +01:00
kTableFromTbl // Hyrise file format
2016-02-27 15:01:06 +01:00
};
CreateStatement(CreateType type) :
SQLStatement(kStmtCreate),
type(type),
2016-02-27 15:22:22 +01:00
ifNotExists(false),
filePath(NULL),
tableName(NULL),
columns(NULL) {};
2016-02-27 15:01:06 +01:00
virtual ~CreateStatement() {
delete columns;
2016-02-27 15:22:22 +01:00
delete filePath;
delete tableName;
2016-02-27 15:01:06 +01:00
}
CreateType type;
2016-02-27 15:22:22 +01:00
bool ifNotExists;
const char* filePath;
const char* tableName;
2016-02-27 15:01:06 +01:00
std::vector<ColumnDefinition*>* columns;
};
} // namespace hsql
#endif