Commit c881d82c authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: ha_myisam::data_file_name and index_file_name

don't allocate them on THD::mem_root on every init(HA_STATUS_CONST) call,
do it once in open() (because they don't change) on TABLE::mem_root
(so they stay valid until the table is closed)
parent 2fe61861
...@@ -729,6 +729,7 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) ...@@ -729,6 +729,7 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
{ {
MI_KEYDEF *keyinfo; MI_KEYDEF *keyinfo;
MI_COLUMNDEF *recinfo= 0; MI_COLUMNDEF *recinfo= 0;
char readlink_buf[FN_REFLEN], name_buff[FN_REFLEN];
uint recs; uint recs;
uint i; uint i;
...@@ -783,6 +784,30 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) ...@@ -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); (void) mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0);
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); 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)) if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
(void) mi_extra(file, HA_EXTRA_WAIT_LOCK, 0); (void) mi_extra(file, HA_EXTRA_WAIT_LOCK, 0);
if (!table->s->db_record_offset) if (!table->s->db_record_offset)
...@@ -1847,7 +1872,6 @@ void ha_myisam::position(const uchar *record) ...@@ -1847,7 +1872,6 @@ void ha_myisam::position(const uchar *record)
int ha_myisam::info(uint flag) int ha_myisam::info(uint flag)
{ {
MI_ISAMINFO misam_info; MI_ISAMINFO misam_info;
char name_buff[FN_REFLEN];
if (!table) if (!table)
return 1; return 1;
...@@ -1895,27 +1919,6 @@ int ha_myisam::info(uint flag) ...@@ -1895,27 +1919,6 @@ int ha_myisam::info(uint flag)
sizeof(table->key_info[0].rec_per_key[0])*share->key_parts); sizeof(table->key_info[0].rec_per_key[0])*share->key_parts);
if (table_share->tmp_table == NO_TMP_TABLE) if (table_share->tmp_table == NO_TMP_TABLE)
mysql_mutex_unlock(&table_share->LOCK_share); 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) if (flag & HA_STATUS_ERRKEY)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment