summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-02-05 18:07:31 -0800
committerIgor Babaev <igor@askmonty.org>2018-02-05 18:07:31 -0800
commitf271100836d8a91a775894ec36b869a66a3145e5 (patch)
tree179679955378d944a5414dd7022d31f1186f03b7 /sql
parent465979eabfe3acacc0566fa93402e449e1a9f476 (diff)
downloadmariadb-git-f271100836d8a91a775894ec36b869a66a3145e5.tar.gz
Fixed mdev-15162 Query with CTE hangs if assignment operator (:=) is used
If setting user variable was used in the specification of a recursive CTE then Item_func_set_user_var::fix_fields() went into an infinite loop.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_func.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index e130831cb6a..3583b6aed62 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -54,6 +54,7 @@
#include "set_var.h"
#include "debug_sync.h"
#include "sql_base.h"
+#include "sql_cte.h"
#ifdef NO_EMBEDDED_ACCESS_CHECKS
#define sp_restore_security_context(A,B) while (0) {}
@@ -4514,10 +4515,13 @@ bool Item_func_set_user_var::fix_fields(THD *thd, Item **ref)
TABLE_LIST *derived;
for (derived= unit->derived;
derived;
- derived= derived->select_lex->master_unit()->derived)
+ derived= unit->derived)
{
derived->set_materialized_derived();
derived->prohibit_cond_pushdown= true;
+ if (unit->with_element && unit->with_element->is_recursive)
+ break;
+ unit= derived->select_lex->master_unit();
}
}