示例#1
0
bool ParserSetQuery::parseImpl(Pos & pos, Pos end, ASTPtr & node, Pos & max_parsed_pos, Expected & expected)
{
    Pos begin = pos;

    ParserWhiteSpaceOrComments ws;
    ParserString s_comma(",");

    bool global = false;

    if (!parse_only_internals)
    {
        ParserString s_set("SET", true, true);
        ParserString s_global("GLOBAL", true, true);

        ws.ignore(pos, end);

        if (!s_set.ignore(pos, end, max_parsed_pos, expected))
            return false;

        ws.ignore(pos, end);

        global = s_global.ignore(pos, end, max_parsed_pos, expected);
    }

    ASTSetQuery::Changes changes;

    while (true)
    {
        ws.ignore(pos, end);

        if (!changes.empty() && !s_comma.ignore(pos, end))
            break;

        ws.ignore(pos, end);

        changes.push_back(ASTSetQuery::Change());

        if (!parseNameValuePair(changes.back(), pos, end, max_parsed_pos, expected))
            return false;
    }

    auto query = std::make_shared<ASTSetQuery>(StringRange(begin, pos));
    node = query;

    query->changes = changes;
    query->global = global;

    return true;
}
示例#2
0
 inline
 bool parseNameIntegerPair(const std::string& token, std::string& name, int& value)
 {
     std::string strValue;
     return parseNameValuePair(token, name, strValue, '=') && stringToInteger(strValue, value);
 }