Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ if(BUILD_TESTS)
add_cloudsql_test(columnar_table_tests tests/columnar_table_tests.cpp)
add_cloudsql_test(heap_table_tests tests/heap_table_tests.cpp)
add_cloudsql_test(lexer_tests tests/lexer_tests.cpp)
add_cloudsql_test(parser_tests tests/parser_tests.cpp)
add_cloudsql_test(storage_manager_tests tests/storage_manager_tests.cpp)
add_cloudsql_test(rpc_server_tests tests/rpc_server_tests.cpp)
add_cloudsql_test(operator_tests tests/operator_tests.cpp)
Expand Down
1 change: 1 addition & 0 deletions Testing/Temporary/CTestCostData.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
3 changes: 3 additions & 0 deletions include/parser/statement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ class CreateTableStatement : public Statement {
private:
std::string table_name_;
std::vector<ColumnDef> columns_;
bool if_not_exists_ = false;

public:
CreateTableStatement() = default;
Expand All @@ -232,6 +233,8 @@ class CreateTableStatement : public Statement {
columns_.push_back({std::move(name), std::move(type), false, false, false, nullptr});
}
[[nodiscard]] ColumnDef& get_last_column() { return columns_.back(); }
void set_if_not_exists(bool v) { if_not_exists_ = v; }
[[nodiscard]] bool if_not_exists() const { return if_not_exists_; }

[[nodiscard]] const std::string& table_name() const { return table_name_; }
[[nodiscard]] const std::vector<ColumnDef>& columns() const { return columns_; }
Expand Down
6 changes: 5 additions & 1 deletion src/parser/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ std::unique_ptr<Statement> Parser::parse_create_table() {
}

/* IF NOT EXISTS */
if (consume(TokenType::Not)) {
if (consume(TokenType::If)) {
if (!consume(TokenType::Not)) {
return nullptr;
}
if (!consume(TokenType::Exists)) {
return nullptr;
}
stmt->set_if_not_exists(true);
}

const Token name = next_token();
Expand Down
Loading