From fe359593baac8933c3435d3a32023a3fd634db42 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Mon, 25 Mar 2019 16:56:14 +0200 Subject: [PATCH] MXS-2407 Report database for SHOW TABLES FROM db The database used in 'SHOW TABLES FROM db' is now available via qc_get_database_names(). --- query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc | 6 +++--- query_classifier/qc_sqlite/qc_sqlite.cc | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc index e83c4d2c2..ceb581800 100644 --- a/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc +++ b/query_classifier/qc_mysqlembedded/qc_mysqlembedded.cc @@ -1848,14 +1848,14 @@ int32_t qc_mysql_get_database_names(GWBUF* querybuf, char*** databasesp, int* si goto retblock; } - if (lex->describe || is_show_command(lex->sql_command)) + if (lex->describe || (is_show_command(lex->sql_command) && !(lex->sql_command == SQLCOM_SHOW_TABLES))) { goto retblock; } - if (lex->sql_command == SQLCOM_CHANGE_DB) + if (lex->sql_command == SQLCOM_CHANGE_DB || lex->sql_command == SQLCOM_SHOW_TABLES) { - if (lex->select_lex.db) + if (lex->select_lex.db && (strcmp(lex->select_lex.db, "skygw_virtual") != 0)) { if (i >= currsz) { diff --git a/query_classifier/qc_sqlite/qc_sqlite.cc b/query_classifier/qc_sqlite/qc_sqlite.cc index bb5e4a5a7..d57cbc4e3 100644 --- a/query_classifier/qc_sqlite/qc_sqlite.cc +++ b/query_classifier/qc_sqlite/qc_sqlite.cc @@ -3031,6 +3031,14 @@ public: case MXS_SHOW_TABLES: m_type_mask = QUERY_TYPE_SHOW_TABLES; + if (pShow->pDatabase->z) + { + char db[pShow->pDatabase->n + 1]; + strncpy(db, pShow->pDatabase->z, pShow->pDatabase->n); + db[pShow->pDatabase->n] = 0; + + update_database_names(db); + } break; case MXS_SHOW_VARIABLES: