[Commits] bzr commit into Mariadb 5.2, with Maria 2.0:maria/5.2 branch (igor:2798)

Igor Babaev igor at askmonty.org
Fri Jul 2 08:13:31 EEST 2010


#At lp:maria/5.2 based on revid:psergey at askmonty.org-20100627055214-gyo81dxt7gh18g8k

 2798 Igor Babaev	2010-07-01
      Added missing calls of update_virtual_fields() in the 
      join cache module.
      Without these calls SELECTs over tables with virtual columns
      that used join cache could return wrong results. This could
      be seen with the test case added into vcol_misc.test 
      added:
        mysql-test/suite/vcol/r/vcol_misc.result
        mysql-test/suite/vcol/t/vcol_misc.test
      modified:
        sql/sql_join_cache.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-02 05:13:19 +0000
@@ -0,0 +1,20 @@
+drop table if exists t1,t2;
+create table t1 (a int, b int);
+insert into t1 values (3, 30), (4, 20), (1, 20);
+create table t2 (c int, d int, v int as (d+1), index idx(c));
+insert into t2(c,d) values 
+(20, 100), (20, 300), (30, 100), (30, 200), (40, 500),
+(70, 100), (40, 300), (60, 100), (40, 100), (70, 100);
+set join_cache_level=6;
+explain
+select * from t1,t2 where t1.b=t2.c and d <= 100;
+id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
+1	SIMPLE	t1	ALL	NULL	NULL	NULL	NULL	3	
+1	SIMPLE	t2	ref	idx	idx	5	test.t1.b	2	Using where; Using join buffer
+select * from t1,t2 where t1.b=t2.c and d <= 100;
+a	b	c	d	v
+4	20	20	100	101
+1	20	20	100	101
+3	30	30	100	101
+set join_cache_level=default;
+drop table t1, t2;

=== 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-02 05:13:19 +0000
@@ -0,0 +1,23 @@
+--disable_warnings
+drop table if exists t1,t2;
+--enable_warnings
+
+#
+#  SELECT that uses a virtual column and executed with BKA
+#
+
+create table t1 (a int, b int);
+insert into t1 values (3, 30), (4, 20), (1, 20);
+create table t2 (c int, d int, v int as (d+1), index idx(c));
+insert into t2(c,d) values 
+  (20, 100), (20, 300), (30, 100), (30, 200), (40, 500),
+  (70, 100), (40, 300), (60, 100), (40, 100), (70, 100);                           
+
+set join_cache_level=6;
+explain
+select * from t1,t2 where t1.b=t2.c and d <= 100;
+
+select * from t1,t2 where t1.b=t2.c and d <= 100;
+set join_cache_level=default;
+
+drop table t1, t2;
\ No newline at end of file

=== modified file 'sql/sql_join_cache.cc'
--- a/sql/sql_join_cache.cc	2010-06-26 10:05:41 +0000
+++ b/sql/sql_join_cache.cc	2010-07-02 05:13:19 +0000
@@ -1799,11 +1799,8 @@ enum_nested_loop_state JOIN_CACHE_BNL::j
     }
     int err= 0;
 
-    /*
-     psergey3-merge: should we have this here by any chance:
      if (rc == NESTED_LOOP_OK)
-      update_virtual_fields(join_tab->table);
-    */
+       update_virtual_fields(join_tab->table);
  
     /* 
       Do not look for matches if the last read record of the joined table
@@ -2324,6 +2321,7 @@ enum_nested_loop_state JOIN_CACHE_BKA::j
         (!check_only_first_match || !get_match_flag_by_pos(rec_ptr)))
     {
       get_record_by_pos(rec_ptr);
+      update_virtual_fields(join_tab->table);
       rc= generate_full_extensions(rec_ptr);
       if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS)
 	goto finish;   
@@ -3211,6 +3209,7 @@ JOIN_CACHE_BKA_UNIQUE::join_matching_rec
           (!check_only_first_match || !get_match_flag_by_pos(rec_ptr)))
       {
         get_record_by_pos(rec_ptr);
+        update_virtual_fields(join_tab->table);
         rc= generate_full_extensions(rec_ptr);
         if (rc != NESTED_LOOP_OK && rc != NESTED_LOOP_NO_MORE_ROWS)
 	  goto finish;   



More information about the commits mailing list