From 70e1974f76af61269de66ae056afc02290cea214 Mon Sep 17 00:00:00 2001 From: "evgen@moonbone.local" <> Date: Mon, 14 Nov 2005 21:52:39 +0300 Subject: [PATCH] Fix bug #14850 Item_ref's null_value wasn't updated Item_ref's null_value wasn't updated in save_org_in_field() causing reported error. --- mysql-test/r/view.result | 8 ++++++++ mysql-test/t/view.test | 10 ++++++++++ sql/item.h | 6 +++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 97df059c86a..ded9eb199f7 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2385,3 +2385,11 @@ show create view v1; View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY INVOKER VIEW `v1` AS select 1 AS `1` drop view v1; +create table t1(f1 int, f2 int); +insert into t1 values (null, 10), (null,2); +create view v1 as select * from t1; +select f1, sum(f2) from v1 group by f1; +f1 sum(f2) +NULL 12 +drop view v1; +drop table t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 5addcd2570d..899279dc912 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2253,3 +2253,13 @@ drop view v1; create definer = current_user sql security invoker view v1 as select 1; show create view v1; drop view v1; + +# +# Bug #14850 Item_ref's values wasn't updated +# +create table t1(f1 int, f2 int); +insert into t1 values (null, 10), (null,2); +create view v1 as select * from t1; +select f1, sum(f2) from v1 group by f1; +drop view v1; +drop table t1; diff --git a/sql/item.h b/sql/item.h index 8bc659c3060..332eac70145 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1603,7 +1603,11 @@ public: void make_field(Send_field *field); bool fix_fields(THD *, Item **); int save_in_field(Field *field, bool no_conversions); - void save_org_in_field(Field *field) { (*ref)->save_org_in_field(field); } + void save_org_in_field(Field *field) + { + (*ref)->save_org_in_field(field); + null_value= (*ref)->null_value; + } enum Item_result result_type () const { return (*ref)->result_type(); } enum_field_types field_type() const { return (*ref)->field_type(); } Field *get_tmp_table_field()