Hi Timour, Please find it below. Any objections? === modified file 'sql/sql_select.cc' --- sql/sql_select.cc 2011-11-25 19:54:36 +0000 +++ sql/sql_select.cc 2011-11-28 11:40:42 +0000 @@ -14776,14 +14776,10 @@ do_select(JOIN *join,List<Item> *fields, /* HAVING will be checked after processing aggregate functions, But WHERE should checkd here (we alredy have read tables). - If there is join->exec_const_cond, and all tables are constant, then it - is equivalent to join->conds. exec_const_cond is already checked in the - beginning of JOIN::exec. If it is false, JOIN::exec returns zero - result already there, therefore execution reaches this point only if - exec_const_cond is TRUE. Since it is equvalent to join->conds, then - join->conds is also TRUE. + + (TODO new comment here) */ - if (!join->conds || join->exec_const_cond || join->conds->val_int()) + if (!join->outer_ref_cond || join->outer_ref_cond->val_int()) { error= (*end_select)(join, 0, 0); if (error == NESTED_LOOP_OK || error == NESTED_LOOP_QUERY_LIMIT) BR Sergei -- Sergei Petrunia, Software Developer Monty Program AB, http://askmonty.org Blog: http://s.petrunia.net/blog