usql update

This commit is contained in:
2021-12-19 13:33:47 +01:00
parent 37d0d9b3f5
commit 5c925f2608
23 changed files with 1570 additions and 1124 deletions

View File

@@ -15,6 +15,8 @@ namespace usql {
if (m_lexer.tokenType() == TokenType::keyword_create && m_lexer.nextTokenType() == TokenType::keyword_table)
return parse_create_table();
if (m_lexer.tokenType() == TokenType::keyword_create && m_lexer.nextTokenType() == TokenType::keyword_index)
return parse_create_index();
if (m_lexer.tokenType() == TokenType::keyword_drop)
return parse_drop_table();
@@ -302,6 +304,18 @@ namespace usql {
return std::make_unique<UpdateTableNode>(table_name, cols_names, std::move(values), std::move(where_node));
}
std::unique_ptr<Node> Parser::parse_create_index() {
m_lexer.skipToken(TokenType::keyword_create);
m_lexer.skipToken(TokenType::keyword_index);
std::string index_name = m_lexer.consumeToken(TokenType::identifier).token_string;
m_lexer.skipToken(TokenType::keyword_on);
std::string table_name = m_lexer.consumeToken(TokenType::identifier).token_string;
m_lexer.skipToken(TokenType::open_paren);
std::string column_name = m_lexer.consumeToken(TokenType::identifier).token_string;
m_lexer.skipToken(TokenType::close_paren);
return std::make_unique<CreateIndexNode>(index_name, table_name, column_name);
}
std::vector<ColOrderNode> Parser::parse_order_by_clause() {
std::vector<ColOrderNode> order_cols;
@@ -331,7 +345,7 @@ namespace usql {
order_cols.emplace_back(cspec_token, asc);
break;
default:
throw Exception("order by column can be either column index or identifier");
throw Exception("order by column can be either column m_index or identifier");
}
m_lexer.skipTokenOptional(TokenType::comma);