summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergey Glukhov <Sergey.Glukhov@sun.com>2010-10-18 14:47:26 +0400
committerSergey Glukhov <Sergey.Glukhov@sun.com>2010-10-18 14:47:26 +0400
commit9a8f22fa2d9126cf7344cdd90e258f72dfa2e51e (patch)
tree2531ef5b40462491747a2d3283a13f594835277f /sql
parentab3417b636c5b3f2514ccdfbf166a7f1361527ad (diff)
downloadmariadb-git-9a8f22fa2d9126cf7344cdd90e258f72dfa2e51e.tar.gz
Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine
Subquery executes twice, at top level JOIN::optimize and ::execute stages. At first execution create_sort_index() function is called and FT_SELECT object is created and destroyed. HANDLER::ft_handler is cleaned up in the object destructor and at second execution FT_SELECT::get_next() method returns error. The fix is to reinit HANDLER::ft_handler field before re-execution of subquery.
Diffstat (limited to 'sql')
-rw-r--r--sql/item_func.cc10
-rw-r--r--sql/item_func.h2
-rw-r--r--sql/sql_select.cc3
3 files changed, 14 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc
index eaf6a1b6d14..30d5d844f7c 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -5297,7 +5297,17 @@ void Item_func_match::init_search(bool no_order)
/* Check if init_search() has been called before */
if (ft_handler)
+ {
+ /*
+ We should reset ft_handler as it is cleaned up
+ on destruction of FT_SELECT object
+ (necessary in case of re-execution of subquery).
+ TODO: FT_SELECT should not clean up ft_handler.
+ */
+ if (join_key)
+ table->file->ft_handler= ft_handler;
DBUG_VOID_RETURN;
+ }
if (key == NO_SUCH_KEY)
{
diff --git a/sql/item_func.h b/sql/item_func.h
index 256348eee08..26a7e033692 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1531,7 +1531,7 @@ public:
join_key(0), ft_handler(0), table(0), master(0), concat_ws(0) { }
void cleanup()
{
- DBUG_ENTER("Item_func_match");
+ DBUG_ENTER("Item_func_match::cleanup");
Item_real_func::cleanup();
if (!master && ft_handler)
ft_handler->please->close_search(ft_handler);
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 08bd0c28738..a260b78f131 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1713,6 +1713,9 @@ JOIN::reinit()
func->clear();
}
+ if (!(select_options & SELECT_DESCRIBE))
+ init_ftfuncs(thd, select_lex, test(order));
+
DBUG_RETURN(0);
}