List:Commits« Previous MessageNext Message »
From:Martin Hansson Date:October 1 2009 2:41pm
Subject:Re: bzr commit into mysql-5.1-bugteam branch (jorgen.loland:3146)
Bug#47280
View as plain text  
Jorgen Loland wrote:
> ...
>      if (item->type() == Item::SUM_FUNC_ITEM)
>      {
>        Item_sum *item_sum= (((Item_sum*) item));
> @@ -213,7 +220,6 @@ int opt_sum_query(TABLE_LIST *tables, Li
>              is_exact_count= 1;                  // count is now exact
>            }
>            ((Item_sum_count*) item)->make_const((longlong) count);
> -          recalc_const_item= 1;
>          }
>          else
>            const_result= 0;
> @@ -363,7 +369,6 @@ int opt_sum_query(TABLE_LIST *tables, Li
>          else
>            ((Item_sum_min*) item_sum)->reset(); /* Set to the constant value. */
>          ((Item_sum_min*) item_sum)->make_const();
> -        recalc_const_item= 1;
>          break;
>        }
>        case Item_sum::MAX_FUNC:
> @@ -451,7 +456,6 @@ int opt_sum_query(TABLE_LIST *tables, Li
>          else
>            ((Item_sum_max*) item_sum)->reset(); /* Set to the constant value. */
>          ((Item_sum_max*) item_sum)->make_const();
> -        recalc_const_item= 1;
>          break;
>        }
>        default:
> @@ -459,13 +463,6 @@ int opt_sum_query(TABLE_LIST *tables, Li
>          break;
>        }
>      }
> -    else if (const_result)
> -    {
> -      if (recalc_const_item)
> -        item->update_used_tables();
> -      if (!item->const_item())
> -        const_result= 0;
> -    }
>    }
I don't think you should do this. Consider:

CREATE TABLE t2 ( pk INT, PRIMARY KEY (pk) );
SELECT COUNT(pk) AS cpk, COUNT(pk)+1, pk FROM t2 ORDER BY cpk, pk;

In this case used_tables for the item COUNT(pk)+1 will still be {t2} 
after const substitution, and that's not correct if COUNT(pk) is a constant.

Please see if you come to the same conclusion or I missed something.

/Martin
Thread
bzr commit into mysql-5.1-bugteam branch (jorgen.loland:3146) Bug#47280Jorgen Loland1 Oct
  • Re: bzr commit into mysql-5.1-bugteam branch (jorgen.loland:3146)Bug#47280Jørgen Løland1 Oct
  • Re: bzr commit into mysql-5.1-bugteam branch (jorgen.loland:3146)Bug#47280Martin Hansson1 Oct