Bug#20045: Server crash on INSERT ... SELECT ... FROM non-mergeable view
The regression is caused by the fix for bug 14767. When INSERT ... SELECT used a view in the SELECT list that was not inlined, and there was an active transaction, the server could crash in Query_cache::invalidate. On INSERT ... SELECT only the table being inserted into is invalidated. Thus views that can't be inlined are skipped from invalidation. The bug manifests itself in two ways so there is 2 test cases. One checks that the only the table being inserted into is invalidated. And the second one checks that there is no crash on INSERT ... SELECT.
This commit is contained in:
parent
cd7613b265
commit
5198354584
@ -1274,3 +1274,51 @@ Variable_name Value
|
||||
Last_query_cost 0.000000
|
||||
drop table t1;
|
||||
SET GLOBAL query_cache_size=0;
|
||||
set global query_cache_size=1024*1024;
|
||||
flush status;
|
||||
create table t1 (a int);
|
||||
insert into t1 (a) values (1), (2), (3);
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 0
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 1
|
||||
create table t2 like t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 2
|
||||
insert into t2 select * from t1;
|
||||
select * from t1;
|
||||
a
|
||||
1
|
||||
2
|
||||
3
|
||||
show status like 'Qcache_hits';
|
||||
Variable_name Value
|
||||
Qcache_hits 3
|
||||
drop table t1, t2;
|
||||
create table t1(c1 int);
|
||||
create table t2(c1 int);
|
||||
create table t3(c1 int);
|
||||
create view v1 as select t3.c1 as c1 from t3,t2 where t3.c1 = t2.c1;
|
||||
start transaction;
|
||||
insert into t1(c1) select c1 from v1;
|
||||
drop table t1, t2, t3;
|
||||
drop view v1;
|
||||
set global query_cache_size=0;
|
||||
|
@ -870,3 +870,32 @@ select * from t1 where a > 3;
|
||||
show status like 'last_query_cost';
|
||||
drop table t1;
|
||||
SET GLOBAL query_cache_size=0;
|
||||
|
||||
#
|
||||
# Bug #20045: Server crash on INSERT ... SELECT ... FROM non-mergeable view
|
||||
#
|
||||
set global query_cache_size=1024*1024;
|
||||
flush status;
|
||||
create table t1 (a int);
|
||||
insert into t1 (a) values (1), (2), (3);
|
||||
select * from t1;
|
||||
show status like 'Qcache_hits';
|
||||
select * from t1;
|
||||
show status like 'Qcache_hits';
|
||||
create table t2 like t1;
|
||||
select * from t1;
|
||||
show status like 'Qcache_hits';
|
||||
insert into t2 select * from t1;
|
||||
select * from t1;
|
||||
show status like 'Qcache_hits';
|
||||
drop table t1, t2;
|
||||
|
||||
create table t1(c1 int);
|
||||
create table t2(c1 int);
|
||||
create table t3(c1 int);
|
||||
create view v1 as select t3.c1 as c1 from t3,t2 where t3.c1 = t2.c1;
|
||||
start transaction;
|
||||
insert into t1(c1) select c1 from v1;
|
||||
drop table t1, t2, t3;
|
||||
drop view v1;
|
||||
set global query_cache_size=0;
|
||||
|
@ -3421,8 +3421,12 @@ end_with_restore_list:
|
||||
if (first_table->lock_type == TL_WRITE_CONCURRENT_INSERT &&
|
||||
thd->lock)
|
||||
{
|
||||
/* INSERT ... SELECT should invalidate only the very first table */
|
||||
TABLE_LIST *save_table= first_table->next_local;
|
||||
first_table->next_local= 0;
|
||||
mysql_unlock_tables(thd, thd->lock);
|
||||
query_cache_invalidate3(thd, first_table, 1);
|
||||
first_table->next_local= save_table;
|
||||
thd->lock=0;
|
||||
}
|
||||
delete result;
|
||||
|
Loading…
x
Reference in New Issue
Block a user