mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
A set of mysql_home_path-related fixes
mysys/mf_format.c: I think here i fixed a bug sql/item_strfunc.cc: mysql_real_data_home added sql/sql_class.cc: it's more closer to what manual says sql/sql_load.cc: code rewritten to be similar sql/sql_table.cc: mysql_real_data_home added to the path
This commit is contained in:
parent
3c3db07321
commit
89ee639541
5 changed files with 31 additions and 14 deletions
|
@ -42,7 +42,7 @@ my_string fn_format(my_string to, const char *name, const char *dir,
|
|||
/* Use given directory */
|
||||
convert_dirname(dev,dir,NullS); /* Fix to this OS */
|
||||
}
|
||||
else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(name))
|
||||
else if ((flag & MY_RELATIVE_PATH) && !test_if_hard_path(dev))
|
||||
{
|
||||
/* Put 'dir' before the given path */
|
||||
strmake(buff,dev,sizeof(buff)-1);
|
||||
|
|
|
@ -2412,14 +2412,23 @@ String *Item_load_file::val_str(String *str)
|
|||
String *file_name;
|
||||
File file;
|
||||
MY_STAT stat_info;
|
||||
char path[FN_REFLEN];
|
||||
DBUG_ENTER("load_file");
|
||||
|
||||
if (!(file_name= args[0]->val_str(str)) ||
|
||||
if (!(file_name= args[0]->val_str(str))
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
!(current_thd->master_access & FILE_ACL) ||
|
||||
|| !(current_thd->master_access & FILE_ACL)
|
||||
#endif
|
||||
!my_stat(file_name->c_ptr(), &stat_info, MYF(MY_WME)))
|
||||
)
|
||||
goto err;
|
||||
|
||||
(void) fn_format(path, file_name->c_ptr(),
|
||||
mysql_real_data_home, "", MY_RELATIVE_PATH);
|
||||
unpack_filename(path, path); /* Convert to system format */
|
||||
|
||||
if (!my_stat(path, &stat_info, MYF(MY_WME)))
|
||||
goto err;
|
||||
|
||||
if (!(stat_info.st_mode & S_IROTH))
|
||||
{
|
||||
/* my_error(ER_TEXTFILE_NOT_READABLE, MYF(0), file_name->c_ptr()); */
|
||||
|
|
|
@ -891,8 +891,15 @@ static File create_file(THD *thd, char *path, sql_exchange *exchange,
|
|||
option|= MY_REPLACE_DIR; // Force use of db directory
|
||||
#endif
|
||||
|
||||
strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "");
|
||||
(void) fn_format(path, exchange->file_name, path, "", option);
|
||||
if (!dirname_length(path))
|
||||
{
|
||||
strxnmov(path, FN_REFLEN, mysql_real_data_home, thd->db ? thd->db : "", NullS);
|
||||
(void) fn_format(path, exchange->file_name, path, "", option);
|
||||
}
|
||||
else
|
||||
(void) fn_format(path, exchange->file_name, mysql_real_data_home, "", option);
|
||||
|
||||
|
||||
if (!access(path, F_OK))
|
||||
{
|
||||
my_error(ER_FILE_EXISTS_ERROR, MYF(0), exchange->file_name);
|
||||
|
|
|
@ -179,17 +179,16 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list,
|
|||
#ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS
|
||||
ex->file_name+=dirname_length(ex->file_name);
|
||||
#endif
|
||||
if (!dirname_length(ex->file_name) &&
|
||||
strlen(ex->file_name)+strlen(mysql_real_data_home)+strlen(tdb)+3 <
|
||||
FN_REFLEN)
|
||||
if (!dirname_length(ex->file_name))
|
||||
{
|
||||
(void) sprintf(name,"%s/%s/%s",mysql_data_home,tdb,ex->file_name);
|
||||
unpack_filename(name,name); /* Convert to system format */
|
||||
strxnmov(name, FN_REFLEN, mysql_real_data_home, tdb, NullS);
|
||||
(void) fn_format(name, ex->file_name, name, "", MY_RELATIVE_PATH);
|
||||
unpack_filename(name,name);
|
||||
}
|
||||
else
|
||||
{
|
||||
my_load_path(name, ex->file_name, mysql_real_data_home);
|
||||
unpack_filename(name, name);
|
||||
(void) fn_format(name, ex->file_name, mysql_real_data_home, "", MY_RELATIVE_PATH);
|
||||
unpack_filename(name,name);
|
||||
#if !defined(__WIN__) && !defined(OS2) && ! defined(__NETWARE__)
|
||||
MY_STAT stat_info;
|
||||
if (!my_stat(name,&stat_info,MYF(MY_WME)))
|
||||
|
|
|
@ -2602,7 +2602,9 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!access(fn_format(new_name_buff,new_name_buff,new_db,reg_ext,0),
|
||||
char dir_buff[FN_REFLEN];
|
||||
strxnmov(dir_buff, FN_REFLEN, mysql_real_data_home, new_db, NullS);
|
||||
if (!access(fn_format(new_name_buff,new_name_buff,dir_buff,reg_ext,0),
|
||||
F_OK))
|
||||
{
|
||||
/* Table will be closed in do_command() */
|
||||
|
|
Loading…
Reference in a new issue