From: Date: October 31 2006 10:27pm Subject: bk commit into 5.0 tree (sergefp:1.2292) BUG#8804 List-Archive: http://lists.mysql.com/commits/14636 X-Bug: 8804 Message-Id: <20061031212756.48FCF18030@pylon.mylan> Below is the list of changes that have just been committed into a local 5.0 repository of psergey. When psergey does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2006-11-01 00:27:51+03:00, sergefp@stripped +1 -0 BUG#8804: Incorrect results for NULL IN (SELECT ...): review fixes: - Better comments - Remove redundant and dead code. sql/item_subselect.cc@stripped, 2006-11-01 00:27:49+03:00, sergefp@stripped +20 -22 BUG#8804: Incorrect results for NULL IN (SELECT ...): review fixes: - Better comments - Remove redundant and dead code. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: sergefp # Host: pylon.mylan # Root: /home/psergey/mysql-5.0-bug8804-r4 --- 1.138/sql/item_subselect.cc 2006-11-01 00:27:56 +03:00 +++ 1.139/sql/item_subselect.cc 2006-11-01 00:27:56 +03:00 @@ -769,43 +769,47 @@ SYNOPSIS Item_in_subselect::single_value_transformer() - join - func + join Join object of the subquery (i.e. 'child' join). + func Subquery comparison creator DESCRIPTION Rewrite a single-column subquery using rule-based approach. The subquery - oe $cmp$ (SELECT sel FROM ... WHERE subq_where HAVING subq_having) + oe $cmp$ (SELECT ie FROM ... WHERE subq_where ... HAVING subq_having) First, try to convert the subquery to scalar-result subquery in one of the forms: - oe $cmp$ (SELECT MAX(...) ) // handled by Item_singlerow_subselect - - oe $cmp$ (SELECT ...) // handled by Item_maxminsubselect + - oe $cmp$ (SELECT ...) // handled by Item_maxmin_subselect If that fails, the subquery will be handled with class Item_in_optimizer, Inject the predicates into subquery, i.e. convert it to: - If the subquery has aggregates, GROUP BY, or HAVING, convert to - SELECT sel FROM ... HAVING subq_having AND + SELECT ie FROM ... HAVING subq_having AND trigcond(oe $cmp$ ref_or_null_helper) the addition is wrapped into trigger only when we want to distinguish between NULL and FALSE results. - - Else, if we don't care if subquery result is NULL or FALSE, convert to - - SELECT 1 ... WHERE (oe $CMP$ ie) AND subq_where - - - Else convert to: - - SELECT 1 WHERE ... - WHERE subq_where AND trigcond((oe $CMP$ ie) OR ie IS NULL) - HAVING subq_having AND trigcond((ie)) + - Otherwise (no aggregates/GROUP BY/HAVING) convert it to one of the + following: + + = If we don't need to distinguish between NULL and FALSE subquery: + + SELECT 1 FROM ... WHERE (oe $cmp$ ie) AND subq_where + + = If we need to distinguish between those: + + SELECT 1 FROM ... + WHERE subq_where AND trigcond((oe $cmp$ ie) OR (ie IS NULL)) + HAVING trigcond((ie)) RETURN - RES_OK - Transformed successfully (or done nothing?) + RES_OK - OK, either subquery was transformed, or appopriate + predicates where injected into it. RES_REDUCE - The subquery was reduced to non-subquery RES_ERROR - Error */ @@ -1010,10 +1014,7 @@ we can assign select_lex->having here, and pass 0 as last argument (reference) to fix_fields() */ - select_lex->having= - join->having= (join->having ? - new Item_cond_and(having, join->having) : - having); + select_lex->having= join->having= having; select_lex->having_fix_field= 1; /* we do not check join->having->fixed, because Item_and (from @@ -1608,7 +1609,6 @@ bool subselect_single_select_engine::no_rows() { -// return test(!join->send_records); return !item->assigned(); } @@ -1791,9 +1791,7 @@ int error; TABLE *table= tab->table; DBUG_ENTER("subselect_uniquesubquery_engine::scan_table"); - empty_result_set= TRUE; - bool is_uncorrelated= !cond || !(cond->used_tables() & OUTER_REF_TABLE_BIT); if (table->file->inited) table->file->ha_index_end();