diff options
-rw-r--r-- | storage/myisam/ha_myisam.cc | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 3a9bf45e22f..7f2afc3130a 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -729,6 +729,7 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) { MI_KEYDEF *keyinfo; MI_COLUMNDEF *recinfo= 0; + char readlink_buf[FN_REFLEN], name_buff[FN_REFLEN]; uint recs; uint i; @@ -783,6 +784,30 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) (void) mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); + + /* + Set data_file_name and index_file_name to point at the symlink value + if table is symlinked (Ie; Real name is not same as generated name) + */ + fn_format(name_buff, file->filename, "", MI_NAME_DEXT, + MY_APPEND_EXT | MY_UNPACK_FILENAME); + if (my_is_symlink(name_buff)) + { + my_readlink(readlink_buf, name_buff, MYF(0)); + data_file_name= strdup_root(&table->mem_root, readlink_buf); + } + else + data_file_name= 0; + fn_format(name_buff, file->filename, "", MI_NAME_IEXT, + MY_APPEND_EXT | MY_UNPACK_FILENAME); + if (my_is_symlink(name_buff)) + { + my_readlink(readlink_buf, name_buff, MYF(0)); + index_file_name= strdup_root(&table->mem_root, readlink_buf); + } + else + index_file_name= 0; + if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED)) (void) mi_extra(file, HA_EXTRA_WAIT_LOCK, 0); if (!table->s->db_record_offset) @@ -1847,7 +1872,6 @@ void ha_myisam::position(const uchar *record) int ha_myisam::info(uint flag) { MI_ISAMINFO misam_info; - char name_buff[FN_REFLEN]; if (!table) return 1; @@ -1895,27 +1919,6 @@ int ha_myisam::info(uint flag) sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); if (table_share->tmp_table == NO_TMP_TABLE) mysql_mutex_unlock(&table_share->LOCK_share); - - /* - Set data_file_name and index_file_name to point at the symlink value - if table is symlinked (Ie; Real name is not same as generated name) - */ - char buf[FN_REFLEN]; - data_file_name= index_file_name= 0; - fn_format(name_buff, file->filename, "", MI_NAME_DEXT, - MY_APPEND_EXT | MY_UNPACK_FILENAME); - if (my_is_symlink(name_buff)) - { - my_readlink(buf, name_buff, MYF(0)); - data_file_name= ha_thd()->strdup(buf); - } - fn_format(name_buff, file->filename, "", MI_NAME_IEXT, - MY_APPEND_EXT | MY_UNPACK_FILENAME); - if (my_is_symlink(name_buff)) - { - my_readlink(buf, name_buff, MYF(0)); - index_file_name= ha_thd()->strdup(buf); - } } if (flag & HA_STATUS_ERRKEY) { |