Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDEV-11966: Impossible to execute prepared ANALYZE SELECT
Prepare os ANALYZE now respond as EXPLAIN.
  • Loading branch information
sanja-byelkin committed Mar 9, 2017
1 parent 5ff6694 commit 24cbc8d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sql/sql_prepare.cc
Expand Up @@ -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);
Expand Down
20 changes: 20 additions & 0 deletions tests/mysql_client_test.c
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 }
};

Expand Down

0 comments on commit 24cbc8d

Please sign in to comment.