From: Date: March 16 2007 3:30pm Subject: bk commit into 5.1 tree (svoj:1.2481) BUG#25908 List-Archive: http://lists.mysql.com/commits/22140 X-Bug: 25908 Message-Id: <20070316143009.60F6341CEC2@june.myoffice.izhnet.ru> Below is the list of changes that have just been committed into a local 5.1 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, 2007-03-16 18:30:04+04:00, svoj@stripped +1 -0 BUG#25908 - corrupted myisam table crashes server even after repair Opening certain tables that have different definitions in .MYI and .frm may result in a server crash. Compare .MYI and .frm definition when myisam table is opened. In case definitions are diffirent refuse to open such table. No test case, since it requires broken table. storage/myisam/ha_myisam.cc@stripped, 2007-03-16 18:30:01+04:00, svoj@stripped +28 -0 Compare .MYI and .frm definition when myisam table is opened. In case definitions are diffirent refuse to open such table. # 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: june.mysql.com # Root: /home/svoj/devel/mysql/BUG25908/mysql-5.1-engines --- 1.211/storage/myisam/ha_myisam.cc 2007-03-13 19:05:30 +04:00 +++ 1.212/storage/myisam/ha_myisam.cc 2007-03-16 18:30:01 +04:00 @@ -632,6 +632,9 @@ bool ha_myisam::check_if_locking_is_allo int ha_myisam::open(const char *name, int mode, uint test_if_locked) { + MI_KEYDEF *keyinfo; + MI_COLUMNDEF *recinfo= 0; + uint recs; uint i; /* @@ -654,6 +657,26 @@ int ha_myisam::open(const char *name, in if (!(file=mi_open(name, mode, test_if_locked | HA_OPEN_FROM_SQL_LAYER))) return (my_errno ? my_errno : -1); + if (!table->s->tmp_table) /* No need to perform a check for tmp table */ + { + if ((my_errno= table2myisam(table, &keyinfo, &recinfo, &recs))) + { + /* purecov: begin inspected */ + DBUG_PRINT("error", ("Failed to convert TABLE object to MyISAM " + "key and column definition")); + goto err; + /* purecov: end */ + } + if (check_definition(keyinfo, recinfo, table->s->keys, recs, + file->s->keyinfo, file->s->rec, + file->s->base.keys, file->s->base.fields, true)) + { + /* purecov: begin inspected */ + my_errno= HA_ERR_CRASHED; + goto err; + /* purecov: end */ + } + } if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE)) VOID(mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0)); @@ -675,6 +698,11 @@ int ha_myisam::open(const char *name, in table->key_info[i].block_size= file->s->keyinfo[i].block_length; } return (0); +err: + this->close(); + if (recinfo) + my_free((gptr) recinfo, MYF(0)); + return my_errno; } int ha_myisam::close(void)