Loading mysql-test/r/func_group.result +28 −0 Original line number Diff line number Diff line Loading @@ -656,3 +656,31 @@ select stddev(2) from t1; stddev(2) NULL drop table t1; create table t1 (a int); insert into t1 values (1),(2); prepare stmt1 from 'SELECT COUNT(*) FROM t1'; execute stmt1; COUNT(*) 2 execute stmt1; COUNT(*) 2 execute stmt1; COUNT(*) 2 deallocate prepare stmt1; drop table t1; create table t1 (a int, primary key(a)); insert into t1 values (1),(2); prepare stmt1 from 'SELECT max(a) FROM t1'; execute stmt1; max(a) 2 execute stmt1; max(a) 2 execute stmt1; max(a) 2 deallocate prepare stmt1; drop table t1; mysql-test/t/func_group.test +22 −0 Original line number Diff line number Diff line Loading @@ -396,3 +396,25 @@ create table t1 (a int); select variance(2) from t1; select stddev(2) from t1; drop table t1; # # cleunup() of optimized away count(*) and max/min # create table t1 (a int); insert into t1 values (1),(2); prepare stmt1 from 'SELECT COUNT(*) FROM t1'; execute stmt1; execute stmt1; execute stmt1; deallocate prepare stmt1; drop table t1; create table t1 (a int, primary key(a)); insert into t1 values (1),(2); prepare stmt1 from 'SELECT max(a) FROM t1'; execute stmt1; execute stmt1; execute stmt1; deallocate prepare stmt1; drop table t1; sql/item_sum.cc +19 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,16 @@ longlong Item_sum_count::val_int() return (longlong) count; } void Item_sum_count::cleanup() { DBUG_ENTER("Item_sum_count::cleanup"); Item_sum_int::cleanup(); used_table_cache= ~(table_map) 0; DBUG_VOID_RETURN; } /* Avgerage */ Loading Loading @@ -575,6 +585,15 @@ Item_sum_hybrid::val_str(String *str) } void Item_sum_hybrid::cleanup() { DBUG_ENTER("Item_sum_hybrid::cleanup"); Item_sum::cleanup(); used_table_cache= ~(table_map) 0; DBUG_VOID_RETURN; } Item *Item_sum_min::copy_or_same(THD* thd) { return new (&thd->mem_root) Item_sum_min(thd, this); Loading sql/item_sum.h +2 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,7 @@ class Item_sum_count :public Item_sum_int void make_const(longlong count_arg) { count=count_arg; used_table_cache=0; } longlong val_int(); void reset_field(); void cleanup(); void update_field(); const char *func_name() const { return "count"; } Item *copy_or_same(THD* thd); Loading Loading @@ -428,6 +429,7 @@ class Item_sum_hybrid :public Item_sum void min_max_update_str_field(); void min_max_update_real_field(); void min_max_update_int_field(); void cleanup(); }; Loading Loading
mysql-test/r/func_group.result +28 −0 Original line number Diff line number Diff line Loading @@ -656,3 +656,31 @@ select stddev(2) from t1; stddev(2) NULL drop table t1; create table t1 (a int); insert into t1 values (1),(2); prepare stmt1 from 'SELECT COUNT(*) FROM t1'; execute stmt1; COUNT(*) 2 execute stmt1; COUNT(*) 2 execute stmt1; COUNT(*) 2 deallocate prepare stmt1; drop table t1; create table t1 (a int, primary key(a)); insert into t1 values (1),(2); prepare stmt1 from 'SELECT max(a) FROM t1'; execute stmt1; max(a) 2 execute stmt1; max(a) 2 execute stmt1; max(a) 2 deallocate prepare stmt1; drop table t1;
mysql-test/t/func_group.test +22 −0 Original line number Diff line number Diff line Loading @@ -396,3 +396,25 @@ create table t1 (a int); select variance(2) from t1; select stddev(2) from t1; drop table t1; # # cleunup() of optimized away count(*) and max/min # create table t1 (a int); insert into t1 values (1),(2); prepare stmt1 from 'SELECT COUNT(*) FROM t1'; execute stmt1; execute stmt1; execute stmt1; deallocate prepare stmt1; drop table t1; create table t1 (a int, primary key(a)); insert into t1 values (1),(2); prepare stmt1 from 'SELECT max(a) FROM t1'; execute stmt1; execute stmt1; execute stmt1; deallocate prepare stmt1; drop table t1;
sql/item_sum.cc +19 −0 Original line number Diff line number Diff line Loading @@ -361,6 +361,16 @@ longlong Item_sum_count::val_int() return (longlong) count; } void Item_sum_count::cleanup() { DBUG_ENTER("Item_sum_count::cleanup"); Item_sum_int::cleanup(); used_table_cache= ~(table_map) 0; DBUG_VOID_RETURN; } /* Avgerage */ Loading Loading @@ -575,6 +585,15 @@ Item_sum_hybrid::val_str(String *str) } void Item_sum_hybrid::cleanup() { DBUG_ENTER("Item_sum_hybrid::cleanup"); Item_sum::cleanup(); used_table_cache= ~(table_map) 0; DBUG_VOID_RETURN; } Item *Item_sum_min::copy_or_same(THD* thd) { return new (&thd->mem_root) Item_sum_min(thd, this); Loading
sql/item_sum.h +2 −0 Original line number Diff line number Diff line Loading @@ -172,6 +172,7 @@ class Item_sum_count :public Item_sum_int void make_const(longlong count_arg) { count=count_arg; used_table_cache=0; } longlong val_int(); void reset_field(); void cleanup(); void update_field(); const char *func_name() const { return "count"; } Item *copy_or_same(THD* thd); Loading Loading @@ -428,6 +429,7 @@ class Item_sum_hybrid :public Item_sum void min_max_update_str_field(); void min_max_update_real_field(); void min_max_update_int_field(); void cleanup(); }; Loading