Below is the list of changes that have just been committed into a local
5.1 repository of antony. When antony does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-09-22 11:35:45-07:00, acurtis@stripped +5 -0
Bug#22080
"CHECK fails to identify some corruption"
Amended code to recogise corruption as illustrated in bug report.
Support NULL in CSV
mysql-test/r/csv.result@stripped, 2006-09-22 11:35:40-07:00, acurtis@stripped +31 -0
Test for bug + NULL
mysql-test/r/log_state.result@stripped, 2006-09-22 11:35:40-07:00, acurtis@stripped +1 -1
NULL supported in CSV
mysql-test/r/log_tables.result@stripped, 2006-09-22 11:35:40-07:00, acurtis@stripped +1 -4
NULL supported in CSV
mysql-test/t/csv.test@stripped, 2006-09-22 11:35:40-07:00, acurtis@stripped +35 -0
Test for bug + NULL
storage/csv/ha_tina.cc@stripped, 2006-09-22 11:35:40-07:00, acurtis@stripped +32 -16
NULL support
Bug#22080
CSV fails to recognise corruption
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: acurtis
# Host: ltamd64.xiphis.org
# Root: /home/antony/work2/p2-bug22080.1
--- 1.12/mysql-test/r/csv.result 2006-09-22 11:35:58 -07:00
+++ 1.13/mysql-test/r/csv.result 2006-09-22 11:35:58 -07:00
@@ -5205,3 +5205,34 @@
val
drop table bug15205;
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;
+create table t1 (id int,string varchar(64)) Engine=CSV;
+insert into t1 values(1,'string 1');
+insert into t1 values(2,NULL);
+insert into t1 values(3,'string 2');
+"1","string 1"
+"2","\N"
+"3","string 2"
+select * from t1 where string is not null;
+id string
+1 string 1
+3 string 2
+drop table t1;
--- 1.15/mysql-test/t/csv.test 2006-09-22 11:35:58 -07:00
+++ 1.16/mysql-test/t/csv.test 2006-09-22 11:35:58 -07:00
@@ -1582,3 +1582,38 @@
select * from bug15205;
drop table bug15205;
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;
+
+#
+# NULL feature
+#
+
+create table t1 (id int,string varchar(64)) Engine=CSV;
+insert into t1 values(1,'string 1');
+insert into t1 values(2,NULL);
+insert into t1 values(3,'string 2');
+--exec cat $MYSQLTEST_VARDIR/master-data/test/t1.CSV
+select * from t1 where string is not null;
+drop table t1;
--- 1.61/storage/csv/ha_tina.cc 2006-09-22 11:35:58 -07:00
+++ 1.62/storage/csv/ha_tina.cc 2006-09-22 11:35:58 -07:00
@@ -540,7 +540,10 @@
in the code.
*/
if ((*field)->is_null())
- ptr= end_ptr= 0;
+ {
+ buffer.append(STRING_WITH_LEN("\"\\N\","));
+ continue;
+ }
else
{
(*field)->val_str(&attribute,&attribute);
@@ -641,6 +644,7 @@
off_t end_offset, curr_offset= current_position;
int eoln_len;
my_bitmap_map *org_bitmap;
+ int error;
DBUG_ENTER("ha_tina::find_current_row");
/*
@@ -654,23 +658,24 @@
/* Avoid asserts in ::store() for columns that are not going to be updated */
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++)
{
+ bool set_null= false;
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
else
- {
- dbug_tmp_restore_column_map(table->write_set, org_bitmap);
- DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
- }
- for(;curr_offset != end_offset; curr_offset++)
+ goto err;
+ for(;curr_offset < end_offset; curr_offset++)
{
// Need to convert line feeds!
if (file_buff->get_value(curr_offset) == '"' &&
- (((file_buff->get_value(curr_offset + 1) == ',') &&
- (file_buff->get_value(curr_offset + 2) == '"')) ||
+ ((file_buff->get_value(curr_offset + 1) == ',') ||
(curr_offset == end_offset -1 )))
{
curr_offset+= 2; // Move past the , and the "
@@ -684,6 +689,16 @@
buffer.append('\r');
else if (file_buff->get_value(curr_offset) == 'n' )
buffer.append('\n');
+ else if (file_buff->get_value(curr_offset) == 'N' &&
+ !buffer.length() &&
+ file_buff->get_value(curr_offset + 1) == '"' &&
+ ((file_buff->get_value(curr_offset + 2) == ',') ||
+ (curr_offset == end_offset - 2 )))
+ {
+ curr_offset+= 3; // Move past the , and the "
+ set_null= true;
+ break;
+ }
else if ((file_buff->get_value(curr_offset) == '\\') ||
(file_buff->get_value(curr_offset) == '"'))
buffer.append(file_buff->get_value(curr_offset));
@@ -700,22 +715,23 @@
we are working with a damaged file.
*/
if (curr_offset == end_offset - 1)
- {
- dbug_tmp_restore_column_map(table->write_set, org_bitmap);
- DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE);
- }
+ goto err;
buffer.append(file_buff->get_value(curr_offset));
}
}
+ if (set_null)
+ (*field)->set_null();
+ else
if (bitmap_is_set(table->read_set, (*field)->field_index))
(*field)->store(buffer.ptr(), buffer.length(), system_charset_info);
}
next_position= end_offset + eoln_len;
- /* Maybe use \N for null? */
- memset(buf, 0, table->s->null_bytes); /* We do not implement nulls! */
+ error= 0;
+
+err:
dbug_tmp_restore_column_map(table->write_set, org_bitmap);
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
/*
--- 1.8/mysql-test/r/log_tables.result 2006-09-22 11:35:58 -07:00
+++ 1.9/mysql-test/r/log_tables.result 2006-09-22 11:35:58 -07:00
@@ -71,7 +71,7 @@
0
select * from mysql.slow_log;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
-TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(2)
+TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test NULL NULL 1 select sleep(2)
alter table mysql.general_log engine=myisam;
ERROR HY000: You can't alter a log table if logging is enabled
alter table mysql.slow_log engine=myisam;
@@ -111,9 +111,6 @@
) ENGINE=CSV DEFAULT CHARSET=utf8 COMMENT='Slow log'
alter table mysql.general_log engine=myisam;
alter table mysql.slow_log engine=myisam;
-Warnings:
-Warning 1264 Out of range value for column 'last_insert_id' at row 0
-Warning 1264 Out of range value for column 'insert_id' at row 0
show create table mysql.general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
--- 1.3/mysql-test/r/log_state.result 2006-09-22 11:35:58 -07:00
+++ 1.4/mysql-test/r/log_state.result 2006-09-22 11:35:58 -07:00
@@ -46,7 +46,7 @@
0
select * from mysql.slow_log;
start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text
-TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test 0 0 1 select sleep(2)
+TIMESTAMP USER_HOST QUERY_TIME 00:00:00 1 0 test NULL NULL 1 select sleep(2)
show global variables
where Variable_name = 'log' or Variable_name = 'log_slow_queries' or
Variable_name = 'general_log' or Variable_name = 'slow_query_log';
| Thread |
|---|
| • bk commit into 5.1 tree (acurtis:1.2341) BUG#22080 | antony | 22 Sep |