[Commits] Rev 4478: MDEV-6785 Wrong result on 2nd execution of PS with aggregate function, FROM SQ or MERGE view in lp:~maria-captains/maria/10.0

Sergei Golubchik serg at mariadb.org
Thu Nov 13 14:02:34 EET 2014


At lp:~maria-captains/maria/10.0

------------------------------------------------------------
revno: 4478
revision-id: sergii at pisem.net-20141113120233-khex21etexdixr4u
parent: sergii at pisem.net-20141112184336-4ge700t4xww1e1au
fixes bug: https://mariadb.atlassian.net/browse/MDEV-6785
committer: Sergei Golubchik <sergii at pisem.net>
branch nick: 10.0
timestamp: Thu 2014-11-13 13:02:33 +0100
message:
  MDEV-6785 Wrong result on 2nd execution of PS with aggregate function, FROM SQ or MERGE view
  
  a different patch for view.test --ps-protocol crash
=== modified file 'mysql-test/r/view.result'
--- a/mysql-test/r/view.result	2014-08-07 16:06:56 +0000
+++ b/mysql-test/r/view.result	2014-11-13 12:02:33 +0000
@@ -5500,6 +5500,20 @@ a	b	a	b	a	c
 9	10	9	10	9	10
 drop view v1;
 drop table t1,t2;
+create table t1 (i int not null);
+insert into t1 values (1),(2);
+create table t2 (j int not null);
+insert into t2 values (11),(12);
+create algorithm=merge view v3 as select t1.* from t2 left join t1 on (t2.j = t1.i);
+prepare stmt from 'select count(v3.i) from t1, v3';
+execute stmt;
+count(v3.i)
+0
+execute stmt;
+count(v3.i)
+0
+drop table t1, t2;
+drop view v3;
 # -----------------------------------------------------------------
 # -- End of 10.0 tests.
 # -----------------------------------------------------------------

=== modified file 'mysql-test/t/view.test'
--- a/mysql-test/t/view.test	2014-08-07 16:06:56 +0000
+++ b/mysql-test/t/view.test	2014-11-13 12:02:33 +0000
@@ -5364,6 +5364,21 @@ select * from t2, t1, v1 where t1.a=t2.a
 drop view v1;
 drop table t1,t2;
 
+#
+# MDEV-6785 Wrong result on 2nd execution of PS with aggregate function, FROM SQ or MERGE view
+#
+
+create table t1 (i int not null);
+insert into t1 values (1),(2);
+create table t2 (j int not null);
+insert into t2 values (11),(12);
+create algorithm=merge view v3 as select t1.* from t2 left join t1 on (t2.j = t1.i);
+prepare stmt from 'select count(v3.i) from t1, v3';
+execute stmt;
+execute stmt;
+drop table t1, t2;
+drop view v3;
+
 --echo # -----------------------------------------------------------------
 --echo # -- End of 10.0 tests.
 --echo # -----------------------------------------------------------------

=== modified file 'sql/sql_derived.cc'
--- a/sql/sql_derived.cc	2014-09-30 17:31:14 +0000
+++ b/sql/sql_derived.cc	2014-11-13 12:02:33 +0000
@@ -465,8 +465,6 @@ bool mysql_derived_merge(THD *thd, LEX *
     }
   }
 
-  if (!derived->merged_for_insert)
-    dt_select->first_cond_optimization= FALSE; // consider it optimized
 exit_merge:
   if (arena)
     thd->restore_active_arena(arena, &backup);

=== modified file 'sql/sql_select.cc'
--- a/sql/sql_select.cc	2014-11-03 16:47:37 +0000
+++ b/sql/sql_select.cc	2014-11-13 12:02:33 +0000
@@ -633,7 +633,7 @@ inline int setup_without_group(THD *thd,
   res= setup_conds(thd, tables, leaves, conds);
   if (thd->lex->current_select->first_cond_optimization)
   {
-    if (!res && *conds)
+    if (!res && *conds && ! thd->lex->current_select->merged_into)
       (*reserved)= (*conds)->exists2in_reserved_items();
     else
       (*reserved)= 0;



More information about the commits mailing list