summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-07-05 00:06:39 -0700
committerIgor Babaev <igor@askmonty.org>2018-07-05 00:06:39 -0700
commit058554027f6696775ca1b289688956606f59ce7d (patch)
tree6b4cf9941f68cb3fdeb9cfa0fb69c73453a4185b /sql/sp_head.cc
parent400cf017152c732387c89deaa082b43c8fb42d71 (diff)
downloadmariadb-git-058554027f6696775ca1b289688956606f59ce7d.tar.gz
MDEV-16629 "Table Does Not Exist" Error from Recursive CTE Query Inside Function
When processing a query containing with clauses a call of the function check_dependencies_in_with_clauses() before opening tables used in the query is necessary if with clauses include specifications of recursive CTEs. This call was missing if such a query belonged to a stored function. This caused misbehavior of the server: it could report a fake error as in the test case for MDEV-16629 or the executed query could hang as in the test cases for MDEV-16661 and MDEV-15151.
Diffstat (limited to 'sql/sp_head.cc')
-rw-r--r--sql/sp_head.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index a832aa91004..effe9d1735f 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -29,6 +29,7 @@
#include "sql_array.h" // Dynamic_array
#include "log_event.h" // Query_log_event
#include "sql_derived.h" // mysql_handle_derived
+#include "sql_cte.h"
#ifdef USE_PRAGMA_IMPLEMENTATION
#pragma implementation
@@ -3000,7 +3001,8 @@ sp_lex_keeper::reset_lex_and_exec_core(THD *thd, uint *nextp,
#endif
if (open_tables)
- res= instr->exec_open_and_lock_tables(thd, m_lex->query_tables);
+ res= check_dependencies_in_with_clauses(m_lex->with_clauses_list) ||
+ instr->exec_open_and_lock_tables(thd, m_lex->query_tables);
if (!res)
{