From 19fe33e16ca3fe23e3df42a9d388e8f649446dbe Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Tue, 2 Aug 2005 11:33:26 +0500 Subject: [PATCH 1/5] BUG#11684 fix. Repair crashes mysql when table has fulltext index. --- myisam/sort.c | 14 ++++++++------ mysql-test/r/fulltext.result | 8 ++++++++ mysql-test/t/fulltext.test | 11 +++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/myisam/sort.c b/myisam/sort.c index 95ede6ddaa1..45a670c3f6b 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -532,13 +532,15 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) while (!got_error && !my_b_read(&sinfo->tempfile_for_exceptions,(byte*)&key_length, - sizeof(key_length)) && - !my_b_read(&sinfo->tempfile_for_exceptions,(byte*)mergebuf, - (uint) key_length)) + sizeof(key_length))) { - if (_mi_ck_write(info,sinfo->key,(uchar*) mergebuf, - key_length - info->s->rec_reflength)) - got_error=1; + byte ft_buf[HA_FT_MAXLEN + HA_FT_WLEN + 10]; + if (key_length > sizeof(ft_buf) || + my_b_read(&sinfo->tempfile_for_exceptions, (byte*)ft_buf, + (uint)key_length) || + _mi_ck_write(info, sinfo->key, (uchar*)ft_buf, + key_length - info->s->rec_reflength)) + got_error=1; } } } diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index ce1703fca0e..c94a9bbee85 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -321,3 +321,11 @@ SELECT MATCH(a) AGAINST ('nosuchword') FROM t1; MATCH(a) AGAINST ('nosuchword') 0 DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(30), FULLTEXT(a)); +INSERT INTO t1 VALUES('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +SET myisam_repair_threads=@@global.myisam_repair_threads; +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 90020e9468e..f9f61bb14a0 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -260,3 +260,14 @@ CREATE TABLE t1 ( a TEXT, FULLTEXT (a) ); INSERT INTO t1 VALUES ('testing ft_nlq_find_relevance'); SELECT MATCH(a) AGAINST ('nosuchword') FROM t1; DROP TABLE t1; + +# +# BUG#11684 - repair crashes mysql when table has fulltext index +# + +CREATE TABLE t1 (a VARCHAR(30), FULLTEXT(a)); +INSERT INTO t1 VALUES('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +SET myisam_repair_threads=@@global.myisam_repair_threads; +DROP TABLE t1; From a4d6113d2228e7eab50547508f49baf0fd72d515 Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Tue, 2 Aug 2005 12:57:26 +0500 Subject: [PATCH 2/5] After merge fix. --- myisam/sort.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myisam/sort.c b/myisam/sort.c index 0bbf7efa659..e8cd9938e42 100644 --- a/myisam/sort.c +++ b/myisam/sort.c @@ -589,7 +589,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) !my_b_read(&sinfo->tempfile_for_exceptions,(byte*)&key_length, sizeof(key_length))) { - byte ft_buf[HA_FT_MAXLEN + HA_FT_WLEN + 10]; + byte ft_buf[HA_FT_MAXBYTELEN + HA_FT_WLEN + 10]; if (key_length > sizeof(ft_buf) || my_b_read(&sinfo->tempfile_for_exceptions, (byte*)ft_buf, (uint)key_length) || From 315e4efc3fb7bb4e9c8e6600f71ac37f3e75790f Mon Sep 17 00:00:00 2001 From: "svoj@mysql.com" <> Date: Tue, 2 Aug 2005 14:27:52 +0500 Subject: [PATCH 3/5] Fix for BUG#12075. FULLTEXT non-functional for big5 strings --- mysql-test/r/ctype_big5.result | 6 ++++++ mysql-test/t/ctype_big5.test | 8 ++++++++ strings/ctype-big5.c | 12 ++++++------ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/ctype_big5.result b/mysql-test/r/ctype_big5.result index 8d2c39df853..01b59b93b52 100644 --- a/mysql-test/r/ctype_big5.result +++ b/mysql-test/r/ctype_big5.result @@ -128,3 +128,9 @@ SELECT * FROM t1; a ùØ DROP TABLE t1; +CREATE TABLE t1 (a CHAR(50) CHARACTER SET big5 NOT NULL, FULLTEXT(a)); +INSERT INTO t1 VALUES(0xA741ADCCA66EB6DC20A7DAADCCABDCA66E); +SELECT HEX(a) FROM t1 WHERE MATCH(a) AGAINST (0xA741ADCCA66EB6DC IN BOOLEAN MODE); +HEX(a) +A741ADCCA66EB6DC20A7DAADCCABDCA66E +DROP TABLE t1; diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test index e4fb1d2a32b..73d9f06042c 100644 --- a/mysql-test/t/ctype_big5.test +++ b/mysql-test/t/ctype_big5.test @@ -28,4 +28,12 @@ INSERT INTO t1 VALUES (' SELECT * FROM t1; DROP TABLE t1; +# +# BUG#12075 - FULLTEXT non-functional for big5 strings +# +CREATE TABLE t1 (a CHAR(50) CHARACTER SET big5 NOT NULL, FULLTEXT(a)); +INSERT INTO t1 VALUES(0xA741ADCCA66EB6DC20A7DAADCCABDCA66E); +SELECT HEX(a) FROM t1 WHERE MATCH(a) AGAINST (0xA741ADCCA66EB6DC IN BOOLEAN MODE); +DROP TABLE t1; + # End of 4.1 tests diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index b467c8c5ba3..73e3efd09a7 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -61,12 +61,12 @@ static uchar NEAR ctype_big5[257] = 2,2,2,2,2,2,2,2,2,2,2,16,16,16,16,32, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3, + 3,3,3,3,3,3,3,3,3,3,0,0,0,0,0,0, }; static uchar NEAR to_lower_big5[]= From 8420d76f8d5ad60310e970db643b351930231baa Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 2 Aug 2005 11:58:52 -0700 Subject: [PATCH 4/5] sql_select.cc, sql_class.h: Reversed the changes to fix bug #12095 after review done by SergeyG. Applied a fix suggested by him. --- sql/sql_class.h | 4 +--- sql/sql_select.cc | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/sql/sql_class.h b/sql/sql_class.h index 85ff901fe72..b6bf0dcdc45 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1325,12 +1325,10 @@ public: bool using_indirect_summary_function; /* If >0 convert all blob fields to varchar(convert_blob_length) */ uint convert_blob_length; - bool need_const; /* <=> const items are saved in tmp table */ TMP_TABLE_PARAM() :copy_field(0), group_parts(0), - group_length(0), group_null_parts(0), convert_blob_length(0), - need_const(0) + group_length(0), group_null_parts(0), convert_blob_length(0) {} ~TMP_TABLE_PARAM() { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fc85f49093d..1bde62276b8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -5201,8 +5201,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List &fields, param->using_indirect_summary_function=1; continue; } - if (item->const_item() && (int) hidden_field_count <= 0 && - !param->need_const) + if (item->const_item() && (int) hidden_field_count <= 0) continue; // We don't have to store this } if (type == Item::SUM_FUNC_ITEM && !group && !save_sum_fields) From 5e851429de6489e33776364e56ee7a597b016cc8 Mon Sep 17 00:00:00 2001 From: "igor@rurik.mysql.com" <> Date: Tue, 2 Aug 2005 13:12:41 -0700 Subject: [PATCH 5/5] item_sum.cc: Reversed the changes to fix bug #12095 after review done by SergeyG. Applied a fix suggested by him. Added my comment. --- sql/item_sum.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 1ee48dfb763..74a7fee113e 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1577,7 +1577,11 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, the temporary table, not the original field */ Field *field= (*field_item)->get_tmp_table_field(); - if (field) + /* + If field_item is a const item then either get_tp_table_field returns 0 + or it is an item over a const table. + */ + if (field && !(*field_item)->const_item()) { int res; uint offset= field->offset(); @@ -1610,7 +1614,11 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) the temporary table, not the original field */ Field *field= item->get_tmp_table_field(); - if (field) + /* + If item is a const item then either get_tp_table_field returns 0 + or it is an item over a const table. + */ + if (field && !item->const_item()) { int res; uint offset= field->offset(); @@ -1986,7 +1994,6 @@ bool Item_func_group_concat::setup(THD *thd) } count_field_types(tmp_table_param,all_fields,0); - tmp_table_param->need_const= 1; if (table) { /*