MXS-1196: Handle "while" correctly

"while" is both a mysqltest and PL/SQL keyword.
This commit is contained in:
Johan Wikman
2017-05-23 14:43:33 +03:00
parent b700a77da6
commit f26fb085bc

View File

@ -150,7 +150,7 @@ void init_keywords()
} }
} }
skip_action_t get_action(const string& keyword) skip_action_t get_action(const string& keyword, const string& delimiter)
{ {
skip_action_t action = SKIP_NOTHING; skip_action_t action = SKIP_NOTHING;
@ -158,12 +158,19 @@ skip_action_t get_action(const string& keyword)
std::transform(key.begin(), key.end(), key.begin(), ::tolower); std::transform(key.begin(), key.end(), key.begin(), ::tolower);
// "while" is both a mysqltest and PL/SQL keyword. We use the
// heuristic that if the delimiter is something else but ";"
// we assume it used in a PL/SQL context.
if ((key != "while") || (delimiter == ";"))
{
KeywordActionMapping::iterator i = mtl_keywords.find(key); KeywordActionMapping::iterator i = mtl_keywords.find(key);
if (i != mtl_keywords.end()) if (i != mtl_keywords.end())
{ {
action = i->second; action = i->second;
} }
}
return action; return action;
} }
@ -229,7 +236,7 @@ TestReader::result_t TestReader::get_statement(std::string& stmt)
std::ptr_fun<int,int>(std::isspace)); std::ptr_fun<int,int>(std::isspace));
string keyword = line.substr(0, i - line.begin()); string keyword = line.substr(0, i - line.begin());
skip_action_t action = get_action(keyword); skip_action_t action = get_action(keyword, m_delimiter);
switch (action) switch (action)
{ {