summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-05-04 22:45:32 -0700
committerIgor Babaev <igor@askmonty.org>2017-05-04 22:45:32 -0700
commit15f9931f6d2b0eb4006fdc42072c2905fd67c1aa (patch)
treefff72f8e5466e551753d589b54243a48c13541e9 /sql/sql_select.cc
parent14fca28ea44dabf62e75e2aa9a90d71bd7be45c0 (diff)
downloadmariadb-git-15f9931f6d2b0eb4006fdc42072c2905fd67c1aa.tar.gz
Fixed the bug mdev-12673.
This patch corrects the fix for the bug mdev-10693. It is critical for the function get_best_combination() not to call create_ref_for_key() for constant tables. This bug could manifest itself only in multi-table subqueries where one of the tables is accessed by a constant primary key.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index c5f2a83fc01..09e6ece7807 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -7844,12 +7844,14 @@ get_best_combination(JOIN *join)
{
if (j->bush_children)
j= j->bush_children->start;
-
+
used_tables|= j->table->map;
- if ((keyuse= join->best_positions[tablenr].key) &&
- create_ref_for_key(join, j, keyuse, TRUE, used_tables))
- DBUG_RETURN(TRUE); // Something went wrong
-
+ if (j->type != JT_CONST && j->type != JT_SYSTEM)
+ {
+ if ((keyuse= join->best_positions[tablenr].key) &&
+ create_ref_for_key(join, j, keyuse, TRUE, used_tables))
+ DBUG_RETURN(TRUE); // Something went wrong
+ }
if (j->last_leaf_in_bush)
j= j->bush_root_tab;
}