From 71401eaccaa3dcb35875a36f9a84d7605609b0f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Sep 2006 09:04:19 -0700 Subject: [PATCH 1/9] 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 --- mysql-test/r/csv.result | 19 +++++++++++++++++++ mysql-test/t/csv.test | 23 +++++++++++++++++++++++ storage/csv/ha_tina.cc | 34 ++++++++++++++++++---------------- 3 files changed, 60 insertions(+), 16 deletions(-) diff --git a/mysql-test/r/csv.result b/mysql-test/r/csv.result index e342af32a80..222d4de8059 100644 --- a/mysql-test/r/csv.result +++ b/mysql-test/r/csv.result @@ -5205,3 +5205,22 @@ select * from bug15205; 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; diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 9815da4fb55..f70b5b40766 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1582,3 +1582,26 @@ select * from bug15205_2; 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; diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 012e9b9bd7f..5e71ebe6ccc 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -540,7 +540,10 @@ int ha_tina::encode_quote(byte *buf) in the code. */ if ((*field)->is_null()) - ptr= end_ptr= 0; + { + buffer.append(STRING_WITH_LEN("\"\",")); + continue; + } else { (*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; int eoln_len; my_bitmap_map *org_bitmap; + int error; 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 */ 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++) { 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 " @@ -700,10 +704,7 @@ int ha_tina::find_current_row(byte *buf) 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)); } } @@ -711,11 +712,12 @@ int ha_tina::find_current_row(byte *buf) (*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); } /* From c0acb5d545322c7502cdbd0604b54fc0c0c46799 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Oct 2006 16:50:15 +0500 Subject: [PATCH 2/9] BUG#22924 - windows test fails with wrong errno Fixed a test case according to fix for bug10974. mysql-test/r/windows.result: Fixed a test case according to fix for bug10974. mysql-test/t/windows.test: Fixed a test case according to fix for bug10974. --- mysql-test/r/windows.result | 2 +- mysql-test/t/windows.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index e3241daf719..ee430c534bc 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -27,7 +27,7 @@ select * from mt; ERROR HY000: Can't lock file (errno: 155) FLUSH TABLES; select * from mt; -ERROR HY000: Can't find file: 'mt' (errno: 2) +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists ALTER TABLE `t` RENAME TO `t2`; INSERT INTO mt VALUES ('2006-01-01',0); select * from mt; diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test index 79517df6517..0ce1c8983ce 100644 --- a/mysql-test/t/windows.test +++ b/mysql-test/t/windows.test @@ -49,7 +49,7 @@ INSERT INTO mt VALUES ('2006-01-01',0); select * from mt; FLUSH TABLES; ---error 1017 +--error 1168 select * from mt; # Alter one of the tables that are part of the merge table From 2268afedea366951d1f4ac10d1aa8394fb2b5b69 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 5 Oct 2006 18:23:53 +0500 Subject: [PATCH 3/9] BUG#21381 - Engine not notified about multi-table UPDATE IGNORE Though this is not storage engine specific problem, I was able to repeat this problem with BDB and NDB engines only. That was the reason to add a test case into ndb_update.test. As a result different bad things could happen. BDB has removed duplicate rows which is not expected. NDB returns an error. For multi table update notify storage engine about UPDATE IGNORE as it is done in single table UPDATE. mysql-test/r/ndb_update.result: A test case for bug#21381. mysql-test/t/ndb_update.test: A test case for bug#21381. sql/sql_update.cc: For multi table update notify storage engine about UPDATE IGNORE as it is done in single table UPDATE. --- mysql-test/r/ndb_update.result | 8 ++++++++ mysql-test/t/ndb_update.test | 9 +++++++++ sql/sql_update.cc | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index c2247564e65..4848284b4af 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -31,3 +31,11 @@ pk1 b c 12 2 2 14 1 1 DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES(1),(2); +UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; +SELECT a FROM t1 ORDER BY a; +a +1 +3 +DROP TABLE t1; diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index 45e3add4639..e7c5fd0c4a5 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -33,4 +33,13 @@ select * from t1 order by pk1; DROP TABLE IF EXISTS t1; --enable_warnings +# +# BUG#21381 - Engine not notified about multi-table UPDATE IGNORE +# +CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; +INSERT INTO t1 VALUES(1),(2); +UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; +SELECT a FROM t1 ORDER BY a; +DROP TABLE t1; + # End of 4.1 tests diff --git a/sql/sql_update.cc b/sql/sql_update.cc index af4ba8025f9..6742fbad5c4 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -901,6 +901,8 @@ multi_update::initialize_tables(JOIN *join) List temp_fields= *fields_for_table[cnt]; ORDER group; + if (ignore) + table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); if (table == main_table) // First table in join { if (safe_update_on_fly(join->join_tab, &temp_fields)) @@ -1007,7 +1009,11 @@ multi_update::~multi_update() { TABLE_LIST *table; for (table= update_tables ; table; table= table->next) + { table->table->no_keyread= table->table->no_cache= 0; + if (ignore) + table->table->file->extra(HA_EXTRA_NO_IGNORE_DUP_KEY); + } if (tmp_tables) { From 45c91e43e5f1c5ac007c1d7c320fc2b009ca7550 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 00:22:41 +0500 Subject: [PATCH 4/9] After merge fix. --- mysql-test/r/ndb_update.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index 49d7a7f3e29..e83a1206aed 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -36,6 +36,6 @@ INSERT INTO t1 VALUES(1),(2); UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; SELECT a FROM t1 ORDER BY a; a -1 +2 3 DROP TABLE t1; From f463cb389be2a421b117190b863f72ddf72b354b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 10:54:47 +0500 Subject: [PATCH 5/9] Addition to fix for bug#10974. Fixed spelling. --- mysql-test/r/merge.result | 8 ++++---- sql/share/english/errmsg.txt | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/merge.result b/mysql-test/r/merge.result index ff4828144a7..a1ef7597143 100644 --- a/mysql-test/r/merge.result +++ b/mysql-test/r/merge.result @@ -178,9 +178,9 @@ t3 CREATE TABLE `t3` ( ) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 UNION=(`t1`,`t2`) create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist alter table t4 add column c int; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist create database mysqltest; create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); @@ -775,9 +775,9 @@ DROP TABLE t1, t2; CREATE TABLE t1(a INT) ENGINE=MEMORY; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); SELECT * FROM t2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist DROP TABLE t1, t2; CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); SELECT * FROM t2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist DROP TABLE t2; diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index a8b06a07218..62c8f4f9991 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -184,7 +184,7 @@ character-set=latin1 "INSERT DELAYED can't be used with table '%-.64s' because it is locked with LOCK TABLES", "Incorrect column name '%-.100s'", "The used storage engine can't index column '%-.64s'", -"Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists", +"Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist", "Can't write, because of unique constraint, to table '%-.64s'", "BLOB/TEXT column '%-.64s' used in key specification without a key length", "All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead", From 15d2a32c0f43ea73a683eda384da52373fe8c2e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 11:03:14 +0500 Subject: [PATCH 6/9] Addition to fix for bug#10974. Fixed spelling. --- sql/share/errmsg.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt index 5ed7466b0df..2b6d2b18f88 100644 --- a/sql/share/errmsg.txt +++ b/sql/share/errmsg.txt @@ -3813,7 +3813,7 @@ ER_WRONG_MRG_TABLE cze "V-B¹echny tabulky v MERGE tabulce nejsou definovány stejnì" dan "Tabellerne i MERGE er ikke defineret ens" nla "Niet alle tabellen in de MERGE tabel hebben identieke gedefinities" - eng "Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists" + eng "Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist" est "Kõik tabelid MERGE tabeli määratluses ei ole identsed" fre "Toutes les tables de la table de type MERGE n'ont pas la même définition" ger "Nicht alle Tabellen in der MERGE-Tabelle sind gleich definiert" From 62e91f6d6d51de1c945a9575e16cfccb7b4b6a51 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 11:11:47 +0500 Subject: [PATCH 7/9] Addition to fix for bug#10974. Fixed spelling. --- mysql-test/r/windows.result | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/r/windows.result b/mysql-test/r/windows.result index ee430c534bc..b977bc3ab16 100644 --- a/mysql-test/r/windows.result +++ b/mysql-test/r/windows.result @@ -27,7 +27,7 @@ select * from mt; ERROR HY000: Can't lock file (errno: 155) FLUSH TABLES; select * from mt; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exists +ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist ALTER TABLE `t` RENAME TO `t2`; INSERT INTO mt VALUES ('2006-01-01',0); select * from mt; From b7d1c482130820faa714a126c4a858517c1f268c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 14:47:58 +0500 Subject: [PATCH 8/9] Per discussion with pekka removed non-deterministic test case for bug#21381. --- mysql-test/r/ndb_update.result | 8 -------- mysql-test/t/ndb_update.test | 9 --------- 2 files changed, 17 deletions(-) diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index 4848284b4af..c2247564e65 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -31,11 +31,3 @@ pk1 b c 12 2 2 14 1 1 DROP TABLE IF EXISTS t1; -CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; -INSERT INTO t1 VALUES(1),(2); -UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; -SELECT a FROM t1 ORDER BY a; -a -1 -3 -DROP TABLE t1; diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index e7c5fd0c4a5..45e3add4639 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -33,13 +33,4 @@ select * from t1 order by pk1; DROP TABLE IF EXISTS t1; --enable_warnings -# -# BUG#21381 - Engine not notified about multi-table UPDATE IGNORE -# -CREATE TABLE t1(a INT NOT NULL, UNIQUE(a)) ENGINE=ndbcluster; -INSERT INTO t1 VALUES(1),(2); -UPDATE IGNORE t1, t1 AS t1a SET t1.a=3; -SELECT a FROM t1 ORDER BY a; -DROP TABLE t1; - # End of 4.1 tests From 47a70282f91fed6dfae77d5d0e5ce3424cfb6c1d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 6 Oct 2006 15:17:42 +0500 Subject: [PATCH 9/9] BUG#22937 - Valgrind failure in 'merge' test (ha_myisammrg.cc:329) This is addition to fix for bug21617. Valgrind reports an error when opening merge table that has underlying tables with less indexes than in a merge table itself. Copy at most min(file->keys, table->key_parts) elements from rec_per_key array. This fixes problems when merge table and subtables have different number of keys. sql/ha_myisammrg.cc: Copy at most min(file->keys, table->key_parts) elements from rec_per_key array. This fixes problems when merge table and subtables have different number of keys. --- sql/ha_myisammrg.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index edb3521470f..3408f7090f2 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -249,9 +249,22 @@ void ha_myisammrg::info(uint flag) if (flag & HA_STATUS_CONST) { if (table->key_parts && info.rec_per_key) + { +#ifdef HAVE_purify + /* + valgrind may be unhappy about it, because optimizer may access values + between file->keys and table->key_parts, that will be uninitialized. + It's safe though, because even if opimizer will decide to use a key + with such a number, it'll be an error later anyway. + */ + bzero((char*) table->key_info[0].rec_per_key, + sizeof(table->key_info[0].rec_per_key) * table->key_parts); +#endif memcpy((char*) table->key_info[0].rec_per_key, (char*) info.rec_per_key, - sizeof(table->key_info[0].rec_per_key)*table->key_parts); + sizeof(table->key_info[0].rec_per_key) * + min(file->keys, table->key_parts)); + } } }