mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Bug#22080
"CHECK fails to identify some corruption" change to allow it to detect more errors in data format mysql-test/r/csv.result: Test for bug mysql-test/t/csv.test: Test for bug
This commit is contained in:
parent
80fc43c1fe
commit
71401eacca
3 changed files with 60 additions and 16 deletions
|
@ -5205,3 +5205,22 @@ select * from bug15205;
|
||||||
val
|
val
|
||||||
drop table bug15205;
|
drop table bug15205;
|
||||||
drop table bug15205_2;
|
drop table bug15205_2;
|
||||||
|
create table bug22080_1 (id int,string varchar(64)) Engine=CSV;
|
||||||
|
create table bug22080_2 (id int,string varchar(64)) Engine=CSV;
|
||||||
|
create table bug22080_3 (id int,string varchar(64)) Engine=CSV;
|
||||||
|
insert into bug22080_1 values(1,'string');
|
||||||
|
insert into bug22080_1 values(2,'string');
|
||||||
|
insert into bug22080_1 values(3,'string');
|
||||||
|
"1","string"
|
||||||
|
2","string"
|
||||||
|
"3","string"
|
||||||
|
check table bug22080_2;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.bug22080_2 check error Corrupt
|
||||||
|
"1","string"
|
||||||
|
"2",string"
|
||||||
|
"3","string"
|
||||||
|
check table bug22080_3;
|
||||||
|
Table Op Msg_type Msg_text
|
||||||
|
test.bug22080_3 check error Corrupt
|
||||||
|
drop tables bug22080_1,bug22080_2,bug22080_3;
|
||||||
|
|
|
@ -1582,3 +1582,26 @@ select * from bug15205_2;
|
||||||
select * from bug15205;
|
select * from bug15205;
|
||||||
drop table bug15205;
|
drop table bug15205;
|
||||||
drop table bug15205_2;
|
drop table bug15205_2;
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug#22080 "CHECK fails to identify some corruption"
|
||||||
|
#
|
||||||
|
|
||||||
|
create table bug22080_1 (id int,string varchar(64)) Engine=CSV;
|
||||||
|
create table bug22080_2 (id int,string varchar(64)) Engine=CSV;
|
||||||
|
create table bug22080_3 (id int,string varchar(64)) Engine=CSV;
|
||||||
|
insert into bug22080_1 values(1,'string');
|
||||||
|
insert into bug22080_1 values(2,'string');
|
||||||
|
insert into bug22080_1 values(3,'string');
|
||||||
|
|
||||||
|
# Currupt the file as described in the bug report
|
||||||
|
--exec sed -e 's/"2"/2"/' $MYSQLTEST_VARDIR/master-data/test/bug22080_1.CSV > $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
|
||||||
|
--exec sed -e 's/2","/2",/' $MYSQLTEST_VARDIR/master-data/test/bug22080_1.CSV > $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
|
||||||
|
|
||||||
|
--exec cat $MYSQLTEST_VARDIR/master-data/test/bug22080_2.CSV
|
||||||
|
check table bug22080_2;
|
||||||
|
|
||||||
|
--exec cat $MYSQLTEST_VARDIR/master-data/test/bug22080_3.CSV
|
||||||
|
check table bug22080_3;
|
||||||
|
|
||||||
|
drop tables bug22080_1,bug22080_2,bug22080_3;
|
||||||
|
|
|
@ -540,7 +540,10 @@ int ha_tina::encode_quote(byte *buf)
|
||||||
in the code.
|
in the code.
|
||||||
*/
|
*/
|
||||||
if ((*field)->is_null())
|
if ((*field)->is_null())
|
||||||
ptr= end_ptr= 0;
|
{
|
||||||
|
buffer.append(STRING_WITH_LEN("\"\","));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*field)->val_str(&attribute,&attribute);
|
(*field)->val_str(&attribute,&attribute);
|
||||||
|
@ -641,6 +644,7 @@ int ha_tina::find_current_row(byte *buf)
|
||||||
off_t end_offset, curr_offset= current_position;
|
off_t end_offset, curr_offset= current_position;
|
||||||
int eoln_len;
|
int eoln_len;
|
||||||
my_bitmap_map *org_bitmap;
|
my_bitmap_map *org_bitmap;
|
||||||
|
int error;
|
||||||
DBUG_ENTER("ha_tina::find_current_row");
|
DBUG_ENTER("ha_tina::find_current_row");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -654,23 +658,23 @@ int ha_tina::find_current_row(byte *buf)
|
||||||
|
|
||||||
/* Avoid asserts in ::store() for columns that are not going to be updated */
|
/* Avoid asserts in ::store() for columns that are not going to be updated */
|
||||||
org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
|
org_bitmap= dbug_tmp_use_all_columns(table, table->write_set);
|
||||||
|
error= HA_ERR_CRASHED_ON_USAGE;
|
||||||
|
|
||||||
|
memset(buf, 0, table->s->null_bytes);
|
||||||
|
|
||||||
for (Field **field=table->field ; *field ; field++)
|
for (Field **field=table->field ; *field ; field++)
|
||||||
{
|
{
|
||||||
buffer.length(0);
|
buffer.length(0);
|
||||||
if (file_buff->get_value(curr_offset) == '"')
|
if (curr_offset < end_offset &&
|
||||||
|
file_buff->get_value(curr_offset) == '"')
|
||||||
curr_offset++; // Incrementpast the first quote
|
curr_offset++; // Incrementpast the first quote
|
||||||
else
|
else
|
||||||
{
|
goto err;
|
||||||
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
for(;curr_offset < end_offset; curr_offset++)
|
||||||
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
||||||
}
|
|
||||||
for(;curr_offset != end_offset; curr_offset++)
|
|
||||||
{
|
{
|
||||||
// Need to convert line feeds!
|
// Need to convert line feeds!
|
||||||
if (file_buff->get_value(curr_offset) == '"' &&
|
if (file_buff->get_value(curr_offset) == '"' &&
|
||||||
(((file_buff->get_value(curr_offset + 1) == ',') &&
|
((file_buff->get_value(curr_offset + 1) == ',') ||
|
||||||
(file_buff->get_value(curr_offset + 2) == '"')) ||
|
|
||||||
(curr_offset == end_offset -1 )))
|
(curr_offset == end_offset -1 )))
|
||||||
{
|
{
|
||||||
curr_offset+= 2; // Move past the , and the "
|
curr_offset+= 2; // Move past the , and the "
|
||||||
|
@ -700,10 +704,7 @@ int ha_tina::find_current_row(byte *buf)
|
||||||
we are working with a damaged file.
|
we are working with a damaged file.
|
||||||
*/
|
*/
|
||||||
if (curr_offset == end_offset - 1)
|
if (curr_offset == end_offset - 1)
|
||||||
{
|
goto err;
|
||||||
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
|
||||||
DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
|
|
||||||
}
|
|
||||||
buffer.append(file_buff->get_value(curr_offset));
|
buffer.append(file_buff->get_value(curr_offset));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -711,11 +712,12 @@ int ha_tina::find_current_row(byte *buf)
|
||||||
(*field)->store(buffer.ptr(), buffer.length(), system_charset_info);
|
(*field)->store(buffer.ptr(), buffer.length(), system_charset_info);
|
||||||
}
|
}
|
||||||
next_position= end_offset + eoln_len;
|
next_position= end_offset + eoln_len;
|
||||||
/* Maybe use \N for null? */
|
error= 0;
|
||||||
memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */
|
|
||||||
|
err:
|
||||||
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
|
||||||
|
|
||||||
DBUG_RETURN(0);
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue