diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index 04f0636d400..e342af32a80 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5195,3 +5195,13 @@ select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); i v 4 3r4f drop table t1; +create table bug15205 (val int(11) default null) engine=csv; +create table bug15205_2 (val int(11) default null) engine=csv; +select * from bug15205; +ERROR HY000: Can't get stat of './test/bug15205.CSV' (Errcode: 2) +select * from bug15205_2; +val +select * from bug15205; +val +drop table bug15205; +drop table bug15205_2; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 9ba99167ab9..a042f163635 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1558,3 +1558,27 @@ select * from t1; alter table t1 add unique key (i, v); select * from t1 where i between 2 and 4 and v in ('def','3r4f','lmn'); drop table t1; + +# +# Bug #15205 Select from CSV table without the datafile causes crash +# +# NOTE: the bug is not deterministic + +# The crash happens because the necessary cleanup after an error wasn't +# performed. Namely, the table share, inserted in the hash during table +# open, was not deleted from hash. At the same time the share was freed +# when an error was encountered. Thus, subsequent access to the hash +# resulted in scanning through deleted memory and we were geting a crash. +# that's why we need two tables in the bugtest + +create table bug15205 (val int(11) default null) engine=csv; +create table bug15205_2 (val int(11) default null) engine=csv; +--exec rm $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV +# system error (can't open the datafile) +--error ER_GET_ERRNO +select * from bug15205; +select * from bug15205_2; +--exec touch $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV +select * from bug15205; +drop table bug15205; +drop table bug15205_2;