From ac0d94a98ab93a8b0e827384cdbddf94ee90b49b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 26 Aug 2004 13:11:06 +0300 Subject: [PATCH] fix of Item_ref with result_field (BUG#5104) mysql-test/r/view.result: distinct in temporary table with a VIEW mysql-test/t/view.test: distinct in temporary table with a VIEW sql/item.cc: fix of Item_ref with result_field sql/item.h: fix of Item_ref with result_field --- mysql-test/r/view.result | 18 ++++++++++++++++++ mysql-test/t/view.test | 12 ++++++++++++ sql/item.cc | 8 ++++++++ sql/item.h | 2 +- 4 files changed, 39 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index c1b079fe527..8ee7675812a 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1116,3 +1116,21 @@ c1 c2 7 almost real Beer drop view v1; drop table t1; +create table t1 (a int); +insert into t1 values (1),(1),(2),(2),(3),(3); +create view v1 as select a from t1; +select distinct a from v1; +a +1 +2 +3 +select distinct a from v1 limit 2; +a +1 +2 +select distinct a from t1 limit 2; +a +1 +2 +drop view v1; +drop table t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 616b1bbedd5..5ce409bd6e0 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1066,3 +1066,15 @@ CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer'); select * from v1; drop view v1; drop table t1; + +# +# distinct in temporary table with a VIEW +# +create table t1 (a int); +insert into t1 values (1),(1),(2),(2),(3),(3); +create view v1 as select a from t1; +select distinct a from v1; +select distinct a from v1 limit 2; +select distinct a from t1 limit 2; +drop view v1; +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index b6dfb97d128..17e911cfbb9 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -2156,6 +2156,14 @@ void Item_ref::print(String *str) } +bool Item_ref::send(Protocol *prot, String *tmp) +{ + if (result_field) + return prot->store(result_field); + return (*ref)->send(prot, tmp); +} + + void Item_ref_null_helper::print(String *str) { str->append("(", 18); diff --git a/sql/item.h b/sql/item.h index b3dbc0ce46f..f6ad9ed1567 100644 --- a/sql/item.h +++ b/sql/item.h @@ -964,7 +964,7 @@ public: { return (null_value=(*ref)->get_date_result(ltime,fuzzydate)); } - bool send(Protocol *prot, String *tmp){ return (*ref)->send(prot, tmp); } + bool send(Protocol *prot, String *tmp); void make_field(Send_field *field) { (*ref)->make_field(field); } bool fix_fields(THD *, struct st_table_list *, Item **); int save_in_field(Field *field, bool no_conversions)