summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorunknown <sergefp@mysql.com>2004-08-23 12:31:56 +0400
committerunknown <sergefp@mysql.com>2004-08-23 12:31:56 +0400
commit34c8e46dc35d03751fde16efd2ce3c70192827b8 (patch)
treedaa94554cc7a543da8a8344e49828686dae0bc44 /sql/sql_select.cc
parent83e3d3f9a3ab6888292b8bcb15e0f77f00249289 (diff)
downloadmariadb-git-34c8e46dc35d03751fde16efd2ce3c70192827b8.tar.gz
Fix for bug#5088:
* When executing EXPLAIN, do the same as for the query: convert join type to JT_CONST if keyuse array covers all key parts and all of them are constants. * In remove_const, don't remove conditions that depend on some-const-table and current-table. mysql-test/r/join_outer.result: Testcase for bug#5088 mysql-test/t/join_outer.test: Testcase for bug#5088
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index fdea963b3ca..8830b2b2d17 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -3215,6 +3215,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
store_key **ref_key= j->ref.key_copy;
byte *key_buff=j->ref.key_buff, *null_ref_key= 0;
+ bool keyuse_uses_no_tables= true;
if (ftkey)
{
j->ref.items[0]=((Item_func*)(keyuse->val))->key_item();
@@ -3234,6 +3235,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
uint maybe_null= test(keyinfo->key_part[i].null_bit);
j->ref.items[i]=keyuse->val; // Save for cond removal
+ keyuse_uses_no_tables= keyuse_uses_no_tables & !keyuse->used_tables;
if (!keyuse->used_tables &&
!(join->select_options & SELECT_DESCRIBE))
{ // Compare against constant
@@ -3273,7 +3275,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse,
j->type= null_ref_key ? JT_REF_OR_NULL : JT_REF;
j->ref.null_ref_key= null_ref_key;
}
- else if (ref_key == j->ref.key_copy)
+ else if (keyuse_uses_no_tables)
{
/*
This happen if we are using a constant expression in the ON part
@@ -4062,7 +4064,7 @@ remove_const(JOIN *join,ORDER *first_order, COND *cond, bool *simple_order)
}
if ((ref=order_tables & (not_const_tables ^ first_table)))
{
- if (only_eq_ref_tables(join,first_order,ref))
+ if (!(order_tables & first_table) && only_eq_ref_tables(join,first_order,ref))
{
DBUG_PRINT("info",("removing: %s", order->item[0]->full_name()));
continue;