summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorAlexander Nozdrin <alik@ibmvm>2009-12-08 09:55:52 +0300
committerAlexander Nozdrin <alik@ibmvm>2009-12-08 09:55:52 +0300
commit6fd3866c6c104f8bc991d71583e627ae6fabe0ab (patch)
tree9e087da0ea351f94c35f6996a5e0c4c468d2333a /sql/sql_table.cc
parent04fe40393d9d0ef81cc6a770bda67ab67fe4154e (diff)
parenta8e80f3146779c9783aa6d29d5f8ffef7a4a9f69 (diff)
downloadmariadb-git-6fd3866c6c104f8bc991d71583e627ae6fabe0ab.tar.gz
Auto-merge from mysql-next-mr.
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc44
1 files changed, 36 insertions, 8 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 30ffa3703c2..e594499b4d8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -3934,15 +3934,43 @@ bool mysql_create_table_no_lock(THD *thd,
create_info->table_existed= 0; // Mark that table is created
#ifdef HAVE_READLINK
- if (test_if_data_home_dir(create_info->data_file_name))
{
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY");
- goto unlock_and_end;
- }
- if (test_if_data_home_dir(create_info->index_file_name))
- {
- my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY");
- goto unlock_and_end;
+ size_t dirlen;
+ char dirpath[FN_REFLEN];
+
+ /*
+ data_file_name and index_file_name include the table name without
+ extension. Mostly this does not refer to an existing file. When
+ comparing data_file_name or index_file_name against the data
+ directory, we try to resolve all symbolic links. On some systems,
+ we use realpath(3) for the resolution. This returns ENOENT if the
+ resolved path does not refer to an existing file. my_realpath()
+ does then copy the requested path verbatim, without symlink
+ resolution. Thereafter the comparison can fail even if the
+ requested path is within the data directory. E.g. if symlinks to
+ another file system are used. To make realpath(3) return the
+ resolved path, we strip the table name and compare the directory
+ path only. If the directory doesn't exist either, table creation
+ will fail anyway.
+ */
+ if (create_info->data_file_name)
+ {
+ dirname_part(dirpath, create_info->data_file_name, &dirlen);
+ if (test_if_data_home_dir(dirpath))
+ {
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "DATA DIRECTORY");
+ goto unlock_and_end;
+ }
+ }
+ if (create_info->index_file_name)
+ {
+ dirname_part(dirpath, create_info->index_file_name, &dirlen);
+ if (test_if_data_home_dir(dirpath))
+ {
+ my_error(ER_WRONG_ARGUMENTS, MYF(0), "INDEX DIRECTORY");
+ goto unlock_and_end;
+ }
+ }
}
#ifdef WITH_PARTITION_STORAGE_ENGINE