From 4bf11aacd039dc6f7554681b846251af241ca701 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 29 Sep 2004 23:25:32 +0400 Subject: Fix for BUG#4785 part two: * If at least one of indexes is disabled, use data file size as an estimate for key file size. * Added handling for joined tables. --- myisam/myisampack.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'myisam') diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 4b784641266..5efd6b3a7fd 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -111,6 +111,8 @@ typedef struct st_isam_mrg { uint ref_length; uint max_blob_length; my_off_t records; + /* true if at least one source file has at least one disabled index */ + my_bool src_file_has_indexes_disabled; } PACK_MRG_INFO; @@ -413,9 +415,16 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count) mrg->current=0; mrg->file=(MI_INFO**) my_malloc(sizeof(MI_INFO*)*count,MYF(MY_FAE)); mrg->free_file=1; + mrg->src_file_has_indexes_disabled= 0; for (i=0; i < count ; i++) { - if (!(mrg->file[i]=open_isam_file(names[i],O_RDONLY))) + if ((mrg->file[i]=open_isam_file(names[i],O_RDONLY))) + { + mrg->src_file_has_indexes_disabled |= + (mrg->file[i]->s->state.key_map != + (1ULL << mrg->file[i]->s->base.keys) - 1); + } + else goto error; } /* Check that files are identical */ @@ -2040,12 +2049,21 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, share->state.dellink= HA_OFFSET_ERROR; share->state.split=(ha_rows) mrg->records; share->state.version=(ulong) time((time_t*) 0); - share->state.key_map=0; + if (share->state.key_map != (1ULL << share->base.keys) - 1) + { + /* + Some indexes are disabled, cannot use current key_file_length value + as an estimate of upper bound of index file size. Use packed data file + size instead. + */ + share->state.state.key_file_length= new_length; + } /* - Don't save key_file_length here, keep key_file_length of original file - so "myisamchk -rq" can use this value (this is necessary because index - size cannot be easily calculated for fulltext keys) + If there are no disabled indexes, keep key_file_length value from + original file so "myisamchk -rq" can use this value (this is necessary + because index size cannot be easily calculated for fulltext keys) */ + share->state.key_map=0; for (key=0 ; key < share->base.keys ; key++) share->state.key_root[key]= HA_OFFSET_ERROR; for (key=0 ; key < share->state.header.max_block_size ; key++) @@ -2054,8 +2072,7 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, share->changed=1; /* Force write of header */ share->state.open_count=0; share->global_changed=0; - VOID(my_chsize(share->kfile, share->state.state.key_file_length, 0, - MYF(0))); + VOID(my_chsize(share->kfile, share->base.keystart, 0, MYF(0))); if (share->base.keys) isamchk_neaded=1; DBUG_RETURN(mi_state_info_write(share->kfile,&share->state,1+2)); @@ -2078,7 +2095,12 @@ static int save_state_mrg(File file,PACK_MRG_INFO *mrg,my_off_t new_length, state.state.del=0; state.state.empty=0; state.state.records=state.split=(ha_rows) mrg->records; - state.state.key_file_length=isam_file->s->base.keystart; + /* See comment above in save_state about key_file_length handling. */ + if (mrg->src_file_has_indexes_disabled) + { + isam_file->s->state.state.key_file_length= + max(isam_file->s->state.state.key_file_length, new_length); + } state.dellink= HA_OFFSET_ERROR; state.version=(ulong) time((time_t*) 0); state.key_map=0; -- cgit v1.2.1 From 4736d0fe9963742e2788960d60da7f0f2dd593e9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Oct 2004 01:28:42 +0300 Subject: Review of all code pushed since last review Simple optimzations and cleanups Removed compiler warnings and fixed portability issues Added client functions 'mysql_embedded()' to allow client to check if we are using embedded server Fixes for purify client/mysqlimport.c: Remove not used variable client/mysqltest.c: Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN) Simplified code Remove usage of sprintf("%llu") as this is not portable include/mysql.h: Added mysql_embedded() to be able to easily check if we are using the embedded server innobase/srv/srv0start.c: Don't use memcmp() when using purify (to avoid false warnings) libmysql/libmysql.c: Added mysql_embedded() to be able to easily check if we are using the embedded server libmysql/libmysql.def: Added mysql_embedded() to be able to easily check if we are using the embedded server myisam/myisam_ftdump.c: Remove compiler warning myisam/myisamchk.c: Remove compiler warning myisam/rt_test.c: #ifdef not used code mysys/hash.c: Remove compiler warning (from last push) mysys/my_gethwaddr.c: Remove compiler warning ndb/src/ndbapi/ndberror.c: #ifdef not used code regex/regcomp.c: Remove not used code regex/regcomp.ih: Remove not used code (to remove compiler warnings) sql-common/client.c: Remove compiler warnings sql/field.cc: Simple optimization sql/ha_innodb.cc: Rename mysql_embedded -> mysqld_embedded sql/item.cc: Fix comments Move variables first on block Remove else after return Simple optimizations (no logic changes) sql/item_cmpfunc.cc: Added comment sql/mysql_priv.h: Rename mysql_embedded -> mysqld_embedded sql/mysqld.cc: Rename mysql_embedded -> mysqld_embedded sql/sql_acl.cc: Added comments simple optimization Fixed 'very unlikely' bug when doing REVOKE ALL PRIVILEGES sql/sql_select.cc: More comments Simple optimization sql/sql_show.cc: Simple changes to make similar code similar More comments sql/sql_string.cc: Trivial optimization and better code layout strings/Makefile.am: Change xml.c to use bcmp to avoid warnings from purify strings/xml.c: Change xml.c to use bcmp to avoid warnings from purify tests/client_test.c: Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN) --- myisam/myisam_ftdump.c | 2 +- myisam/myisamchk.c | 2 +- myisam/rt_test.c | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'myisam') diff --git a/myisam/myisam_ftdump.c b/myisam/myisam_ftdump.c index 8219c19848a..54b2cc77965 100644 --- a/myisam/myisam_ftdump.c +++ b/myisam/myisam_ftdump.c @@ -68,7 +68,7 @@ int main(int argc,char *argv[]) struct { MI_INFO *info; } aio0, *aio=&aio0; /* for GWS_IN_USE */ MY_INIT(argv[0]); - if (error=handle_options(&argc, &argv, my_long_options, get_one_option)) + if ((error= handle_options(&argc, &argv, my_long_options, get_one_option))) exit(error); if (count || dump) verbose=0; diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 98cbc838d31..6c0c30b7056 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -1695,7 +1695,7 @@ err: static my_bool not_killed= 0; -volatile my_bool *killed_ptr(MI_CHECK *param) +volatile my_bool *killed_ptr(MI_CHECK *param __attribute__((unused))) { return ¬_killed; /* always NULL */ } diff --git a/myisam/rt_test.c b/myisam/rt_test.c index 5e883e223b3..4f04aa11fce 100644 --- a/myisam/rt_test.c +++ b/myisam/rt_test.c @@ -425,6 +425,7 @@ static void create_record1(char *record,uint rownr) } } +#ifdef NOT_USED static void create_record0(char *record,uint rownr) { @@ -447,6 +448,8 @@ static void create_record0(char *record,uint rownr) } } +#endif + static void create_record(char *record,uint rownr) { int i; -- cgit v1.2.1 From ed8ec2cf1613e1bb57705698b8962e767fd89320 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Oct 2004 11:24:08 +0300 Subject: Code cleanups (done during review of new code) Rename innodb_table_locks_old_behavior -> innodb_table_locks Set innodb_table_locks to off by default to get same behaviour as in MySQL 4.0.20 (This means that Innodb ignore table locks by default, which makes it easier to combine MyISAM and InnoDB to simulate a transaction) libmysql/libmysql.c: Use ulong instead of unsigned long Reuse _dig_vec() myisam/myisampack.c: Simplify code mysql-test/r/innodb-lock.result: new test case mysql-test/t/innodb-lock.test: new test case sql/ha_innodb.cc: Rename innodb_table_locks_old_behavior -> innodb_table_locks sql/mysqld.cc: Rename innodb_table_locks_old_behavior -> innodb_table_locks Set this off by default to get same behaviour as in MySQL 4.0.20 sql/set_var.cc: Rename innodb_table_locks_old_behavior -> innodb_table_locks sql/sql_class.h: Rename innodb_table_locks_old_behavior -> innodb_table_locks --- myisam/myisampack.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'myisam') diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 5efd6b3a7fd..0dde1916f03 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -418,14 +418,12 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count) mrg->src_file_has_indexes_disabled= 0; for (i=0; i < count ; i++) { - if ((mrg->file[i]=open_isam_file(names[i],O_RDONLY))) - { - mrg->src_file_has_indexes_disabled |= - (mrg->file[i]->s->state.key_map != - (1ULL << mrg->file[i]->s->base.keys) - 1); - } - else + if (!(mrg->file[i]=open_isam_file(names[i],O_RDONLY))) goto error; + + mrg->src_file_has_indexes_disabled|= ((mrg->file[i]->s->state.key_map != + (((ulonglong) 1) << + mrg->file[i]->s->base. keys) - 1)); } /* Check that files are identical */ for (j=0 ; j < count-1 ; j++) -- cgit v1.2.1