MXS-2688 Handle SET [ROLE|NAMES|PASSWORD|CHARACTER] explicitly

It's not correct to claim that they would modify a system variable,
so they are purely classified as QUERY_TYPE_SESSION_WRITE.
This commit is contained in:
Johan Wikman
2019-09-19 16:16:27 +03:00
parent f587ec191d
commit aa7be1447d
4 changed files with 49 additions and 23 deletions

View File

@ -625,9 +625,18 @@ return_here:
* Consequently, we just look at the string and deduce whether it is a
* set [ROLE|NAMES|PASSWORD|CHARACTER] statement.
*/
bool is_set_specific(const char* s)
enum set_type_t
{
bool rv = false;
SET_TYPE_CHARACTER,
SET_TYPE_NAMES,
SET_TYPE_PASSWORD,
SET_TYPE_ROLE,
SET_TYPE_UNKNOWN
};
set_type_t get_set_type(const char* s)
{
set_type_t rv = SET_TYPE_UNKNOWN;
// Remove space from the beginning.
while (isspace(*s))
@ -665,7 +674,7 @@ bool is_set_specific(const char* s)
if (strncasecmp(token, "role", 4) == 0)
{
// YES it was!
rv = true;
rv = SET_TYPE_ROLE;
}
}
else if (s - token == 5) // Might be "names"
@ -673,7 +682,7 @@ bool is_set_specific(const char* s)
if (strncasecmp(token, "names", 5) == 0)
{
// YES it was!
rv = true;
rv = SET_TYPE_NAMES;
}
}
else if (s - token == 8) // Might be "password
@ -681,7 +690,7 @@ bool is_set_specific(const char* s)
if (strncasecmp(token, "password", 8) == 0)
{
// YES it was!
rv = true;
rv = SET_TYPE_PASSWORD;
}
}
else if (s - token == 9) // Might be "character"
@ -689,7 +698,7 @@ bool is_set_specific(const char* s)
if (strncasecmp(token, "character", 9) == 0)
{
// YES it was!
rv = true;
rv = SET_TYPE_CHARACTER;
}
}
}
@ -807,6 +816,7 @@ static uint32_t resolve_query_type(parsing_info_t* pi, THD* thd)
*/
else if (lex->sql_command == SQLCOM_SET_OPTION)
{
type |= QUERY_TYPE_SESSION_WRITE;
type |= QUERY_TYPE_GSYSVAR_WRITE;
}
@ -844,13 +854,11 @@ static uint32_t resolve_query_type(parsing_info_t* pi, THD* thd)
*/
else if (lex->sql_command == SQLCOM_SET_OPTION)
{
/** Either user- or system variable write */
if (is_set_specific(pi->pi_query_plain_str))
{
type |= QUERY_TYPE_GSYSVAR_WRITE;
}
else
type |= QUERY_TYPE_SESSION_WRITE;
if (get_set_type(pi->pi_query_plain_str) == SET_TYPE_UNKNOWN)
{
/** Either user- or system variable write */
List_iterator<set_var_base> ilist(lex->var_list);
size_t n = 0;
@ -972,6 +980,11 @@ static uint32_t resolve_query_type(parsing_info_t* pi, THD* thd)
goto return_qtype;
break;
case SQLCOM_SET_OPTION:
type |= QUERY_TYPE_SESSION_WRITE;
goto return_qtype;
break;
case SQLCOM_SHOW_DATABASES:
type |= QUERY_TYPE_SHOW_DATABASES;
goto return_qtype;