summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2005-08-10 12:25:26 +0400
committerkonstantin@mysql.com <>2005-08-10 12:25:26 +0400
commitf6306a8db10a17d5ad560b8e53b0ec3d425bb977 (patch)
tree77e725a2c20217e76ac1195f1b18b198b4ac4815 /sql
parentec5ceecab718298a37274058e56d474275dda35f (diff)
downloadmariadb-git-f6306a8db10a17d5ad560b8e53b0ec3d425bb977.tar.gz
A fix for Bug#11901 "mysql_stmt_attr_set CURSOR_TYPE_READ_ONLY join in
subqry order by server crash": failing DBUG_ASSERT(curr_join == this) when opening a cursor. Ensure that for top-level join curr_join == join (always), and thus fix the failing assert. curr_join is a hack to ensure that uncacheable subqueries can be re-evaluated safely, and should be never different from main join in case of top-level join.
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_select.cc9
-rw-r--r--sql/sql_select.h5
2 files changed, 9 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index fb0407e1405..630406dba07 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1090,9 +1090,10 @@ JOIN::optimize()
order=0;
}
}
-
- if (thd->lex->subqueries)
+
+ if (select_lex->uncacheable && !is_top_level_join())
{
+ /* If this join belongs to an uncacheable subquery */
if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
DBUG_RETURN(-1);
error= 0; // Ensure that tmp_join.error= 0
@@ -1636,9 +1637,7 @@ JOIN::exec()
curr_join->fields= curr_fields_list;
curr_join->procedure= procedure;
- if (unit == &thd->lex->unit &&
- (unit->fake_select_lex == 0 || select_lex == unit->fake_select_lex) &&
- thd->cursor && tables != const_tables)
+ if (is_top_level_join() && thd->cursor && tables != const_tables)
{
/*
We are here if this is JOIN::exec for the last select of the main unit
diff --git a/sql/sql_select.h b/sql/sql_select.h
index c950444e1c6..3b9a3093682 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -366,6 +366,11 @@ class JOIN :public Sql_alloc
!group_list);
}
bool change_result(select_result *result);
+ bool is_top_level_join() const
+ {
+ return (unit == &thd->lex->unit && (unit->fake_select_lex == 0 ||
+ select_lex == unit->fake_select_lex));
+ }
};