Commit 0d734037 authored by Igor Babaev's avatar Igor Babaev

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 
parent 16053e66
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;
--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
......@@ -1799,11 +1799,8 @@ enum_nested_loop_state JOIN_CACHE_BNL::join_matching_records(bool skip_last)
}
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::join_matching_records(bool skip_last)
(!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_records(bool skip_last)
(!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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment