diff options
author | unknown <evgen@moonbone.local> | 2005-08-18 22:46:17 +0400 |
---|---|---|
committer | unknown <evgen@moonbone.local> | 2005-08-18 22:46:17 +0400 |
commit | 88a7d01eba6960ebd73307b37527946a22142d34 (patch) | |
tree | 066fbaea85a3e01edf160e37ba0534d4ef2a6ab7 | |
parent | 0b8e774e5faa9650ea13ee9cdb0cbc4475a1de7c (diff) | |
parent | def42df9feebef4d513e834cfeacf73691927110 (diff) | |
download | mariadb-git-88a7d01eba6960ebd73307b37527946a22142d34.tar.gz |
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0
into moonbone.local:/work/10624-bug-5.0-mysql
sql/sql_lex.cc:
Auto merged
-rw-r--r-- | mysql-test/r/view.result | 12 | ||||
-rw-r--r-- | mysql-test/t/view.test | 12 | ||||
-rw-r--r-- | sql/sql_lex.cc | 5 |
3 files changed, 28 insertions, 1 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 2af2f06ad52..a1566fa30c2 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2097,3 +2097,15 @@ select * from v1; f1 1 drop view v1; +create table t1 (f1 int); +create table t2 (f1 int); +insert into t1 values (1); +insert into t2 values (2); +create view v1 as select * from t1 union select * from t2 union all select * from t2; +select * from v1; +f1 +1 +2 +2 +drop view v1; +drop table t1,t2; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index ceff7af401c..f2fe5f460e2 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1942,3 +1942,15 @@ DROP TABLE t1,t2,t3,t4,t5; create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; select * from v1; drop view v1; + +# +# Bug #10624 Views with multiple UNION and UNION ALL produce incorrect results +# +create table t1 (f1 int); +create table t2 (f1 int); +insert into t1 values (1); +insert into t2 values (2); +create view v1 as select * from t1 union select * from t2 union all select * from t2; +select * from v1; +drop view v1; +drop table t1,t2; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 7fcc16c681e..6ede870a7fb 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1511,13 +1511,16 @@ bool st_select_lex::setup_ref_array(THD *thd, uint order_group_num) void st_select_lex_unit::print(String *str) { + bool union_all= !union_distinct; for (SELECT_LEX *sl= first_select(); sl; sl= sl->next_select()) { if (sl != first_select()) { str->append(" union ", 7); - if (!union_distinct) + if (union_all) str->append("all ", 4); + else if (union_distinct == sl) + union_all= true; } if (sl->braces) str->append('('); |