work on settings (set and show), perf improvement when adding row into table

This commit is contained in:
2021-08-09 14:15:42 +02:00
parent 474b789d12
commit 710531c455
13 changed files with 124 additions and 49 deletions

View File

@@ -15,6 +15,9 @@ 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_drop)
return parse_drop_table();
if (m_lexer.tokenType() == TokenType::keyword_insert)
return parse_insert_into_table();
if (m_lexer.tokenType() == TokenType::keyword_select)
@@ -23,12 +26,16 @@ namespace usql {
return parse_delete_from_table();
if (m_lexer.tokenType() == TokenType::keyword_update)
return parse_update_table();
if (m_lexer.tokenType() == TokenType::keyword_load)
return parse_load_table();
if (m_lexer.tokenType() == TokenType::keyword_save)
return parse_save_table();
if (m_lexer.tokenType() == TokenType::keyword_drop)
return parse_drop_table();
if (m_lexer.tokenType() == TokenType::keyword_set)
return parse_set();
if (m_lexer.tokenType() == TokenType::keyword_show)
return parse_show();
std::cout << "ERROR, token:" << m_lexer.currentToken().token_string << std::endl;
return std::make_unique<Node>(NodeType::error);
@@ -145,6 +152,24 @@ namespace usql {
return std::make_unique<DropTableNode>(table_name);
}
std::unique_ptr<Node> Parser::parse_set() {
m_lexer.skipToken(TokenType::keyword_set);
// TODO check these are string literals
std::string name = m_lexer.consumeCurrentToken().token_string;
m_lexer.skipTokenOptional(TokenType::equal);
std::string value = m_lexer.consumeCurrentToken().token_string;
return std::make_unique<SetNode>(name, value);
}
std::unique_ptr<Node> Parser::parse_show() {
m_lexer.skipToken(TokenType::keyword_show);
// TODO check these are string literals
std::string name = m_lexer.consumeCurrentToken().token_string;
return std::make_unique<ShowNode>(name);
}
std::unique_ptr<Node> Parser::parse_insert_into_table() {
std::vector<ColNameNode> column_names{};