[Commits] bzr commit into Mariadb 5.2, with Maria 2.0:maria/5.2 branch (igor:2818) Bug#601164

Igor Babaev igor at askmonty.org
Sat Jul 3 06:24:45 EEST 2010


#At lp:maria/5.2 based on revid:hakan at askmonty.org-20100624204030-5pxgjpwm7i4wgeh8

 2818 Igor Babaev	2010-07-02
      Fixed bug #601164.
      The functions mysql_delete and mysql_update lacked calls of
      updated_virtual_fields(). This caused wrong results for
      some DELETEs/UPDATEs.
      Added test cases for this bug.
      added:
        mysql-test/suite/vcol/r/vcol_misc.result
        mysql-test/suite/vcol/t/vcol_misc.test
      modified:
        sql/sql_delete.cc
        sql/sql_update.cc

=== added file 'mysql-test/suite/vcol/r/vcol_misc.result'
--- a/mysql-test/suite/vcol/r/vcol_misc.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/vcol/r/vcol_misc.result	2010-07-03 03:24:39 +0000
@@ -0,0 +1,32 @@
+drop table if exists t1,t2;
+create table t1 (a int, b int, v int as (a+1), index idx(b));
+insert into t1(a, b) values
+(4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10);
+select * from t1 order by b;
+a	b	v
+1	10	2
+2	20	3
+3	30	4
+4	40	5
+5	50	6
+7	70	8
+8	80	9
+delete from t1 where v > 6 order by b limit 1;
+select * from t1 order by b;
+a	b	v
+1	10	2
+2	20	3
+3	30	4
+4	40	5
+5	50	6
+8	80	9
+update t1 set a=v order by b limit 1;
+select * from t1 order by b;
+a	b	v
+2	10	3
+2	20	3
+3	30	4
+4	40	5
+5	50	6
+8	80	9
+drop table t1;

=== added file 'mysql-test/suite/vcol/t/vcol_misc.test'
--- a/mysql-test/suite/vcol/t/vcol_misc.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/vcol/t/vcol_misc.test	2010-07-03 03:24:39 +0000
@@ -0,0 +1,21 @@
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+#
+# Bug#601164: DELETE/UPDATE with ORDER BY index and LIMIT
+#             
+
+create table t1 (a int, b int, v int as (a+1), index idx(b));
+insert into t1(a, b) values
+  (4, 40), (3, 30), (5, 50), (7, 70), (8, 80), (2, 20), (1, 10);
+
+select * from t1 order by b;
+
+delete from t1 where v > 6 order by b limit 1;
+select * from t1 order by b;
+
+update t1 set a=v order by b limit 1;
+select * from t1 order by b;
+
+drop table t1;

=== modified file 'sql/sql_delete.cc'
--- a/sql/sql_delete.cc	2010-05-26 06:14:18 +0000
+++ b/sql/sql_delete.cc	2010-07-03 03:24:39 +0000
@@ -304,6 +304,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *
   while (!(error=info.read_record(&info)) && !thd->killed &&
 	 ! thd->is_error())
   {
+    update_virtual_fields(table);
     // thd->is_error() is tested to disallow delete row on error
     if (!select || select->skip_record(thd) > 0)
     {

=== modified file 'sql/sql_update.cc'
--- a/sql/sql_update.cc	2010-06-01 19:52:20 +0000
+++ b/sql/sql_update.cc	2010-07-03 03:24:39 +0000
@@ -469,6 +469,7 @@ int mysql_update(THD *thd,
       while (!(error=info.read_record(&info)) && 
              !thd->killed && !thd->is_error())
       {
+        update_virtual_fields(table);
 	if (!select || select->skip_record(thd) > 0)
 	{
           if (table->file->was_semi_consistent_read())
@@ -575,6 +576,7 @@ int mysql_update(THD *thd,
 
   while (!(error=info.read_record(&info)) && !thd->killed)
   {
+    update_virtual_fields(table);
     if (!select || select->skip_record(thd) > 0)
     {
       if (table->file->was_semi_consistent_read())



More information about the commits mailing list