From 5c7d82934690991ae98331c0ad14fce6e2f9760d Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Fri, 9 Sep 2016 13:25:02 -0700 Subject: [PATCH] Another attempt to fix bug mdev-10736. --- mysql-test/r/cte_recursive.result | 9 +++++++++ mysql-test/t/cte_recursive.test | 19 +++++++++---------- sql/sql_derived.cc | 6 +----- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/cte_recursive.result b/mysql-test/r/cte_recursive.result index da5f380c0e43c..b37a32a8ae75d 100644 --- a/mysql-test/r/cte_recursive.result +++ b/mysql-test/r/cte_recursive.result @@ -1623,3 +1623,12 @@ n 3 4 5 +# +# MDEV-10736: recursive definition with anchor over a table with blob +# +CREATE TABLE t1 (f VARCHAR(1024)); +WITH RECURSIVE cte(f) AS +(SELECT t1.f FROM t1 UNION ALL SELECT cte.f FROM cte) +SELECT * FROM cte as t; +f +DROP TABLE t1; diff --git a/mysql-test/t/cte_recursive.test b/mysql-test/t/cte_recursive.test index 445b257b6468c..5eb84bae4fb53 100644 --- a/mysql-test/t/cte_recursive.test +++ b/mysql-test/t/cte_recursive.test @@ -1185,13 +1185,12 @@ WITH RECURSIVE cte(n) AS ( SELECT n+1 FROM cte WHERE n < 5 UNION SELECT 1 UNION SELECT 1 ) SELECT * FROM cte; -# --echo # -# --echo # MDEV-10736: recursive definition with anchor over a table with blob -# --echo # -# -# CREATE TABLE t1 (f VARCHAR(1024)); -# set statement max_recursive_iterations=1 for -# WITH RECURSIVE cte(f) AS -# (SELECT t1.f FROM t1 UNION ALL SELECT cte.f FROM cte) -# SELECT * FROM cte; -# DROP TABLE t1; +--echo # +--echo # MDEV-10736: recursive definition with anchor over a table with blob +--echo # + +CREATE TABLE t1 (f VARCHAR(1024)); +WITH RECURSIVE cte(f) AS + (SELECT t1.f FROM t1 UNION ALL SELECT cte.f FROM cte) +SELECT * FROM cte as t; +DROP TABLE t1; diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index a5e73acdc4791..b0d505b8b38b6 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -480,10 +480,6 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) derived->set_materialized_derived(); if (!derived->table || !derived->table->is_created()) res= mysql_derived_create(thd, lex, derived); -#if 0 - if (!res) - res= mysql_derived_fill(thd, lex, derived); -#endif goto exit_merge; } @@ -920,7 +916,7 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) if (table->is_created()) DBUG_RETURN(FALSE); - select_union *result= (select_union*)unit->result; + select_union *result= derived->derived_result; if (table->s->db_type() == TMP_ENGINE_HTON) { result->tmp_table_param.keyinfo= table->s->key_info;