List:Internals« Previous MessageNext Message »
From:eugene Date:August 15 2005 9:05pm
Subject:bk commit into 5.0 tree (evgen:1.1995) BUG#10624
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.1995 05/08/15 23:05:05 evgen@stripped +3 -0
  Fix bug #10624 Views with multiple UNION and UNION ALL produce incorrect
  results.
  
  st_select_lex_unit::print() was losing UNION ALL if in statement were present
  UNION DISTINCT.

  sql/sql_lex.cc
    1.162 05/08/15 23:04:02 evgen@stripped +4 -1
    Fix bug #10624 Views with multiple UNION and UNION ALL produce incorrect results.

  mysql-test/t/view.test
    1.98 05/08/15 23:03:52 evgen@stripped +12 -0
    Test case for bug #10624  Views with multiple UNION and UNION ALL produce incorrect
results.

  mysql-test/r/view.result
    1.104 05/08/15 23:03:24 evgen@stripped +12 -0
    Test case for bug #10624  Views with multiple UNION and UNION ALL produce incorrect
results.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	evgen
# Host:	moonbone.local
# Root:	/work/10624-bug-5.0-mysql

--- 1.161/sql/sql_lex.cc	2005-08-12 19:04:48 +04:00
+++ 1.162/sql/sql_lex.cc	2005-08-15 23:04:02 +04:00
@@ -1511,13 +1511,16 @@
 
 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('(');

--- 1.103/mysql-test/r/view.result	2005-08-12 22:08:29 +04:00
+++ 1.104/mysql-test/r/view.result	2005-08-15 23:03:24 +04:00
@@ -2097,3 +2097,15 @@
 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;

--- 1.97/mysql-test/t/view.test	2005-08-12 22:08:20 +04:00
+++ 1.98/mysql-test/t/view.test	2005-08-15 23:03:52 +04:00
@@ -1942,3 +1942,15 @@
 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;
Thread
bk commit into 5.0 tree (evgen:1.1995) BUG#10624eugene15 Aug