diff options
author | ingo@mysql.com <> | 2005-04-28 19:34:05 +0200 |
---|---|---|
committer | ingo@mysql.com <> | 2005-04-28 19:34:05 +0200 |
commit | be34b54e1d5e06eba85e92462bff70bc9a5b7586 (patch) | |
tree | 4e65f44049751fec4d3ff85e114155f9fe894035 /sql/ha_myisammrg.cc | |
parent | b31960f71dd4d5809635858d774bdf292a067b3d (diff) | |
parent | 8ccbea47e8550be6ea79454dca704938f69e1ec0 (diff) | |
download | mariadb-git-be34b54e1d5e06eba85e92462bff70bc9a5b7586.tar.gz |
Merge mysql.com:/home/mydev/mysql-4.1-4100
into mysql.com:/home/mydev/mysql-5.0-5000
Diffstat (limited to 'sql/ha_myisammrg.cc')
-rw-r--r-- | sql/ha_myisammrg.cc | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 5add9478bf4..20b5ad44629 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -400,6 +400,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form, const char **table_names, **pos; TABLE_LIST *tables= (TABLE_LIST*) create_info->merge_list.first; THD *thd= current_thd; + uint dirlgt= dirname_length(name); DBUG_ENTER("ha_myisammrg::create"); if (!(table_names= (const char**) @@ -413,11 +414,30 @@ int ha_myisammrg::create(const char *name, register TABLE *form, tbl= find_temporary_table(thd, tables->db, tables->table_name); if (!tbl) { - uint length= my_snprintf(buff,FN_REFLEN,"%s%s/%s", - mysql_real_data_home, + /* + Construct the path to the MyISAM table. Try to meet two conditions: + 1.) Allow to include MyISAM tables from different databases, and + 2.) allow for moving DATADIR around in the file system. + The first means that we need paths in the .MRG file. The second + means that we should not have absolute paths in the .MRG file. + The best, we can do, is to use 'mysql_data_home', which is '.' + in mysqld and may be an absolute path in an embedded server. + This means that it might not be possible to move the DATADIR of + an embedded server without changing the paths in the .MRG file. + */ + uint length= my_snprintf(buff, FN_REFLEN, "%s/%s/%s", mysql_data_home, tables->db, tables->table_name); - if (!(table_name= thd->strmake(buff, length))) - DBUG_RETURN(HA_ERR_OUT_OF_MEM); + /* + If a MyISAM table is in the same directory as the MERGE table, + we use the table name without a path. This means that the + DATADIR can easily be moved even for an embedded server as long + as the MyISAM tables are from the same database as the MERGE table. + */ + if ((dirname_length(buff) == dirlgt) && ! memcmp(buff, name, dirlgt)) + table_name= tables->real_name; + else + if (! (table_name= thd->strmake(buff, length))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); } else table_name= (*tbl)->s->path; |