Add support for optimizer_switch syntax

pull/4274/head
René Cannaò 3 years ago
parent dcd4a4f72f
commit 536bd62f54

@ -15,7 +15,7 @@ static void remove_quotes(string& v) {
char firstChar = v[0];
char lastChar = v[v.length()-1];
if (firstChar == lastChar) {
if (firstChar == '\'' || firstChar == '"') {
if (firstChar == '\'' || firstChar == '"' || firstChar == '`') {
v.erase(v.length()-1, 1);
v.erase(0, 1);
}
@ -182,7 +182,19 @@ void SetParser::generateRE_parse1v2() {
var_patterns.push_back(s); // add with quote
}
// regex for optimizer_switch
{
string v1 = "(?:on|off)"; // on|off
string v2 = "\\w+=" + v1; // "\\w+=(?:on|off)" , example: index_merge_sort_union=on
string v3 = v2 + "(?:," + v2 + ")*"; // "\\w+=(?:on|off)(?:,\\w+=(?:on|off))*"
// example index_merge=on,index_merge_union=on,index_merge_sort_union=off
// note: spaces are not allowed
// NOTE: the whole set of flags must be quoted
for (auto it = quote_symbol.begin(); it != quote_symbol.end(); it++) {
string s = *it + v3 + *it;
var_patterns.push_back(s); // add with quote
}
}
// DO NOT REMOVE THIS COMMENTED CODE

@ -191,6 +191,8 @@ static Test various[] = {
{ "SET SESSION sql_safe_updates = 1", { Expected("sql_safe_updates", {"1"}) } },
{ "SET SQL_SAFE_UPDATES = OFF", { Expected("sql_safe_updates", {"OFF"}) } },
{ "SET @@sql_safe_updates = ON", { Expected("sql_safe_updates", {"ON"}) } },
{ "SET optimizer_switch=`index_merge=OFF`" , { Expected("optimizer_switch", {"index_merge=OFF"}) } },
{ "SET optimizer_switch='index_merge=on,index_merge_union=off,index_merge_sort_union=on'" , { Expected("optimizer_switch", {"index_merge=on,index_merge_union=off,index_merge_sort_union=on"}) } },
};
static Test multiple[] = {

Loading…
Cancel
Save