summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2017-02-02 12:09:49 +0100
committerOleksandr Byelkin <sanja@mariadb.com>2017-03-08 14:26:53 +0100
commitc544bba6d7c2c400a288a3d2f468d4f0e84d3908 (patch)
tree3e3d7836e073a3211f0911a4d3d2da2fc682d3e9
parent0b1abc2f0f391d4e55029fa53f1e5da926f7be61 (diff)
downloadmariadb-git-bb-10.2-MDEV-11966.tar.gz
MDEV-11966: Impossible to execute prepared ANALYZE SELECTbb-10.2-MDEV-11966
Prepare os ANALYZE now respond as EXPLAIN.
-rw-r--r--sql/sql_prepare.cc2
-rw-r--r--tests/mysql_client_test.c20
2 files changed, 21 insertions, 1 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 303460a5fb4..c8765f45273 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1591,7 +1591,7 @@ static int mysql_test_select(Prepared_statement *stmt,
*/
if (unit->prepare(thd, 0, 0))
goto error;
- if (!lex->describe && !stmt->is_sql_prepare())
+ if (!lex->describe && !thd->lex->analyze_stmt && !stmt->is_sql_prepare())
{
/* Make copy of item list, as change_columns may change it */
List<Item> fields(lex->select_lex.item_list);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index 58e3dda2b0d..da486dfd442 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -19460,6 +19460,25 @@ static void test_big_packet()
}
+/* Test simple prepares of all DML statements */
+
+static void test_prepare_analyze()
+{
+ MYSQL_STMT *stmt;
+ int rc;
+ myheader("test_prepare_analyze");
+
+ stmt= mysql_stmt_init(mysql);
+ check_stmt(stmt);
+ rc= mysql_stmt_prepare(stmt, "ANALYZE SELECT 1", -1);
+ check_execute(stmt, rc);
+ verify_param_count(stmt, 0);
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ mysql_stmt_close(stmt);
+}
+
static struct my_tests_st my_tests[]= {
{ "disable_query_logs", disable_query_logs },
{ "test_view_sp_list_fields", test_view_sp_list_fields },
@@ -19733,6 +19752,7 @@ static struct my_tests_st my_tests[]= {
{ "test_ps_sp_out_params", test_ps_sp_out_params },
{ "test_compressed_protocol", test_compressed_protocol },
{ "test_big_packet", test_big_packet },
+ { "test_prepare_analyze", test_prepare_analyze },
{ 0, 0 }
};