summaryrefslogtreecommitdiff
path: root/sql/ha_myisammrg.cc
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-04-28 18:28:50 +0200
committerunknown <ingo@mysql.com>2005-04-28 18:28:50 +0200
commitf0e256efe4a569788908d4ff9d672010b878449b (patch)
tree0f234f007885333223f6233c5d1e6f54e303446f /sql/ha_myisammrg.cc
parente2f5671064639b4dfe22fda07349fa00220a9af2 (diff)
downloadmariadb-git-f0e256efe4a569788908d4ff9d672010b878449b.tar.gz
BUG#5964 - 4.1 MERGE tables regression from 4.0
Changed the creation of the .MRG file so that only the table name is written when the MyISAM table is in the same database as the MERGE table, a relative path is used in other cases in mysqld, and possibly an absolute path is used in an embedded server. No test case is added as the external behaviour is unchanged. Only the file names within the .MRG file are changed. include/my_sys.h: BUG#5964 - 4.1 MERGE tables regression from 4.0 Added declaration for a new function. myisammrg/myrg_open.c: BUG#5964 - 4.1 MERGE tables regression from 4.0 Changed check for absolute path to check for any path. mysys/my_getwd.c: BUG#5964 - 4.1 MERGE tables regression from 4.0 Added a new functions which checks for absolute _or_ relative paths. sql/ha_myisammrg.cc: BUG#5964 - 4.1 MERGE tables regression from 4.0 Changed the creation of the .MRG file so that only the table name is written when the MyISAM table is in the same database as the MERGE table, a relative path is used in other cases in mysqld, and possibly an absolute path is used in an embedded server.
Diffstat (limited to 'sql/ha_myisammrg.cc')
-rw-r--r--sql/ha_myisammrg.cc28
1 files changed, 24 insertions, 4 deletions
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc
index bf47b4625e0..7a5d4fcf0a1 100644
--- a/sql/ha_myisammrg.cc
+++ b/sql/ha_myisammrg.cc
@@ -381,6 +381,7 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
char buff[FN_REFLEN],**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= (char**) thd->alloc((create_info->merge_list.elements+1)*
@@ -394,11 +395,30 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
tbl= find_temporary_table(thd, tables->db, tables->real_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->real_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)->path;