summaryrefslogtreecommitdiff
path: root/sql/mysql_install_db.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-02-03 17:22:05 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-02-03 17:22:05 +0200
commita249e57b684a23dce4cbb870ca3eb30c77cb9fd6 (patch)
tree9c50673311474f7efa0d5d110461ad324c7a62e6 /sql/mysql_install_db.cc
parent261ce5286f266f1a5fab5e8adc2c08adef658d13 (diff)
parent955c7b32226c816b24a2ed1750e12bc0256565ad (diff)
downloadmariadb-git-a249e57b684a23dce4cbb870ca3eb30c77cb9fd6.tar.gz
Merge 10.1 into 10.2
Temporarily disable a test for commit 2175bfce3e9da8332f10ab0e0286dc93915533a2 because fixing it in 10.2 requires updating libmariadb.
Diffstat (limited to 'sql/mysql_install_db.cc')
-rw-r--r--sql/mysql_install_db.cc72
1 files changed, 66 insertions, 6 deletions
diff --git a/sql/mysql_install_db.cc b/sql/mysql_install_db.cc
index 17e83126bc9..73281161335 100644
--- a/sql/mysql_install_db.cc
+++ b/sql/mysql_install_db.cc
@@ -27,6 +27,8 @@
#include <shellapi.h>
#include <accctrl.h>
#include <aclapi.h>
+struct IUnknown;
+#include <shlwapi.h>
#define USAGETEXT \
"mysql_install_db.exe Ver 1.00 for Windows\n" \
@@ -556,20 +558,78 @@ static int create_db_instance()
DWORD cwd_len= MAX_PATH;
char cmdline[3*MAX_PATH];
FILE *in;
+ bool cleanup_datadir= true;
+ DWORD last_error;
verbose("Running bootstrap");
GetCurrentDirectory(cwd_len, cwd);
- CreateDirectory(opt_datadir, NULL); /*ignore error, it might already exist */
+
+ /* Create datadir and datadir/mysql, if they do not already exist. */
+
+ if (!CreateDirectory(opt_datadir, NULL) && (GetLastError() != ERROR_ALREADY_EXISTS))
+ {
+ last_error = GetLastError();
+ switch(last_error)
+ {
+ case ERROR_ACCESS_DENIED:
+ die("Can't create data directory '%s' (access denied)\n",
+ opt_datadir);
+ break;
+ case ERROR_PATH_NOT_FOUND:
+ die("Can't create data directory '%s' "
+ "(one or more intermediate directories do not exist)\n",
+ opt_datadir);
+ break;
+ default:
+ die("Can't create data directory '%s', last error %u\n",
+ opt_datadir, last_error);
+ break;
+ }
+ }
if (!SetCurrentDirectory(opt_datadir))
{
- die("Cannot set current directory to '%s'\n",opt_datadir);
- return -1;
+ last_error = GetLastError();
+ switch (last_error)
+ {
+ case ERROR_DIRECTORY:
+ die("Can't set current directory to '%s', the path is not a valid directory \n",
+ opt_datadir);
+ break;
+ default:
+ die("Can' set current directory to '%s', last error %u\n",
+ opt_datadir, last_error);
+ break;
+ }
+ }
+
+ if (PathIsDirectoryEmpty(opt_datadir))
+ {
+ cleanup_datadir= false;
}
- CreateDirectory("mysql",NULL);
- CreateDirectory("test", NULL);
+ if (!CreateDirectory("mysql",NULL))
+ {
+ last_error = GetLastError();
+ DWORD attributes;
+ switch(last_error)
+ {
+ case ERROR_ACCESS_DENIED:
+ die("Can't create subdirectory 'mysql' in '%s' (access denied)\n",opt_datadir);
+ break;
+ case ERROR_ALREADY_EXISTS:
+ attributes = GetFileAttributes("mysql");
+
+ if (attributes == INVALID_FILE_ATTRIBUTES)
+ die("GetFileAttributes() failed for existing file '%s\\mysql', last error %u",
+ opt_datadir, GetLastError());
+ else if (!(attributes & FILE_ATTRIBUTE_DIRECTORY))
+ die("File '%s\\mysql' exists, but it is not a directory", opt_datadir);
+
+ break;
+ }
+ }
/*
Set data directory permissions for both current user and
@@ -675,7 +735,7 @@ static int create_db_instance()
}
end:
- if (ret)
+ if (ret && cleanup_datadir)
{
SetCurrentDirectory(cwd);
clean_directory(opt_datadir);