diff options
author | unknown <tomas@poseidon.ndb.mysql.com> | 2005-05-02 13:18:26 +0200 |
---|---|---|
committer | unknown <tomas@poseidon.ndb.mysql.com> | 2005-05-02 13:18:26 +0200 |
commit | 5326bdc616ca307942f646e8e28cfa838555377d (patch) | |
tree | 3e17ad766a1ecabf2eda4cd41b97efb6367c627e /sql/ha_myisammrg.cc | |
parent | 9bfa6d1afa296ffbf1404d058572dc9554434651 (diff) | |
parent | 21eed96b0261a6c6eff4f8df1493a0e57decf2bb (diff) | |
download | mariadb-git-5326bdc616ca307942f646e8e28cfa838555377d.tar.gz |
Merge tulin@bk-internal.mysql.com:/home/bk/mysql-5.0
into poseidon.ndb.mysql.com:/home/tomas/mysql-5.1-clean
BitKeeper/etc/logging_ok:
auto-union
configure.in:
Auto merged
sql/ha_innodb.cc:
Auto merged
sql/ha_myisam.cc:
Auto merged
sql/ha_myisammrg.cc:
Auto merged
sql/lock.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_repl.cc:
Auto merged
storage/heap/hp_hash.c:
Auto merged
storage/innobase/dict/dict0dict.c:
Auto merged
storage/innobase/fil/fil0fil.c:
Auto merged
storage/innobase/include/dict0dict.h:
Auto merged
storage/myisam/Makefile.am:
Auto merged
storage/myisam/mi_key.c:
Auto merged
storage/myisam/myisampack.c:
Auto merged
storage/myisammrg/myrg_open.c:
Auto merged
storage/ndb/include/ndbapi/NdbDictionary.hpp:
Auto merged
storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
Auto merged
storage/ndb/src/ndbapi/ndberror.c:
Auto merged
Diffstat (limited to 'sql/ha_myisammrg.cc')
-rw-r--r-- | sql/ha_myisammrg.cc | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index 1d86e31054e..71f0564c82b 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -32,8 +32,16 @@ ** MyISAM MERGE tables *****************************************************************************/ +static const char *ha_myisammrg_exts[] = { + ".MRG", + NullS +}; + const char **ha_myisammrg::bas_ext() const -{ static const char *ext[]= { ".MRG", NullS }; return ext; } +{ + return ha_myisammrg_exts; +} + const char *ha_myisammrg::index_type(uint key_number) { @@ -392,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**) @@ -405,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->table_name; + else + if (! (table_name= thd->strmake(buff, length))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); } else table_name= (*tbl)->s->path; |