diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index dd002c05e..1b4244b98 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -985,31 +985,41 @@ 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; - - if (get_set_type(pi->pi_query_plain_str) == SET_TYPE_UNKNOWN) + switch (get_set_type(pi->pi_query_plain_str)) { - /** Either user- or system variable write */ - List_iterator ilist(lex->var_list); - size_t n = 0; + case SET_TYPE_PASSWORD: + type |= QUERY_TYPE_WRITE; + break; - while (set_var_base* var = ilist++) + case SET_TYPE_UNKNOWN: { - if (var->is_system()) + type |= QUERY_TYPE_SESSION_WRITE; + /** Either user- or system variable write */ + List_iterator ilist(lex->var_list); + size_t n = 0; + + while (set_var_base* var = ilist++) + { + if (var->is_system()) + { + type |= QUERY_TYPE_GSYSVAR_WRITE; + } + else + { + type |= QUERY_TYPE_USERVAR_WRITE; + } + ++n; + } + + if (n == 0) { type |= QUERY_TYPE_GSYSVAR_WRITE; } - else - { - type |= QUERY_TYPE_USERVAR_WRITE; - } - ++n; } + break; - if (n == 0) - { - type |= QUERY_TYPE_GSYSVAR_WRITE; - } + default: + type |= QUERY_TYPE_SESSION_WRITE; } } else diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index 6c7326bf5..437cd6470 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -2743,6 +2743,13 @@ public: } break; + case TK_SET: + if (m_keyword_2 == TK_PASSWORD) + { + m_type_mask = QUERY_TYPE_WRITE; + } + break; + case TK_START: switch (m_keyword_2) { @@ -2962,6 +2969,9 @@ public: && pVariable->op == TK_ID && strcasecmp(pVariable->u.zToken, "password") == 0) { + // Even though SET PASSWORD looks like a session command it + // is not, the password change will be replicated to slaves. + m_type_mask = QUERY_TYPE_WRITE; // Ok, it was, so we break out. i = pList->nExpr; break; diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y index 801c8b1ed..008ae939a 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/src/parse.y @@ -634,7 +634,7 @@ columnid(A) ::= nm(X). { NAMES NEXT NO OF OFFSET OPEN - PARTITIONS PREVIOUS + PARTITIONS PASSWORD PREVIOUS QUERY QUICK RAISE RECURSIVE /*REINDEX*/ RELEASE /*RENAME*/ /*REPLACE*/ RESET RESTRICT ROLLBACK ROLLUP ROW SAVEPOINT SELECT_OPTIONS_KW /*SEQUENCE*/ SLAVE /*START*/ STATEMENT STATUS diff --git a/query_classifier/qc_sqlite/sqlite-src-3110100/tool/mkkeywordhash.c b/query_classifier/qc_sqlite/sqlite-src-3110100/tool/mkkeywordhash.c index d0e14c40a..fd5fe2768 100644 --- a/query_classifier/qc_sqlite/sqlite-src-3110100/tool/mkkeywordhash.c +++ b/query_classifier/qc_sqlite/sqlite-src-3110100/tool/mkkeywordhash.c @@ -381,6 +381,7 @@ static Keyword aKeywordTable[] = { #ifdef MAXSCALE { "PARTITION", "TK_PARTITION", ALWAYS }, { "PARTITIONS", "TK_PARTITIONS", ALWAYS }, + { "PASSWORD", "TK_PASSWORD", ALWAYS }, { "PERSISTENT", "TK_PERSISTENT", ALWAYS }, #endif #ifndef MAXSCALE diff --git a/query_classifier/test/expected.sql b/query_classifier/test/expected.sql index 5c010428e..20361008a 100644 --- a/query_classifier/test/expected.sql +++ b/query_classifier/test/expected.sql @@ -32,3 +32,4 @@ QUERY_TYPE_READ QUERY_TYPE_READ QUERY_TYPE_SESSION_WRITE|QUERY_TYPE_USERVAR_WRITE QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ +QUERY_TYPE_WRITE diff --git a/query_classifier/test/input.sql b/query_classifier/test/input.sql index 43fc0af57..1a03641b3 100644 --- a/query_classifier/test/input.sql +++ b/query_classifier/test/input.sql @@ -32,3 +32,4 @@ select timediff(cast('2004-12-30 12:00:00' as time), '12:00:00'); (select 1 as a from t1) union all (select 1 from dual) limit 1; SET @saved_cs_client= @@character_set_client; SELECT 1 AS c1 FROM t1 ORDER BY ( SELECT 1 AS c2 FROM t1 GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ORDER BY GREATEST(LAST_INSERT_ID(), t1.a) LIMIT 1); +SET PASSWORD FOR 'user'@'10.0.0.1'='*C50EB75D7CB4C76B5264218B92BC69E6815B057A'; diff --git a/query_classifier/test/maxscale.test b/query_classifier/test/maxscale.test index 36606fb46..052b4935d 100644 --- a/query_classifier/test/maxscale.test +++ b/query_classifier/test/maxscale.test @@ -137,6 +137,9 @@ SET @saved_cs_client= @@character_set_client; SELECT NEXTVAL(id_generator), context FROM t1 WHERE (a,b,c) >= (1,2,3); select soundex(_utf8mb4 0xD091D092D093) as vx, gray_user_tag from user_extends where user_id > last_insert_id(); +# MXS-2713 +SET PASSWORD FOR 'user'@'10.0.0.1'='*C50EB75D7CB4C76B5264218B92BC69E6815B057A'; + # MXS-2432 RESET QUERY CACHE; RESET MASTER;