summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2014-08-13 18:06:53 +0400
committerSergei Petrunia <psergey@askmonty.org>2014-08-13 18:06:53 +0400
commit8d3a432f12e5fdfbde3368dc5a859ecc3e42621f (patch)
treea817d86820cb4876b1f2576d85f6604efa66afb7 /sql/sql_prepare.cc
parent2062c9a65acc660c03ab07b1358f6bf8aab4488f (diff)
downloadmariadb-git-8d3a432f12e5fdfbde3368dc5a859ecc3e42621f.tar.gz
MDEV-6575: main.view --ps-protocol fails in ANALYZE code
- After PREPARE is done, save the value of thd->select_number (this is what will be assigned to next select_lex object) - Restore the value at each execution of the prepared statement.
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 9ea496a81dc..6b5a3396abe 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -160,6 +160,20 @@ public:
uint param_count;
uint last_errno;
uint flags;
+ /*
+ The value of thd->select_number at the end of the PREPARE phase.
+
+ The issue is: each statement execution opens VIEWs, which may cause
+ select_lex objects to be created, and select_number values to be assigned.
+
+ On the other hand, PREPARE assigns select_number values for triggers and
+ subqueries.
+
+ In order for select_number values from EXECUTE not to conflict with
+ select_number values from PREPARE, we keep the number and set it at each
+ execution.
+ */
+ uint select_number_after_prepare;
char last_error[MYSQL_ERRMSG_SIZE];
#ifndef EMBEDDED_LIBRARY
bool (*set_params)(Prepared_statement *st, uchar *data, uchar *data_end,
@@ -3455,6 +3469,8 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
trans_rollback_implicit(thd);
thd->mdl_context.release_transactional_locks();
}
+
+ select_number_after_prepare= thd->select_number;
lex_end(lex);
cleanup_stmt();
@@ -3581,7 +3597,8 @@ Prepared_statement::execute_loop(String *expanded_query,
Reprepare_observer reprepare_observer;
bool error;
int reprepare_attempt= 0;
-
+
+ thd->select_number= select_number_after_prepare;
/* Check if we got an error when sending long data */
if (state == Query_arena::STMT_ERROR)
{