From: Date: November 9 2006 12:55pm Subject: bk commit into 5.0 tree (svoj:1.2294) BUG#23526 List-Archive: http://lists.mysql.com/commits/15083 X-Bug: 23526 Message-Id: <20061109115532.C990EA32@april.pils.ru> Below is the list of changes that have just been committed into a local 5.0 repository of svoj. When svoj 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-11-09 15:55:27+04:00, svoj@stripped +3 -0 BUG#23526 - show table status reports incorrect values for MyISAM tables This problem could happen when show table status get outdated copy of TABLE object from table cache. MyISAM updates state info when external_lock() method is called. Though I_S does not lock a table to avoid deadlocks. If I_S opens a table which is in a table cache it will likely get outdated state info copy. In this case shared state copy is more recent than local copy. This problem is fixed by reading state info directly from share not locking it. As a side effect show table status will report outdated state info when it is run inside LOCK TABLES. Affects MyISAM only. include/my_base.h@stripped, 2006-11-09 15:55:26+04:00, svoj@stripped +5 -0 Added HA_STATUS_FROM_SHARE flag, that instruct handler to read state info from share not performing a lock. myisam/mi_info.c@stripped, 2006-11-09 15:55:26+04:00, svoj@stripped +10 -8 In case HA_STATUS_FROM_SHARE is set, read state info from myisam share. sql/sql_show.cc@stripped, 2006-11-09 15:55:26+04:00, svoj@stripped +1 -1 Get state info from share, which is likely more recent than local handler copy of the state. # 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: svoj # Host: april.(none) # Root: /home/svoj/devel/mysql/BUG23526/mysql-5.0-engines --- 1.81/include/my_base.h 2006-11-09 15:55:32 +04:00 +++ 1.82/include/my_base.h 2006-11-09 15:55:32 +04:00 @@ -316,6 +316,11 @@ enum ha_base_keytype { update handler::auto_increment_value */ #define HA_STATUS_AUTO 64 +/* + in case local copy of the 'info' is likely outdated, read it from the share. +*/ +#define HA_STATUS_FROM_SHARE 128 + /* Errorcodes given by functions */ --- 1.15/myisam/mi_info.c 2006-11-09 15:55:32 +04:00 +++ 1.16/myisam/mi_info.c 2006-11-09 15:55:32 +04:00 @@ -50,17 +50,19 @@ int mi_status(MI_INFO *info, register MI } if (flag & HA_STATUS_VARIABLE) { - x->records = info->state->records; - x->deleted = info->state->del; - x->delete_length = info->state->empty; - x->data_file_length =info->state->data_file_length; - x->index_file_length=info->state->key_file_length; + MI_STATUS_INFO *state= (flag & HA_STATUS_FROM_SHARE) ? &share->state.state : + info->state; + x->records= state->records; + x->deleted= state->del; + x->delete_length= state->empty; + x->data_file_length= state->data_file_length; + x->index_file_length= state->key_file_length; x->keys = share->state.header.keys; x->check_time = share->state.check_time; - x->mean_reclength = info->state->records ? - (ulong) ((info->state->data_file_length-info->state->empty)/ - info->state->records) : (ulong) share->min_pack_length; + x->mean_reclength= state->records ? + (ulong) ((x->data_file_length - x->delete_length) / + x->records) : (ulong) share->min_pack_length; } if (flag & HA_STATUS_ERRKEY) { --- 1.329/sql/sql_show.cc 2006-11-09 15:55:32 +04:00 +++ 1.330/sql/sql_show.cc 2006-11-09 15:55:32 +04:00 @@ -2444,7 +2444,7 @@ static int get_schema_tables_record(THD handler *file= show_table->file; file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_AUTO | - HA_STATUS_NO_LOCK); + HA_STATUS_NO_LOCK | HA_STATUS_FROM_SHARE); if (share->tmp_table == SYSTEM_TMP_TABLE) table->field[3]->store(STRING_WITH_LEN("SYSTEM VIEW"), cs); else if (share->tmp_table)