Hi, V!
On Nov 20, V Narayanan wrote:
> #At
> file:///home/narayanan/Work/mysql_checkouts/shared_repository_directory/mysql-5.1-bugteam-47762-3/
> based on revid:sven.sandberg@stripped
>
> 3208 V Narayanan 2009-11-20
> Bug#47762 Incorrect result from MIN() when WHERE tests NOT NULL column for
> NULL
>
> The lookup of a NULL value in a column having a NOT NULL
> index was resulting in wrong query result. This was
> happening because NULLs were not being handled properly.
>
> === added file 'mysql-test/t/min_null_cond.test'
> --- a/mysql-test/t/min_null_cond.test 1970-01-01 00:00:00 +0000
> +++ b/mysql-test/t/min_null_cond.test 2009-11-20 04:02:14 +0000
> @@ -0,0 +1,75 @@
> === modified file 'sql/opt_sum.cc'
> --- a/sql/opt_sum.cc 2009-10-14 08:46:50 +0000
> +++ b/sql/opt_sum.cc 2009-11-20 04:02:14 +0000
> @@ -527,7 +527,7 @@ bool simple_pred(Item_func *func_item, I
> {
> args[0]= item;
> item= func_item->arguments()[1];
> - if (!item->const_item())
> + if (!item->const_item() || item->type() == Item::NULL_ITEM)
> return 0;
> args[1]= item;
> }
That's not enough. It handles the case
a = NULL
but not
NULL = a
(that's the 'else' branch, two lines down).
Also, it doesn't cover BETWEEN (that's 'case 3' further down).
Regards / Mit vielen Grüßen,
Sergei
--
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@stripped>
/ /|_/ / // /\ \/ /_/ / /__ Principal Software Engineer/Server Architect
/_/ /_/\_, /___/\___\_\___/ Sun Microsystems GmbH, HRB München 161028
<___/ Sonnenallee 1, 85551 Kirchheim-Heimstetten
Geschäftsführer: Thomas Schroeder, Wolfgang Engels, Wolf Frenkel
Vorsitzender des Aufsichtsrates: Martin Häring