From e0aadfd491700fc072ffee1e1612f52fa5fc39b1 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Fri, 12 Mar 2010 14:43:30 +0400 Subject: [PATCH 1/2] BUG#47444 - --myisam_repair_threads>1can result in all index cardinalities=1 Parallel repair didn't poroperly update index cardinality in certain cases. When myisam_sort_buffer_size is not enough to store all keys, index cardinality was updated before index was actually written, when no index statistic is available. mysql-test/r/myisam.result: A test case for BUG#47444. mysql-test/t/myisam.test: A test case for BUG#47444. storage/myisam/sort.c: update_key_parts() must be called after all index entries are written, when index statistic is available. --- mysql-test/r/myisam.result | 19 +++++++++++++++++++ mysql-test/t/myisam.test | 14 ++++++++++++++ storage/myisam/sort.c | 14 +++++++------- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/myisam.result b/mysql-test/r/myisam.result index ba417d54998..5b9745a7b81 100644 --- a/mysql-test/r/myisam.result +++ b/mysql-test/r/myisam.result @@ -2389,4 +2389,23 @@ SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1; a a 1 1 DROP TABLE t1; +# +# BUG#47444 - --myisam_repair_threads>1can result in all index +# cardinalities=1 +# +SET myisam_repair_threads=2; +SET myisam_sort_buffer_size=4096; +CREATE TABLE t1(a CHAR(255), KEY(a), KEY(a), KEY(a)); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(0),(1),(2),(3); +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; +CARDINALITY +14 +14 +14 +DROP TABLE t1; +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; +SET myisam_repair_threads=@@global.myisam_repair_threads; End of 5.1 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index 7dcfe058039..4abd7dd2b1b 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -1631,4 +1631,18 @@ INSERT INTO t1 VALUES('1'); SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1; DROP TABLE t1; +--echo # +--echo # BUG#47444 - --myisam_repair_threads>1can result in all index +--echo # cardinalities=1 +--echo # +SET myisam_repair_threads=2; +SET myisam_sort_buffer_size=4096; +CREATE TABLE t1(a CHAR(255), KEY(a), KEY(a), KEY(a)); +INSERT INTO t1 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9),(0),(1),(2),(3); +REPAIR TABLE t1; +SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; +DROP TABLE t1; +SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; +SET myisam_repair_threads=@@global.myisam_repair_threads; + --echo End of 5.1 tests diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index b450d27de66..e01dad68555 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -506,7 +506,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) for (i= 0, sinfo= sort_param ; i < sort_info->total_keys ; - i++, rec_per_key_part+=sinfo->keyinfo->keysegs, sinfo++) + i++, sinfo++) { if (!sinfo->sort_keys) { @@ -529,11 +529,6 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) flush_ft_buf(sinfo) || flush_pending_blocks(sinfo)) got_error=1; } - if (!got_error && param->testflag & T_STATISTICS) - update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique, - param->stats_method == MI_STATS_METHOD_IGNORE_NULLS? - sinfo->notnull: NULL, - (ulonglong) info->state->records); } my_free((uchar*) sinfo->sort_keys,MYF(0)); my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff), @@ -547,7 +542,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) delete_dynamic(&sinfo->buffpek), close_cached_file(&sinfo->tempfile), close_cached_file(&sinfo->tempfile_for_exceptions), - sinfo++) + rec_per_key_part+= sinfo->keyinfo->keysegs, sinfo++) { if (got_error) continue; @@ -639,6 +634,11 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) got_error=1; } } + if (!got_error && param->testflag & T_STATISTICS) + update_key_parts(sinfo->keyinfo, rec_per_key_part, sinfo->unique, + param->stats_method == MI_STATS_METHOD_IGNORE_NULLS ? + sinfo->notnull : NULL, + (ulonglong) info->state->records); } my_free((uchar*) mergebuf,MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(got_error); From 52c2d8410a6918235e4f1c86d093141af6adeb73 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 16 Mar 2010 17:15:19 +0400 Subject: [PATCH 2/2] Plugin author, description and version are available via I_S.PLUGINS, not via SHOW PLUGINS. --- include/mysql/plugin.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index 2e59262d061..58b3848b85f 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -396,12 +396,12 @@ struct st_mysql_plugin int type; /* the plugin type (a MYSQL_XXX_PLUGIN value) */ void *info; /* pointer to type-specific plugin descriptor */ const char *name; /* plugin name */ - const char *author; /* plugin author (for SHOW PLUGINS) */ - const char *descr; /* general descriptive text (for SHOW PLUGINS ) */ + const char *author; /* plugin author (for I_S.PLUGINS) */ + const char *descr; /* general descriptive text (for I_S.PLUGINS) */ int license; /* the plugin license (PLUGIN_LICENSE_XXX) */ int (*init)(void *); /* the function to invoke when plugin is loaded */ int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ - unsigned int version; /* plugin version (for SHOW PLUGINS) */ + unsigned int version; /* plugin version (for I_S.PLUGINS) */ struct st_mysql_show_var *status_vars; struct st_mysql_sys_var **system_vars; void * __reserved1; /* reserved for dependency checking */