mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Merge 10.2 into 10.3
This commit is contained in:
@@ -4019,63 +4019,6 @@ void do_mkdir(struct st_command *command)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Remove directory recursively.
|
||||
*/
|
||||
static int rmtree(const char *dir)
|
||||
{
|
||||
char path[FN_REFLEN];
|
||||
char sep[]={ FN_LIBCHAR, 0 };
|
||||
int err=0;
|
||||
|
||||
MY_DIR *dir_info= my_dir(dir, MYF(MY_DONT_SORT | MY_WANT_STAT));
|
||||
if (!dir_info)
|
||||
return 1;
|
||||
|
||||
for (uint i= 0; i < dir_info->number_of_files; i++)
|
||||
{
|
||||
FILEINFO *file= dir_info->dir_entry + i;
|
||||
/* Skip "." and ".." */
|
||||
if (!strcmp(file->name, ".") || !strcmp(file->name, ".."))
|
||||
continue;
|
||||
|
||||
strxnmov(path, sizeof(path), dir, sep, file->name, NULL);
|
||||
|
||||
if (!MY_S_ISDIR(file->mystat->st_mode))
|
||||
{
|
||||
err= my_delete(path, 0);
|
||||
#ifdef _WIN32
|
||||
/*
|
||||
On Windows, check and possible reset readonly attribute.
|
||||
my_delete(), or DeleteFile does not remove theses files.
|
||||
*/
|
||||
if (err)
|
||||
{
|
||||
DWORD attr= GetFileAttributes(path);
|
||||
if (attr != INVALID_FILE_ATTRIBUTES &&
|
||||
(attr & FILE_ATTRIBUTE_READONLY))
|
||||
{
|
||||
SetFileAttributes(path, attr &~ FILE_ATTRIBUTE_READONLY);
|
||||
err= my_delete(path, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
err= rmtree(path);
|
||||
|
||||
if(err)
|
||||
break;
|
||||
}
|
||||
|
||||
my_dirend(dir_info);
|
||||
|
||||
if (!err)
|
||||
err= rmdir(dir);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
SYNOPSIS
|
||||
@@ -4103,7 +4046,7 @@ void do_rmdir(struct st_command *command)
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
DBUG_PRINT("info", ("removing directory: %s", ds_dirname.str));
|
||||
if (rmtree(ds_dirname.str))
|
||||
if (my_rmtree(ds_dirname.str, MYF(0)))
|
||||
handle_command_error(command, 1, errno);
|
||||
|
||||
dynstr_free(&ds_dirname);
|
||||
@@ -6118,7 +6061,6 @@ void do_connect(struct st_command *command)
|
||||
#endif
|
||||
if (opt_compress || con_compress)
|
||||
mysql_options(con_slot->mysql, MYSQL_OPT_COMPRESS, NullS);
|
||||
mysql_options(con_slot->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
|
||||
mysql_options(con_slot->mysql, MYSQL_SET_CHARSET_NAME,
|
||||
csname?csname: charset_info->csname);
|
||||
if (opt_charsets_dir)
|
||||
@@ -6218,6 +6160,11 @@ void do_connect(struct st_command *command)
|
||||
if (con_slot == next_con)
|
||||
next_con++; /* if we used the next_con slot, advance the pointer */
|
||||
}
|
||||
else // Failed to connect. Free the memory.
|
||||
{
|
||||
mysql_close(con_slot->mysql);
|
||||
con_slot->mysql= NULL;
|
||||
}
|
||||
|
||||
dynstr_free(&ds_connection_name);
|
||||
dynstr_free(&ds_host);
|
||||
@@ -9326,7 +9273,6 @@ int main(int argc, char **argv)
|
||||
(void *) &opt_connect_timeout);
|
||||
if (opt_compress)
|
||||
mysql_options(con->mysql,MYSQL_OPT_COMPRESS,NullS);
|
||||
mysql_options(con->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
|
||||
mysql_options(con->mysql, MYSQL_SET_CHARSET_NAME,
|
||||
charset_info->csname);
|
||||
if (opt_charsets_dir)
|
||||
|
Reference in New Issue
Block a user