summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorSeppo Jaakola <seppo.jaakola@codership.com>2013-12-04 10:32:43 +0200
committerSeppo Jaakola <seppo.jaakola@codership.com>2013-12-04 10:32:43 +0200
commit496e22cf3bd2a481fd3502d86e5a4e8228bf9823 (patch)
tree80549f8005fcf3236bfa004a5aea35e4e67b36ca /sql/sql_prepare.cc
parent45f484b8381a5923aec9c704e54c7f7bcfa02a40 (diff)
parent26f56089c734852dc31d98fd73e1d8f1750bd1a8 (diff)
downloadmariadb-git-496e22cf3bd2a481fd3502d86e5a4e8228bf9823.tar.gz
merge with MariaDB 5.6 bzr merge lp:maria --rtag:mariadb-10.0.6
and a number of fixes to make this buildable. Run also few short multi-master high conflict rate tests, with no issues
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc43
1 files changed, 37 insertions, 6 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index da3226afddd..f31438f75c2 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1471,7 +1471,10 @@ static bool mysql_test_delete(Prepared_statement *stmt,
goto error;
}
- DBUG_RETURN(mysql_prepare_delete(thd, table_list, &lex->select_lex.where));
+ DBUG_RETURN(mysql_prepare_delete(thd, table_list,
+ lex->select_lex.with_wild,
+ lex->select_lex.item_list,
+ &lex->select_lex.where));
error:
DBUG_RETURN(TRUE);
}
@@ -2305,7 +2308,7 @@ void mysqld_stmt_prepare(THD *thd, const char *packet, uint packet_length)
DBUG_PRINT("prep_query", ("%s", packet));
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (! (stmt= new Prepared_statement(thd)))
goto end; /* out of memory: error is set in Sql_alloc */
@@ -2520,6 +2523,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
object and because of this can be used in different threads.
*/
lex->thd= thd;
+ DBUG_ASSERT(!lex->explain);
if (lex->empty_field_list_on_rset)
{
@@ -2580,7 +2584,13 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
/* Fix ORDER list */
for (order= sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr;
- sl->handle_derived(lex, DT_REINIT);
+ {
+#ifndef DBUG_OFF
+ bool res=
+#endif
+ sl->handle_derived(lex, DT_REINIT);
+ DBUG_ASSERT(res == 0);
+ }
}
{
SELECT_LEX_UNIT *unit= sl->master_unit();
@@ -2689,7 +2699,7 @@ void mysqld_stmt_execute(THD *thd, char *packet_arg, uint packet_length)
packet+= 9; /* stmt_id + 5 bytes of flags */
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
if (!(stmt= find_prepared_statement(thd, stmt_id)))
{
@@ -2788,7 +2798,7 @@ void mysqld_stmt_fetch(THD *thd, char *packet, uint packet_length)
DBUG_ENTER("mysqld_stmt_fetch");
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
status_var_increment(thd->status_var.com_stmt_fetch);
if (!(stmt= find_prepared_statement(thd, stmt_id)))
@@ -2848,7 +2858,7 @@ void mysqld_stmt_reset(THD *thd, char *packet)
DBUG_ENTER("mysqld_stmt_reset");
/* First of all clear possible warnings from the previous command */
- mysql_reset_thd_for_next_command(thd, opt_userstat_running);
+ mysql_reset_thd_for_next_command(thd);
status_var_increment(thd->status_var.com_stmt_reset);
if (!(stmt= find_prepared_statement(thd, stmt_id)))
@@ -3963,6 +3973,12 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
thd->m_statement_psi= parent_locker;
MYSQL_QUERY_EXEC_DONE(error);
}
+ else
+ {
+ thd->lex->sql_command= SQLCOM_SELECT;
+ status_var_increment(thd->status_var.com_stat[SQLCOM_SELECT]);
+ thd->update_stats();
+ }
}
/*
@@ -3981,6 +3997,21 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor)
if (! cursor)
cleanup_stmt();
+
+ /*
+ EXECUTE command has its own dummy "explain data". We don't need it,
+ instead, we want to keep the query plan of the statement that was
+ executed.
+ */
+ if (!stmt_backup.lex->explain ||
+ !stmt_backup.lex->explain->have_query_plan())
+ {
+ delete_explain_query(stmt_backup.lex);
+ stmt_backup.lex->explain = thd->lex->explain;
+ thd->lex->explain= NULL;
+ }
+ else
+ delete_explain_query(thd->lex);
thd->set_statement(&stmt_backup);
thd->stmt_arena= old_stmt_arena;