Skip to content
Permalink
Browse files

MDEV-11883 MariaDB crashes with out-of-memory when query information_…

…schema

CSV engine didn't expect CSM files to be read-only
  • Loading branch information...
vuvova committed May 12, 2017
1 parent 71b4503 commit a65623b3eb2695069791aa21d278b8bc751a560e
Showing with 58 additions and 6 deletions.
  1. +30 −0 mysql-test/suite/csv/read_only.result
  2. +19 −0 mysql-test/suite/csv/read_only.test
  3. +9 −6 storage/csv/ha_tina.cc
@@ -0,0 +1,30 @@
create table t1 (a int not null) engine=csv;
insert t1 values (1),(2);
flush tables;
select * from information_schema.tables where table_schema='test';
TABLE_CATALOG def
TABLE_SCHEMA test
TABLE_NAME t1
TABLE_TYPE BASE TABLE
ENGINE NULL
VERSION NULL
ROW_FORMAT NULL
TABLE_ROWS NULL
AVG_ROW_LENGTH NULL
DATA_LENGTH NULL
MAX_DATA_LENGTH NULL
INDEX_LENGTH NULL
DATA_FREE NULL
AUTO_INCREMENT NULL
CREATE_TIME NULL
UPDATE_TIME NULL
CHECK_TIME NULL
TABLE_COLLATION NULL
CHECKSUM NULL
CREATE_OPTIONS NULL
TABLE_COMMENT File './test/t1.CSM' not found (Errcode: 13 "Permission denied")
Warnings:
Level Warning
Code 29
Message File './test/t1.CSM' not found (Errcode: 13 "Permission denied")
drop table t1;
@@ -0,0 +1,19 @@
#
# MDEV-11883 MariaDB crashes with out-of-memory when query information_schema
#
source include/have_csv.inc;

let datadir=`select @@datadir`;

create table t1 (a int not null) engine=csv;
insert t1 values (1),(2);
flush tables;

chmod 0400 $datadir/test/t1.CSM;
chmod 0400 $datadir/test/t1.CSV;

--replace_result $datadir ./
query_vertical select * from information_schema.tables where table_schema='test';

drop table t1;

@@ -289,7 +289,7 @@ static int read_meta_file(File meta_file, ha_rows *rows)
mysql_file_seek(meta_file, 0, MY_SEEK_SET, MYF(0));
if (mysql_file_read(meta_file, (uchar*)meta_buffer, META_BUFFER_SIZE, 0)
!= META_BUFFER_SIZE)
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
DBUG_RETURN(my_errno= HA_ERR_CRASHED_ON_USAGE);

/*
Parse out the meta data, we ignore version at the moment
@@ -418,10 +418,13 @@ static int free_share(TINA_SHARE *share)
int result_code= 0;
if (!--share->use_count){
/* Write the meta file. Mark it as crashed if needed. */
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->crashed ? TRUE :FALSE);
if (mysql_file_close(share->meta_file, MYF(0)))
result_code= 1;
if (share->meta_file != -1)
{
(void)write_meta_file(share->meta_file, share->rows_recorded,
share->crashed ? TRUE :FALSE);
if (mysql_file_close(share->meta_file, MYF(0)))
result_code= 1;
}
if (share->tina_write_opened)
{
if (mysql_file_close(share->tina_write_filedes, MYF(0)))
@@ -930,7 +933,7 @@ int ha_tina::open(const char *name, int mode, uint open_options)
if (share->crashed && !(open_options & HA_OPEN_FOR_REPAIR))
{
free_share(share);
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
DBUG_RETURN(my_errno ? my_errno : HA_ERR_CRASHED_ON_USAGE);
}

local_data_file_version= share->data_file_version;

0 comments on commit a65623b

Please sign in to comment.
You can’t perform that action at this time.