summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 6753b857b54..261f745cb24 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -328,9 +328,13 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns)
error= my_net_write(net, buff, sizeof(buff));
if (stmt->param_count && likely(!error))
{
+ /*
+ Force the column info to be written
+ (in this case PS parameter type info).
+ */
error= thd->protocol_text.send_result_set_metadata((List<Item> *)
&stmt->lex->param_list,
- Protocol::SEND_EOF);
+ Protocol::SEND_EOF|Protocol::SEND_FORCE_COLUMN_INFO);
}
if (likely(!error))
@@ -3222,10 +3226,15 @@ static void mysql_stmt_execute_common(THD *thd,
thd->protocol= &thd->protocol_binary;
MYSQL_EXECUTE_PS(thd->m_statement_psi, stmt->m_prepared_stmt);
+ auto save_cur_stmt= thd->cur_stmt;
+ thd->cur_stmt= stmt;
+
if (!bulk_op)
stmt->execute_loop(&expanded_query, open_cursor, packet, packet_end);
else
stmt->execute_bulk_loop(&expanded_query, open_cursor, packet, packet_end);
+
+ thd->cur_stmt= save_cur_stmt;
thd->protocol= save_protocol;
sp_cache_enforce_limit(thd->sp_proc_cache, stored_program_cache_size);
@@ -3235,7 +3244,6 @@ static void mysql_stmt_execute_common(THD *thd,
/* Close connection socket; for use with client testing (Bug#43560). */
DBUG_EXECUTE_IF("close_conn_after_stmt_execute", vio_shutdown(thd->net.vio,SHUT_RD););
-
DBUG_VOID_RETURN;
}
@@ -3971,6 +3979,8 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
old_stmt_arena= thd->stmt_arena;
thd->stmt_arena= this;
+ auto save_cur_stmt= thd->cur_stmt;
+ thd->cur_stmt= this;
Parser_state parser_state;
if (parser_state.init(thd, thd->query(), thd->query_length()))
@@ -3978,6 +3988,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
thd->restore_backup_statement(this, &stmt_backup);
thd->restore_active_arena(this, &stmt_backup);
thd->stmt_arena= old_stmt_arena;
+ thd->cur_stmt = save_cur_stmt;
DBUG_RETURN(TRUE);
}
@@ -3987,6 +3998,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
lex_start(thd);
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_PREPARE;
+
error= (parse_sql(thd, & parser_state, NULL) ||
thd->is_error() ||
init_param_array(this));
@@ -4062,6 +4074,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
cleanup_stmt();
thd->restore_backup_statement(this, &stmt_backup);
thd->stmt_arena= old_stmt_arena;
+ thd->cur_stmt= save_cur_stmt;
if (likely(error == 0))
{
@@ -4090,6 +4103,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
if (thd->spcont == NULL)
general_log_write(thd, COM_STMT_PREPARE, query(), query_length());
}
+
DBUG_RETURN(error);
}
@@ -4503,6 +4517,7 @@ Prepared_statement::reprepare()
it's failed, we need to return all the warnings to the user.
*/
thd->get_stmt_da()->clear_warning_info(thd->query_id);
+ column_info_state.reset();
}
return error;
}