summaryrefslogtreecommitdiff
path: root/sql/sql_cte.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2016-07-26 22:58:33 -0700
committerIgor Babaev <igor@askmonty.org>2016-07-26 22:58:33 -0700
commitf982d1074a3bc880462ab2372803b278af8dc4dd (patch)
treee20df01a7f0378e045811b2d7e44585ef8b8c389 /sql/sql_cte.cc
parent8c6a9aa30f9e74388aaf923ac8e3b19ca0f86188 (diff)
downloadmariadb-git-f982d1074a3bc880462ab2372803b278af8dc4dd.tar.gz
Fixed the following problem:
Temporary tables created for recursive CTE were instantiated at the prepare phase. As a result these temporary tables missed indexes for look-ups and optimizer could not use them.
Diffstat (limited to 'sql/sql_cte.cc')
-rw-r--r--sql/sql_cte.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/sql_cte.cc b/sql/sql_cte.cc
index 3c663d7d260..dd877b5598a 100644
--- a/sql/sql_cte.cc
+++ b/sql/sql_cte.cc
@@ -3,6 +3,7 @@
#include "sql_cte.h"
#include "sql_view.h" // for make_valid_column_names
#include "sql_parse.h"
+#include "sql_select.h"
/**
@@ -956,3 +957,20 @@ void With_element::print(String *str, enum_query_type query_type)
}
+bool With_element::instantiate_tmp_tables()
+{
+ List_iterator_fast<TABLE> li(rec_result->rec_tables);
+ TABLE *rec_table;
+ while ((rec_table= li++))
+ {
+ if (!rec_table->is_created() &&
+ instantiate_tmp_table(rec_table,
+ rec_result->tmp_table_param.keyinfo,
+ rec_result->tmp_table_param.start_recinfo,
+ &rec_result->tmp_table_param.recinfo,
+ 0))
+ return true;
+ }
+ return false;
+}
+