Commit 393ed84c authored by unknown's avatar unknown

a fix (Bug #3435: STDDEV|VARIANCE(constant) returns constant if no rows)

parent 575541b9
...@@ -648,3 +648,11 @@ select a from t1 having a=1; ...@@ -648,3 +648,11 @@ select a from t1 having a=1;
a a
1 1
drop table t1; drop table t1;
create table t1 (a int);
select variance(2) from t1;
variance(2)
NULL
select stddev(2) from t1;
stddev(2)
NULL
drop table t1;
...@@ -387,3 +387,12 @@ insert into t1 values (1); ...@@ -387,3 +387,12 @@ insert into t1 values (1);
select max(a) as b from t1 having b=1; select max(a) as b from t1 having b=1;
select a from t1 having a=1; select a from t1 having a=1;
drop table t1; drop table t1;
#
# Bug #3435: variance(const), stddev(const) and an empty table
#
create table t1 (a int);
select variance(2) from t1;
select stddev(2) from t1;
drop table t1;
...@@ -351,6 +351,7 @@ class Item_sum_variance : public Item_sum_num ...@@ -351,6 +351,7 @@ class Item_sum_variance : public Item_sum_num
void update_field(); void update_field();
Item *result_item(Field *field) Item *result_item(Field *field)
{ return new Item_variance_field(this); } { return new Item_variance_field(this); }
void no_rows_in_result() {}
const char *func_name() const { return "variance"; } const char *func_name() const { return "variance"; }
Item *copy_or_same(THD* thd); Item *copy_or_same(THD* thd);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment