#include #include #include #include #include #include #include namespace DB { /// Parse `name = value`. bool ParserSetQuery::parseNameValuePair(SettingChange & change, IParser::Pos & pos, Expected & expected) { ParserCompoundIdentifier name_p; ParserLiteral value_p; ParserToken s_eq(TokenType::Equals); ASTPtr name; ASTPtr value; if (!name_p.parse(pos, name, expected)) return false; if (!s_eq.ignore(pos, expected)) return false; if (ParserKeyword("TRUE").ignore(pos, expected)) value = std::make_shared(Field(static_cast(1))); else if (ParserKeyword("FALSE").ignore(pos, expected)) value = std::make_shared(Field(static_cast(0))); else if (!value_p.parse(pos, value, expected)) return false; tryGetIdentifierNameInto(name, change.name); change.value = value->as().value; return true; } bool ParserSetQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & expected) { ParserToken s_comma(TokenType::Comma); if (!parse_only_internals) { ParserKeyword s_set("SET"); if (!s_set.ignore(pos, expected)) return false; /// Parse SET TRANSACTION ... queries using ParserTransactionControl if (ParserKeyword{"TRANSACTION"}.check(pos, expected)) return false; } SettingsChanges changes; while (true) { if (!changes.empty() && !s_comma.ignore(pos)) break; changes.push_back(SettingChange{}); if (!parseNameValuePair(changes.back(), pos, expected)) return false; } auto query = std::make_shared(); node = query; query->is_standalone = !parse_only_internals; query->changes = std::move(changes); return true; } }